gr.uoa.di.madgik.grs.writer
Interface IRecordWriter<T extends Record>

All Known Implementing Classes:
RecordWriter

public interface IRecordWriter<T extends Record>


Method Summary
 int availableRecords()
          The number of readily available for consumption Records
 void close()
          Closes the underlying buffer.
 void dispose()
          Disposes the underlying buffer.
 void emit(BufferEvent event)
          Emits the provided event to the reader.
 int getCapacity()
          The underlying IBuffer capacity used
 java.net.URI getLocator()
           
 IBuffer.Status getStatus()
          Retrieves the status of the underlying IBuffer
 boolean importRecord(T record)
          Dissociates a Record from the underlying IBuffer of a producer and stores it to the IBuffer of this IRecordWriter.
 boolean importRecord(T record, int newDefinitionIndex)
          Dissociates a Record from the underlying IBuffer of a producer and stores it to the IBuffer of this RecordWriter.
 boolean importRecord(T record, int newDefinitionIndex, long timeout, java.util.concurrent.TimeUnit unit)
          Dissociates a Record from the underlying IBuffer of a producer and stores it to the IBuffer of this RecordWriter.
 boolean importRecord(T record, long timeout, java.util.concurrent.TimeUnit unit)
          Dissociates a Record from the underlying IBuffer of a producer and stores it to the IBuffer of this RecordWriter.
 boolean put(T record)
          Stores the provided Record to the underlying IBuffer
 boolean put(T record, long timeout, java.util.concurrent.TimeUnit unit)
          Stores the provided Record to the underlying IBuffer.
 BufferEvent receive()
          Receives a previously emitted event from a reader
 void setBufferStore(IBufferStore store)
          If this writer is populated by an IBufferStore this store is provided in order to keep the store alive and active even after the respective BufferStoreReader has closed the writer but the client reader is still using it
 long totalRecords()
          The number of total Records that have passed through the IBuffer this far
 

Method Detail

setBufferStore

void setBufferStore(IBufferStore store)
                    throws GRS2WriterException
If this writer is populated by an IBufferStore this store is provided in order to keep the store alive and active even after the respective BufferStoreReader has closed the writer but the client reader is still using it

Parameters:
store - the store which serves the writer
Throws:
GRS2WriterException - the operation could not be completed

getCapacity

int getCapacity()
                throws GRS2WriterException
The underlying IBuffer capacity used

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

getLocator

java.net.URI getLocator()
                        throws GRS2WriterException
Returns:
the locator identifying the authored IBuffer created through the IWriterProxy provided at writer initialization
Throws:
GRS2WriterException - the operation could not be completed

getStatus

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

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

availableRecords

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

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

totalRecords

long totalRecords()
                  throws GRS2WriterException
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:
GRS2WriterException - the operation could not be completed
See Also:
IBuffer.totalRecords()

put

boolean put(T record)
            throws GRS2WriterException
Stores the provided Record to the underlying IBuffer

Parameters:
record - the Record to add
Returns:
true if the addition was successful or false if the IBuffer has reached its capacity
Throws:
GRS2WriterException - the operation could not be completed
See Also:
IBuffer.put(Record)

put

boolean put(T record,
            long timeout,
            java.util.concurrent.TimeUnit unit)
            throws GRS2WriterException
Stores the provided Record to the underlying IBuffer. If the IBuffer has already reached its capacity, the method will block for a maximum of timeout unit units of time waiting for a record to be consumed or until the IBuffer uses the IBuffer.getWriterImmediateNotificationObject() to notify blocked writers

Parameters:
record - the Record to add
timeout - the timeout to wait for
unit - the unit of time to use to interpret the timeout value
Returns:
true if the addition was successful or false if the IBuffer has reached its capacity and the timeout expired
Throws:
GRS2WriterException - the operation could not be completed
See Also:
IBuffer.put(Record)

importRecord

boolean importRecord(T record)
                     throws GRS2Exception
Dissociates a Record from the underlying IBuffer of a producer and stores it to the IBuffer of this IRecordWriter. Before put(Record) is called, the record is unbound from the buffer to which is associated, and its definition index is re-set to the same value it had before.

Equivalent to calling importRecord(Record, int) with the second parameter being equal to Record.getDefinitionIndex(). Used for convenience if this IRecordWriter is associated with the same definitions as the reader from which the record is originating

Parameters:
record - the Record to import to the RecordWriter
Returns:
true if the import was successful or false if the IBuffer has reached its capacity
Throws:
GRS2Exception - an error has occurred
See Also:
put(Record)

importRecord

boolean importRecord(T record,
                     long timeout,
                     java.util.concurrent.TimeUnit unit)
                     throws GRS2Exception
Dissociates a Record from the underlying IBuffer of a producer and stores it to the IBuffer of this RecordWriter. Before RecordWriter.put(Record, long, TimeUnit) is called, the record is unbound from the buffer to which is associated, and its definition index is re-set to the same value it had before.

Equivalent to calling RecordWriter.importRecord(Record, int, long, TimeUnit) with the second parameter being equal to Record.getDefinitionIndex(). Used for convenience if this RecordWriter is associated with the same definitions as the reader from which the record is originating

Parameters:
record - the Record to import to the RecordWriter
Returns:
true if the import was successful or false if the IBuffer has reached its capacity and the timeout expired
Throws:
GRS2Exception - an error has occurred
See Also:
RecordWriter.put(Record, long, TimeUnit)

importRecord

boolean importRecord(T record,
                     int newDefinitionIndex)
                     throws GRS2Exception
Dissociates a Record from the underlying IBuffer of a producer and stores it to the IBuffer of this RecordWriter. Before RecordWriter.put(Record) is called, the record is unbound from the buffer to which is associated, and its definition index is set to the supplied value

Parameters:
record - the Record to import to this RecordWriter
newDefinitionIndex - the definition index that the Record will have in this RecordWriter
Returns:
true if the import was successful or false if the IBuffer has reached its capacity
Throws:
GRS2Exception - an error has occurred
See Also:
RecordWriter.put(Record)

importRecord

boolean importRecord(T record,
                     int newDefinitionIndex,
                     long timeout,
                     java.util.concurrent.TimeUnit unit)
                     throws GRS2Exception
Dissociates a Record from the underlying IBuffer of a producer and stores it to the IBuffer of this RecordWriter. Before RecordWriter.put(Record, long, TimeUnit) is called, the record is unbound from the buffer to which is associated, and its definition index is set to the supplied value

Parameters:
record - the Record to import to this RecordWriter
newDefinitionIndex - the definition index that the Record will have in this RecordWriter
Returns:
true if the import was successful or false if the IBuffer has reached its capacity and the timeout expired
Throws:
GRS2Exception - an error has occurred
See Also:
RecordWriter.put(Record, long, TimeUnit)

close

void close()
           throws GRS2WriterException
Closes the underlying buffer. After this method has been invoked, no more Records can be added

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

dispose

void dispose()
Disposes the underlying buffer. After this method has been invoked, all associated resources are disposed. If there are any readers connected through the underlying IBuffer, their resources will also be disposed

See Also:
IBuffer.dispose()

emit

void emit(BufferEvent event)
          throws GRS2WriterException,
                 GRS2WriterInvalidArgumentException
Emits the provided event to the reader. The source of the event is set to BufferEvent.EventSource.Writer

Parameters:
event - the event to send to the reader
Throws:
GRS2WriterException - the operation could not be completed
GRS2WriterInvalidArgumentException - the event provided cannot be null

receive

BufferEvent receive()
                    throws GRS2WriterException
Receives a previously emitted event from a reader

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