public abstract static class ErrorConverters.WriteErrorsToTextIO<T,V> extends org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<FailsafeElement<T,V>>,org.apache.beam.sdk.values.PDone>
ErrorConverters.WriteErrorsToTextIO is a PTransform that writes strings error messages to file
system using TextIO and custom line format SerializableFunction to convert errors in
necessary format.
pCollection.apply("Write to TextIO",
WriteErrorsToTextIO.<String,String>newBuilder()
.setErrorWritePath("errors.txt")
.setTranslateFunction((FailsafeElement<String,String> failsafeElement) -> {
ArrayList<String> outputRow = new ArrayList<>();
final String message = failsafeElement.getOriginalPayload();
String timestamp = Instant.now().toString();
outputRow.add(timestamp);
outputRow.add(failsafeElement.getErrorMessage());
outputRow.add(failsafeElement.getStacktrace());
// Only set the payload if it's populated on the message.
if (failsafeElement.getOriginalPayload() != null) {
outputRow.add(message);
}
return String.join(",",outputRow);
})
| Modifier and Type | Class and Description |
|---|---|
static class |
ErrorConverters.WriteErrorsToTextIO.Builder<T,V>
Builder for
ErrorConverters.WriteErrorsToTextIO. |
| Constructor and Description |
|---|
WriteErrorsToTextIO() |
| Modifier and Type | Method and Description |
|---|---|
abstract java.lang.String |
errorWritePath() |
org.apache.beam.sdk.values.PDone |
expand(org.apache.beam.sdk.values.PCollection<FailsafeElement<T,V>> pCollection) |
static <T,V> ErrorConverters.WriteErrorsToTextIO.Builder<T,V> |
newBuilder() |
abstract org.apache.beam.sdk.transforms.SerializableFunction<FailsafeElement<T,V>,java.lang.String> |
translateFunction() |
abstract @Nullable org.joda.time.Duration |
windowDuration() |
public static <T,V> ErrorConverters.WriteErrorsToTextIO.Builder<T,V> newBuilder()
public abstract java.lang.String errorWritePath()
public abstract org.apache.beam.sdk.transforms.SerializableFunction<FailsafeElement<T,V>,java.lang.String> translateFunction()
public abstract @Nullable org.joda.time.Duration windowDuration()
public org.apache.beam.sdk.values.PDone expand(org.apache.beam.sdk.values.PCollection<FailsafeElement<T,V>> pCollection)
expand in class org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<FailsafeElement<T,V>>,org.apache.beam.sdk.values.PDone>