T - The type of Record specialization that is to be returned by the get operationspublic class KeepAliveReader<T extends Record> extends RecordReaderDelegate<T>
KeepAliveReader adds keep-alive functionality to a IRecordReader. More specifically, it reads records from
the underlying reader periodically, based on a time interval. This functionality is transparent to the client, as each time
a get method is called, the record either originates from the set of prefetched records, or it is actually read
directly from the underlying reader. Keep-alive functionality is useful in order to keep the communication channel open if
a client wishes to delay the consumption of records for long periods of time and the producer has no indication that this behavior
is not problematic.reader| Constructor and Description |
|---|
KeepAliveReader(IRecordReader<T> reader,
long keepAliveFrequency,
TimeUnit keepAliveFrequencyUnit)
Creates a new instance
|
KeepAliveReader(IRecordReader<T> reader,
long keepAliveFrequency,
TimeUnit keepAliveFrequencyUnit,
long inactivityTimeout,
TimeUnit inactivityTimeUnit) |
| Modifier and Type | Method and Description |
|---|---|
long |
currentRecord()
The index of the last
Record retrieved through the reader. |
T |
get()
Retrieves the next available record, which will be either one of the records retrieved via the keep-alive operation or
a record retrieved directly from the underlying
IRecordReader |
T |
get(long timeout,
TimeUnit unit)
Retrieves the next available record, which will be either one of the records retrieved via the keep-alive operation or
a record retrieved directly from the underlying
IRecordReader |
long |
seek(long len)
|
availableRecords, changeWindowSize, close, emit, getCapacity, getConcurrentPartialCapacity, getInactivityTimeout, getInactivityTimeUnit, getIteratorTimeout, getIteratorTimeUnit, getRecordDefinitions, getStatus, iterator, receive, setIteratorTimeout, setIteratorTimeUnit, totalRecords, waitAvailablepublic KeepAliveReader(IRecordReader<T> reader, long keepAliveFrequency, TimeUnit keepAliveFrequencyUnit) throws GRS2ReaderInvalidArgumentException
reader - the IRecordReader to which keep-alive functionality is to be addedkeepAliveFrequency - the frequency of the keep-alive operationkeepAliveFrequencyUnit - the time unit of the frequency of the keep-alive operationGRS2ReaderInvalidArgumentException - one of the arguments is not validpublic KeepAliveReader(IRecordReader<T> reader, long keepAliveFrequency, TimeUnit keepAliveFrequencyUnit, long inactivityTimeout, TimeUnit inactivityTimeUnit) throws GRS2ReaderInvalidArgumentException
reader - the IRecordReader to which keep-alive functionality is to be addedkeepAliveFrequency - the frequency of the keep-alive operationkeepAliveFrequencyUnit - the time unit of the frequency of the keep-alive operationinactivityTimeout - A timeout after which the keep-alive reader will close the underlying readerinactivityTimeUnit - The time unit of the inactivity timeoutGRS2ReaderInvalidArgumentException - one of the arguments is not validpublic T get() throws GRS2ReaderException
IRecordReader
Retrieves the next available Record from the IBuffer. An explicit cast is performed to the
type provided in the generic declaration of the reader.
get in interface IRecordReader<T extends Record>get in class RecordReaderDelegate<T extends Record>Record or null if none was readily availableGRS2ReaderException - the operation could not be completedIRecordReader#get()}public T get(long timeout, TimeUnit unit) throws GRS2ReaderException
IRecordReader
Retrieves the next available Record from the IBuffer. An explicit cast is performed to the
type provided in the generic declaration of the reader. If no record is readily available the reader will
block for a maximum of timeout unit units of time waiting for a record to become
available or until the IBuffer uses the IBuffer.getReaderImmediateNotificationObject()
to notify blocked readers.
get in interface IRecordReader<T extends Record>get in class RecordReaderDelegate<T extends Record>timeout - the timeout to wait forunit - the unit of time to use to interpret the timeout valueRecord retrieved, or null if the timeout expired without a Record becoming availableGRS2ReaderException - the operation could not be completedIRecordReader#get(long, TimeUnit)}public long seek(long len)
throws GRS2ReaderException
Records provided in the list of Records available.
Depending on the actual IRecordReader implementation, forward and/or backward seeks may be supported.seek in interface IRecordReader<T extends Record>seek in class RecordReaderDelegate<T extends Record>len - the number of Record}s to skipRecords actually skippedGRS2ReaderException - the operation could not be completedIRecordReader#seek(long)}public long currentRecord()
throws GRS2ReaderException
Record retrieved through the reader.currentRecord in interface IRecordReader<T extends Record>currentRecord in class RecordReaderDelegate<T extends Record>Record retrieved through the readerGRS2ReaderException - the operation could not be completed because no records were retrieved yetIRecordReader#currentRecord()}Copyright © 2014. All Rights Reserved.