public class DataStreamerImpl<K,V> extends Object implements IgniteDataStreamer<K,V>, Delayed
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DataStreamerImpl.IsolatedUpdater
Isolated receiver which only loads entry initial value.
|
DFLT_MAX_PARALLEL_OPS, DFLT_PARALLEL_OPS_MULTIPLIER, DFLT_PER_NODE_BUFFER_SIZE, DFLT_PER_THREAD_BUFFER_SIZE, DFLT_UNLIMIT_TIMEOUT| 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(Collection<? extends DataStreamerEntry> entries,
boolean useThreadBuffer) |
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) |
protected IgniteCacheFutureImpl |
createDataLoadFuture()
Creates data load future and register its as active future.
|
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() |
void |
ioPolicyResolver(IgniteClosure<ClusterNode,Byte> ioPlcRslvr) |
boolean |
keepBinary()
Gets flag indicating that objects should be kept in binary format when passed to the stream receiver.
|
void |
keepBinary(boolean keepBinary)
Sets flag indicating that objects should be kept in binary format when passes to the steam receiver.
|
int |
maxRemapCount() |
void |
maxRemapCount(int maxRemapCnt) |
void |
onDisconnected(IgniteFuture<?> reconnectFut) |
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.
|
int |
perThreadBufferSize()
Gets buffer size set by
IgniteDataStreamer.perThreadBufferSize(int). |
void |
perThreadBufferSize(int size)
Allows to set buffer size for thread in case of stream by
IgniteDataStreamer.addData(Object, Object) call. |
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.
|
long |
timeout()
Gets timeout set by
IgniteDataStreamer.timeout(long). |
void |
timeout(long timeout)
Sets the timeout that is used in the following cases:
any data addition method can be blocked when all per node parallel operations are exhausted.
|
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 void perThreadBufferSize(int size)
IgniteDataStreamer.addData(Object, Object) call.perThreadBufferSize in interface IgniteDataStreamer<K,V>size - Size of buffer.public int perThreadBufferSize()
IgniteDataStreamer.perThreadBufferSize(int).perThreadBufferSize in interface IgniteDataStreamer<K,V>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)
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).
The flag has no effect when custom cache receiver set using IgniteDataStreamer.receiver(StreamReceiver) method.
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.public boolean keepBinary()
false.keepBinary in interface IgniteDataStreamer<K,V>public void keepBinary(boolean keepBinary)
false.keepBinary in interface IgniteDataStreamer<K,V>keepBinary - Keep binary 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 calculated as follows
IgniteDataStreamer.DFLT_PARALLEL_OPS_MULTIPLIER * DATA_STREAMER_POOL_SIZE_ON_REMOTE_NODE.
perNodeParallelOperations in interface IgniteDataStreamer<K,V>parallelOps - Maximum number of parallel stream operations for a single node.IgniteConfiguration.getDataStreamerThreadPoolSize()public void timeout(long timeout)
IgniteDataStreamer.flush() operation;IgniteDataStreamer.close() operation.timeout in interface IgniteDataStreamer<K,V>timeout - Timeout in milliseconds.public long timeout()
IgniteDataStreamer.timeout(long).timeout in interface IgniteDataStreamer<K,V>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. The data may not be sent until IgniteDataStreamer.flush() or IgniteDataStreamer.close() are called.
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.IgniteDataStreamer.flush() or IgniteDataStreamer.close() are explicitly called.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. The data may not be sent until IgniteDataStreamer.flush() or IgniteDataStreamer.close() are called.
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.flush() or IgniteDataStreamer.close() are explicitly called.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<?> addDataInternal(Collection<? extends DataStreamerEntry> entries, boolean useThreadBuffer)
entries - Entries.useThreadBuffer - @NotNull protected IgniteCacheFutureImpl createDataLoadFuture()
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. The data may not be sent until IgniteDataStreamer.flush() or IgniteDataStreamer.close() are called.
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.flush() or IgniteDataStreamer.close() are explicitly called.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. The data may not be sent until IgniteDataStreamer.flush() or IgniteDataStreamer.close() are called.
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.flush() or IgniteDataStreamer.close() are explicitly called.IgniteDataStreamer.allowOverwrite()public IgniteFuture<?> removeData(K key)
addData(key, null).removeData in interface IgniteDataStreamer<K,V>key - Key.IgniteDataStreamer.flush() or IgniteDataStreamer.close() are explicitly called.public void ioPolicyResolver(IgniteClosure<ClusterNode,Byte> ioPlcRslvr)
ioPlcRslvr - IO policy resolver.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.
Note that #flush() guarantees completion of all futures returned by IgniteDataStreamer.addData(Object, Object), listeners
should be tracked separately.
flush in interface IgniteDataStreamer<K,V>javax.cache.CacheException - If failed to load data from buffer.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 onDisconnected(IgniteFuture<?> reconnectFut) throws IgniteCheckedException
reconnectFut - Reconnect future.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 Database and Caching Platform : ver. 2.7.5 Release Date : June 4 2019