public class AsyncWriter extends ProxyWriter
DataEndpoint.State
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEY
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
AsyncWriter(DataWriter nestedDataWriter)
Creates an
AsyncWriter object, with the given DataWriter
and default capacity of 500 records that can be queued. |
AsyncWriter(DataWriter nestedDataWriter,
int maxQueuedRecords)
Creates an
AsyncWriter object, with the given DataWriter
and maximum number of records that can be queued. |
Modifier and Type | Method and Description |
---|---|
DataException |
addExceptionProperties(DataException exception)
Adds this endpoint's current state to a
DataException . |
protected DataException |
addExceptionPropertiesImpl(DataException exception) |
int |
available()
Returns the number of records that can probably be written without blocking.
|
void |
close()
Indicates that this endpoint has finished reading or writing.
|
DataException |
exception(String message)
Creates an exception with the specified message and containing this endpoint's properties (name-value pairs).
|
DataException |
exception(String message,
Throwable exception)
Converts an exception to a
DataException , prefixing the original message with the specified text
and adding this endpoint's properties (name-value pairs). |
DataException |
exception(Throwable exception)
Converts an exception to a
DataException and adds this endpoint's properties (name-value pairs). |
long |
getBufferSizeInBytes() |
DataException |
getException() |
long |
getPeakBufferSizeInBytes() |
int |
getPriority() |
void |
open()
Makes this endpoint ready for reading or writing.
|
void |
rethrowAsyncException()
Rethrows the exception thrown by the internal thread or returns silently if no exception was thrown.
|
AsyncWriter |
setPriority(int priority) |
void |
write(Record record)
Writes the specified record to this
DataWriter and increases the record-count by 1. |
protected void |
writeImpl(Record record)
Overridden by subclasses to write the specified record to this
DataWriter . |
getNestedWriter, interceptRecord, map, map, setNestedDataWriter, setNestedDataWriter
getNestedEndpoint, getRootEndpoint, getRootWriter
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toString
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
getId, getName, resetID
public AsyncWriter(DataWriter nestedDataWriter, int maxQueuedRecords)
AsyncWriter
object, with the given DataWriter
and maximum number of records that can be queued.public AsyncWriter(DataWriter nestedDataWriter)
AsyncWriter
object, with the given DataWriter
and default capacity of 500 records that can be queued.public long getBufferSizeInBytes()
public long getPeakBufferSizeInBytes()
public int getPriority()
public AsyncWriter setPriority(int priority)
public DataException getException()
public void open() throws DataException
DataEndpoint
open
in class ProxyWriter
DataException
public void close() throws DataException
DataEndpoint
close
in class ProxyWriter
DataException
public int available() throws DataException
DataWriter
available
in class ProxyWriter
DataException
public void write(Record record) throws DataException
DataWriter
DataWriter
and increases the record-count by 1.
Any exception raised while writing will be converted to a DataException
using DataObject.exception(Throwable)
.
Subclasses generally do not need to override this method, instead they should implement DataWriter.writeImpl(Record)
.
write
in class DataWriter
DataException
protected void writeImpl(Record record) throws Throwable
DataWriter
DataWriter
.writeImpl
in class ProxyWriter
Throwable
public void rethrowAsyncException()
public final DataException exception(String message, Throwable exception)
DataObject
DataException
, prefixing the original message with the specified text
and adding this endpoint's properties (name-value pairs).
The returned exception can then be thrown in the normal way.
If the supplied exception is an instanceof DataException
, it will be returned, otherwise it will be
nested inside a DataException
. In either case the result message will contain the new prefix along
with this endpoint properties.
exception
in class DataObject
public final DataException exception(Throwable exception)
DataObject
DataException
and adds this endpoint's properties (name-value pairs).
The returned exception can then be thrown in the normal way.
If the supplied exception is an instanceof DataException
, it will be returned, otherwise it will be
nested inside a DataException
. In either case the result message will contain this endpoint properties.
exception
in class DataObject
public final DataException exception(String message)
DataObject
The returned exception can then be thrown in the normal way.
exception
in class DataObject
public final DataException addExceptionProperties(DataException exception)
Endpoint
DataException
. Since this method is called whenever an
exception is thrown, subclasses should override it to add their specific information.addExceptionProperties
in class ProxyWriter
protected DataException addExceptionPropertiesImpl(DataException exception)
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.