Class SessionState.ExportBuilder<T>

java.lang.Object
io.deephaven.server.session.SessionState.ExportBuilder<T>
Enclosing class:
SessionState

public class SessionState.ExportBuilder<T> extends Object
  • Method Details

    • queryPerformanceRecorder

      public SessionState.ExportBuilder<T> queryPerformanceRecorder(@NotNull @NotNull QueryPerformanceRecorder queryPerformanceRecorder)
      Set the performance recorder to resume when running this export.
      Parameters:
      queryPerformanceRecorder - the performance recorder
      Returns:
      this builder
    • requiresSerialQueue

      public SessionState.ExportBuilder<T> requiresSerialQueue()
      Some exports must happen serially w.r.t. other exports. For example, an export that acquires the exclusive UGP lock. We enqueue these dependencies independently of the otherwise regularly concurrent exports.
      Returns:
      this builder
    • require

      public SessionState.ExportBuilder<T> require(SessionState.ExportObject<?>... dependencies)
      Invoke this method to set the required dependencies for this export. A parent may be null to simplify usage of optional export dependencies.
      Parameters:
      dependencies - the parent dependencies
      Returns:
      this builder
    • require

      public SessionState.ExportBuilder<T> require(List<? extends SessionState.ExportObject<?>> dependencies)
      Invoke this method to set the required dependencies for this export. A parent may be null to simplify usage of optional export dependencies.
      Parameters:
      dependencies - the parent dependencies
      Returns:
      this builder
    • onError

      Invoke this method to set the error handler to be notified if this export fails. Only one error handler may be set. Exactly one of the onError and onSuccess handlers will be invoked.

      Not synchronized: a callback that writes to a gRPC stream observer must synchronize on it itself, as GrpcUtil.safely* does.

      The handler must not throw: the export is already in its final state, so an exception here cannot affect it or reach the client, and is treated as fatal to the server. It runs while holding the export's monitor and must not release, cancel, or look up exports; queue such work via SessionState.nonExport(), catching the UNAUTHENTICATED it throws once the session has expired, as it has when session teardown is what cancelled this export.

      Parameters:
      errorHandler - the error handler to be notified
      Returns:
      this builder
    • onErrorHandler

      public SessionState.ExportBuilder<T> onErrorHandler(SessionState.ExportErrorGrpcHandler errorHandler)
      Invoke this method to set the error handler to be notified if this export fails. Only one error handler may be set. Exactly one of the onError and onSuccess handlers will be invoked.

      Not synchronized: a callback that writes to a gRPC stream observer must synchronize on it itself, as GrpcUtil.safely* does.

      The handler must not throw: the export is already in its final state, so an exception here cannot affect it or reach the client, and is treated as fatal to the server. It runs while holding the export's monitor and must not release, cancel, or look up exports; queue such work via SessionState.nonExport(), catching the UNAUTHENTICATED it throws once the session has expired, as it has when session teardown is what cancelled this export.

      Parameters:
      errorHandler - the error handler to be notified
      Returns:
      this builder
    • onError

      public SessionState.ExportBuilder<T> onError(io.grpc.stub.StreamObserver<?> streamObserver)
      Invoke this method to set the error handler to be notified if this export fails. Only one error handler may be set. This is a convenience method for use with StreamObserver. Exactly one of the onError and onSuccess handlers will be invoked.

      Invoking onError will be synchronized on the StreamObserver instance, so callers can rely on that mechanism to deal with more than one thread trying to write to the stream, and an exception from the observer's onError is caught and logged rather than propagated.

      The observer's onError runs while holding the export's monitor and must not release, cancel, or look up exports; queue such work via SessionState.nonExport(), catching the UNAUTHENTICATED it throws once the session has expired, as it has when session teardown is what cancelled this export.

      Parameters:
      streamObserver - the streamObserver to be notified of any error
      Returns:
      this builder
    • onSuccess

      public SessionState.ExportBuilder<T> onSuccess(Consumer<? super T> successHandler)
      Invoke this method to set the onSuccess handler to be notified if this export succeeds. Only one success handler may be set. Exactly one of the onError and onSuccess handlers will be invoked.

      Not synchronized: a callback that writes to a gRPC stream observer must synchronize on it itself, as GrpcUtil.safely* does.

      The handler must not throw: the export is already in its final state, so an exception here cannot affect it or reach the client, and is treated as fatal to the server. It runs while holding the export's monitor and must not release, cancel, or look up exports; queue such work via SessionState.nonExport(), catching the UNAUTHENTICATED it throws once the session has expired, as it has when session teardown is what cancelled this export. Do fallible work in submit(java.util.concurrent.Callable<T>); use this only to deliver an already-computed result.

      Parameters:
      successHandler - the onSuccess handler to be notified
      Returns:
      this builder
    • onSuccess

      public SessionState.ExportBuilder<T> onSuccess(Runnable successHandler)
      Invoke this method to set the onSuccess handler to be notified if this export succeeds. Only one success handler may be set. Exactly one of the onError and onSuccess handlers will be invoked.

      Not synchronized: a callback that writes to a gRPC stream observer must synchronize on it itself, as GrpcUtil.safely* does.

      The handler must not throw: the export is already in its final state, so an exception here cannot affect it or reach the client, and is treated as fatal to the server. It runs while holding the export's monitor and must not release, cancel, or look up exports; queue such work via SessionState.nonExport(), catching the UNAUTHENTICATED it throws once the session has expired, as it has when session teardown is what cancelled this export. Do fallible work in submit(java.util.concurrent.Callable<T>); use this only to deliver an already-computed result.

      Parameters:
      successHandler - the onSuccess handler to be notified
      Returns:
      this builder
    • onSuccess

      public SessionState.ExportBuilder<T> onSuccess(io.grpc.stub.StreamObserver<?> streamObserver)
      Invoke this method to set the StreamObserver to be safely completed if this export succeeds. Only one success handler may be set. Exactly one of the onError and onSuccess handlers will be invoked.

      Completion is synchronized on the observer, and an exception from its onCompleted is caught and logged rather than propagated.

      The observer's onCompleted runs while holding the export's monitor and must not release, cancel, or look up exports; queue such work via SessionState.nonExport(), catching the UNAUTHENTICATED it throws once the session has expired, as it has when session teardown is what cancelled this export.

      Parameters:
      streamObserver - the streamObserver to be notified
      Returns:
      this builder
    • submit

      public SessionState.ExportObject<T> submit(Callable<T> exportMain)
      This method is the final method for submitting an export to the session. The provided callable is enqueued on the scheduler when all dependencies have been satisfied. Only the dependencies supplied to the builder are guaranteed to be resolved when the exportMain is executing.

      Warning! It is the SessionState owner's responsibility to wait to release any dependency until after this exportMain callable/runnable has complete.

      Parameters:
      exportMain - the callable that generates the export
      Returns:
      the submitted export object
      ApiNote:
      For exports used in RPC handling, it is recommended to use onSuccess for result message (unary) and completion (unary or streaming) delivery, rather than from exportMain. This allows clients to observe performance results more predictably.
    • submit

      public SessionState.ExportObject<T> submit(Runnable exportMain)
      This method is the final method for submitting an export to the session. The provided runnable is enqueued on the scheduler when all dependencies have been satisfied. Only the dependencies supplied to the builder are guaranteed to be resolved when the exportMain is executing.

      Warning! It is the SessionState owner's responsibility to wait to release any dependency until after this exportMain callable/runnable has complete.

      Parameters:
      exportMain - the runnable to execute once dependencies have resolved
      Returns:
      the submitted export object
      ApiNote:
      For exports used in RPC handling, it is recommended to use onSuccess for result message (unary) and completion (unary or streaming) delivery, rather than from exportMain. This allows clients to observe performance results more predictably.
    • getExport

      public SessionState.ExportObject<T> getExport()
      Returns:
      the export object that this builder is building
    • getExportId

      public int getExportId()
      Returns:
      the export id of this export or SessionState.NON_EXPORT_ID if is a non-export