|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgr.uoa.di.madgik.grs.reader.decorators.RecordReaderDelegate<T>
gr.uoa.di.madgik.grs.reader.decorators.keepalive.KeepAliveReader<T>
T
- The type of Record
specialization that is to be returned by the get
operationspublic class KeepAliveReader<T extends Record>
A 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.
Constructor Summary | |
---|---|
KeepAliveReader(IRecordReader<T> reader,
long keepAliveFrequency,
java.util.concurrent.TimeUnit keepAliveFrequencyUnit)
Creates a new instance |
|
KeepAliveReader(IRecordReader<T> reader,
long keepAliveFrequency,
java.util.concurrent.TimeUnit keepAliveFrequencyUnit,
long inactivityTimeout,
java.util.concurrent.TimeUnit inactivityTimeUnit)
|
Method Summary | |
---|---|
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,
java.util.concurrent.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)
Seeks the number of Record s provided in the list of Record s available. |
Methods inherited from class gr.uoa.di.madgik.grs.reader.decorators.RecordReaderDelegate |
---|
availableRecords, close, emit, getCapacity, getConcurrentPartialCapacity, getInactivityTimeout, getInactivityTimeUnit, getIteratorTimeout, getIteratorTimeUnit, getRecordDefinitions, getStatus, iterator, receive, setIteratorTimeout, setIteratorTimeUnit, totalRecords, waitAvailable |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public KeepAliveReader(IRecordReader<T> reader, long keepAliveFrequency, java.util.concurrent.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 operation
GRS2ReaderInvalidArgumentException
- one of the arguments is not validpublic KeepAliveReader(IRecordReader<T> reader, long keepAliveFrequency, java.util.concurrent.TimeUnit keepAliveFrequencyUnit, long inactivityTimeout, java.util.concurrent.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 timeout
GRS2ReaderInvalidArgumentException
- one of the arguments is not validMethod Detail |
---|
public 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 available
GRS2ReaderException
- the operation could not be completedIRecordReader#get()}
public T get(long timeout, java.util.concurrent.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 value
Record
retrieved, or null if the timeout expired without a Record
becoming available
GRS2ReaderException
- the operation could not be completedIRecordReader#get(long, TimeUnit)}
public long seek(long len) throws GRS2ReaderException
Record
s provided in the list of Record
s 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 skip
Record
s actually skipped
GRS2ReaderException
- 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 reader
GRS2ReaderException
- the operation could not be completed because no records were retrieved yetIRecordReader#currentRecord()}
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |