public class RetryingWriter 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 |
---|
RetryingWriter(DataWriter nestedDataWriter) |
Modifier and Type | Method and Description |
---|---|
DataException |
addExceptionProperties(DataException exception)
Adds this endpoint's current state to a
DataException . |
void |
close()
Indicates that this endpoint has finished reading or writing.
|
String |
getDiscardReasonFieldName()
Returns the field in the record to place the description of the exception that was thrown
by the failing write or
null if one should not be added. |
DataWriter |
getDiscardWriter()
Returns the discard sink for failing records or
null if one was not assigned. |
long |
getExceptionCount()
Returns the total number of exceptions/failures seen by this writer.
|
Throwable |
getFirstException()
Returns the first exception thrown for any individual write attempt.
|
long |
getInitialRetryDelay()
Returns the amount of time to wait (in milliseconds) after the first error, before retrying (default 1 second).
|
Throwable |
getLastException()
Returns the last exception thrown for any individual write attempt.
|
long |
getMaxErrorCount()
Returns the number of retries allowed across all write attempts (default max long - 1).
|
int |
getMaxRetryCount()
Returns the number of retries allowed for any individual write attempt (default 5).
|
IRetryStrategy |
getStrategy()
Returns the retry strategy (default
RetryStrategy.EXPONENTIAL_BACKOFF ). |
protected void |
onFailure(Record record,
Throwable exception) |
void |
open()
Makes this endpoint ready for reading or writing.
|
RetryingWriter |
setDiscardReasonFieldName(String discardReasonFieldName)
Specifies the field in the record to place the description of the exception that was thrown
by the failing write or
null if one should not be added. |
RetryingWriter |
setDiscardWriter(DataWriter writer)
Assign a discard sink for failing records.
|
RetryingWriter |
setInitialRetryDelay(long initialRetryDelay)
Sets the amount of time to wait (in milliseconds) after the first error, before retrying (default 1 second).
|
RetryingWriter |
setMaxErrorCount(long maxErrorCount)
Sets the number of retries allowed across all write attempts (default max long -1).
|
RetryingWriter |
setMaxRetryCount(int maxRetryCount)
Sets the number of retries allowed for any individual write attempt (default 5).
|
RetryingWriter |
setStrategy(IRetryStrategy strategy)
Sets the retry strategy (default
RetryStrategy.EXPONENTIAL_BACKOFF ). |
protected void |
writeImpl(Record record)
Overridden by subclasses to write the specified record to this
DataWriter . |
available, getNestedWriter, interceptRecord, map, map, setNestedDataWriter, setNestedDataWriter
getNestedEndpoint, getRootEndpoint, getRootWriter, write
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
public RetryingWriter(DataWriter nestedDataWriter)
public int getMaxRetryCount()
public RetryingWriter setMaxRetryCount(int maxRetryCount)
public long getMaxErrorCount()
public RetryingWriter setMaxErrorCount(long maxErrorCount)
public long getInitialRetryDelay()
public RetryingWriter setInitialRetryDelay(long initialRetryDelay)
public IRetryStrategy getStrategy()
RetryStrategy.EXPONENTIAL_BACKOFF
).public RetryingWriter setStrategy(IRetryStrategy strategy)
RetryStrategy.EXPONENTIAL_BACKOFF
).public long getExceptionCount()
public Throwable getFirstException()
public Throwable getLastException()
public DataWriter getDiscardWriter()
null
if one was not assigned.public RetryingWriter setDiscardWriter(DataWriter writer)
writer
- the discard sinkpublic String getDiscardReasonFieldName()
null
if one should not be added.public RetryingWriter setDiscardReasonFieldName(String discardReasonFieldName)
null
if one should not be added.public void open() throws DataException
DataEndpoint
open
in class ProxyWriter
DataException
public void close() throws DataException
DataEndpoint
close
in class ProxyWriter
DataException
protected void writeImpl(Record record) throws Throwable
DataWriter
DataWriter
.writeImpl
in class ProxyWriter
Throwable
public 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
Copyright (c) 2006-2023 North Concepts Inc. All Rights Reserved.