Class AbstractTimeTrackingRemoteIterator<T>

    • Field Detail

      • snapshot

        protected Boolean snapshot
        Whether the iterator is a snapshot. This will either be provided by the constructor or it will be null which will set the value retrieved from getSnapshotImpl() when first calling isSnapshot().
      • busyThreads

        protected final Map<Thread,​AtomicInteger> busyThreads
        The threads which are currently accessing this server-side proxy (and and how often). This is used to avoid closing a currently active server-side proxy.
    • Constructor Detail

      • AbstractTimeTrackingRemoteIterator

        @Deprecated(since="15.0.0",
                    forRemoval=true)
        protected AbstractTimeTrackingRemoteIterator​(boolean snapshot,
                                                     boolean isForwardOnly,
                                                     long aliveTime,
                                                     long aliveTimeExtension)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Creates a new remote iterator with the designated attributes.
        Parameters:
        snapshot - Whether the iterator is a snapshot.
        isForwardOnly - Whether the iterator is forward only.
        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.
      • AbstractTimeTrackingRemoteIterator

        protected AbstractTimeTrackingRemoteIterator​(boolean snapshot,
                                                     boolean isForwardOnly,
                                                     long aliveTime,
                                                     long aliveTimeExtension,
                                                     Logger logger)
        Creates a new remote iterator with the designated attributes.
        Parameters:
        snapshot - Whether the iterator is a snapshot.
        isForwardOnly - Whether the iterator is forward only.
        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.
      • AbstractTimeTrackingRemoteIterator

        @Deprecated(since="15.0.0",
                    forRemoval=true)
        protected AbstractTimeTrackingRemoteIterator​(boolean isForwardOnly,
                                                     long initialAliveTime,
                                                     long aliveTimeExtension)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Creates a new remote iterator with the designated attributes with the snapshot being retrieved via getSnapshotImpl(). Subclasses calling this constructor need to override getSnapshotImpl().
        Parameters:
        isForwardOnly - Whether the iterator is forward only.
        initialAliveTime - The time in milliseconds this remote iterator is alive.
        aliveTimeExtension - The time in milliseconds to extend the alive time when accessing this remote iterator.
      • AbstractTimeTrackingRemoteIterator

        protected AbstractTimeTrackingRemoteIterator​(boolean isForwardOnly,
                                                     long initialAliveTime,
                                                     long aliveTimeExtension,
                                                     Logger logger)
        Creates a new remote iterator with the designated attributes with the snapshot being retrieved via getSnapshotImpl(). Subclasses calling this constructor need to override getSnapshotImpl().
        Parameters:
        isForwardOnly - Whether the iterator is forward only.
        initialAliveTime - 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

      • getCloseTime

        public long getCloseTime()
        Specified by:
        getCloseTime in interface de.aristaflow.adept2.model.communication.TimeTrackingSsProxy
      • setCloseTime

        public long setCloseTime​(long closeTime)
        Specified by:
        setCloseTime in interface de.aristaflow.adept2.model.communication.TimeTrackingSsProxy
      • isBusy

        public boolean isBusy()
        Specified by:
        isBusy in interface de.aristaflow.adept2.model.communication.TimeTrackingSsProxy
      • getRemainingAliveTime

        public long getRemainingAliveTime()
        Description copied from interface: RemoteIterator
        Gets the time in milliseconds this iterator will still be valid and does allow access to the underlying data. Afterwards the iterator will be closed automatically to save memory and resources.
        A negative value indicates a closed iterator. Such an iterator cannot be kept alive. Note that this alive time does not need to correspond to the original alive time requested
        Specified by:
        getRemainingAliveTime in interface RemoteIterator<T>
        Specified by:
        getRemainingAliveTime in interface de.aristaflow.adept2.model.communication.ServerSideProxy
        Specified by:
        getRemainingAliveTime in interface de.aristaflow.adept2.model.communication.TimeTrackingSsProxy
        Returns:
        The time this iterator remains valid and can be used. Afterwards the iterator will be closed. Long.MIN_VALUE for an already closed remote iterator.
      • keepAlive

        public long keepAlive​(long aliveTime)
                       throws IOException
        Description copied from interface: RemoteIterator
        Keeps this iterator alive for the designated time span (in milliseconds). This allows to continue using this iterator. However, note that extending the usage time significantly impacts resource occupation.
        Note that extending the time need not be successful. The underlying iterator implementation may not be able to extend the alive time of all used resource, for instance pooled database connections.

        A 0 or a negative value is equal to closed this iterator.

        Specified by:
        keepAlive in interface RemoteIterator<T>
        Specified by:
        keepAlive in interface de.aristaflow.adept2.model.communication.ServerSideProxy
        Specified by:
        keepAlive in interface de.aristaflow.adept2.model.communication.TimeTrackingSsProxy
        Parameters:
        aliveTime - The time in milliseconds to keep this iterator alive that is not to close it automatically.
        Returns:
        The relative time this iterator will be kept alive longer. 0 indicates immediate closing. A negative value represents the failure of extending the alive time, check RemoteIterator.getRemainingAliveTime() in this case whether extending the keep alive time has been successful or not.
        Throws:
        IOException - If there are problems accessing the underlying data source, an IOException will be thrown.
      • enter

        protected void enter()
        Tracks entering a method reentrant which is adding another invocation of the current thread to properly set isBusy().
        Overrides:
        enter in class AbstractRemoteIterator<T,​T>
      • exit

        protected Long exit()
        Tracks exiting a method reentrant which is removing an invocation of the current thread to properly set isBusy(). If the thread leaves completely, the alive time will be extended; it will not be shortened in case the extension is less than the already set close time. If this remote iterator has been closed, no extension will take place.
        Overrides:
        exit in class AbstractRemoteIterator<T,​T>
        Returns:
        The possibly new remaining alive time in milliseconds or null in case the thread is still active and not exiting finally.
      • getSnapshotImpl

        protected boolean getSnapshotImpl()
                                   throws DataSourceException
        Gets whether this iterator is a snapshot and therefore its contents is not subject of change while iterating.
        This method will need to be overridden if the snapshot status cannot be provided when creating this instance (AbstractTimeTrackingRemoteIterator(boolean, boolean, long, long, Logger)).

        This implementation always throws an UnsupportedOperationException.

        Returns:
        Whether this iterator is a snapshot and therefore its contents is not subject of change while iterating.
        Throws:
        DataSourceException - If there are problems retrieving the snapshot status of this remote iterator, a DataSourceException will be thrown.
      • isSnapshot

        public final boolean isSnapshot()
                                 throws DataSourceException
        Description copied from interface: RemoteIterator
        Gets whether this iterator is a snapshot and therefore its contents is not subject of change while iterating. However, the contents may be outdated while iterating.
        Specified by:
        isSnapshot in interface RemoteIterator<T>
        Returns:
        Whether this iterator is a snapshot providing stable but maybe outdated data.
        Throws:
        DataSourceException - If there are problems accessing the underlying data source, a DataSourceException will be thrown.