Package org.apache.ignite.internal.util
Class GridCloseableIteratorAdapterEx<T>
- java.lang.Object
-
- org.apache.ignite.internal.util.lang.GridIteratorAdapter<T>
-
- org.apache.ignite.internal.util.GridCloseableIteratorAdapterEx<T>
-
- All Implemented Interfaces:
Serializable,AutoCloseable,Iterable<T>,Iterator<T>,GridSerializableIterator<T>,GridCloseableIterator<T>,GridIterator<T>,IgniteSpiCloseableIterator<T>
public abstract class GridCloseableIteratorAdapterEx<T> extends GridIteratorAdapter<T> implements GridCloseableIterator<T>
Adapter for closeable iterator that can be safely closed concurrently.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GridCloseableIteratorAdapterEx()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the iterator and frees all the resources held by the iterator.booleanhasNextX()This method is the same asIterator.hasNext(), but allows for failure with exception.booleanisClosed()Checks if iterator has been closed.TnextX()This method is the same asIterator.next(), but allows for failure with exception.protected voidonClose()Invoked on iterator close.protected abstract booleanonHasNext()protected abstract TonNext()protected voidonRemove()Called on remove from iterator.voidremoveX()This method is the same asIterator.remove(), but allows for failure with exception.-
Methods inherited from class org.apache.ignite.internal.util.lang.GridIteratorAdapter
hasNext, iterator, next, remove
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
-
-
-
Method Detail
-
nextX
public final T nextX() throws IgniteCheckedException
This method is the same asIterator.next(), but allows for failure with exception. Often iterators are used to iterate through values that have not or have partially been received from remote nodes, and need to account for possible network failures, rather than throwingNoSuchElementExceptionruntime exception.s- Specified by:
nextXin interfaceGridIterator<T>- Returns:
Trueif iterator contains more elements.- Throws:
IgniteCheckedException- If no more elements can be returned due to some failure, like a network error for example.- See Also:
Iterator.next()
-
onNext
protected abstract T onNext() throws IgniteCheckedException
- Returns:
- Next element.
- Throws:
IgniteCheckedException- If failed.NoSuchElementException- If no element found.
-
hasNextX
public final boolean hasNextX() throws IgniteCheckedExceptionThis method is the same asIterator.hasNext(), but allows for failure with exception. Often iterators are used to iterate through values that have not or have partially been received from remote nodes, and need to account for possible network failures, rather than just returningfalseout ofIterator.hasNext()method.- Specified by:
hasNextXin interfaceGridIterator<T>- Returns:
Trueif iterator contains more elements.- Throws:
IgniteCheckedException- If no more elements can be returned due to some failure, like a network error for example.- See Also:
Iterator.hasNext()
-
onHasNext
protected abstract boolean onHasNext() throws IgniteCheckedException- Returns:
Trueif iterator has next element.- Throws:
IgniteCheckedException- If failed.
-
removeX
public final void removeX() throws IgniteCheckedExceptionThis method is the same asIterator.remove(), but allows for failure with exception.- Specified by:
removeXin interfaceGridIterator<T>- Throws:
IgniteCheckedException- If failed.
-
onRemove
protected void onRemove() throws IgniteCheckedExceptionCalled on remove from iterator.- Throws:
IgniteCheckedException- If failed.
-
close
public final void close() throws IgniteCheckedExceptionCloses the iterator and frees all the resources held by the iterator. Iterator can not be used any more after calling this method.The method is invoked automatically on objects managed by the
try-with-resourcesstatement.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceGridCloseableIterator<T>- Specified by:
closein interfaceIgniteSpiCloseableIterator<T>- Throws:
IgniteCheckedException- In case of error.
-
onClose
protected void onClose() throws IgniteCheckedExceptionInvoked on iterator close.- Throws:
IgniteCheckedException- If closing failed.
-
isClosed
public boolean isClosed()
Checks if iterator has been closed.- Specified by:
isClosedin interfaceGridCloseableIterator<T>- Returns:
Trueif iterator has been closed.
-
-