public class DataStreamerImpl<K,V> extends Object implements IgniteDataStreamer<K,V>, Delayed
DFLT_MAX_PARALLEL_OPS, DFLT_PER_NODE_BUFFER_SIZE| Constructor and Description |
|---|
DataStreamerImpl(GridKernalContext ctx,
String cacheName,
DelayQueue<DataStreamerImpl<K,V>> flushQ) |
| Modifier and Type | Method and Description |
|---|---|
IgniteFuture<?> |
addData(Collection<? extends Map.Entry<K,V>> entries)
Adds data for streaming on remote node.
|
IgniteFuture<?> |
addData(K key,
V val)
Adds data for streaming on remote node.
|
IgniteFuture<?> |
addData(Map.Entry<K,V> entry)
Adds data for streaming on remote node.
|
IgniteFuture<?> |
addData(Map<K,V> entries)
Adds data for streaming on remote node.
|
IgniteFuture<?> |
addDataInternal(Collection<? extends DataStreamerEntry> entries) |
IgniteFuture<?> |
addDataInternal(KeyCacheObject key,
CacheObject val) |
boolean |
allowOverwrite()
Gets flag enabling overwriting existing values in cache.
|
void |
allowOverwrite(boolean allow)
Sets flag enabling overwriting existing values in cache.
|
long |
autoFlushFrequency()
Gets automatic flush frequency.
|
void |
autoFlushFrequency(long autoFlushFreq)
Sets automatic flush frequency.
|
String |
cacheName()
Name of cache to stream data to.
|
CacheObjectContext |
cacheObjectContext() |
void |
close()
Closes data streamer.
|
void |
close(boolean cancel)
Streams any remaining data and closes this streamer.
|
void |
closeEx(boolean cancel) |
int |
compareTo(Delayed o) |
void |
deployClass(Class<?> depCls)
Optional deploy class for peer deployment.
|
void |
flush()
Streams any remaining data, but doesn't close the streamer.
|
IgniteFuture<?> |
future()
Gets future for this streaming process.
|
long |
getDelay(TimeUnit unit) |
IgniteInternalFuture<?> |
internalFuture() |
int |
maxRemapCount() |
void |
maxRemapCount(int maxRemapCnt) |
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 |
perNodeParallelOperations()
Gets maximum number of parallel stream operations for a single node.
|
void |
perNodeParallelOperations(int parallelOps)
Sets maximum number of parallel stream operations for a single node.
|
void |
receiver(StreamReceiver<K,V> rcvr)
Sets custom stream receiver to this data streamer.
|
IgniteFuture<?> |
removeData(K key)
Adds key for removal on remote node.
|
IgniteFuture<?> |
removeDataInternal(KeyCacheObject key) |
boolean |
skipStore()
Gets flag indicating that write-through behavior should be disabled for data streaming.
|
void |
skipStore(boolean skipStore)
Sets flag indicating that write-through behavior should be disabled for data streaming.
|
String |
toString() |
void |
tryFlush()
Flushes every internal buffer if buffer was flushed before passed in
threshold.
|
public DataStreamerImpl(GridKernalContext ctx, @Nullable String cacheName, DelayQueue<DataStreamerImpl<K,V>> flushQ)
ctx - Grid kernal context.cacheName - Cache name.flushQ - Flush queue.public CacheObjectContext cacheObjectContext()
public IgniteFuture<?> future()
IgniteDataStreamer.close(boolean) completes. By attaching listeners to this future
it is possible to get asynchronous notifications for completion of this
streaming process.future in interface IgniteDataStreamer<K,V>public IgniteInternalFuture<?> internalFuture()
public void deployClass(Class<?> depCls)
deployClass in interface IgniteDataStreamer<K,V>depCls - Any class loaded by the class-loader for given data.public void receiver(StreamReceiver<K,V> rcvr)
receiver in interface IgniteDataStreamer<K,V>rcvr - Stream receiver.public boolean allowOverwrite()
This flag is disabled by default (default is false).
allowOverwrite in interface IgniteDataStreamer<K,V>True if overwriting is allowed, false otherwise..public void allowOverwrite(boolean allow)
Should not be used when custom cache receiver set using IgniteDataStreamer.receiver(StreamReceiver) method.
Note that when this flag is false, updates will not be propagated to the cache store
(i.e. IgniteDataStreamer.skipStore() flag will be set to true implicitly).
This flag is disabled by default (default is false).
allowOverwrite in interface IgniteDataStreamer<K,V>allow - Flag value.public boolean skipStore()
false.skipStore in interface IgniteDataStreamer<K,V>public void skipStore(boolean skipStore)
false.skipStore in interface IgniteDataStreamer<K,V>skipStore - Skip store flag.@Nullable public String cacheName()
cacheName in interface IgniteDataStreamer<K,V>null for default cache.public int perNodeBufferSize()
perNodeBufferSize in interface IgniteDataStreamer<K,V>public void perNodeBufferSize(int bufSize)
This method should be called prior to IgniteDataStreamer.addData(Object, Object) call.
If not provided, default value is IgniteDataStreamer.DFLT_PER_NODE_BUFFER_SIZE.
perNodeBufferSize in interface IgniteDataStreamer<K,V>bufSize - Per node buffer size.public int perNodeParallelOperations()
perNodeParallelOperations in interface IgniteDataStreamer<K,V>public void perNodeParallelOperations(int parallelOps)
This method should be called prior to IgniteDataStreamer.addData(Object, Object) call.
If not provided, default value is IgniteDataStreamer.DFLT_MAX_PARALLEL_OPS.
perNodeParallelOperations in interface IgniteDataStreamer<K,V>parallelOps - Maximum number of parallel stream 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 IgniteDataStreamer<K,V>0 if automatic flush is disabled.IgniteDataStreamer.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 IgniteDataStreamer<K,V>autoFlushFreq - Flush frequency or 0 to disable automatic flush.IgniteDataStreamer.flush()public IgniteFuture<?> addData(Map<K,V> entries) throws IllegalStateException
Note that streamer will stream data concurrently by multiple internal threads, so the data may get to remote nodes in different order from which it was added to the streamer.
Note: if IgniteDataStreamer.allowOverwrite() set to false (by default)
then data streamer will not overwrite existing cache entries for better performance
(to change, set IgniteDataStreamer.allowOverwrite(boolean) to true)
addData in interface IgniteDataStreamer<K,V>entries - Map to be streamed.IllegalStateException - If grid has been concurrently stopped or
IgniteDataStreamer.close(boolean) has already been called on streamer.IgniteDataStreamer.allowOverwrite()public IgniteFuture<?> addData(Collection<? extends Map.Entry<K,V>> entries)
Note that streamer will stream data concurrently by multiple internal threads, so the data may get to remote nodes in different order from which it was added to the streamer.
Note: if IgniteDataStreamer.allowOverwrite() set to false (by default)
then data streamer will not overwrite existing cache entries for better performance
(to change, set IgniteDataStreamer.allowOverwrite(boolean) to true)
addData in interface IgniteDataStreamer<K,V>entries - Collection of entries to be streamed.IgniteDataStreamer.allowOverwrite()public IgniteFuture<?> addDataInternal(KeyCacheObject key, CacheObject val)
key - Key.val - Value.public IgniteFuture<?> removeDataInternal(KeyCacheObject key)
key - Key.public IgniteFuture<?> addDataInternal(Collection<? extends DataStreamerEntry> entries)
entries - Entries.public IgniteFuture<?> addData(Map.Entry<K,V> entry)
Note that streamer will stream data concurrently by multiple internal threads, so the data may get to remote nodes in different order from which it was added to the streamer.
Note: if IgniteDataStreamer.allowOverwrite() set to false (by default)
then data streamer will not overwrite existing cache entries for better performance
(to change, set IgniteDataStreamer.allowOverwrite(boolean) to true)
addData in interface IgniteDataStreamer<K,V>entry - Entry.IgniteDataStreamer.allowOverwrite()public IgniteFuture<?> addData(K key, V val)
Note that streamer will stream data concurrently by multiple internal threads, so the data may get to remote nodes in different order from which it was added to the streamer.
Note: if IgniteDataStreamer.allowOverwrite() set to false (by default)
then data streamer will not overwrite existing cache entries for better performance
(to change, set IgniteDataStreamer.allowOverwrite(boolean) to true)
addData in interface IgniteDataStreamer<K,V>key - Key.val - Value or null if respective entry must be removed from cache.IgniteDataStreamer.allowOverwrite()public IgniteFuture<?> removeData(K key)
addData(key, null).removeData in interface IgniteDataStreamer<K,V>key - Key.public void flush()
throws javax.cache.CacheException
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 IgniteDataStreamer.tryFlush() method.
flush in interface IgniteDataStreamer<K,V>javax.cache.CacheException - If failed to map key to node.IgniteDataStreamer.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 IgniteDataStreamer<K,V>IgniteInterruptedException - If thread has been interrupted.IgniteDataStreamer.flush()public void close(boolean cancel)
throws javax.cache.CacheException
IgniteDataStreamerclose in interface IgniteDataStreamer<K,V>cancel - True to close with cancellation.javax.cache.CacheException - If failed.public void closeEx(boolean cancel)
throws IgniteCheckedException
cancel - True to close with cancellation.IgniteCheckedException - If failed.public void close()
throws javax.cache.CacheException
close(false) method.
The method is invoked automatically on objects managed by the
try-with-resources statement.
close in interface AutoCloseableclose in interface IgniteDataStreamer<K,V>javax.cache.CacheException - If failed to close data streamer.public int maxRemapCount()
public void maxRemapCount(int maxRemapCnt)
maxRemapCnt - New max remap count.public int compareTo(Delayed o)
compareTo in interface Comparable<Delayed>
Follow @ApacheIgnite
Ignite Fabric : ver. 1.0.0 Release Date : March 31 2015