|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcascading.property.Props
cascading.tap.TrapProps
public class TrapProps
Class TrapProps is a fluent helper class to set properties which control the behaviour of Tap
instances used as traps on a given Flow
.
Throwable
within a
Cascading Operation
or Tap
(either as a source or sink).
When a trap captures a failure, the Tuple
arguments to the Operation or Tap will be
captured and the Flow will continue executing with the next Tuple in the stream. Otherwise a Flow would
typically fail.
Due to the variability of data in the stream at any given point, a Tap trap should be configured with a
Scheme
that sinks Fields.ALL
, or is guaranteed to sink known
fields common to all Operations within the branch the trap has been bound too.
Optionally diagnostic information, with the given field names, may be captured along with the argument Tuple.
element-trace
- the file and line number the failed operation was instantiatedthrowable-message
- the Throwable.getMessage()
valuethrowable-stacktrace
- the Throwable.printStackTrace()
value, cleansed\t
) and each new line (\n
) will be replaced with a pipe character (|
).
Each value is prepended to the argument Tuple in the order given above. Since the argument Tuple may vary
in size, prepending the diagnostic value deterministically allows for simple grep and sed like commands to be
applied to the files.
Trap properties can be applied to a given Flow by calling Props.buildProperties()
on the properties instance
handed to the target FlowConnector
or directly to any given Tap via the
Tap.getConfigDef()
using Props.setProperties(cascading.property.ConfigDef)
.
It should be noted that traps are not intended for 'flow control' of a data stream. They are for exceptional
cases that when reached should not cause a Flow to fail. Flow control (sending known bad data down a different
branch) should be part of the application. Traps capture the values that are unaccounted for and cause errors,
if missing them doesn't compromise the integrity of the application.
Field Summary | |
---|---|
static String |
LOG_THROWABLE_STACK_TRACE
|
protected boolean |
logThrowableStackTrace
|
static String |
RECORD_ELEMENT_TRACE
|
static String |
RECORD_THROWABLE_MESSAGE
|
static String |
RECORD_THROWABLE_STACK_TRACE
|
protected boolean |
recordElementTrace
|
protected boolean |
recordThrowableMessage
|
protected boolean |
recordThrowableStackTrace
|
static String |
STACK_TRACE_LINE_DELIMITER
|
static String |
STACK_TRACE_LINE_TRIM
|
protected String |
stackTraceLineDelimiter
|
protected boolean |
stackTraceTrimLine
|
Constructor Summary | |
---|---|
TrapProps()
|
Method Summary | |
---|---|
protected void |
addPropertiesTo(Properties properties)
|
String |
getStackTraceLineDelimiter()
|
boolean |
isLogThrowableStackTrace()
|
boolean |
isRecordElementTrace()
|
boolean |
isRecordThrowableMessage()
|
boolean |
isRecordThrowableStackTrace()
|
boolean |
isStackTraceTrimLine()
|
TrapProps |
recordAllDiagnostics()
Method recordAllDiagnostics enables recording of all configurable diagnostic values. |
TrapProps |
setLogThrowableStackTrace(boolean logThrowableStackTrace)
Method setLogThrowableStackTrace will disable logging of the Throwable stacktrace value if set to false . |
TrapProps |
setRecordElementTrace(boolean recordElementTrace)
Method setRecordElementTrace will enable recording the element trace value if set to true . |
TrapProps |
setRecordThrowableMessage(boolean recordThrowableMessage)
Method setRecordThrowableMessage will enable recording the Throwable message value if set to true . |
TrapProps |
setRecordThrowableStackTrace(boolean recordThrowableStackTrace)
Method setRecordThrowableStackTrace will enable recording the Throwable stacktrace value if set to true . |
TrapProps |
setStackTraceLineDelimiter(String stackTraceLineDelimiter)
Method setStackTraceLineDelimiter will set the text delimiter used to denote stacktrace lines. |
TrapProps |
setStackTraceTrimLine(boolean stackTraceTrimLine)
Method setStackTraceTrimLine will disable trimming of whitespace on every recorded stacktrace line if set to false . |
static TrapProps |
trapProps()
|
Methods inherited from class cascading.property.Props |
---|
buildProperties, buildProperties, buildProperties, buildProperties, setProperties, setProperties |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String RECORD_ELEMENT_TRACE
public static final String RECORD_THROWABLE_MESSAGE
public static final String RECORD_THROWABLE_STACK_TRACE
public static final String LOG_THROWABLE_STACK_TRACE
public static final String STACK_TRACE_LINE_TRIM
public static final String STACK_TRACE_LINE_DELIMITER
protected boolean recordElementTrace
protected boolean recordThrowableMessage
protected boolean recordThrowableStackTrace
protected boolean logThrowableStackTrace
protected boolean stackTraceTrimLine
protected String stackTraceLineDelimiter
Constructor Detail |
---|
public TrapProps()
Method Detail |
---|
public static TrapProps trapProps()
public TrapProps recordAllDiagnostics()
public boolean isRecordElementTrace()
public TrapProps setRecordElementTrace(boolean recordElementTrace)
true
.
The default is false
.
recordElementTrace
- of type boolean
public boolean isRecordThrowableMessage()
public TrapProps setRecordThrowableMessage(boolean recordThrowableMessage)
true
.
The default is false
.
recordThrowableMessage
- of type boolean
public boolean isRecordThrowableStackTrace()
public TrapProps setRecordThrowableStackTrace(boolean recordThrowableStackTrace)
true
.
The default is false
.
recordThrowableStackTrace
- of type boolean
public boolean isLogThrowableStackTrace()
public TrapProps setLogThrowableStackTrace(boolean logThrowableStackTrace)
false
.
The default is true
.
logThrowableStackTrace
- of type boolean
public boolean isStackTraceTrimLine()
public TrapProps setStackTraceTrimLine(boolean stackTraceTrimLine)
false
.
The default is true
.
stackTraceTrimLine
- of type boolean
public String getStackTraceLineDelimiter()
public TrapProps setStackTraceLineDelimiter(String stackTraceLineDelimiter)
|
(the pipe character).
stackTraceLineDelimiter
- of type boolean
protected void addPropertiesTo(Properties properties)
addPropertiesTo
in class Props
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |