Package org.apache.arrow.flight
Class SyncPutListener
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
Wait for the stream to finish on the server side.boolean
Check if the call has been cancelled.void
Indicate that the transmission is finished.void
Indicate an error to the client.void
Called 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.PutListener
Wait 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:
getResult
in interfaceFlightClient.PutListener
-
onNext
Description copied from interface:FlightClient.PutListener
Called when a message from the server is received.- Specified by:
onNext
in interfaceFlightClient.PutListener
- Specified by:
onNext
in 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.StreamListener
Indicate an error to the client.Terminates the stream; do not call
FlightProducer.StreamListener.onCompleted()
.- Specified by:
onError
in interfaceFlightProducer.StreamListener<PutResult>
-
onCompleted
public void onCompleted()Description copied from interface:FlightProducer.StreamListener
Indicate that the transmission is finished.- Specified by:
onCompleted
in interfaceFlightProducer.StreamListener<PutResult>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
isCancelled
public boolean isCancelled()Description copied from interface:FlightClient.PutListener
Check 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:
isCancelled
in interfaceFlightClient.PutListener
-