|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgr.uoa.di.madgik.grs.reader.ForwardReader<T>
T - The type of Record specialization that is to be returned by the get operationspublic class ForwardReader<T extends Record>
The ForwardReader class provides access over an authored IBuffer in a forward only fashion. The Records
retrieved can be defined to be cast to the specific Record extending class
| Field Summary | |
|---|---|
static int |
DefaultIteratorTimeout
The default timeout to be used by the ForwardReaderIterators initialized by this reader when retrieving
records or checking if more records are available. |
static java.util.concurrent.TimeUnit |
DefaultIteratorTimeUnit
The default time unit to be used by the ForwardReaderIterators initialized by this reader when retrieving
records or checking if more records are available. |
| Constructor Summary | |
|---|---|
ForwardReader(java.net.URI locator)
Creates a new reader accessing the IBuffer referenced by the provided locator |
|
ForwardReader(java.net.URI locator,
int capacity)
Creates a new reader accessing the IBuffer referenced by the provided locator. |
|
| Method Summary | |
|---|---|
int |
availableRecords()
The number of readily available for consumption Records. |
void |
close()
Closes and disposes the underlying buffer. |
long |
currentRecord()
The index of the last Record retrieved through the reader. |
void |
emit(BufferEvent event)
Emits the provided event to the writer. |
T |
get()
Retrieves the next available Record from the IBuffer. |
T |
get(long timeout,
java.util.concurrent.TimeUnit unit)
Retrieves the next available Record from the IBuffer. |
int |
getCapacity()
The underlying IBuffer capacity used. |
int |
getConcurrentPartialCapacity()
The underlying IBuffer concurrent partial capacity used |
long |
getInactivityTimeout()
Retrieves the Inactivity timeout set for the lifecycle management of the underlying IBuffer. |
java.util.concurrent.TimeUnit |
getInactivityTimeUnit()
Retrieves the Inactivity time unit set for the lifecycle management of the underlying IBuffer. |
long |
getIteratorTimeout()
The timeout that is used by the Iterators that are created by this reader. |
java.util.concurrent.TimeUnit |
getIteratorTimeUnit()
The time unit that is used by the Iterators that are created by this reader. |
RecordDefinition[] |
getRecordDefinitions()
Retrieves the RecordDefinitions that define the Records that are accessible through the reader. |
IBuffer.Status |
getStatus()
Retrieves the status of the underlying IBuffer. |
java.util.Iterator<T> |
iterator()
|
BufferEvent |
receive()
Receives a previously emitted event from a writer. |
long |
seek(long len)
Seeks the number of Records provided in the list of Records available. |
void |
setIteratorTimeout(long iteratorTimeout)
The timeout that should be used by the Iterators that are created by this reader. |
void |
setIteratorTimeUnit(java.util.concurrent.TimeUnit iteratorTimeUnit)
The time unit that should be used by the Iterators that are created by this reader. |
long |
totalRecords()
The number of total Records that have passed through the IBuffer this far. |
boolean |
waitAvailable(long timeout,
java.util.concurrent.TimeUnit unit)
Makes sure that within the provided time frame, there is a Record that can be retrieved without blocking. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DefaultIteratorTimeout
ForwardReaderIterators initialized by this reader when retrieving
records or checking if more records are available. This value should be interpreted in conjunction with the
value of DefaultIteratorTimeUnit
public static final java.util.concurrent.TimeUnit DefaultIteratorTimeUnit
ForwardReaderIterators initialized by this reader when retrieving
records or checking if more records are available. This value should be interpreted in conjunction with the
value of DefaultIteratorTimeout
| Constructor Detail |
|---|
public ForwardReader(java.net.URI locator)
throws GRS2ReaderException
IBuffer referenced by the provided locator
locator - the locator identifying the IBuffer to consume
GRS2ReaderException - the operation could not be completed
public ForwardReader(java.net.URI locator,
int capacity)
throws GRS2ReaderException
IBuffer referenced by the provided locator.
The IBuffer will have the specified capacity, if possible
locator - the locator identifying the IBuffer to consumecapacity - a desired capacity for the IBuffer which will be consumed. Used as
a hint to the underlying IReaderProxy, which might or might not honor it depending
on its strategy
GRS2ReaderException - the operation could not be completed| Method Detail |
|---|
public RecordDefinition[] getRecordDefinitions()
throws GRS2ReaderException
RecordDefinitions that define the Records that are accessible through the reader.
getRecordDefinitions in interface IRecordReader<T extends Record>RecordDefinitions as were provided by the corresponding writer
GRS2ReaderException - the operation could not be completedIRecordReader.getRecordDefinitions()
public long getInactivityTimeout()
throws GRS2ReaderException
IBuffer. This value
should be interpreted in conjunction with the value of IRecordReader.getInactivityTimeUnit().
getInactivityTimeout in interface IRecordReader<T extends Record>GRS2ReaderException - the operation could not be completedIRecordReader.getInactivityTimeout()
public java.util.concurrent.TimeUnit getInactivityTimeUnit()
throws GRS2ReaderException
IBuffer. This value
should be interpreted in conjunction with the value of IRecordReader.getInactivityTimeout()
getInactivityTimeUnit in interface IRecordReader<T extends Record>GRS2ReaderException - the operation could not be completedIRecordReader.getInactivityTimeUnit()public void setIteratorTimeout(long iteratorTimeout)
Iterators that are created by this reader. This value
is interpreted in conjunction with the value of IRecordReader.getIteratorTimeUnit()
The Iterators which will use the timeout are instances of ForwardReaderIterator.
setIteratorTimeout in interface IRecordReader<T extends Record>iteratorTimeout - the timeoutIRecordReader#setIteratorTimeout(long)}public long getIteratorTimeout()
Iterators that are created by this reader. This value
is interpreted in conjunction with the value of IRecordReader.getIteratorTimeUnit().
The Iterators which use the timeout are instances of ForwardReaderIterator.
getIteratorTimeout in interface IRecordReader<T extends Record>IRecordReader#getIteratorTimeout()}public void setIteratorTimeUnit(java.util.concurrent.TimeUnit iteratorTimeUnit)
Iterators that are created by this reader. This value
is interpreted in conjunction with the value of IRecordReader.getIteratorTimeout()
The Iterators which will use the time unit are instances of ForwardReaderIterator.
setIteratorTimeUnit in interface IRecordReader<T extends Record>iteratorTimeUnit - the time unitIRecordReader#setIteratorTimeUnit(TimeUnit)}public java.util.concurrent.TimeUnit getIteratorTimeUnit()
Iterators that are created by this reader. This value
is interpreted in conjunction with the value of IRecordReader.getIteratorTimeout()
The Iterators which use the time unit are instances of ForwardReaderIterator.
getIteratorTimeUnit in interface IRecordReader<T extends Record>IRecordReader#getIteratorTimeUnit()}
public int getCapacity()
throws GRS2ReaderException
IBuffer capacity used.
getCapacity in interface IRecordReader<T extends Record>GRS2ReaderException - the operation could not be completedIRecordReader.getCapacity()
public int getConcurrentPartialCapacity()
throws GRS2ReaderException
IBuffer concurrent partial capacity used
getConcurrentPartialCapacity in interface IRecordReader<T extends Record>GRS2ReaderException - the operation could not be completedIRecordReader.getConcurrentPartialCapacity()public IBuffer.Status getStatus()
IBuffer.
getStatus in interface IRecordReader<T extends Record>IRecordReader.getStatus()
public void close()
throws GRS2ReaderException
close in interface IRecordReader<T extends Record>GRS2ReaderException - the operation could not be completedIRecordReader.close()
public long totalRecords()
throws GRS2ReaderException
Records that have passed through the IBuffer this far.
totalRecords in interface IRecordReader<T extends Record>Records that have passed through the IBuffer this far
GRS2ReaderException - the operation could not be completedIRecordReader.totalRecords()
public int availableRecords()
throws GRS2ReaderException
Records.
availableRecords in interface IRecordReader<T extends Record>GRS2ReaderException - the operation could not be completedIRecordReader.availableRecords()
public long currentRecord()
throws GRS2ReaderException
Record retrieved through the reader.
currentRecord in interface IRecordReader<T extends Record>Record retrieved through the reader
GRS2ReaderException - the operation could not be completed because no records were retrieved yetIRecordReader.currentRecord()
public T get()
throws GRS2ReaderException
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>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
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>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
Records provided in the list of Records available.
Depending on the actual IRecordReader implementation, forward and/or backward seeks may be supported.
Seeks the number of Records provided forward in the list of Records available. If the seek
length is larger than the readily available Records, then the timeout and time unit available through
getIteratorTimeout() and getIteratorTimeUnit()
seek in interface IRecordReader<T extends Record>len - the number of Record}s to skip
Records actually skipped
GRS2ReaderException - the operation could not be completedpublic java.util.Iterator<T> iterator()
The iterator returned is an instance of ForwardReaderIterator
iterator in interface IRecordReader<T extends Record>iterator in interface java.lang.Iterable<T extends Record>Iterable.iterator()
public boolean waitAvailable(long timeout,
java.util.concurrent.TimeUnit unit)
throws GRS2ReaderException
Record that can be retrieved without blocking.
If the timeout defined expires and no Record has been made available, false is returned. Otherwise, or if
there are already available Records, true is returned.
waitAvailable in interface IRecordReader<T extends Record>timeout - the timeout value interpreted in conjunction with the unit valueunit - the time unit to use to interpret the timeout value
Record available before the timeout has expired, false otherwise
GRS2ReaderException - the operation could not be completedIRecordReader#waitAvailable(long, TimeUnit)}
public void emit(BufferEvent event)
throws GRS2ReaderException,
GRS2ReaderInvalidArgumentException
BufferEvent.EventSource.Reader.
emit in interface IRecordReader<T extends Record>event - the event to send to the writer
GRS2ReaderException - the operation could not be completed
GRS2ReaderInvalidArgumentException - the event provided cannot be nullIRecordReader.emit(BufferEvent)
public BufferEvent receive()
throws GRS2ReaderException
receive in interface IRecordReader<T extends Record>GRS2ReaderException - the operation could not be completedIRecordReader.receive()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||