Class FlightClient

java.lang.Object
org.apache.arrow.flight.FlightClient
All Implemented Interfaces:
AutoCloseable

public class FlightClient extends Object implements AutoCloseable
Client for Flight services.
  • Method Details

    • listFlights

      public Iterable<FlightInfo> listFlights(Criteria criteria, CallOption... options)
      Get a list of available flights.
      Parameters:
      criteria - Criteria for selecting flights
      options - RPC-layer hints for the call.
      Returns:
      FlightInfo Iterable
    • listActions

      public Iterable<ActionType> listActions(CallOption... options)
      Lists actions available on the Flight service.
      Parameters:
      options - RPC-layer hints for the call.
    • doAction

      public Iterator<Result> doAction(Action action, CallOption... options)
      Performs an action on the Flight service.
      Parameters:
      action - The action to perform.
      options - RPC-layer hints for this call.
      Returns:
      An iterator of results.
    • authenticateBasic

      public void authenticateBasic(String username, String password)
      Authenticates with a username and password.
    • authenticate

      public void authenticate(ClientAuthHandler handler, CallOption... options)
      Authenticates against the Flight service.
      Parameters:
      options - RPC-layer hints for this call.
      handler - The auth mechanism to use.
    • authenticateBasicToken

      public Optional<CredentialCallOption> authenticateBasicToken(String username, String password)
      Authenticates with a username and password.
      Parameters:
      username - the username.
      password - the password.
      Returns:
      a CredentialCallOption containing a bearer token if the server emitted one, or empty if no bearer token was returned. This can be used in subsequent API calls.
    • handshake

      public void handshake(CallOption... options)
      Executes the handshake against the Flight service.
      Parameters:
      options - RPC-layer hints for this call.
    • startPut

      public FlightClient.ClientStreamListener startPut(FlightDescriptor descriptor, VectorSchemaRoot root, FlightClient.PutListener metadataListener, CallOption... options)
      Create or append a descriptor with another stream.
      Parameters:
      descriptor - FlightDescriptor the descriptor for the data
      root - VectorSchemaRoot the root containing data
      metadataListener - A handler for metadata messages from the server. This will be passed buffers that will be freed after FlightProducer.StreamListener.onNext(Object) is called!
      options - RPC-layer hints for this call.
      Returns:
      ClientStreamListener an interface to control uploading data
    • startPut

      public FlightClient.ClientStreamListener startPut(FlightDescriptor descriptor, VectorSchemaRoot root, DictionaryProvider provider, FlightClient.PutListener metadataListener, CallOption... options)
      Create or append a descriptor with another stream.
      Parameters:
      descriptor - FlightDescriptor the descriptor for the data
      root - VectorSchemaRoot the root containing data
      metadataListener - A handler for metadata messages from the server.
      options - RPC-layer hints for this call.
      Returns:
      ClientStreamListener an interface to control uploading data. OutboundStreamListener.start(VectorSchemaRoot, DictionaryProvider) will already have been called.
    • startPut

      public FlightClient.ClientStreamListener startPut(FlightDescriptor descriptor, FlightClient.PutListener metadataListener, CallOption... options)
      Create or append a descriptor with another stream.
      Parameters:
      descriptor - FlightDescriptor the descriptor for the data
      metadataListener - A handler for metadata messages from the server.
      options - RPC-layer hints for this call.
      Returns:
      ClientStreamListener an interface to control uploading data. OutboundStreamListener.start(VectorSchemaRoot, DictionaryProvider) will NOT already have been called.
    • getInfo

      public FlightInfo getInfo(FlightDescriptor descriptor, CallOption... options)
      Get info on a stream.
      Parameters:
      descriptor - The descriptor for the stream.
      options - RPC-layer hints for this call.
    • pollInfo

      public PollInfo pollInfo(FlightDescriptor descriptor, CallOption... options)
      Start or get info on execution of a long-running query.
      Parameters:
      descriptor - The descriptor for the stream.
      options - RPC-layer hints for this call.
      Returns:
      Metadata about execution.
    • getSchema

      public SchemaResult getSchema(FlightDescriptor descriptor, CallOption... options)
      Get schema for a stream.
      Parameters:
      descriptor - The descriptor for the stream.
      options - RPC-layer hints for this call.
    • getStream

      public FlightStream getStream(Ticket ticket, CallOption... options)
      Retrieve a stream from the server.
      Parameters:
      ticket - The ticket granting access to the data stream.
      options - RPC-layer hints for this call.
    • doExchange

      public FlightClient.ExchangeReaderWriter doExchange(FlightDescriptor descriptor, CallOption... options)
      Initiate a bidirectional data exchange with the server.
      Parameters:
      descriptor - A descriptor for the data stream.
      options - RPC call options.
      Returns:
      A pair of a readable stream and a writable stream.
    • cancelFlightInfo

      public CancelFlightInfoResult cancelFlightInfo(CancelFlightInfoRequest request, CallOption... options)
      Cancel execution of a distributed query.
      Parameters:
      request - The query to cancel.
      options - Call options.
      Returns:
      The server response.
    • renewFlightEndpoint

      public FlightEndpoint renewFlightEndpoint(RenewFlightEndpointRequest request, CallOption... options)
      Request the server to extend the lifetime of a query result set.
      Parameters:
      request - The result set partition.
      options - Call options.
      Returns:
      The new endpoint with an updated expiration time.
    • setSessionOptions

      public SetSessionOptionsResult setSessionOptions(SetSessionOptionsRequest request, CallOption... options)
      Set server session option(s) by name/value.

      Sessions are generally persisted via HTTP cookies.

      Parameters:
      request - The session options to set on the server.
      options - Call options.
      Returns:
      The result containing per-value error statuses, if any.
    • getSessionOptions

      public GetSessionOptionsResult getSessionOptions(GetSessionOptionsRequest request, CallOption... options)
      Get the current server session options.

      The session is generally accessed via an HTTP cookie.

      Parameters:
      request - The (empty) GetSessionOptionsRequest.
      options - Call options.
      Returns:
      The result containing the set of session options configured on the server.
    • closeSession

      public CloseSessionResult closeSession(CloseSessionRequest request, CallOption... options)
      Close/invalidate the current server session.

      The session is generally accessed via an HTTP cookie.

      Parameters:
      request - The (empty) CloseSessionRequest.
      options - Call options.
      Returns:
      The result containing the status of the close operation.
    • close

      public void close() throws InterruptedException
      Shut down this client.
      Specified by:
      close in interface AutoCloseable
      Throws:
      InterruptedException
    • builder

      public static FlightClient.Builder builder()
      Create a builder for a Flight client.
    • builder

      public static FlightClient.Builder builder(BufferAllocator allocator, Location location)
      Create a builder for a Flight client.
      Parameters:
      allocator - The allocator to use for the client.
      location - The location to connect to.