gr.uoa.di.madgik.grs.reader
Interface IRecordReader<T extends Record>

All Superinterfaces:
java.lang.Iterable<T>
All Known Implementing Classes:
ForwardReader, KeepAliveReader, RandomReader, RecordReaderDelegate

public interface IRecordReader<T extends Record>
extends java.lang.Iterable<T>


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.
 

Method Detail

getRecordDefinitions

RecordDefinition[] getRecordDefinitions()
                                        throws GRS2ReaderException
Retrieves the RecordDefinitions that define the Records that are accessible through the reader.

Returns:
the RecordDefinitions as were provided by the corresponding writer
Throws:
GRS2ReaderException - the operation could not be completed
See Also:
IBuffer.getRecordDefinitions()

getInactivityTimeout

long getInactivityTimeout()
                          throws GRS2ReaderException
Retrieves the Inactivity timeout set for the lifecycle management of the underlying IBuffer. This value should be interpreted in conjunction with the value of getInactivityTimeUnit().

Returns:
the inactivity timeout
Throws:
GRS2ReaderException - the operation could not be completed
See Also:
IBuffer.getInactivityTimeout()

getInactivityTimeUnit

java.util.concurrent.TimeUnit getInactivityTimeUnit()
                                                    throws GRS2ReaderException
Retrieves the Inactivity time unit set for the lifecycle management of the underlying IBuffer. This value should be interpreted in conjunction with the value of getInactivityTimeout()

Returns:
the inactivity time unit
Throws:
GRS2ReaderException - the operation could not be completed
See Also:
IBuffer.getInactivityTimeUnit()

getCapacity

int getCapacity()
                throws GRS2ReaderException
The underlying IBuffer capacity used.

Returns:
the buffer capacity
Throws:
GRS2ReaderException - the operation could not be completed
See Also:
IBuffer.getCapacity()

getConcurrentPartialCapacity

int getConcurrentPartialCapacity()
                                 throws GRS2ReaderException
The underlying IBuffer concurrent partial capacity used

Returns:
the concurrency partial record buffer capacity
Throws:
GRS2ReaderException - the operation could not be completed
See Also:
IBuffer.getConcurrentPartialCapacity()

getStatus

IBuffer.Status getStatus()
Retrieves the status of the underlying IBuffer.

Returns:
the status of the underlying buffer
See Also:
IBuffer.getStatus()

close

void close()
           throws GRS2ReaderException
Closes and disposes the underlying buffer. After this method has been invoked, all associated resources are disposed.

Throws:
GRS2ReaderException - the operation could not be completed
See Also:
IBuffer.close(), IBuffer.dispose()

totalRecords

long totalRecords()
                  throws GRS2ReaderException
The number of total Records that have passed through the IBuffer this far.

Returns:
the number of total Records that have passed through the IBuffer this far
Throws:
GRS2ReaderException - the operation could not be completed
See Also:
IBuffer.totalRecords()

availableRecords

int availableRecords()
                     throws GRS2ReaderException
The number of readily available for consumption Records.

Returns:
the number of readily available for consumption records
Throws:
GRS2ReaderException - the operation could not be completed
See Also:
IBuffer.availableRecords()

currentRecord

long currentRecord()
                   throws GRS2ReaderException
The index of the last Record retrieved through the reader.

Returns:
the index of the last Record retrieved through the reader
Throws:
GRS2ReaderException - the operation could not be completed because no records were retrieved yet

get

T get()
                     throws GRS2ReaderException
Retrieves the next available Record from the IBuffer. An explicit cast is performed to the type provided in the generic declaration of the reader.

Returns:
the retrieved Record or null if none was readily available
Throws:
GRS2ReaderException - the operation could not be completed
See Also:
IBuffer.get()

get

T get(long timeout,
      java.util.concurrent.TimeUnit unit)
                     throws GRS2ReaderException
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.

Parameters:
timeout - the timeout to wait for
unit - the unit of time to use to interpret the timeout value
Returns:
the Record retrieved, or null if the timeout expired without a Record becoming available
Throws:
GRS2ReaderException - the operation could not be completed
See Also:
IBuffer.get()

waitAvailable

boolean waitAvailable(long timeout,
                      java.util.concurrent.TimeUnit unit)
                      throws GRS2ReaderException
Makes sure that within the provided time frame, there is a 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.

Parameters:
timeout - the timeout value interpreted in conjunction with the unit value
unit - the time unit to use to interpret the timeout value
Returns:
true if there is a Record available before the timeout has expired, false otherwise
Throws:
GRS2ReaderException - the operation could not be completed

setIteratorTimeout

void setIteratorTimeout(long iteratorTimeout)
The timeout that should be used by the Iterators that are created by this reader. This value is interpreted in conjunction with the value of getIteratorTimeUnit()

Parameters:
iteratorTimeout - the timeout

setIteratorTimeUnit

void setIteratorTimeUnit(java.util.concurrent.TimeUnit iteratorTimeUnit)
The time unit that should be used by the Iterators that are created by this reader. This value is interpreted in conjunction with the value of getIteratorTimeout()

Parameters:
iteratorTimeUnit - the time unit

getIteratorTimeout

long getIteratorTimeout()
                        throws GRS2ReaderException
The timeout that is used by the Iterators that are created by this reader. This value is interpreted in conjunction with the value of getIteratorTimeUnit().

Returns:
the timeout
Throws:
GRS2ReaderException

getIteratorTimeUnit

java.util.concurrent.TimeUnit getIteratorTimeUnit()
The time unit that is used by the Iterators that are created by this reader. This value is interpreted in conjunction with the value of getIteratorTimeout()

Returns:
the time unit

iterator

java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T extends Record>

seek

long seek(long len)
          throws GRS2ReaderException
Seeks the number of Records provided in the list of Records available. Depending on the actual IRecordReader implementation, forward and/or backward seeks may be supported.

Parameters:
len - the number of Record}s to skip
Returns:
the number of Records actually skipped
Throws:
GRS2ReaderException - the operation could not be completed

emit

void emit(BufferEvent event)
          throws GRS2ReaderException,
                 GRS2ReaderInvalidArgumentException
Emits the provided event to the writer. The source of the event is set to BufferEvent.EventSource.Reader.

Parameters:
event - the event to send to the writer
Throws:
GRS2ReaderException - the operation could not be completed
GRS2ReaderInvalidArgumentException - the event provided cannot be null

receive

BufferEvent receive()
                    throws GRS2ReaderException
Receives a previously emitted event from a writer.

Returns:
the event received or null if no pending events exist
Throws:
GRS2ReaderException - the operation could not be completed