public class IgniteDataLoaderImpl<K,V> extends Object implements IgniteDataLoader<K,V>, Delayed
IgniteDataLoader.Updater<K,V>DFLT_MAX_PARALLEL_OPS, DFLT_PER_NODE_BUFFER_SIZE| Constructor and Description |
|---|
IgniteDataLoaderImpl(GridKernalContext ctx,
String cacheName,
DelayQueue<IgniteDataLoaderImpl<K,V>> flushQ,
boolean compact) |
| Modifier and Type | Method and Description |
|---|---|
IgniteFuture<?> |
addData(Collection<? extends Map.Entry<K,V>> entries)
Adds data for loading on remote node.
|
IgniteFuture<?> |
addData(K key,
V val)
Adds data for loading on remote node.
|
IgniteFuture<?> |
addData(Map.Entry<K,V> entry)
Adds data for loading on remote node.
|
IgniteFuture<?> |
addData(Map<K,V> entries)
Adds data for loading on remote node.
|
boolean |
allowOverwrite()
Gets flag value indicating that this data loader assumes that there are no other concurrent updates to the cache.
|
void |
allowOverwrite(boolean allow)
Sets flag indicating that this data loader should assume that there are no other concurrent updates to the cache.
|
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.
|
void |
closeEx(boolean cancel) |
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.
|
IgniteFuture<?> |
future()
Gets future for this loading process.
|
long |
getDelay(TimeUnit unit) |
IgniteInternalFuture<?> |
internalFuture() |
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.
|
IgniteFuture<?> |
removeData(K key)
Adds key for removal on remote node.
|
boolean |
skipStore()
Gets flag indicating that write-through behavior should be disabled for data loading.
|
void |
skipStore(boolean skipStore)
Sets flag indicating that write-through behavior should be disabled for data loading.
|
String |
toString() |
void |
tryFlush()
Flushes every internal buffer if buffer was flushed before passed in
threshold.
|
void |
updater(IgniteDataLoader.Updater<K,V> updater)
Sets custom cache updater to this data loader.
|
public IgniteDataLoaderImpl(GridKernalContext ctx, @Nullable String cacheName, DelayQueue<IgniteDataLoaderImpl<K,V>> flushQ, boolean compact)
ctx - Grid kernal context.cacheName - Cache name.flushQ - Flush queue.compact - If true data is transferred in compact mode (only keys and values).
Otherwise full map entry will be transferred (this is required by DR internal logic).public IgniteFuture<?> future()
IgniteDataLoader.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 IgniteDataLoader<K,V>public IgniteInternalFuture<?> internalFuture()
public void deployClass(Class<?> depCls)
deployClass in interface IgniteDataLoader<K,V>depCls - Any class loaded by the class-loader for given data.public void updater(IgniteDataLoader.Updater<K,V> updater)
updater in interface IgniteDataLoader<K,V>updater - Cache updater.public boolean allowOverwrite()
true.allowOverwrite in interface IgniteDataLoader<K,V>public void allowOverwrite(boolean allow)
IgniteDataLoader.updater(IgniteDataLoader.Updater) method.
Default is true. When this flag is set, updates will not be propagated to the cache store.allowOverwrite in interface IgniteDataLoader<K,V>allow - Flag value.public boolean skipStore()
false.skipStore in interface IgniteDataLoader<K,V>public void skipStore(boolean skipStore)
false.skipStore in interface IgniteDataLoader<K,V>skipStore - Skip store flag.@Nullable public String cacheName()
cacheName in interface IgniteDataLoader<K,V>null for default cache.public int perNodeBufferSize()
perNodeBufferSize in interface IgniteDataLoader<K,V>public void perNodeBufferSize(int bufSize)
This method should be called prior to IgniteDataLoader.addData(Object, Object) call.
If not provided, default value is IgniteDataLoader.DFLT_PER_NODE_BUFFER_SIZE.
perNodeBufferSize in interface IgniteDataLoader<K,V>bufSize - Per node buffer size.public int perNodeParallelLoadOperations()
perNodeParallelLoadOperations in interface IgniteDataLoader<K,V>public void perNodeParallelLoadOperations(int parallelOps)
This method should be called prior to IgniteDataLoader.addData(Object, Object) call.
If not provided, default value is IgniteDataLoader.DFLT_MAX_PARALLEL_OPS.
perNodeParallelLoadOperations in interface IgniteDataLoader<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 IgniteDataLoader<K,V>0 if automatic flush is disabled.IgniteDataLoader.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 IgniteDataLoader<K,V>autoFlushFreq - Flush frequency or 0 to disable automatic flush.IgniteDataLoader.flush()public IgniteFuture<?> 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 IgniteDataLoader<K,V>entries - Map to be loaded.IllegalStateException - If grid has been concurrently stopped or
IgniteDataLoader.close(boolean) has already been called on loader.public IgniteFuture<?> 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 IgniteDataLoader<K,V>entries - Collection of entries to be loaded.public IgniteFuture<?> addData(Map.Entry<K,V> entry)
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 IgniteDataLoader<K,V>entry - Entry.public IgniteFuture<?> addData(K key, V val)
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 IgniteDataLoader<K,V>key - Key.val - Value or null if respective entry must be removed from cache.public IgniteFuture<?> removeData(K key)
addData(key, null).removeData in interface IgniteDataLoader<K,V>key - Key.public void flush()
throws IgniteException
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 IgniteDataLoader.tryFlush() method.
flush in interface IgniteDataLoader<K,V>IgniteException - If failed to map key to node.IgniteInterruptedException - If thread has been interrupted.IgniteDataLoader.tryFlush()public void tryFlush()
throws IgniteInterruptedException
Does not wait for result and does not fail on errors assuming that this method should be called periodically.
tryFlush in interface IgniteDataLoader<K,V>IgniteInterruptedException - If thread has been interrupted.IgniteDataLoader.flush()public void close(boolean cancel)
throws IgniteException
IgniteDataLoaderclose in interface IgniteDataLoader<K,V>cancel - True to close with cancellation.IgniteException - If failed.public void closeEx(boolean cancel)
throws IgniteCheckedException
cancel - True to close with cancellation.IgniteCheckedException - If failed.public void close()
throws IgniteException
close(false) method.
The method is invoked automatically on objects managed by the
try-with-resources statement.
close in interface AutoCloseableclose in interface IgniteDataLoader<K,V>IgniteException - If failed to close data loader.IgniteInterruptedException - If thread has been interrupted.public int compareTo(Delayed o)
compareTo in interface Comparable<Delayed>
Follow @ApacheIgnite
Ignite Fabric : ver. 1.0.0-RC1 Release Date : February 17 2015