Class SessionImpl

All Implemented Interfaces:
ApplicationService, ConfigService, ConsoleService, InputTableService, ObjectService, Session, TableHandleManager, TableService, TableCreator<TableHandle>, AutoCloseable

public final class SessionImpl extends SessionBase
A Session implementation that uses batch requests and memoizes based on TableSpec equality.

  • Method Details

    • create

      public static SessionImpl create(SessionImplConfig config) throws InterruptedException
      Creates a session. Closing the session does not close the underlying channel.
      Parameters:
      config - the config
      Returns:
      the session
      Throws:
      InterruptedException - if the thread is interrupted
    • create

      public static SessionImpl create(SessionImplConfig config, Authentication authentication)
    • _hackBearerHandler

      public BearerHandler _hackBearerHandler()
    • newStatefulTableService

      public TableService newStatefulTableService()
      Description copied from interface: Session
      Creates a new stateful TableService that keeps references to the exports created from said service for executing queries with maximum cacheability. This allows callers to implicitly take advantage of existing exports when they are executing new queries. In the following example, the second query does not need to re-execute from the beginning; it is able to build off of the export for h1 and simply execute the where operation.
       TableServices ts = session.tableServices();
       TableHandle h1 = ts.execute(TableSpec.emptyTable(42).view("I=ii"));
       TableHandle h2 = ts.execute(TableSpec.emptyTable(42).view("I=ii").where("I % 2 == 0"));
       
      While this Session also implements TableService, query executions against this are not cached. In the following example, the second query is re-executed from the beginning.
       TableHandle h1 = session.execute(TableSpec.emptyTable(42).view("I=ii"));
       TableHandle h2 = session.execute(TableSpec.emptyTable(42).view("I=ii").where("I % 2 == 0"));
       
      When using a stateful TableService, callers may encounter exceptions that refer to an "unreferenceable table". This is an indication that the caller is trying to export a strict sub-DAG of the existing exports; this is problematic because there isn't (currently) a way to construct a query that guarantees the returned export would refer to the same physical table that the existing exports are based on. The following example demonstrates a case where such an exception would occur.
       TableServices ts = session.tableServices();
       TableHandle h1 = ts.execute(TableSpec.emptyTable(42).view("I=ii").where("I % 2 == 0"));
       // This execution will throw an "unreferenceable table" exception.
       TableHandle h2 = ts.execute(TableSpec.emptyTable(42).view("I=ii"));
       
      Returns:
      a new stateful table services
      See Also:
    • batch

      public TableHandleManager batch()
      Description copied from interface: TableService
      A batch table handle manager.
      Returns:
      a batch manager
    • batch

      public TableHandleManager batch(boolean mixinStacktraces)
      Description copied from interface: TableService
      A batch table handle manager.

      When mixinStacktraces == true, preemptive stacktraces will taken in the the TableCreationLogic methods. While relatively expensive, in exceptional circumstances this mixin allows errors to be more appropriately attributed with their source.

      Parameters:
      mixinStacktraces - if stacktraces should be mixin
      Returns:
      a batch manager
    • serial

      public TableHandleManager serial()
      Description copied from interface: TableService
      A serial table handle manager.
      Returns:
      a serial manager
    • console

      public CompletableFuture<? extends ConsoleSession> console(String type)
      Description copied from interface: ConsoleService
      Creates a new console session of script type type.

      Note: the server does not currently support independent console sessions. See Issue 1172.

      Parameters:
      type - the script type
      Returns:
      the console session future
    • publish

      public CompletableFuture<Void> publish(String name, HasTicketId ticketId)
      Description copied from interface: ConsoleService
      Publishes ticket into the global scope with name.
      Parameters:
      name - the name, must conform to SourceVersion.isName(CharSequence)
      ticketId - the export ID
      Returns:
      the publish completable future
    • publish

      public CompletableFuture<Void> publish(HasTicketId resultId, HasTicketId sourceId)
      Description copied from interface: Session
      Makes a copy from a source ticket and publishes to a result ticket. Neither the source ticket, nor the destination ticket, need to be a client managed ticket.
      Parameters:
      resultId - the result id
      sourceId - the source id
      Returns:
      the future
    • fetch

      public CompletableFuture<ServerData> fetch(HasTypedTicket typedTicket)
      Description copied from interface: ObjectService
      The low-level interface for fetching data. See ObjectService.fetchable(HasTypedTicket) for a higher-level interface.
      Parameters:
      typedTicket - the typed ticket
      Returns:
      the future
    • connect

      Description copied from interface: ObjectService
      The low-level interface for initiating a connection for a bidirectional message stream for typedTicket. See ObjectService.bidirectional(HasTypedTicket) for a higher-level interface.

      Opens a bidirectional message stream for a typedTicket. References sent to the server are generic typed tickets, while the references received from the server are server objects. The caller is responsible for releasing or closing the server objects.

      This provides a generic stream feature for Deephaven instances to use to add arbitrary functionality. This API lets a client open a stream to a particular object on the server, to be mediated by a server side plugin. In theory this could effectively be used to "tunnel" a custom gRPC call, but in practice there are a few deliberate shortcomings that still make this possible, but not trivial.

      Presently it is required that the server respond immediately, at least to acknowledge that the object was correctly contacted (as opposed to waiting for a pending ticket, or dealing with network lag, etc). This is a small (and possibly not required, but convenient) departure from a offering a gRPC stream (a server-streaming or bidi-streaming call need not send a message right away).

      Parameters:
      typedTicket - the typed ticket
      receiveStream - the stream where the client will receive messages
      Returns:
      the stream where the client will send messages
    • export

      public CompletableFuture<? extends ServerObject> export(HasTypedTicket typedTicket)
      Description copied from interface: Session
      Exports typedTicket to a client-managed server object.
      Parameters:
      typedTicket - the typed ticket
      Returns:
      the future
    • fetchable

      public CompletableFuture<? extends ObjectService.Fetchable> fetchable(HasTypedTicket typedTicket)
      Description copied from interface: ObjectService
      Exports typedTicket to a client-managed fetchable server object.
      Parameters:
      typedTicket - the typed ticket
      Returns:
      the future
      See Also:
    • bidirectional

      public CompletableFuture<? extends ObjectService.Bidirectional> bidirectional(HasTypedTicket typedTicket)
      Description copied from interface: ObjectService
      Exports typedTicket to a client-managed bidirectional server object.
      Parameters:
      typedTicket - the typed ticket
      Returns:
      the future
      See Also:
    • close

      public void close()
      Description copied from interface: Session
      Closes the session, waiting some amount of time for completion. Logs on error. Delegates to Session.closeFuture().
    • closeFuture

      public CompletableFuture<Void> closeFuture()
      Description copied from interface: Session
      Closes the session and return a future containing the results. Will return the same future if invoked more than once.
      Returns:
      the future
    • delegate

      protected TableService delegate()
    • newExportId

      public ExportId newExportId()
      Description copied from interface: Session
      Advanced usage, creates a new table export ID for this session, but must be managed by the caller. Useful for more advanced integrations, particularly around doPut. Callers are responsible for releasing the export ID if necessary.
      Returns:
      the new export ID
      See Also:
    • release

      public CompletableFuture<Void> release(ExportId exportId)
      Description copied from interface: Session
      Releases an export ID.
      Parameters:
      exportId - the export ID
      Returns:
      the future
    • channel

      public DeephavenChannel channel()
      Description copied from interface: Session
      The authenticated channel.
      Returns:
      the authenticated channel
    • addToInputTable

      public CompletableFuture<Void> addToInputTable(HasTicketId destination, HasTicketId source)
      Description copied from interface: InputTableService
      Add source to the input table destination.
      Parameters:
      destination - the input table
      source - the source to add
      Returns:
      the future
    • deleteFromInputTable

      public CompletableFuture<Void> deleteFromInputTable(HasTicketId destination, HasTicketId source)
      Description copied from interface: InputTableService
      Delete source from the input table destination.
      Parameters:
      destination - the input table
      source - the source to delete
      Returns:
      the future
    • subscribeToFields

      public ApplicationService.Cancel subscribeToFields(ApplicationService.Listener listener)
    • getAuthenticationConstants

      public CompletableFuture<Map<String,ConfigValue>> getAuthenticationConstants()
      Description copied from interface: ConfigService
      Returns constants from the server that may be helpful to correctly authenticate with the server. As such, authentication is not required to obtain these values.
    • getConfigurationConstants

      public CompletableFuture<Map<String,ConfigValue>> getConfigurationConstants()
      Description copied from interface: ConfigService
      Returns constants from the server that are specified as being appropriate for clients to read. By default these include values like the suggested authentication token refresh interval, and the server-side version of deephaven, barrage, and java.
    • executeAsync

      public TableService.TableHandleFuture executeAsync(TableSpec table)
      Description copied from interface: TableService
      Executes the given table and returns a future. If this is a stateful instance, the request will build off of the existing exports.
      Specified by:
      executeAsync in interface TableService
      Parameters:
      table - the table spec
      Returns:
      the table handle future
    • executeAsync

      public List<? extends TableService.TableHandleFuture> executeAsync(Iterable<? extends TableSpec> tables)
      Description copied from interface: TableService
      Executes the given tables and returns a future for each. If this is a stateful instance, the request will build off of the existing exports.
      Specified by:
      executeAsync in interface TableService
      Parameters:
      tables - the tables specs
      Returns:
      the table handle futures