public abstract class AbstractTransientStore extends Object implements TransientStore
TransientStore implementation.| Modifier and Type | Field and Description |
|---|---|
protected File |
cacheDir |
protected TransientStoreConfig |
config |
protected static org.apache.commons.logging.Log |
log |
| Constructor and Description |
|---|
AbstractTransientStore() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract long |
decrementStorageSize(long size) |
void |
doGC()
Runs garbage collecting to delete the file system resources that are associated with entries that were removed.
|
abstract boolean |
exists(String key)
Returns
true if an entry exists with the given key. |
abstract List<Blob> |
getBlobs(String key)
Gets the blobs associated with the entry with the given
key. |
File |
getCacheDir() |
File |
getCachingDirectory(String key) |
protected String |
getCachingDirName(String key) |
protected long |
getFilePathSize(Path entry) |
protected String |
getKeyCachingDirName(String dir) |
abstract Serializable |
getParameter(String key,
String parameter)
Gets the value of
parameter in the entry with the given key. |
abstract Map<String,Serializable> |
getParameters(String key)
Gets values of the parameters in the entry with the given
key. |
abstract long |
getSize(String key)
Returns the size of the blobs associated with the entry with the given
key or -1 if entry does
not exist. |
protected long |
getSizeOfBlobs(List<Blob> blobs) |
abstract long |
getStorageSize()
Returns the size of the disk storage in bytes.
|
int |
getStorageSizeMB()
Returns the size of the used disk storage in MB.
|
protected abstract long |
incrementStorageSize(long size) |
void |
init(TransientStoreConfig config)
Initializes the store from the given
config. |
abstract boolean |
isCompleted(String key)
Returns
true if the entry with the given key is ready. |
abstract Set<String> |
keySet()
Returns the set of keys for all entries.
|
protected List<Blob> |
loadBlobs(List<Map<String,String>> blobInfos) |
protected abstract void |
persistBlobs(String key,
long sizeOfBlobs,
List<Map<String,String>> blobInfos)
Updates the total storage size and the storage size of the entry with the given
key according to
sizeOfBlobs and stores the blob information in this entry. |
void |
putBlobs(String key,
List<Blob> blobs)
Associates the given
blobs with the entry with the given key. |
abstract void |
putParameter(String key,
String parameter,
Serializable value)
Sets
parameter to value in the entry with the given key. |
abstract void |
putParameters(String key,
Map<String,Serializable> parameters)
Puts
parameters in the entry with the given key. |
abstract void |
release(String key)
Informs the store that the entry with the given
key can be released if TTL or GC parameters require to do
some cleanup. |
abstract void |
remove(String key)
Removes entry with the given
key. |
void |
removeAll()
Removes all entries from the store.
|
protected abstract void |
removeAllEntries() |
abstract void |
setCompleted(String key,
boolean completed)
Marks the entry with the given
key as ready. |
protected abstract void |
setStorageSize(long newSize)
Sets the size of the disk storage in bytes.
|
abstract void |
shutdown()
Shuts down the store.
|
protected List<Map<String,String>> |
storeBlobs(String key,
List<Blob> blobs) |
protected static final org.apache.commons.logging.Log log
protected TransientStoreConfig config
public AbstractTransientStore()
public void init(TransientStoreConfig config)
TransientStoreconfig.init in interface TransientStorepublic abstract void shutdown()
TransientStoreshutdown in interface TransientStorepublic abstract boolean exists(String key)
TransientStoretrue if an entry exists with the given key.exists in interface TransientStorepublic abstract Set<String> keySet()
TransientStorekeySet in interface TransientStorepublic abstract void putParameter(String key, String parameter, Serializable value)
TransientStoreparameter to value in the entry with the given key.
If entry does not exist a new entry is created. If parameter already exists in the entry it is
overwritten.
putParameter in interface TransientStorepublic abstract Serializable getParameter(String key, String parameter)
TransientStoreparameter in the entry with the given key.
Returns null if entry or parameter does not exist.
getParameter in interface TransientStorepublic abstract void putParameters(String key, Map<String,Serializable> parameters)
TransientStoreparameters in the entry with the given key. Overwrites any existing parameter in the entry.
If entry does not exist a new entry is created.
putParameters in interface TransientStorepublic abstract Map<String,Serializable> getParameters(String key)
TransientStorekey.
Returns null if entry does not exist.
getParameters in interface TransientStorepublic abstract List<Blob> getBlobs(String key)
TransientStorekey.
Returns null if entry does not exist.
getBlobs in interface TransientStorepublic abstract long getSize(String key)
TransientStorekey or -1 if entry does
not exist.getSize in interface TransientStorepublic abstract boolean isCompleted(String key)
TransientStoretrue if the entry with the given key is ready.isCompleted in interface TransientStorepublic abstract void setCompleted(String key, boolean completed)
TransientStorekey as ready.
If entry does not exist a new entry is created.
setCompleted in interface TransientStorepublic abstract void remove(String key)
TransientStorekey.
Has no effect if entry does not exist.
remove in interface TransientStorepublic abstract void release(String key)
TransientStorekey can be released if TTL or GC parameters require to do
some cleanup.
Has no effect if entry does not exist.
release in interface TransientStoreprotected abstract void persistBlobs(String key, long sizeOfBlobs, List<Map<String,String>> blobInfos)
key according to
sizeOfBlobs and stores the blob information in this entry.public abstract long getStorageSize()
protected abstract void setStorageSize(long newSize)
protected abstract long incrementStorageSize(long size)
protected abstract long decrementStorageSize(long size)
protected abstract void removeAllEntries()
public void putBlobs(String key, List<Blob> blobs)
TransientStoreblobs with the entry with the given key.
If entry does not exist a new entry is created.
putBlobs in interface TransientStorepublic File getCachingDirectory(String key)
protected String getCachingDirName(String key)
protected long getSizeOfBlobs(List<Blob> blobs)
public int getStorageSizeMB()
TransientStoregetStorageSizeMB in interface TransientStorepublic void doGC()
TransientStoredoGC in interface TransientStoreprotected String getKeyCachingDirName(String dir)
protected long getFilePathSize(Path entry)
public void removeAll()
TransientStoreremoveAll in interface TransientStorepublic File getCacheDir()
Copyright © 2017 Nuxeo. All rights reserved.