public class GridDataLoaderImpl<K,V> extends Object implements GridDataLoader<K,V>, Delayed
DFLT_MAX_PARALLEL_OPS, DFLT_PER_NODE_BUFFER_SIZE| Constructor and Description |
|---|
GridDataLoaderImpl(GridKernalContext ctx,
String cacheName,
DelayQueue<GridDataLoaderImpl<K,V>> flushQ) |
| Modifier and Type | Method and Description |
|---|---|
GridFuture<?> |
addData(Collection<? extends Map.Entry<K,V>> entries)
Adds data for loading on remote node.
|
GridFuture<?> |
addData(K key,
V val)
Adds data for loading on remote node.
|
GridFuture<?> |
addData(Map.Entry<K,V> entry)
Adds data for loading on remote node.
|
GridFuture<?> |
addData(Map<K,V> entries)
Adds data for loading on remote node.
|
long |
autoFlushFrequency()
Gets automatic flush frequency.
|
void |
autoFlushFrequency(long autoFlushFreq)
Sets automatic flush frequency.
|
String |
cacheName()
Name of cache to load data to.
|
void |
close()
Closes data loader.
|
void |
close(boolean cancel)
Loads any remaining data and closes this loader.
|
int |
compareTo(Delayed o) |
void |
deployClass(Class<?> depCls)
Optional deploy class for peer deployment.
|
void |
flush()
Loads any remaining data, but doesn't close the loader.
|
GridFuture<?> |
future()
Gets future for this loading process.
|
long |
getDelay(TimeUnit unit) |
boolean |
isolated()
Gets flag value indicating that this data loader assumes that there are no other concurrent updates to the cache.
|
void |
isolated(boolean isolated)
Sets flag indicating that this data loader should assume that there are no other concurrent updates to the cache.
|
int |
perNodeBufferSize()
Gets size of per node key-value pairs buffer.
|
void |
perNodeBufferSize(int bufSize)
Sets size of per node key-value pairs buffer.
|
int |
perNodeParallelLoadOperations()
Gets maximum number of parallel load operations for a single node.
|
void |
perNodeParallelLoadOperations(int parallelOps)
Sets maximum number of parallel load operations for a single node.
|
GridFuture<?> |
removeData(K key)
Adds key for removal on remote node.
|
String |
toString() |
void |
tryFlush()
Flushes every internal buffer if buffer was flushed before passed in
threshold.
|
void |
updater(GridDataLoadCacheUpdater<K,V> updater)
Sets custom cache updater to this data loader.
|
public GridDataLoaderImpl(GridKernalContext ctx, @Nullable String cacheName, DelayQueue<GridDataLoaderImpl<K,V>> flushQ)
ctx - Grid kernal context.cacheName - Cache name.flushQ - Flush queue.public GridFuture<?> future()
GridDataLoader.close(boolean) completes. By attaching listeners to this future
it is possible to get asynchronous notifications for completion of this
loading process.future in interface GridDataLoader<K,V>public void deployClass(Class<?> depCls)
deployClass in interface GridDataLoader<K,V>depCls - Any class loaded by the class-loader for given data.public void updater(GridDataLoadCacheUpdater<K,V> updater)
updater in interface GridDataLoader<K,V>updater - Cache updater.public boolean isolated()
false.isolated in interface GridDataLoader<K,V>public void isolated(boolean isolated)
throws GridException
GridDataLoader.updater(GridDataLoadCacheUpdater) method.
Default is false.isolated in interface GridDataLoader<K,V>isolated - Flag value.GridException - If failed.@Nullable public String cacheName()
cacheName in interface GridDataLoader<K,V>null for default cache.public int perNodeBufferSize()
perNodeBufferSize in interface GridDataLoader<K,V>public void perNodeBufferSize(int bufSize)
This method should be called prior to GridDataLoader.addData(Object, Object) call.
If not provided, default value is GridDataLoader.DFLT_PER_NODE_BUFFER_SIZE.
perNodeBufferSize in interface GridDataLoader<K,V>bufSize - Per node buffer size.public int perNodeParallelLoadOperations()
perNodeParallelLoadOperations in interface GridDataLoader<K,V>public void perNodeParallelLoadOperations(int parallelOps)
This method should be called prior to GridDataLoader.addData(Object, Object) call.
If not provided, default value is GridDataLoader.DFLT_MAX_PARALLEL_OPS.
perNodeParallelLoadOperations in interface GridDataLoader<K,V>parallelOps - Maximum number of parallel load operations for a single node.public long autoFlushFrequency()
If set to 0, automatic flush is disabled.
Automatic flush is disabled by default (default value is 0).
autoFlushFrequency in interface GridDataLoader<K,V>0 if automatic flush is disabled.GridDataLoader.flush()public void autoFlushFrequency(long autoFlushFreq)
If set to 0, automatic flush is disabled.
Automatic flush is disabled by default (default value is 0).
autoFlushFrequency in interface GridDataLoader<K,V>autoFlushFreq - Flush frequency or 0 to disable automatic flush.GridDataLoader.flush()public GridFuture<?> addData(Map<K,V> entries) throws IllegalStateException
Note that loader will load data concurrently by multiple internal threads, so the data may get to remote nodes in different order from which it was added to the loader.
addData in interface GridDataLoader<K,V>entries - Map to be loaded.IllegalStateException - If grid has been concurrently stopped or
GridDataLoader.close(boolean) has already been called on loader.public GridFuture<?> addData(Collection<? extends Map.Entry<K,V>> entries)
Note that loader will load data concurrently by multiple internal threads, so the data may get to remote nodes in different order from which it was added to the loader.
addData in interface GridDataLoader<K,V>entries - Collection of entries to be loaded.public GridFuture<?> addData(Map.Entry<K,V> entry) throws GridException, IllegalStateException
Note that loader will load data concurrently by multiple internal threads, so the data may get to remote nodes in different order from which it was added to the loader.
addData in interface GridDataLoader<K,V>entry - Entry.GridException - If failed to map key to node.GridInterruptedException - If thread has been interrupted.IllegalStateException - If grid has been concurrently stopped or
GridDataLoader.close(boolean) has already been called on loader.public GridFuture<?> addData(K key, V val) throws GridException, IllegalStateException
Note that loader will load data concurrently by multiple internal threads, so the data may get to remote nodes in different order from which it was added to the loader.
addData in interface GridDataLoader<K,V>key - Key.val - Value or null if respective entry must be removed from cache.GridException - If failed to map key to node.GridInterruptedException - If thread has been interrupted.IllegalStateException - If grid has been concurrently stopped or
GridDataLoader.close(boolean) has already been called on loader.public GridFuture<?> removeData(K key) throws GridException, IllegalStateException
addData(key, null).removeData in interface GridDataLoader<K,V>key - Key.GridException - If failed to map key to node.GridInterruptedException - If thread has been interrupted.IllegalStateException - If grid has been concurrently stopped or
GridDataLoader.close(boolean) has already been called on loader.public void flush()
throws GridException
If another thread is already performing flush, this method will block, wait for
another thread to complete flush and exit. If you don't want to wait in this case,
use GridDataLoader.tryFlush() method.
flush in interface GridDataLoader<K,V>GridException - If failed to map key to node.GridInterruptedException - If thread has been interrupted.GridDataLoader.tryFlush()public void tryFlush()
throws GridInterruptedException
Does not wait for result and does not fail on errors assuming that this method should be called periodically.
tryFlush in interface GridDataLoader<K,V>GridInterruptedException - If thread has been interrupted.GridDataLoader.flush()public void close(boolean cancel)
throws GridException
GridDataLoaderclose in interface GridDataLoader<K,V>cancel - True to close with cancellation.GridException - If failed.public void close()
throws GridException
close(false) method.
The method is invoked automatically on objects managed by the
try-with-resources statement.
close in interface AutoCloseableclose in interface GridDataLoader<K,V>GridException - If failed to close data loader.GridInterruptedException - If thread has been interrupted.public int compareTo(Delayed o)
compareTo in interface Comparable<Delayed>Copyright © 2014. All rights reserved.