@InterfaceAudience.Private @InterfaceStability.Evolving public class InMemorySCMStore extends SCMStore
StringInterner
. It avoids the pitfalls
of using built-in String interning. The interned strings are also weakly
referenced, so it can be garbage collected once it is done. And there is
little risk of keys being available for other parts of the code so they can
be used as locks accidentally. appChecker
Constructor and Description |
---|
InMemorySCMStore() |
InMemorySCMStore(AppChecker appChecker) |
Modifier and Type | Method and Description |
---|---|
String |
addResource(String key,
String fileName)
Adds the given resource to the store under the key and the filename.
|
String |
addResourceReference(String key,
SharedCacheResourceReference ref)
Adds the provided resource reference to the cache resource under the key,
and updates the access time.
|
void |
cleanResourceReferences(String key)
Provides atomicity for the method.
|
Collection<SharedCacheResourceReference> |
getResourceReferences(String key)
Returns the list of resource references currently registered under the
cache entry.
|
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.
|
boolean |
removeResource(String key)
Removes the given resource from the store.
|
boolean |
removeResourceReference(String key,
SharedCacheResourceReference ref,
boolean updateAccessTime)
Removes the provided resource reference from the resource.
|
void |
removeResourceReferences(String key,
Collection<SharedCacheResourceReference> refs,
boolean updateAccessTime)
Removes the provided collection of resource references from the resource.
|
protected void |
serviceInit(org.apache.hadoop.conf.Configuration conf)
The in-memory store bootstraps itself from the shared cache entries that
exist in HDFS.
|
protected void |
serviceStart() |
protected void |
serviceStop() |
createAppCheckerService
addIfService, addService, getServices, removeService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
public InMemorySCMStore()
public InMemorySCMStore(AppChecker appChecker)
protected void serviceInit(org.apache.hadoop.conf.Configuration conf) throws Exception
serviceInit
in class SCMStore
Exception
protected void serviceStart() throws Exception
serviceStart
in class org.apache.hadoop.service.CompositeService
Exception
protected void serviceStop() throws Exception
serviceStop
in class org.apache.hadoop.service.CompositeService
Exception
public String addResource(String key, String fileName)
addResource
in class SCMStore
key
- a unique identifier for a resourcefileName
- the filename of the resourcepublic String addResourceReference(String key, SharedCacheResourceReference ref)
addResourceReference
in class SCMStore
key
- a unique identifier for a resourceref
- the SharedCacheResourceReference
to addpublic Collection<SharedCacheResourceReference> getResourceReferences(String key)
getResourceReferences
in class SCMStore
key
- a unique identifier for a resourcepublic boolean removeResourceReference(String key, SharedCacheResourceReference ref, boolean updateAccessTime)
removeResourceReference
in class SCMStore
key
- a unique identifier for a resourceref
- the SharedCacheResourceReference
to removeupdateAccessTime
- true if the call should update the access time for
the resourcepublic void removeResourceReferences(String key, Collection<SharedCacheResourceReference> refs, boolean updateAccessTime)
removeResourceReferences
in class SCMStore
key
- a unique identifier for a resourcerefs
- the collection of SharedCacheResourceReference
s to
removeupdateAccessTime
- true if the call should update the access time for
the resourcepublic void cleanResourceReferences(String key) throws org.apache.hadoop.yarn.exceptions.YarnException
cleanResourceReferences
in class SCMStore
key
- a unique identifier for a resourceorg.apache.hadoop.yarn.exceptions.YarnException
public boolean removeResource(String key)
removeResource
in class SCMStore
key
- a unique identifier for a resourceSharedCacheResourceReference
and was not removed.public boolean isResourceEvictable(String key, org.apache.hadoop.fs.FileStatus file)
SCMStore
isResourceEvictable
in class SCMStore
key
- a unique identifier for a resourcefile
- the FileStatus
object for the resource file in the
file system.Copyright © 2020 Apache Software Foundation. All rights reserved.