Package org.apache.beam.sdk.fn.data
Class CompletableFutureInboundDataClient
- java.lang.Object
-
- org.apache.beam.sdk.fn.data.CompletableFutureInboundDataClient
-
- All Implemented Interfaces:
InboundDataClient
public class CompletableFutureInboundDataClient extends java.lang.Object implements InboundDataClient
AnInboundDataClientbacked by aCompletableFuture.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawaitCompletion()Block until the client has completed reading from the inbound stream.voidcancel()Cancels the client, causing it to drop any future inbound data.voidcomplete()Mark the client as completed.static InboundDataClientcreate()Create a newCompletableFutureInboundDataClientusing a newCompletableFuture.voidfail(java.lang.Throwable t)Mark the client as completed with an exception.booleanisDone()Returns true if the client is done, either via completing successfully or by being cancelled.voidrunWhenComplete(java.lang.Runnable completeRunnable)Runs the runnable once the client has completed reading from the inbound stream.
-
-
-
Method Detail
-
create
public static InboundDataClient create()
Create a newCompletableFutureInboundDataClientusing a newCompletableFuture.
-
awaitCompletion
public void awaitCompletion() throws java.lang.ExceptionDescription copied from interface:InboundDataClientBlock until the client has completed reading from the inbound stream.- Specified by:
awaitCompletionin interfaceInboundDataClient- Throws:
java.lang.InterruptedException- if the client is interrupted before completing.java.util.concurrent.CancellationException- if the client is cancelled before completing.java.lang.Exception- if the client throws an exception while awaiting completion.
-
runWhenComplete
public void runWhenComplete(java.lang.Runnable completeRunnable)
Description copied from interface:InboundDataClientRuns the runnable once the client has completed reading from the inbound stream.- Specified by:
runWhenCompletein interfaceInboundDataClient
-
isDone
public boolean isDone()
Description copied from interface:InboundDataClientReturns true if the client is done, either via completing successfully or by being cancelled.- Specified by:
isDonein interfaceInboundDataClient
-
cancel
public void cancel()
Description copied from interface:InboundDataClientCancels the client, causing it to drop any future inbound data.- Specified by:
cancelin interfaceInboundDataClient
-
complete
public void complete()
Description copied from interface:InboundDataClientMark the client as completed.- Specified by:
completein interfaceInboundDataClient
-
fail
public void fail(java.lang.Throwable t)
Description copied from interface:InboundDataClientMark the client as completed with an exception. Calls to awaitCompletion will terminate by throwing the provided exception.- Specified by:
failin interfaceInboundDataClient- Parameters:
t- the throwable that caused this client to fail
-
-