Class MemoryBasedCopyingRemoteIterator<T>
- java.lang.Object
-
- de.aristaflow.adept2.model.common.collection.AbstractRemoteIterator<T,T>
-
- de.aristaflow.adept2.model.common.collection.AbstractTimeTrackingRemoteIterator<T>
-
- de.aristaflow.adept2.model.common.collection.MemoryBasedCopyingRemoteIterator<T>
-
- Type Parameters:
T- The type of the elements that are iterated.
- All Implemented Interfaces:
RemoteIterator<List<T>>,de.aristaflow.adept2.model.communication.ServerSideProxy,de.aristaflow.adept2.model.communication.TimeTrackingSsProxy,Closeable,AutoCloseable
public class MemoryBasedCopyingRemoteIterator<T> extends AbstractTimeTrackingRemoteIterator<T>
A remote iterator based on a list of elements that are completely in memory. This is only useful for memory-based storages which are unable to provide a result partially.
Since all elements are copied when creating this iterator, it is a snapshot and always consistent. It has an expiring alive time thus allowing to release the occupied memory even if no explicitclose()occurs.close()closesAutoCloseableelements and resets the class fields.
-
-
Field Summary
Fields Modifier and Type Field Description protected intcurrentThe reference to the current element which is to be retrieved next.protected List<T>elementsThe elements of this memory based iterator.-
Fields inherited from class de.aristaflow.adept2.model.common.collection.AbstractTimeTrackingRemoteIterator
busyThreads, snapshot
-
Fields inherited from class de.aristaflow.adept2.model.common.collection.AbstractRemoteIterator
cleanup, closeables, logger, transformator
-
-
Constructor Summary
Constructors Constructor Description MemoryBasedCopyingRemoteIterator(Collection<T> elements)Deprecated, for removal: This API element is subject to removal in a future version.MemoryBasedCopyingRemoteIterator(Collection<T> elements, long aliveTime, long aliveTimeExtension, Logger logger)Creates a new remote iterator keeping (a copy of) the designated collection in main memory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Explicitly closes this iterator which allows to release occupied memory and resources.protected List<T>getAllImpl()ImplementsAbstractRemoteIterator.getAll()without the need to consider result transformation, closeable and alive time tracking.protected List<T>getNextImpl(int count)ImplementsAbstractRemoteIterator.getNext(int)without the need to consider result transformation, closeable and alive time tracking.protected List<T>getNextImpl(int count, int start)ImplementsAbstractRemoteIterator.getNext(int, int)without the need to consider result transformation, closeable and alive time tracking.protected List<T>getPreviousImpl(int count)ImplementsAbstractRemoteIterator.getPrevious(int)without the need to consider result transformation, closeable and alive time tracking.protected booleanisClosed()Gets whether this remote iterator has been closed and its data is not available any more.-
Methods inherited from class de.aristaflow.adept2.model.common.collection.AbstractTimeTrackingRemoteIterator
enter, exit, getCloseTime, getRemainingAliveTime, getSnapshotImpl, isBusy, isForwardOnly, isSnapshot, keepAlive, setCloseTime
-
Methods inherited from class de.aristaflow.adept2.model.common.collection.AbstractRemoteIterator
aboutToReturn, closeOnTraversal, getAll, getNext, getNext, getPrevious, setCloseOnTraversal
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.aristaflow.adept2.model.common.collection.RemoteIterator
drop
-
-
-
-
Constructor Detail
-
MemoryBasedCopyingRemoteIterator
@Deprecated(since="15.0.0", forRemoval=true) public MemoryBasedCopyingRemoteIterator(Collection<T> elements)
Deprecated, for removal: This API element is subject to removal in a future version.Creates a new remote iterator keeping (a copy of) the designated collection in main memory. The alive will beLong.MAX_VALUEuntil explicitly closed. Then the alive time will beLong.MIN_VALUE.- Parameters:
elements- The elements of this iterator.
-
MemoryBasedCopyingRemoteIterator
public MemoryBasedCopyingRemoteIterator(Collection<T> elements, long aliveTime, long aliveTimeExtension, Logger logger)
Creates a new remote iterator keeping (a copy of) the designated collection in main memory. The alive will beLong.MAX_VALUEuntil explicitly closed. Then the alive time will beLong.MIN_VALUE.- Parameters:
elements- The elements of this iterator.aliveTime- The time in milliseconds this remote iterator is alive.aliveTimeExtension- The time in milliseconds to extend the alive time when accessing this remote iterator.logger- The logger for logging messages instead of throwing exceptions.
-
-
Method Detail
-
isClosed
protected boolean isClosed()
Description copied from class:AbstractRemoteIteratorGets whether this remote iterator has been closed and its data is not available any more.- Specified by:
isClosedin classAbstractRemoteIterator<T,T>- Returns:
- Whether this remote iterator has been closed and its data is not available any more.
-
getNextImpl
protected List<T> getNextImpl(int count) throws DataConsistencyException
Description copied from class:AbstractRemoteIteratorImplementsAbstractRemoteIterator.getNext(int)without the need to consider result transformation, closeable and alive time tracking.- Specified by:
getNextImplin classAbstractRemoteIterator<T,T>- Throws:
DataConsistencyException
-
getNextImpl
protected List<T> getNextImpl(int count, int start) throws DataConsistencyException
Description copied from class:AbstractRemoteIteratorImplementsAbstractRemoteIterator.getNext(int, int)without the need to consider result transformation, closeable and alive time tracking.- Specified by:
getNextImplin classAbstractRemoteIterator<T,T>- Throws:
DataConsistencyException
-
getPreviousImpl
protected List<T> getPreviousImpl(int count) throws DataConsistencyException
Description copied from class:AbstractRemoteIteratorImplementsAbstractRemoteIterator.getPrevious(int)without the need to consider result transformation, closeable and alive time tracking.- Specified by:
getPreviousImplin classAbstractRemoteIterator<T,T>- Throws:
DataConsistencyException
-
getAllImpl
protected List<T> getAllImpl() throws DataConsistencyException
Description copied from class:AbstractRemoteIteratorImplementsAbstractRemoteIterator.getAll()without the need to consider result transformation, closeable and alive time tracking.- Specified by:
getAllImplin classAbstractRemoteIterator<T,T>- Throws:
DataConsistencyException
-
close
public void close() throws IOExceptionDescription copied from interface:RemoteIteratorExplicitly closes this iterator which allows to release occupied memory and resources. Closing will be done implicitly after the alive time has elapsed.
This method may be called several times. Implementors have to take care of this.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceRemoteIterator<T>- Specified by:
closein interfacede.aristaflow.adept2.model.communication.ServerSideProxy- Overrides:
closein classAbstractRemoteIterator<T,T>- Throws:
IOException- If there are problems accessing the underlying data source, anIOExceptionwill be thrown.
-
-