public class RetryingReader extends ProxyReader
DataEndpoint.State
fieldLineage, recordLineage
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEY
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
RetryingReader(DataReader nestedDataReader) |
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 read 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 reader.
|
Throwable |
getFirstException()
Returns the first exception thrown for any individual read 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 read attempt.
|
long |
getMaxErrorCount()
Returns the number of retries allowed across all read attempts (default max long - 1).
|
int |
getMaxRetryCount()
Returns the number of retries allowed for any individual read 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.
|
protected Record |
readImpl()
Overridden by subclasses to read the next record from this
DataReader . |
RetryingReader |
setDiscardReasonFieldName(String discardReasonFieldName)
Specifies the field in the record to place the description of the exception that was thrown
by the failing read or
null if one should not be added. |
RetryingReader |
setDiscardWriter(DataWriter writer)
Assign a discard sink for failing records.
|
RetryingReader |
setInitialRetryDelay(long initialRetryDelay)
Sets the amount of time to wait (in milliseconds) after the first error, before retrying (default 1 second).
|
RetryingReader |
setMaxErrorCount(long maxErrorCount)
Sets the number of retries allowed across all read attempts (default max long -1).
|
RetryingReader |
setMaxRetryCount(int maxRetryCount)
Sets the number of retries allowed for any individual read attempt (default 5).
|
RetryingReader |
setStrategy(IRetryStrategy strategy)
Sets the retry strategy (default
RetryStrategy.EXPONENTIAL_BACKOFF ). |
available, getNestedReader, interceptRecord, map, map, setNestedDataReader, setNestedDataReader
addLineage, getBufferSize, getNestedEndpoint, getRootEndpoint, getRootReader, isExhausted, isLineageSupported, isSaveLineage, peek, pop, push, read, setSaveLineage, skip
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 RetryingReader(DataReader nestedDataReader)
public int getMaxRetryCount()
public RetryingReader setMaxRetryCount(int maxRetryCount)
public long getMaxErrorCount()
public RetryingReader setMaxErrorCount(long maxErrorCount)
public long getInitialRetryDelay()
public RetryingReader setInitialRetryDelay(long initialRetryDelay)
public IRetryStrategy getStrategy()
RetryStrategy.EXPONENTIAL_BACKOFF
).public RetryingReader 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 RetryingReader setDiscardWriter(DataWriter writer)
writer
- the discard sinkpublic String getDiscardReasonFieldName()
null
if one should not be added.public RetryingReader setDiscardReasonFieldName(String discardReasonFieldName)
null
if one should not be added.public void open() throws DataException
DataEndpoint
open
in class ProxyReader
DataException
public void close() throws DataException
DataEndpoint
close
in class ProxyReader
DataException
protected Record readImpl() throws Throwable
DataReader
DataReader
. The default
implementation of DataReader.read()
now insures that this method will not be called again after it returns
a null
.
If no record is available, null
will be returned.
readImpl
in class ProxyReader
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 ProxyReader
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.