Class SCMStore
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.service.CompositeService
org.apache.hadoop.yarn.server.sharedcachemanager.store.SCMStore
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.service.Service
- Direct Known Subclasses:
InMemorySCMStore
@Private
@Evolving
public abstract class SCMStore
extends org.apache.hadoop.service.CompositeService
An abstract class for the data store used by the shared cache manager
service. All implementations of methods in this interface need to be thread
safe and atomic.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.service.CompositeService
org.apache.hadoop.service.CompositeService.CompositeServiceShutdownHookNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
FieldsFields inherited from class org.apache.hadoop.service.CompositeService
STOP_ONLY_STARTED_SERVICES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringaddResource(String key, String fileName) Add a resource to the shared cache and it's associated filename.abstract StringAdd aSharedCacheResourceReferenceto a resource and update the resource access time.voidClean all resource references to a cache resource that contain application ids pointing to finished applications.static AppCheckercreateAppCheckerService(org.apache.hadoop.conf.Configuration conf) Create an instance of the AppChecker service via reflection based on theYarnConfiguration.SCM_APP_CHECKER_CLASSparameter.abstract Collection<SharedCacheResourceReference>Get theSharedCacheResourceReference(s) associated with the resource.abstract booleanisResourceEvictable(String key, org.apache.hadoop.fs.FileStatus file) Check if a specific resource is evictable according to the store's enabled cache eviction policies.abstract booleanremoveResource(String key) Remove a resource from the shared cache.abstract booleanremoveResourceReference(String key, SharedCacheResourceReference ref, boolean updateAccessTime) Remove aSharedCacheResourceReferencefrom a resource.abstract voidremoveResourceReferences(String key, Collection<SharedCacheResourceReference> refs, boolean updateAccessTime) Remove a collection ofSharedCacheResourceReferencesfrom a resource.protected voidserviceInit(org.apache.hadoop.conf.Configuration conf) Methods inherited from class org.apache.hadoop.service.CompositeService
addIfService, addService, getServices, removeService, serviceStart, serviceStopMethods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
-
Field Details
-
appChecker
-
-
Constructor Details
-
SCMStore
-
-
Method Details
-
serviceInit
- Overrides:
serviceInitin classorg.apache.hadoop.service.CompositeService- Throws:
Exception
-
addResource
Add a resource to the shared cache and it's associated filename. The resource is identified by a unique key. If the key already exists no action is taken and the filename of the existing resource is returned. If the key does not exist, the resource is added, it's access time is set, and the filename of the resource is returned.- Parameters:
key- a unique identifier for a resourcefileName- the filename of the resource- Returns:
- the filename of the resource as represented by the cache
-
removeResource
Remove a resource from the shared cache.- Parameters:
key- a unique identifier for a resource- Returns:
- true if the resource was removed or did not exist, false if the
resource existed, contained at least one
SharedCacheResourceReferenceand was not removed.
-
getResourceReferences
Get theSharedCacheResourceReference(s) associated with the resource.- Parameters:
key- a unique identifier for a resource- Returns:
- an unmodifiable collection of
SharedCacheResourceReferences. If the resource does not exist, an empty set is returned.
-
removeResourceReferences
@Private public abstract void removeResourceReferences(String key, Collection<SharedCacheResourceReference> refs, boolean updateAccessTime) Remove a collection ofSharedCacheResourceReferencesfrom a resource.- Parameters:
key- a unique identifier for a resourcerefs- the collection ofSharedCacheResourceReferences to removeupdateAccessTime- true if the call should update the access time for the resource
-
cleanResourceReferences
@Private public void cleanResourceReferences(String key) throws org.apache.hadoop.yarn.exceptions.YarnException Clean all resource references to a cache resource that contain application ids pointing to finished applications. If the resource key does not exist, do nothing.- Parameters:
key- a unique identifier for a resource- Throws:
org.apache.hadoop.yarn.exceptions.YarnException
-
isResourceEvictable
@Private public abstract boolean isResourceEvictable(String key, org.apache.hadoop.fs.FileStatus file) Check if a specific resource is evictable according to the store's enabled cache eviction policies.- Parameters:
key- a unique identifier for a resourcefile- theFileStatusobject for the resource file in the file system.- Returns:
- true if the resource is evicatble, false otherwise
-
createAppCheckerService
@Private public static AppChecker createAppCheckerService(org.apache.hadoop.conf.Configuration conf) Create an instance of the AppChecker service via reflection based on theYarnConfiguration.SCM_APP_CHECKER_CLASSparameter.- Parameters:
conf-- Returns:
- an instance of the AppChecker class
-