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()
closesAutoCloseable
elements and resets the class fields.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
current
The reference to the current element which is to be retrieved next.protected List<T>
elements
The 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 void
close()
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 boolean
isClosed()
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_VALUE
until 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_VALUE
until 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:AbstractRemoteIterator
Gets whether this remote iterator has been closed and its data is not available any more.- Specified by:
isClosed
in 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:AbstractRemoteIterator
ImplementsAbstractRemoteIterator.getNext(int)
without the need to consider result transformation, closeable and alive time tracking.- Specified by:
getNextImpl
in classAbstractRemoteIterator<T,T>
- Throws:
DataConsistencyException
-
getNextImpl
protected List<T> getNextImpl(int count, int start) throws DataConsistencyException
Description copied from class:AbstractRemoteIterator
ImplementsAbstractRemoteIterator.getNext(int, int)
without the need to consider result transformation, closeable and alive time tracking.- Specified by:
getNextImpl
in classAbstractRemoteIterator<T,T>
- Throws:
DataConsistencyException
-
getPreviousImpl
protected List<T> getPreviousImpl(int count) throws DataConsistencyException
Description copied from class:AbstractRemoteIterator
ImplementsAbstractRemoteIterator.getPrevious(int)
without the need to consider result transformation, closeable and alive time tracking.- Specified by:
getPreviousImpl
in classAbstractRemoteIterator<T,T>
- Throws:
DataConsistencyException
-
getAllImpl
protected List<T> getAllImpl() throws DataConsistencyException
Description copied from class:AbstractRemoteIterator
ImplementsAbstractRemoteIterator.getAll()
without the need to consider result transformation, closeable and alive time tracking.- Specified by:
getAllImpl
in classAbstractRemoteIterator<T,T>
- Throws:
DataConsistencyException
-
close
public void close() throws IOException
Description copied from interface:RemoteIterator
Explicitly 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceRemoteIterator<T>
- Specified by:
close
in interfacede.aristaflow.adept2.model.communication.ServerSideProxy
- Overrides:
close
in classAbstractRemoteIterator<T,T>
- Throws:
IOException
- If there are problems accessing the underlying data source, anIOException
will be thrown.
-
-