Class SessionState.ExportBuilder<T>
- Enclosing class:
SessionState
-
Method Summary
Modifier and TypeMethodDescriptionintonError(SessionState.ExportErrorHandler errorHandler) Invoke this method to set the error handler to be notified if this export fails.onError(io.grpc.stub.StreamObserver<?> streamObserver) Invoke this method to set the error handler to be notified if this export fails.onErrorHandler(SessionState.ExportErrorGrpcHandler errorHandler) Invoke this method to set the error handler to be notified if this export fails.onSuccess(io.grpc.stub.StreamObserver<?> streamObserver) Invoke this method to set theStreamObserverto besafely completedif this export succeeds.Invoke this method to set the onSuccess handler to be notified if this export succeeds.Invoke this method to set the onSuccess handler to be notified if this export succeeds.queryPerformanceRecorder(@NotNull QueryPerformanceRecorder queryPerformanceRecorder) Set the performance recorder to resume when running this export.require(SessionState.ExportObject<?>... dependencies) Invoke this method to set the required dependencies for this export.require(List<? extends SessionState.ExportObject<?>> dependencies) Invoke this method to set the required dependencies for this export.Some exports must happen serially w.r.t.This method is the final method for submitting an export to the session.This method is the final method for submitting an export to the session.
-
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
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
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
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 withStreamObserver. 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
onErroris caught and logged rather than propagated.The observer's
onErrorruns while holding the export's monitor and must not release, cancel, or look up exports; queue such work viaSessionState.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
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 insubmit(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
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 insubmit(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
Invoke this method to set theStreamObserverto besafely completedif 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
onCompletedis caught and logged rather than propagated.The observer's
onCompletedruns while holding the export's monitor and must not release, cancel, or look up exports; queue such work viaSessionState.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
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
onSuccessfor result message (unary) and completion (unary or streaming) delivery, rather than fromexportMain. This allows clients to observe performance results more predictably.
-
submit
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
onSuccessfor result message (unary) and completion (unary or streaming) delivery, rather than fromexportMain. This allows clients to observe performance results more predictably.
-
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_IDif is a non-export
-