java.lang.Object
org.apache.arrow.flight.SyncPutListener
- All Implemented Interfaces:
AutoCloseable,FlightClient.PutListener,FlightProducer.StreamListener<PutResult>
public final class SyncPutListener
extends Object
implements FlightClient.PutListener, AutoCloseable
A listener for server-sent application metadata messages during a Flight DoPut. This class wraps
the messages in a synchronous interface.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidWait for the stream to finish on the server side.booleanCheck if the call has been cancelled.voidIndicate that the transmission is finished.voidIndicate an error to the client.voidCalled when a message from the server is received.Get the next message from the server, blocking for the specified amount of time until it is available.read()Get the next message from the server, blocking until it is available.
-
Constructor Details
-
SyncPutListener
public SyncPutListener()
-
-
Method Details
-
read
Get the next message from the server, blocking until it is available.- Returns:
- The next message, or null if the server is done sending messages. The caller assumes ownership of the metadata and must remember to close it.
- Throws:
InterruptedException- if interrupted while waiting.ExecutionException- if the server sent an error, or if there was an internal error.
-
poll
Get the next message from the server, blocking for the specified amount of time until it is available.- Returns:
- The next message, or null if the server is done sending messages or no message arrived before the timeout. The caller assumes ownership of the metadata and must remember to close it.
- Throws:
InterruptedException- if interrupted while waiting.ExecutionException- if the server sent an error, or if there was an internal error.
-
getResult
public void getResult()Description copied from interface:FlightClient.PutListenerWait for the stream to finish on the server side. You must call this to be notified of any errors that may have happened during the upload.- Specified by:
getResultin interfaceFlightClient.PutListener
-
onNext
Description copied from interface:FlightClient.PutListenerCalled when a message from the server is received.- Specified by:
onNextin interfaceFlightClient.PutListener- Specified by:
onNextin interfaceFlightProducer.StreamListener<PutResult>- Parameters:
val- The application metadata. This buffer will be reclaimed once onNext returns; you must retain a reference to use it outside this method.
-
onError
Description copied from interface:FlightProducer.StreamListenerIndicate an error to the client.Terminates the stream; do not call
FlightProducer.StreamListener.onCompleted().- Specified by:
onErrorin interfaceFlightProducer.StreamListener<PutResult>
-
onCompleted
public void onCompleted()Description copied from interface:FlightProducer.StreamListenerIndicate that the transmission is finished.- Specified by:
onCompletedin interfaceFlightProducer.StreamListener<PutResult>
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
isCancelled
public boolean isCancelled()Description copied from interface:FlightClient.PutListenerCheck if the call has been cancelled.By default, this always returns false. Implementations should provide an appropriate implementation, as otherwise, a DoPut operation may inadvertently block forever.
- Specified by:
isCancelledin interfaceFlightClient.PutListener
-