public class SimpleTransientStore extends AbstractTransientStore
TransientStore
. Uses StorageEntry
as a
representation of an entry in the store.Modifier and Type | Field and Description |
---|---|
protected com.google.common.cache.Cache<String,Serializable> |
l1Cache |
protected com.google.common.cache.Cache<String,Serializable> |
l2Cache |
protected org.apache.commons.logging.Log |
log |
protected AtomicLong |
storageSize |
cacheDir, config
Constructor and Description |
---|
SimpleTransientStore() |
Modifier and Type | Method and Description |
---|---|
protected long |
decrementStorageSize(long size) |
boolean |
exists(String key)
Returns
true if an entry exists with the given key . |
List<Blob> |
getBlobs(String key)
Gets the blobs associated with the entry with the given
key . |
com.google.common.cache.Cache<String,Serializable> |
getL1Cache() |
com.google.common.cache.Cache<String,Serializable> |
getL2Cache() |
Serializable |
getParameter(String key,
String parameter)
Gets the value of
parameter in the entry with the given key . |
Map<String,Serializable> |
getParameters(String key)
Gets values of the parameters in the entry with the given
key . |
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 StorageEntry |
getStorageEntry(String key)
|
long |
getStorageSize()
Returns the size (in bytes) of the disk storage used for blobs.
|
protected long |
incrementStorageSize(long size) |
void |
init(TransientStoreConfig config)
Initializes the store from the given
config . |
boolean |
isCompleted(String key)
Returns
true if the entry with the given key is ready. |
Set<String> |
keySet()
Returns the set of keys for all entries.
|
Stream<String> |
keyStream()
Returns a
Stream of keys for all entries. |
protected 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 |
putParameter(String key,
String parameter,
Serializable value)
Sets
parameter to value in the entry with the given key . |
void |
putParameters(String key,
Map<String,Serializable> parameters)
Puts
parameters in the entry with the given key . |
protected void |
putStorageEntry(String key,
StorageEntry entry)
Stores the given
entry with the given key . |
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. |
protected void |
removeAllEntries() |
protected void |
removeEntry(String key) |
void |
setCompleted(String key,
boolean completed)
Marks the entry with the given
key as ready. |
protected void |
setStorageSize(long newSize)
Sets the size of the disk storage in bytes.
|
void |
shutdown()
Shuts down the store.
|
doGC, getCacheDir, getCachingDirectory, getCachingDirName, getFilePathSize, getKeyCachingDirName, getSizeOfBlobs, loadBlobs, putBlobs, remove, removeAll, removeBlobs, storeBlobs
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getStorageSizeMB
protected org.apache.commons.logging.Log log
protected com.google.common.cache.Cache<String,Serializable> l1Cache
protected com.google.common.cache.Cache<String,Serializable> l2Cache
protected AtomicLong storageSize
public SimpleTransientStore()
public void init(TransientStoreConfig config)
TransientStoreProvider
config
.init
in interface TransientStoreProvider
init
in class AbstractTransientStore
public void shutdown()
TransientStoreProvider
shutdown
in interface TransientStoreProvider
shutdown
in class AbstractTransientStore
public boolean exists(String key)
TransientStore
true
if an entry exists with the given key
.exists
in interface TransientStore
exists
in class AbstractTransientStore
public Set<String> keySet()
TransientStoreProvider
public Stream<String> keyStream()
TransientStoreProvider
Stream
of keys for all entries.public 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
putParameter
in class AbstractTransientStore
public 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
getParameter
in class AbstractTransientStore
public 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
putParameters
in class AbstractTransientStore
public Map<String,Serializable> getParameters(String key)
TransientStore
key
.
Returns null
if entry does not exist.
getParameters
in interface TransientStore
getParameters
in class AbstractTransientStore
public List<Blob> getBlobs(String key)
TransientStore
key
.
Returns null
if entry does not exist.
getBlobs
in interface TransientStore
getBlobs
in class AbstractTransientStore
public long getSize(String key)
TransientStore
key
or -1
if entry does
not exist.getSize
in interface TransientStore
getSize
in class AbstractTransientStore
public boolean isCompleted(String key)
TransientStore
true
if the entry with the given key
is ready.isCompleted
in interface TransientStore
isCompleted
in class AbstractTransientStore
public void setCompleted(String key, boolean completed)
TransientStore
key
as ready.
If entry does not exist a new entry is created.
setCompleted
in interface TransientStore
setCompleted
in class AbstractTransientStore
public 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
release
in class AbstractTransientStore
protected void persistBlobs(String key, long sizeOfBlobs, List<Map<String,String>> blobInfos)
AbstractTransientStore
key
according to
sizeOfBlobs
and stores the blob information in this entry.persistBlobs
in class AbstractTransientStore
public long getStorageSize()
TransientStoreProvider
protected void setStorageSize(long newSize)
AbstractTransientStore
setStorageSize
in class AbstractTransientStore
protected long incrementStorageSize(long size)
incrementStorageSize
in class AbstractTransientStore
protected long decrementStorageSize(long size)
decrementStorageSize
in class AbstractTransientStore
protected void removeEntry(String key)
removeEntry
in class AbstractTransientStore
protected void removeAllEntries()
removeAllEntries
in class AbstractTransientStore
public com.google.common.cache.Cache<String,Serializable> getL1Cache()
public com.google.common.cache.Cache<String,Serializable> getL2Cache()
protected StorageEntry getStorageEntry(String key)
protected void putStorageEntry(String key, StorageEntry entry)
entry
with the given key
.
If an entry exists with the given key
it is overwritten.
Copyright © 2018 Nuxeo. All rights reserved.