Class FederationCache
java.lang.Object
org.apache.hadoop.yarn.server.federation.cache.FederationCache
- Direct Known Subclasses:
FederationCaffeineCache,FederationGuavaCache,FederationJCache
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassInternal class that encapsulates the cache key and a function that returns the value for the specified key.classclassclass -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbuildCacheKey(String className, String methodName) Build CacheKey.protected StringbuildCacheKey(String className, String methodName, String argName) Build CacheKey.buildGetApplicationHomeSubClusterRequest(String cacheKey, org.apache.hadoop.yarn.api.records.ApplicationId applicationId) Build GetApplicationHomeSubCluster CacheRequest.protected FederationCache.CacheRequest<String,FederationCache.CacheResponse<SubClusterPolicyConfiguration>> Build GetPoliciesConfigurations CacheRequest.buildGetSubClustersCacheRequest(String cacheKey, boolean filterInactiveSubClusters) Build GetSubClusters CacheRequest.static Map<String,SubClusterPolicyConfiguration> buildPolicyConfigMap(FederationCache.CacheRequest<String, ?> cacheRequest) According to the cacheRequest, build PolicyConfigMap.static Map<String,SubClusterPolicyConfiguration> According to the response, build PolicyConfigMap.static Map<SubClusterId,SubClusterInfo> buildSubClusterInfoMap(FederationCache.CacheRequest<String, ?> cacheRequest) According to the cacheRequest, build SubClusterInfoMap.static Map<SubClusterId,SubClusterInfo> According to the response, build SubClusterInfoMap.abstract voidclear cache.abstract SubClusterIdgetApplicationHomeSubCluster(org.apache.hadoop.yarn.api.records.ApplicationId appId) Returns the homeSubClusterIdfor the specifiedApplicationId.abstract Map<String,SubClusterPolicyConfiguration> Get the policies that is represented asSubClusterPolicyConfigurationfor all currently active queues in the system.abstract Map<SubClusterId,SubClusterInfo> getSubClusters(boolean filterInactiveSubClusters) Returns theSubClusterInfoof all active sub cluster(s).abstract voidinitCache(org.apache.hadoop.conf.Configuration pConf, FederationStateStore pStateStore) Initialize the cache.abstract booleanDetermine whether to enable cache.abstract voidremoveSubCluster(boolean filterInactiveSubClusters) Remove SubCluster from cache.voidsetStateStore(FederationStateStore stateStore)
-
Field Details
-
GET_SUBCLUSTERS_CACHEID
- See Also:
-
GET_POLICIES_CONFIGURATIONS_CACHEID
- See Also:
-
GET_APPLICATION_HOME_SUBCLUSTER_CACHEID
- See Also:
-
POINT
- See Also:
-
-
Constructor Details
-
FederationCache
public FederationCache()
-
-
Method Details
-
isCachingEnabled
public abstract boolean isCachingEnabled()Determine whether to enable cache. We judge whether to enable the cache according to the cache time. If the cache time is greater than 0, the cache is enabled. If the cache time is less than or equal 0, the cache is not enabled.- Returns:
- true, enable cache; false, not enable cache.
-
initCache
public abstract void initCache(org.apache.hadoop.conf.Configuration pConf, FederationStateStore pStateStore) Initialize the cache.- Parameters:
pConf- Configuration.pStateStore- FederationStateStore.
-
clearCache
public abstract void clearCache()clear cache. -
buildCacheKey
Build CacheKey.- Parameters:
className- Cache Class Name.methodName- Method Name.- Returns:
- append result. Example: className:FederationJCache, methodName:getPoliciesConfigurations. We Will Return FederationJCache.getPoliciesConfigurations.
-
buildCacheKey
Build CacheKey.- Parameters:
className- Cache Class Name.methodName- Method Name.argName- ArgName.- Returns:
- append result. Example: className:FederationJCache, methodName:getApplicationHomeSubCluster, argName: app_1 We Will Return FederationJCache.getApplicationHomeSubCluster.app_1
-
getSubClusters
public abstract Map<SubClusterId,SubClusterInfo> getSubClusters(boolean filterInactiveSubClusters) throws org.apache.hadoop.yarn.exceptions.YarnException Returns theSubClusterInfoof all active sub cluster(s).- Parameters:
filterInactiveSubClusters- whether to filter out inactive sub-clusters- Returns:
- the information of all active sub cluster(s)
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if the call to the state store is unsuccessful
-
getPoliciesConfigurations
public abstract Map<String,SubClusterPolicyConfiguration> getPoliciesConfigurations() throws ExceptionGet the policies that is represented asSubClusterPolicyConfigurationfor all currently active queues in the system.- Returns:
- the policies for all currently active queues in the system
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if the call to the state store is unsuccessfulException
-
getApplicationHomeSubCluster
public abstract SubClusterId getApplicationHomeSubCluster(org.apache.hadoop.yarn.api.records.ApplicationId appId) throws Exception Returns the homeSubClusterIdfor the specifiedApplicationId.- Parameters:
appId- the identifier of the application- Returns:
- the home sub cluster identifier
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if the call to the state store is unsuccessfulException
-
removeSubCluster
public abstract void removeSubCluster(boolean filterInactiveSubClusters) Remove SubCluster from cache.- Parameters:
filterInactiveSubClusters- whether to filter out inactive sub-clusters.
-
buildGetSubClustersCacheRequest
protected FederationCache.CacheRequest<String,FederationCache.CacheResponse<SubClusterInfo>> buildGetSubClustersCacheRequest(String cacheKey, boolean filterInactiveSubClusters) throws org.apache.hadoop.yarn.exceptions.YarnException Build GetSubClusters CacheRequest.- Parameters:
cacheKey- cacheKey.filterInactiveSubClusters- filter Inactive SubClusters.- Returns:
- CacheRequest.
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- exceptions from yarn servers.
-
buildSubClusterInfoMap
public static Map<SubClusterId,SubClusterInfo> buildSubClusterInfoMap(GetSubClustersInfoResponse response) According to the response, build SubClusterInfoMap.- Parameters:
response- GetSubClustersInfoResponse.- Returns:
- SubClusterInfoMap.
-
buildSubClusterInfoMap
public static Map<SubClusterId,SubClusterInfo> buildSubClusterInfoMap(FederationCache.CacheRequest<String, ?> cacheRequest) According to the cacheRequest, build SubClusterInfoMap.- Parameters:
cacheRequest- CacheRequest.- Returns:
- SubClusterInfoMap.
-
buildGetApplicationHomeSubClusterRequest
protected FederationCache.CacheRequest<String,FederationCache.CacheResponse<SubClusterId>> buildGetApplicationHomeSubClusterRequest(String cacheKey, org.apache.hadoop.yarn.api.records.ApplicationId applicationId) throws org.apache.hadoop.yarn.exceptions.YarnException Build GetApplicationHomeSubCluster CacheRequest.- Parameters:
cacheKey- cacheKey.applicationId- applicationId.- Returns:
- CacheRequest.
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- exceptions from yarn servers.
-
buildGetPoliciesConfigurationsCacheRequest
protected FederationCache.CacheRequest<String,FederationCache.CacheResponse<SubClusterPolicyConfiguration>> buildGetPoliciesConfigurationsCacheRequest(String cacheKey) throws org.apache.hadoop.yarn.exceptions.YarnException Build GetPoliciesConfigurations CacheRequest.- Parameters:
cacheKey- cacheKey.- Returns:
- CacheRequest.
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- exceptions from yarn servers.
-
buildPolicyConfigMap
public static Map<String,SubClusterPolicyConfiguration> buildPolicyConfigMap(GetSubClusterPoliciesConfigurationsResponse response) According to the response, build PolicyConfigMap.- Parameters:
response- GetSubClusterPoliciesConfigurationsResponse.- Returns:
- PolicyConfigMap.
-
buildPolicyConfigMap
public static Map<String,SubClusterPolicyConfiguration> buildPolicyConfigMap(FederationCache.CacheRequest<String, ?> cacheRequest) According to the cacheRequest, build PolicyConfigMap.- Parameters:
cacheRequest- CacheRequest.- Returns:
- PolicyConfigMap.
-
getStateStore
-
setStateStore
-