Class FederationCache

java.lang.Object
org.apache.hadoop.yarn.server.federation.cache.FederationCache
Direct Known Subclasses:
FederationCaffeineCache, FederationGuavaCache, FederationJCache

public abstract class FederationCache extends Object
  • Field Details

  • 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

      protected String buildCacheKey(String className, String methodName)
      Build CacheKey.
      Parameters:
      className - Cache Class Name.
      methodName - Method Name.
      Returns:
      append result. Example: className:FederationJCache, methodName:getPoliciesConfigurations. We Will Return FederationJCache.getPoliciesConfigurations.
    • buildCacheKey

      protected String buildCacheKey(String className, String methodName, String argName)
      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 the SubClusterInfo of 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 Exception
      Get the policies that is represented as SubClusterPolicyConfiguration for 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 unsuccessful
      Exception
    • getApplicationHomeSubCluster

      public abstract SubClusterId getApplicationHomeSubCluster(org.apache.hadoop.yarn.api.records.ApplicationId appId) throws Exception
      Returns the home SubClusterId for the specified ApplicationId.
      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 unsuccessful
      Exception
    • 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

      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

      public FederationStateStore getStateStore()
    • setStateStore

      public void setStateStore(FederationStateStore stateStore)