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 |
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. |
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)
TransientStore
config
.init
in interface TransientStore
public abstract void shutdown()
TransientStore
shutdown
in interface TransientStore
public abstract boolean exists(String key)
TransientStore
true
if an entry exists with the given key
.exists
in interface TransientStore
public abstract void putParameter(String key, String parameter, Serializable value)
TransientStore
parameter
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 TransientStore
public abstract Serializable getParameter(String key, String parameter)
TransientStore
parameter
in the entry with the given key
.
Returns null
if entry or parameter does not exist.
getParameter
in interface TransientStore
public abstract void putParameters(String key, Map<String,Serializable> parameters)
TransientStore
parameters
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 TransientStore
public abstract Map<String,Serializable> getParameters(String key)
TransientStore
key
.
Returns null
if entry does not exist.
getParameters
in interface TransientStore
public abstract List<Blob> getBlobs(String key)
TransientStore
key
.
Returns null
if entry does not exist.
getBlobs
in interface TransientStore
public abstract long getSize(String key)
TransientStore
key
or -1
if entry does
not exist.getSize
in interface TransientStore
public abstract boolean isCompleted(String key)
TransientStore
true
if the entry with the given key
is ready.isCompleted
in interface TransientStore
public abstract void setCompleted(String key, boolean completed)
TransientStore
key
as ready.
If entry does not exist a new entry is created.
setCompleted
in interface TransientStore
public abstract void remove(String key)
TransientStore
key
.
Has no effect if entry does not exist.
remove
in interface TransientStore
public abstract void release(String key)
TransientStore
key
can be released if TTL or GC parameters require to do
some cleanup.
Has no effect if entry does not exist.
release
in interface TransientStore
protected 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)
TransientStore
blobs
with the entry with the given key
.
If entry does not exist a new entry is created.
putBlobs
in interface TransientStore
public File getCachingDirectory(String key)
protected String getCachingDirName(String key)
protected long getSizeOfBlobs(List<Blob> blobs)
public int getStorageSizeMB()
TransientStore
getStorageSizeMB
in interface TransientStore
public void doGC()
TransientStore
doGC
in interface TransientStore
protected String getKeyCachingDirName(String dir)
protected long getFilePathSize(Path entry)
public void removeAll()
TransientStore
removeAll
in interface TransientStore
Copyright © 2015 Nuxeo SA. All rights reserved.