Package org.infinispan.stream.impl
Class LocalStreamManagerImpl<Original,K,V>
- java.lang.Object
-
- org.infinispan.stream.impl.LocalStreamManagerImpl<Original,K,V>
-
- Type Parameters:
Original
- original stream typeK
- key type of underlying cacheV
- value type of underlying cache
- All Implemented Interfaces:
LocalStreamManager<Original,K>
public class LocalStreamManagerImpl<Original,K,V> extends Object implements LocalStreamManager<Original,K>
Local stream manager implementation that handles injection of the stream supplier, invoking the operation and subsequently notifying the operation if a rehash has changed one of its segments.
-
-
Constructor Summary
Constructors Constructor Description LocalStreamManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IteratorResponse
continueIterator(Object requestId, long batchSize)
Continues an existing iterator by retrieving the next batchSize of elementsvoid
dataRehashed(DataRehashedEvent<K,V> event)
We need to listen to data rehash events in case if data moves while we are iterating over it.void
inject(Cache<K,V> cache)
Injects the cache - unfortunately this cannot be in start.void
start()
IteratorResponse
startIterator(Object requestId, Address origin, org.infinispan.commons.util.IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, Iterable<IntermediateOperation> intermediateOperations, long batchSize)
Signals that a new iterator is created using the given arguments.<R> void
streamOperation(Object requestId, Address origin, boolean parallelStream, org.infinispan.commons.util.IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, KeyTrackingTerminalOperation<Original,K,R> operation)
Stream operation for a key aware operation without rehash enabled<R> void
streamOperation(Object requestId, Address origin, boolean parallelStream, org.infinispan.commons.util.IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, TerminalOperation<Original,R> operation)
Stream operation for a non key aware operation without rehash enabled.void
streamOperationRehashAware(Object requestId, Address origin, boolean parallelStream, org.infinispan.commons.util.IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, KeyTrackingTerminalOperation<Original,K,?> operation)
Stream operation for a key aware operation with rehash enabled<R> void
streamOperationRehashAware(Object requestId, Address origin, boolean parallelStream, org.infinispan.commons.util.IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, TerminalOperation<Original,R> operation)
Stream operation for a non key aware operation with rehash enabled.
-
-
-
Method Detail
-
inject
public void inject(Cache<K,V> cache)
Injects the cache - unfortunately this cannot be in start. Tests will rewire certain components which will in turn reinject the cache, but they won't call the start method! If the latter is fixed we can add this to start method and add @Inject to the variable.- Parameters:
cache
-
-
start
public void start()
-
dataRehashed
public void dataRehashed(DataRehashedEvent<K,V> event)
We need to listen to data rehash events in case if data moves while we are iterating over it. If a rehash occurs causing this node to lose a segment and there is something iterating over the stream looking for values of that segment, we can't guarantee that the data has all been seen correctly, so we must therefore suspect that node by sending it back to the owner.- Parameters:
event
- The data rehash event
-
streamOperation
public <R> void streamOperation(Object requestId, Address origin, boolean parallelStream, org.infinispan.commons.util.IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, TerminalOperation<Original,R> operation)
Description copied from interface:LocalStreamManager
Stream operation for a non key aware operation without rehash enabled.- Specified by:
streamOperation
in interfaceLocalStreamManager<Original,K>
- Type Parameters:
R
- the type of value from the operation- Parameters:
requestId
- the originating request idorigin
- the node this request came fromparallelStream
- whether this stream is parallel or notsegments
- the segments to include in this operationkeysToInclude
- which keys to includekeysToExclude
- which keys to excludeincludeLoader
- whether or not a cache loader should be utilizedoperation
- the operation to perform
-
streamOperationRehashAware
public <R> void streamOperationRehashAware(Object requestId, Address origin, boolean parallelStream, org.infinispan.commons.util.IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, TerminalOperation<Original,R> operation)
Description copied from interface:LocalStreamManager
Stream operation for a non key aware operation with rehash enabled.- Specified by:
streamOperationRehashAware
in interfaceLocalStreamManager<Original,K>
- Type Parameters:
R
- the type of value from the operation- Parameters:
requestId
- the originating request idorigin
- the node this request came fromparallelStream
- whether this stream is parallel or notsegments
- the segments to include in this operationkeysToInclude
- which keys to includekeysToExclude
- which keys to excludeincludeLoader
- whether or not a cache loader should be utilizedoperation
- the operation to perform
-
streamOperation
public <R> void streamOperation(Object requestId, Address origin, boolean parallelStream, org.infinispan.commons.util.IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, KeyTrackingTerminalOperation<Original,K,R> operation)
Description copied from interface:LocalStreamManager
Stream operation for a key aware operation without rehash enabled- Specified by:
streamOperation
in interfaceLocalStreamManager<Original,K>
- Type Parameters:
R
- the type of value from the operation- Parameters:
requestId
- the originating request idorigin
- the node this request came fromparallelStream
- whether this stream is parallel or notsegments
- the segments to include in this operationkeysToInclude
- which keys to includekeysToExclude
- which keys to excludeincludeLoader
- whether or not a cache loader should be utilizedoperation
- the operation to perform
-
streamOperationRehashAware
public void streamOperationRehashAware(Object requestId, Address origin, boolean parallelStream, org.infinispan.commons.util.IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, KeyTrackingTerminalOperation<Original,K,?> operation)
Description copied from interface:LocalStreamManager
Stream operation for a key aware operation with rehash enabled- Specified by:
streamOperationRehashAware
in interfaceLocalStreamManager<Original,K>
- Parameters:
requestId
- the originating request idorigin
- the node this request came fromparallelStream
- whether this stream is parallel or notsegments
- the segments to include in this operationkeysToInclude
- which keys to includekeysToExclude
- which keys to excludeincludeLoader
- whether or not a cache loader should be utilizedoperation
- the operation to perform
-
startIterator
public IteratorResponse startIterator(Object requestId, Address origin, org.infinispan.commons.util.IntSet segments, Set<K> keysToInclude, Set<K> keysToExclude, boolean includeLoader, boolean entryStream, Iterable<IntermediateOperation> intermediateOperations, long batchSize)
Description copied from interface:LocalStreamManager
Signals that a new iterator is created using the given arguments. Returns a response which only returns the given batchSize worth of elements.- Specified by:
startIterator
in interfaceLocalStreamManager<Original,K>
- Parameters:
requestId
- the originating request idorigin
- the node this request came fromsegments
- the segments to include in this operationkeysToInclude
- which keys to includekeysToExclude
- which keys to excludeincludeLoader
- whether or not a cache loader should be utilizedintermediateOperations
- the operations to apply to the underlying databatchSize
- how many elements to return- Returns:
- the response containing iterator
-
continueIterator
public IteratorResponse continueIterator(Object requestId, long batchSize)
Description copied from interface:LocalStreamManager
Continues an existing iterator by retrieving the next batchSize of elements- Specified by:
continueIterator
in interfaceLocalStreamManager<Original,K>
- Parameters:
requestId
- the originating request idbatchSize
- how many elements to return- Returns:
- the response containing iterator
-
-