public class RecordWriter<T extends Record> extends Object implements IRecordWriter<T>
| Modifier and Type | Field and Description |
|---|---|
static int |
DefaultBufferCapacity |
static int |
DefaultConcurrentPartialCapacity |
static long |
DefaultInactivityTimeout |
static TimeUnit |
DefaultInactivityTimeUnit |
static float |
DefaultMirrorBufferFactor |
static float |
DefaultThreshold |
| Constructor and Description |
|---|
RecordWriter(IWriterProxy proxy,
IRecordReader reader)
Creates a new instance using the configuration retrieved from an
IRecordReader. |
RecordWriter(IWriterProxy proxy,
IRecordReader reader,
int capacity,
int concurrentPartialCapacity,
float mirrorSizeFactor)
Creates a new instance using the same record definitions as the ones of the supplied
IRecordReader. |
RecordWriter(IWriterProxy proxy,
IRecordReader reader,
int capacity,
int concurrentPartialCapacity,
float mirrorSizeFactor,
long inactivityTimeout,
TimeUnit inactivityTimeUnit)
Creates a new instance using the same record definitions as the ones of the supplied
IRecordReader. |
RecordWriter(IWriterProxy proxy,
RecordDefinition[] definitions)
Creates a new instance
|
RecordWriter(IWriterProxy proxy,
RecordDefinition[] definitions,
int capacity,
int concurrentPartialCapacity,
float mirrorSizeFactor)
Creates a new instance
|
RecordWriter(IWriterProxy proxy,
RecordDefinition[] definitions,
int capacity,
int concurrentPartialCapacity,
float mirrorSizeFactor,
long inactivityTimeout,
TimeUnit inactivityTimeUnit)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
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 |
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,
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,
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)
|
boolean |
put(Throwable th,
long timeout,
TimeUnit unit) |
boolean |
put(T record,
long timeout,
TimeUnit unit)
|
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()
|
public static int DefaultBufferCapacity
public static int DefaultConcurrentPartialCapacity
public static float DefaultThreshold
public static float DefaultMirrorBufferFactor
public static long DefaultInactivityTimeout
public static TimeUnit DefaultInactivityTimeUnit
public RecordWriter(IWriterProxy proxy, RecordDefinition[] definitions) throws GRS2WriterException
proxy - the IWriterProxy to use to publish the authored IBufferdefinitions - the RecordDefinitions of the Records addedGRS2WriterException - the operation could not be completedBufferFactory.getBuffer(),
IBuffer.setRecordDefinitions(RecordDefinition[])public RecordWriter(IWriterProxy proxy, RecordDefinition[] definitions, int capacity, int concurrentPartialCapacity, float mirrorSizeFactor) throws GRS2WriterException
proxy - the IWriterProxy to use to publish the authored IBufferdefinitions - the RecordDefinitions of the Records addedcapacity - the capacity of the underlying IBufferconcurrentPartialCapacity - the concurrent partial record capacity of the underlying IBuffermirrorSizeFactor - the factor to calculate the mirror threshold sizeGRS2WriterException - the operation could not be completedBufferFactory.getBuffer(),
IBuffer.setRecordDefinitions(RecordDefinition[]),
IBuffer.setCapacity(int),
IBuffer.setConcurrentPartialCapacity(int),
IBuffer.setMirrorBuffer(int)public RecordWriter(IWriterProxy proxy, RecordDefinition[] definitions, int capacity, int concurrentPartialCapacity, float mirrorSizeFactor, long inactivityTimeout, TimeUnit inactivityTimeUnit) throws GRS2WriterException
proxy - the IWriterProxy to use to publish the authored IBufferdefinitions - the RecordDefinitions of the Records addedcapacity - the capacity of the underlying IBufferconcurrentPartialCapacity - the concurrent partial record capacity of the underlying IBuffermirrorSizeFactor - the factor to calculate the mirror threshold sizeinactivityTimeout - the inactivity timeout after which the IBuffer is considered eligible for
disposal. This value is interpreted in conjunction with the inactivityTimeUnit valueinactivityTimeUnit - the inactivity timeout unit after which the IBuffer is considered eligible for
disposal. This value is interpreted in conjunction with the inactivityTimeout valueGRS2WriterException - the operation could not be completedBufferFactory.getBuffer(),
IBuffer.setRecordDefinitions(RecordDefinition[]),
IBuffer.setCapacity(int),
IBuffer.setConcurrentPartialCapacity(int),
IBuffer#setNotificationThreshold(float),
IBuffer.setMirrorBuffer(int),
IBuffer.setInactivityTimeout(long),
IBuffer.setInactivityTimeUnit(TimeUnit),
IBuffer#getWriterThresholdNotificationObject(),
IBuffer.initialize()public RecordWriter(IWriterProxy proxy, IRecordReader reader) throws GRS2WriterException
IRecordReader. The record definitions, capacity and
concurrent partial capacity configuration parameters are duplicated from the reader and all other configuration parameters
are set to their default values.proxy - the IWriterProxy to use to publish the authored IBufferreader - the IRecordReader to retrieve configuration fromGRS2WriterException - the operation could not be completedBufferFactory.getBuffer(),
IBuffer.setRecordDefinitions(RecordDefinition[])public RecordWriter(IWriterProxy proxy, IRecordReader reader, int capacity, int concurrentPartialCapacity, float mirrorSizeFactor) throws GRS2WriterException
IRecordReader.
Capacity, concurrent partial capacity and mirror buffer factor configuration parameters can be configured to a non-default value.
All other configuration parameters are set to their default values.proxy - the IWriterProxy to use to publish the authored IBufferreader - the IRecordReader to retrieve record definitions fromcapacity - the capacity of the underlying IBufferconcurrentPartialCapacity - the concurrent partial record capacity of the underlying IBuffermirrorSizeFactor - the factor to calculate the mirror threshold sizeGRS2WriterException - the operation could not be completedBufferFactory.getBuffer(),
IBuffer.setRecordDefinitions(RecordDefinition[]),
IBuffer.setCapacity(int),
IBuffer.setConcurrentPartialCapacity(int),
IBuffer.setMirrorBuffer(int)public RecordWriter(IWriterProxy proxy, IRecordReader reader, int capacity, int concurrentPartialCapacity, float mirrorSizeFactor, long inactivityTimeout, TimeUnit inactivityTimeUnit) throws GRS2WriterException
IRecordReader.
All configuration parameters can be configured to a non-default value.proxy - the IWriterProxy to use to publish the authored IBufferreader - the IRecordReader to retrieve record definitions fromcapacity - the capacity of the underlying IBufferconcurrentPartialCapacity - the concurrent partial record capacity of the underlying IBuffermirrorSizeFactor - the factor to calculate the mirror threshold sizeinactivityTimeout - the inactivity timeout after which the IBuffer is considered eligible for
disposal. This value is interpreted in conjunction with the inactivityTimeUnit valueinactivityTimeUnit - the inactivity timeout unit after which the IBuffer is considered eligible for
disposal. This value is interpreted in conjunction with the inactivityTimeout valueGRS2WriterException - the operation could not be completedBufferFactory.getBuffer(),
IBuffer.setRecordDefinitions(RecordDefinition[]),
IBuffer.setCapacity(int),
IBuffer.setConcurrentPartialCapacity(int),
IBuffer#setNotificationThreshold(float),
IBuffer.setMirrorBuffer(int),
IBuffer.setInactivityTimeout(long),
IBuffer.setInactivityTimeUnit(TimeUnit),
IBuffer#getWriterThresholdNotificationObject(),
IBuffer.initialize()public void setBufferStore(IBufferStore store) throws GRS2WriterException
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 itsetBufferStore in interface IRecordWriter<T extends Record>store - the store which serves the writerGRS2WriterException - the operation could not be completedIRecordWriter.setBufferStore(IBufferStore)public int getCapacity()
throws GRS2WriterException
IBuffer capacity usedgetCapacity in interface IRecordWriter<T extends Record>GRS2WriterException - the operation could not be completedIRecordWriter.getCapacity()public URI getLocator() throws GRS2WriterException
getLocator in interface IRecordWriter<T extends Record>IBuffer created through the IWriterProxy provided at
writer initializationGRS2WriterException - the operation could not be completedIRecordWriter.getLocator()public IBuffer.Status getStatus()
IBuffergetStatus in interface IRecordWriter<T extends Record>IRecordWriter.getStatus()public int availableRecords()
throws GRS2WriterException
RecordsavailableRecords in interface IRecordWriter<T extends Record>GRS2WriterException - the operation could not be completedIRecordWriter.availableRecords()public long totalRecords()
throws GRS2WriterException
totalRecords in interface IRecordWriter<T extends Record>Records that have passed through the IBuffer this farGRS2WriterException - the operation could not be completedIRecordWriter.totalRecords()public boolean put(T record) throws GRS2WriterException
put in interface IRecordWriter<T extends Record>record - the Record to addIBuffer has reached its capacityGRS2WriterException - the operation could not be completedIRecordWriter.put(Record)public boolean put(T record, long timeout, TimeUnit unit) throws GRS2WriterException
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 writersput in interface IRecordWriter<T extends Record>record - the Record to addtimeout - the timeout to wait forunit - the unit of time to use to interpret the timeout valueIBuffer has reached its capacity and the timeout expiredGRS2WriterException - the operation could not be completedIRecordWriter.put(Record, long, TimeUnit)public boolean put(Throwable th, long timeout, TimeUnit unit) throws GRS2WriterException
GRS2WriterExceptionpublic boolean importRecord(T record) throws GRS2Exception
Record from the underlying IBuffer of a producer and stores it to the IBuffer of
this IRecordWriter.
Before IRecordWriter.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 IRecordWriter.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
importRecord in interface IRecordWriter<T extends Record>record - the Record to import to the RecordWriterIBuffer has reached its capacityGRS2Exception - an error has occurredIRecordWriter.importRecord(Record)public boolean importRecord(T record, long timeout, TimeUnit unit) throws GRS2Exception
Record from the underlying IBuffer of a producer and stores it to the IBuffer of
this RecordWriter.
Before 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 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
importRecord in interface IRecordWriter<T extends Record>record - the Record to import to the RecordWriterIBuffer has reached its capacity and the timeout expiredGRS2Exception - an error has occurredIRecordWriter.importRecord(Record, long, TimeUnit)public boolean importRecord(T record, int newDefinitionIndex) throws GRS2Exception
Record from the underlying IBuffer of a producer and stores it to the IBuffer of
this RecordWriter.
Before put(Record) is called, the record is unbound from the buffer to which is associated, and its definition index
is set to the supplied valueimportRecord in interface IRecordWriter<T extends Record>record - the Record to import to this RecordWriternewDefinitionIndex - the definition index that the Record will have in this RecordWriterIBuffer has reached its capacityGRS2Exception - an error has occurredIRecordWriter.importRecord(Record, int)public boolean importRecord(T record, int newDefinitionIndex, long timeout, TimeUnit unit) throws GRS2Exception
Record from the underlying IBuffer of a producer and stores it to the IBuffer of
this RecordWriter.
Before 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 valueimportRecord in interface IRecordWriter<T extends Record>record - the Record to import to this RecordWriternewDefinitionIndex - the definition index that the Record will have in this RecordWriterIBuffer has reached its capacity and the timeout expiredGRS2Exception - an error has occurredIRecordWriter.importRecord(Record, int, long, TimeUnit)public void close()
throws GRS2WriterException
Records can be addedclose in interface IRecordWriter<T extends Record>GRS2WriterException - the operation could not be completedIRecordWriter.close()public void dispose()
IBuffer, their resources will also be disposeddispose in interface IRecordWriter<T extends Record>IRecordWriter.dispose()public void emit(BufferEvent event) throws GRS2WriterException, GRS2WriterInvalidArgumentException
BufferEvent.EventSource.Writeremit in interface IRecordWriter<T extends Record>event - the event to send to the readerGRS2WriterException - the operation could not be completedGRS2WriterInvalidArgumentException - the event provided cannot be nullIRecordWriter.emit(BufferEvent)public BufferEvent receive() throws GRS2WriterException
receive in interface IRecordWriter<T extends Record>GRS2WriterException - the operation could not be completedIRecordWriter.receive()Copyright © 2014. All Rights Reserved.