blob: 98e7f61baf382f1309e229ef1bcc9845b14b1cb4 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_181-google-v7) on Wed Aug 14 17:37:13 PDT 2019 -->
<title>WithFailures (Apache Beam 2.15.0-SNAPSHOT)</title>
<meta name="date" content="2019-08-14">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="WithFailures (Apache Beam 2.15.0-SNAPSHOT)";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/beam/sdk/transforms/Watch.Growth.TerminationCondition.html" title="interface in org.apache.beam.sdk.transforms"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionAsMapHandler.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/beam/sdk/transforms/WithFailures.html" target="_top">Frames</a></li>
<li><a href="WithFailures.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#methods.inherited.from.class.java.lang.Object">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li>Method</li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.beam.sdk.transforms</div>
<h2 title="Class WithFailures" class="title">Class WithFailures</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.beam.sdk.transforms.WithFailures</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre><a href="../../../../../org/apache/beam/sdk/annotations/Experimental.html" title="annotation in org.apache.beam.sdk.annotations">@Experimental</a>(<a href="../../../../../org/apache/beam/sdk/annotations/Experimental.html#value--">value</a>=<a href="../../../../../org/apache/beam/sdk/annotations/Experimental.Kind.html#WITH_EXCEPTIONS">WITH_EXCEPTIONS</a>)
public class <span class="typeNameLabel">WithFailures</span>
extends java.lang.Object</pre>
<div class="block">A collection of utilities for writing transforms that can handle exceptions raised during
processing of elements.
<p>Consuming transforms such as <a href="../../../../../org/apache/beam/sdk/transforms/MapElements.MapWithFailures.html" title="class in org.apache.beam.sdk.transforms"><code>MapElements.MapWithFailures</code></a> follow the general pattern of
taking in a user-defined exception handler of type <code>ProcessFunction&lt;ExceptionElement&lt;InputT&gt;, FailureOutputT&gt;</code> where the input <a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionElement.html" title="class in org.apache.beam.sdk.transforms"><code>WithFailures.ExceptionElement</code></a> contains an exception along with the input element that was being processed
when the exception was raised. This handler is responsible for producing some output element that
captures relevant details of the failure and can be encoded as part of a failure output <a href="../../../../../org/apache/beam/sdk/values/PCollection.html" title="class in org.apache.beam.sdk.values"><code>PCollection</code></a>. Transforms can then package together their output and failure collections in a
<a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.Result.html" title="class in org.apache.beam.sdk.transforms"><code>WithFailures.Result</code></a> that avoids users needing to interact with <code>TupleTag</code>s and
indexing into a <a href="../../../../../org/apache/beam/sdk/values/PCollectionTuple.html" title="class in org.apache.beam.sdk.values"><code>PCollectionTuple</code></a>.
<p>Exception handlers can narrow their scope by rethrowing the passed <a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionElement.html#exception--"><code>WithFailures.ExceptionElement.exception()</code></a> and catching only specific subclasses of <code>Exception</code>.
Unhandled exceptions will generally bubble up to a top-level <a href="../../../../../org/apache/beam/sdk/Pipeline.PipelineExecutionException.html" title="class in org.apache.beam.sdk"><code>Pipeline.PipelineExecutionException</code></a> that halts progress.
<p>Users can take advantage of <a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.Result.html#failuresTo-java.util.List-"><code>WithFailures.Result.failuresTo(List)</code></a> for fluent chaining of transforms
that handle exceptions:
<pre><code>
PCollection&lt;Integer&gt; input = ...
List&lt;PCollection&lt;Map&lt;String, String&gt;&gt; failureCollections = new ArrayList&lt;&gt;();
input.apply(MapElements.via(...).exceptionsVia(...))
.failuresTo(failureCollections)
.apply(MapElements.via(...).exceptionsVia(...))
.failuresTo(failureCollections);
PCollection&lt;Map&lt;String, String&gt;&gt; failures = PCollectionList.of(failureCollections)
.apply("FlattenFailureCollections", Flatten.pCollections());
</code></pre></div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== NESTED CLASS SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="nested.class.summary">
<!-- -->
</a>
<h3>Nested Class Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation">
<caption><span>Nested Classes</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Class and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionAsMapHandler.html" title="class in org.apache.beam.sdk.transforms">WithFailures.ExceptionAsMapHandler</a>&lt;<a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionAsMapHandler.html" title="type parameter in WithFailures.ExceptionAsMapHandler">T</a>&gt;</span></code>
<div class="block">A simple handler that extracts information from an exception to a <code>Map&lt;String, String&gt;</code>
and returns a <a href="../../../../../org/apache/beam/sdk/values/KV.html" title="class in org.apache.beam.sdk.values"><code>KV</code></a> where the key is the input element that failed processing, and the
value is the map of exception attributes.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionElement.html" title="class in org.apache.beam.sdk.transforms">WithFailures.ExceptionElement</a>&lt;<a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionElement.html" title="type parameter in WithFailures.ExceptionElement">T</a>&gt;</span></code>
<div class="block">The value type passed as input to exception handlers.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static class&nbsp;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.Result.html" title="class in org.apache.beam.sdk.transforms">WithFailures.Result</a>&lt;<a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.Result.html" title="type parameter in WithFailures.Result">OutputT</a> extends <a href="../../../../../org/apache/beam/sdk/values/POutput.html" title="interface in org.apache.beam.sdk.values">POutput</a>,<a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.Result.html" title="type parameter in WithFailures.Result">FailureElementT</a>&gt;</span></code>
<div class="block">An intermediate output type for PTransforms that allows an output collection to live alongside
a collection of elements that failed the transform.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.html#WithFailures--">WithFailures</a></span>()</code>&nbsp;</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="WithFailures--">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>WithFailures</h4>
<pre>public&nbsp;WithFailures()</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/beam/sdk/transforms/Watch.Growth.TerminationCondition.html" title="interface in org.apache.beam.sdk.transforms"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/beam/sdk/transforms/WithFailures.ExceptionAsMapHandler.html" title="class in org.apache.beam.sdk.transforms"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/beam/sdk/transforms/WithFailures.html" target="_top">Frames</a></li>
<li><a href="WithFailures.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li><a href="#nested.class.summary">Nested</a>&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#methods.inherited.from.class.java.lang.Object">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li>Method</li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>