@GridCacheLocalStore public class GridCacheFileLocalStore<K,V> extends Object implements GridCacheStore<K,GridBiTuple<V,?>>, GridLifecycleAware
GridCacheStore implementation. Internally it uses compact offheap map for key hashes and
pointers to append only update log files. When log file become too sparse (contain too many entries that have already
been removed logically) it will be compacted by background process.
setWriteMode(GridCacheFileLocalStoreWriteMode)setWriteDelay(long)setWriteBufferSize(int)setFsyncDelay(long)setReadBufferSize(int)setCompactBufferSize(int)setMinCompactSize(long)setMaxSparsity(float)setSparcityCheckFrequency(long)setRootPath(String)setChecksum(boolean)setMapCapacity(int)setMapSegments(int)
...
GridCacheStore<String, GridTuple2<String, ?>> store = new GridCacheFileLocalStore<String, String>();
...
...
<bean id="cache.local.store"
class="GridCacheFileLocalStore">
</bean>
...
For information about Spring framework visit www.springframework.org
| Modifier and Type | Field and Description |
|---|---|
protected String |
cacheName |
static GridCacheFileLocalStoreWriteMode |
DFLT_COMMIT_MODE
Default write mode.
|
static int |
DFLT_COMPACT_BUFFER_SIZE
Default compact buffer size.
|
static int |
DFLT_FSYNC_DELAY
Default value for fsync delay in milliseconds.
|
static int |
DFLT_MAP_CAPACITY
Default map capacity.
|
static int |
DFLT_MAP_SEGMENTS
Default number of map segments.
|
static float |
DFLT_MAX_SPARSITY
Default maximum sparsity.
|
static long |
DFLT_MIN_COMPACT_SIZE
Default minimum compaction size.
|
static int |
DFLT_READ_BUFFER_SIZE
Default read buffer size.
|
static String |
DFLT_ROOT_PATH
Default root path for file storage.
|
static long |
DFLT_SPARCITY_CHECK_FREQUENCY
Default sparcity check frequency.
|
static int |
DFLT_WRITE_BUFFER_SIZE
Default write buffer size.
|
static int |
DFLT_WRITE_DELAY
Default value for write delay in microseconds.
|
protected String |
gridName |
protected GridLogger |
log |
protected GridMarshaller |
marsh |
| Constructor and Description |
|---|
GridCacheFileLocalStore() |
| Modifier and Type | Method and Description |
|---|---|
GridBiTuple<V,?> |
load(GridCacheTx tx,
K key)
Loads value for the key from underlying persistent storage.
|
void |
loadAll(GridCacheTx tx,
Collection<? extends K> keys,
GridBiInClosure<K,GridBiTuple<V,?>> c)
Loads all values for given keys and passes every value to the provided closure.
|
void |
loadCache(GridBiInClosure<K,GridBiTuple<V,?>> clo,
Object... args)
Loads all values from underlying persistent storage.
|
void |
put(GridCacheTx tx,
K key,
GridBiTuple<V,?> val)
Stores a given value in persistent storage.
|
void |
putAll(GridCacheTx tx,
Map<? extends K,? extends GridBiTuple<V,?>> map)
Stores given key value pairs in persistent storage.
|
void |
remove(GridCacheTx tx,
K key)
Removes the value identified by given key from persistent storage.
|
void |
removeAll(GridCacheTx tx,
Collection<? extends K> keys)
Removes all vales identified by given keys from persistent storage.
|
void |
setChecksum(boolean checksum)
Enables or disables checksum calculation for entries on disk.
|
void |
setCompactBufferSize(int compactBufSize)
Sets compact buffer size.
|
void |
setFsyncDelay(long fsyncDelay)
Sets maximum delay in milliseconds after which fsync will be issued after a write to a file.
|
void |
setMapCapacity(int mapCap)
Sets initial internal hash map capacity.
|
void |
setMapSegments(int mapSegments)
Sets number of map segments.
|
void |
setMaxSparsity(float maxSparsity)
Sets maximum allowed file sparcity above which compaction has to start.
|
void |
setMinCompactSize(long minCompactSize)
Sets minimum file size for compaction.
|
void |
setReadBufferSize(int readBufSize)
Sets read buffer size.
|
void |
setRootPath(String rootPath)
Sets root directory path for storage.
|
void |
setSparcityCheckFrequency(long sparcityCheckFreq)
Sets frequency to check sparcity of files for compaction.
|
void |
setWriteBufferSize(int writeBufSize)
Sets write buffer size in bytes.
|
void |
setWriteDelay(long writeDelay)
Sets write delay after which write buffer can be flushed to the disk.
|
void |
setWriteMode(GridCacheFileLocalStoreWriteMode writeMode)
Sets write mode.
|
void |
start()
Starts grid component, called on grid start.
|
void |
stop()
Stops grid component, called on grid shutdown.
|
void |
txEnd(GridCacheTx tx,
boolean commit)
Tells store to commit or rollback a transaction depending on the value of the
'commit'
parameter. |
public static final int DFLT_FSYNC_DELAY
public static final int DFLT_WRITE_DELAY
public static final GridCacheFileLocalStoreWriteMode DFLT_COMMIT_MODE
public static final int DFLT_WRITE_BUFFER_SIZE
public static final int DFLT_READ_BUFFER_SIZE
public static final long DFLT_SPARCITY_CHECK_FREQUENCY
public static final int DFLT_COMPACT_BUFFER_SIZE
public static final int DFLT_MAP_CAPACITY
public static final int DFLT_MAP_SEGMENTS
public static final float DFLT_MAX_SPARSITY
public static final long DFLT_MIN_COMPACT_SIZE
public static final String DFLT_ROOT_PATH
@GridMarshallerResource protected GridMarshaller marsh
@GridNameResource protected String gridName
@GridCacheNameResource protected String cacheName
@GridLoggerResource protected GridLogger log
public void setWriteBufferSize(int writeBufSize)
writeBufSize - Buffer size.public void setReadBufferSize(int readBufSize)
readBufSize - Buffer size.public void setCompactBufferSize(int compactBufSize)
setWriteBufferSize(int) size.compactBufSize - Buffer size.public void setSparcityCheckFrequency(long sparcityCheckFreq)
sparcityCheckFreq - Sparcity check frequency in milliseconds.setMaxSparsity(float)public void setFsyncDelay(long fsyncDelay)
0 then fsync will be issued immediately.fsyncDelay - Fsync delay in milliseconds.public void setWriteDelay(long writeDelay)
GridCacheFileLocalStoreWriteMode.SYNC_BUFFERED and
GridCacheFileLocalStoreWriteMode.ASYNC_BUFFERED write modes.writeDelay - Write delay in microseconds.public void setWriteMode(GridCacheFileLocalStoreWriteMode writeMode)
writeMode - Write mode.GridCacheFileLocalStoreWriteModepublic void setMaxSparsity(float maxSparsity)
0 and 1.maxSparsity - Maximum sparcity.public void setMinCompactSize(long minCompactSize)
minCompactSize - Minimum compact size.public void setChecksum(boolean checksum)
checksum - Checksum.public void setMapCapacity(int mapCap)
mapCap - Initial map capacity.public void setMapSegments(int mapSegments)
mapSegments - Number of map segments.public void setRootPath(String rootPath)
rootPath - Root path.public void start()
throws GridException
start in interface GridLifecycleAwareGridException - If failed.public void stop()
throws GridException
stop in interface GridLifecycleAwareGridException - If failed.@Nullable public GridBiTuple<V,?> load(@Nullable GridCacheTx tx, K key) throws GridException
load in interface GridCacheStore<K,GridBiTuple<V,?>>tx - Cache transaction.key - Key to load.null if value was not found.GridException - If load failed.public void loadCache(GridBiInClosure<K,GridBiTuple<V,?>> clo, @Nullable Object... args) throws GridException
GridCache.loadCache(GridBiPredicate, long, Object...)
method is invoked which is usually to preload the cache from persistent storage.
This method is optional, and cache implementation does not depend on this
method to do anything. Default implementation of this method in
GridCacheStoreAdapter does nothing.
For every loaded value method GridBiInClosure.apply(Object, Object)
should be called on the passed in closure. The closure will then make sure
that the loaded value is stored in cache.
loadCache in interface GridCacheStore<K,GridBiTuple<V,?>>clo - Closure for loaded values.args - Arguments passes into
GridCache.loadCache(GridBiPredicate, long, Object...) method.GridException - If loading failed.public void loadAll(@Nullable
GridCacheTx tx,
@Nullable
Collection<? extends K> keys,
GridBiInClosure<K,GridBiTuple<V,?>> c)
throws GridException
For every loaded value method GridInClosure.apply(Object) should be called on
the passed in closure. The closure will then make sure that the loaded value is stored
in cache.
loadAll in interface GridCacheStore<K,GridBiTuple<V,?>>tx - Cache transaction.keys - Collection of keys to load.c - Closure to call for every loaded element.GridException - If load failed.public void put(@Nullable
GridCacheTx tx,
K key,
@Nullable
GridBiTuple<V,?> val)
throws GridException
null.put in interface GridCacheStore<K,GridBiTuple<V,?>>tx - Cache transaction, if write-behind is not enabled, null otherwise.key - Key to put.val - Value to put.GridException - If put failed.public void putAll(@Nullable
GridCacheTx tx,
@Nullable
Map<? extends K,? extends GridBiTuple<V,?>> map)
throws GridException
null.putAll in interface GridCacheStore<K,GridBiTuple<V,?>>tx - Cache transaction, if write-behind is not enabled, null otherwise.map - Values to store.GridException - If store failed.public void remove(@Nullable
GridCacheTx tx,
K key)
throws GridException
null.remove in interface GridCacheStore<K,GridBiTuple<V,?>>tx - Cache transaction, if write-behind is not enabled, null otherwise.key - Key to remove.GridException - If remove failed.public void removeAll(@Nullable
GridCacheTx tx,
@Nullable
Collection<? extends K> keys)
throws GridException
null.removeAll in interface GridCacheStore<K,GridBiTuple<V,?>>tx - Cache transaction, if write-behind is not enabled, null otherwise.keys - Keys to remove.GridException - If remove failed.public void txEnd(GridCacheTx tx, boolean commit) throws GridException
'commit'
parameter.
Note that if explicit transactions are not used in code, then it is possible
to commit or rollback transactions directly in 'put(..)', or 'remove(..)'
methods. In that case, this method should be left empty (GridCacheStoreAdapter provides
empty implementation of this method).
txEnd in interface GridCacheStore<K,GridBiTuple<V,?>>tx - Cache transaction being ended.commit - True if transaction should commit, false for rollback.GridException - If commit or rollback failed. Note that commit failure in some cases
may bring cache transaction into GridCacheTxState.UNKNOWN which will
consequently cause all transacted entries to be invalidated.
Core Products
:
Data Grid ver. 6.0.2,
Streaming ver. 6.0.2
Accelerators
:
Hadoop Accelerator ver. 6.0.2
Release Date
:
March 24 2014