Package io.deephaven.web.client.api
Class WorkerConnection
java.lang.Object
io.deephaven.web.client.api.WorkerConnection
Non-exported class, manages the connection to a given worker server. Exported types like QueryInfo and Table will
refer to this, and allow us to try to keep track of how many open tables there are, so we can close the connection if
not in use.
Might make more sense to be part of QueryInfo, but this way we can WeakMap instances, check periodically if any
QueryInfos are left alive or event handlers still exist, and close connections that seem unused.
Except for the delegated call from QueryInfo.getTable, none of these calls will be possible in Connecting or
Disconnected state if done right. Failed state is possible, and we will want to think more about handling, possible
re-Promise-ing all of the things, or just return stale values if we have them.
Responsible for reconnecting to the query server when required - when that server disappears, and at least one table
is left un-closed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckStatus(io.grpc.Status status) booleancheckStatus(io.grpc.StatusRuntimeException status) voidstatic StringdefinitionType(jsinterop.base.JsPropertyMap<Object> definitionObject) The type named by a definition, whether it is aJsVariableDefinitionor a plain JS object.emptyTable(double size) voidexportedTableUpdateMessage(TableTicket clientId, long size) fetchTableState(elemental2.promise.Promise<JsVariableDefinition> definition, @Nullable Boolean applyPreviewColumns, TableTicket handle) Creates the state for a named table and issues nothing yet: the fetch waits for the server to be ready and fordefinitionto resolve, so the state exists, and operations can be chained on its ticket, before either has happened.org.apache.arrow.flight.impl.FlightServiceGrpc.FlightServiceStubvoidvoidgetBatcher(JsTable table) getCache()elemental2.promise.Promise<JsFigure> getFigure(JsVariableDefinition varDef) elemental2.promise.Promise<JsTreeTable> getJsObject(jsinterop.base.JsPropertyMap<Object> definitionObject) getJsObject(jsinterop.base.JsPropertyMap<Object> definitionObject, @Nullable TableTicket handle) AsgetObject(JsVariableDefinition, TableTicket), for a definition that may still need its name resolved to an id.elemental2.promise.Promise<?> getObject(TypedTicket typedTicket) getObject(JsVariableDefinition definition) getObject(JsVariableDefinition definition, @Nullable TableTicket handle) Fetches the object a definition names.elemental2.promise.Promise<JsPartitionedTable> intgetSharedObject(SharedExportBytesUnion sharedExportBytes, String type) elemental2.promise.Promise<JsTable> getTable(JsVariableDefinition varDef, @Nullable Boolean applyPreviewColumns) elemental2.promise.Promise<JsTable> getTable(JsVariableDefinition varDef, @Nullable Boolean applyPreviewColumns, TableTicket handle) AsgetTable(JsVariableDefinition, Boolean), into a ticket the caller already allocated so that operations can be chained on the table before it is fetched.elemental2.promise.Promise<JsVariableDefinition> getVariableDefinition(String name, String type) elemental2.promise.Promise<JsWidget> getWidget(TypedTicket typedTicket) elemental2.promise.Promise<JsWidget> getWidget(JsVariableDefinition varDef) static booleanisTransportError(io.grpc.Status status) booleanisUsable()elemental2.promise.Promise<JsVariableDefinition> lookupDefinition(jsinterop.base.JsPropertyMap<Object> definitionObject) The definition agetObjectargument names: the argument itself if it is aJsVariableDefinition, otherwise looked up by name, or taken as given by id.mergeTables(JsTableReference[] tables, HasEventHandling failHandler) newState(JsTableFetch fetcher, String fetchSummary) newState(JsTableFetch fetcher, String fetchSummary, TableTicket handle) AsnewState(JsTableFetch, String), for a ticket the caller already allocated so that operations could be chained on it before the state exists.newState(ClientTableState from, TableConfig to) newState(ClientTableState from, TableConfig to, TableTicket handle) newStateFromUnsolicitedTable(ExportedTableCreationResponse unsolicitedTable, String fetchSummary) newTable(List<BarrageColumnType> columnTypes, Chunk<Values>[] data) byte[]newTableToBytes(List<BarrageColumnType> columnTypes, Chunk<Values>[] data) Internal API to write a table to a byte array, prefixed with each FlightData message size as a 32bit LE int.voidonOpen(BiConsumer<Void, String> callback) pendingTable(JsTableFetch fetcher, String fetchSummary) Creates a state for a fetcher-produced table and presents it as a pending table: the ticket is allocated before the fetch is issued, so operations can be chained on the result immediately.pendingTable(JsTableFetch fetcher, String fetchSummary, JsTableReference... operands) AspendingTable(JsTableFetch, String), for a fetch whose request namesoperands' tickets.pendingTable(ClientTableState state) Issues the fetch ofstateand presents it as a pending table whoseJsTableis built on the first await.pendingTable(ClientTableState state, @Nullable Consumer<JsTable> onCreated) AspendingTable(ClientTableState), with a callback for the moment the table is built, which is when it counts as opened.pendingTable(String operationName, JsTableFetch fetcher, String fetchSummary) AspendingTable(JsTableFetch, String), but the fetch waits for the server to be ready.voidvoidreleaseHandle(TableTicket handle) voidreleaseTicket(Ticket ticket) Releases the ticket, indicating no client using this session will reference it any more.voidscheduleCheck(ClientTableState state) Schedules a deferred command to check the given state for active tables.elemental2.promise.Promise<SharedExportBytesUnion> shareObject(ServerObject object, SharedExportBytesUnion sharedTicketBytes) <ReqT,RespT>
BiDiStream.Factory<ReqT, RespT> subscribeToFieldUpdates(JsConsumer<JsVariableChanges> callback) subscribeToLogs(JsConsumer<LogItem> callback) timeTable(double periodNanos, DateWrapper startTime) voidelemental2.promise.Promise<Object> whenServerReady(String operationName)
-
Constructor Details
-
WorkerConnection
-
-
Method Details
-
getSessions
public int getSessions() -
checkStatus
public boolean checkStatus(io.grpc.Status status) -
checkStatus
public boolean checkStatus(io.grpc.StatusRuntimeException status) -
isTransportError
public static boolean isTransportError(io.grpc.Status status) -
exportedTableUpdateMessage
-
connectionLost
public void connectionLost() -
forceReconnect
@JsMethod public void forceReconnect() -
forceClose
@JsMethod public void forceClose() -
getVariableDefinition
public elemental2.promise.Promise<JsVariableDefinition> getVariableDefinition(String name, String type) -
getTable
public elemental2.promise.Promise<JsTable> getTable(JsVariableDefinition varDef, @Nullable Boolean applyPreviewColumns) -
getTable
public elemental2.promise.Promise<JsTable> getTable(JsVariableDefinition varDef, @Nullable Boolean applyPreviewColumns, TableTicket handle) AsgetTable(JsVariableDefinition, Boolean), into a ticket the caller already allocated so that operations can be chained on the table before it is fetched. -
fetchTableState
public ClientTableState fetchTableState(elemental2.promise.Promise<JsVariableDefinition> definition, @Nullable Boolean applyPreviewColumns, TableTicket handle) Creates the state for a named table and issues nothing yet: the fetch waits for the server to be ready and fordefinitionto resolve, so the state exists, and operations can be chained on its ticket, before either has happened. -
lookupDefinition
public elemental2.promise.Promise<JsVariableDefinition> lookupDefinition(jsinterop.base.JsPropertyMap<Object> definitionObject) The definition agetObjectargument names: the argument itself if it is aJsVariableDefinition, otherwise looked up by name, or taken as given by id. -
getObject
-
getObject
Fetches the object a definition names. A table comes back as aJsPendingTable, so that operations can be chained on it before it arrives;handleis the ticket it will occupy, allocated by the caller when it needed the ticket even earlier, or null to allocate one here. Other object types come back as a promise. -
definitionType
The type named by a definition, whether it is aJsVariableDefinitionor a plain JS object. -
getJsObject
-
getJsObject
public JsPendingObject getJsObject(jsinterop.base.JsPropertyMap<Object> definitionObject, @Nullable TableTicket handle) AsgetObject(JsVariableDefinition, TableTicket), for a definition that may still need its name resolved to an id. The table's ticket is known before that lookup completes, so a table can be chained on immediately. -
getObject
-
whenServerReady
-
getPartitionedTable
public elemental2.promise.Promise<JsPartitionedTable> getPartitionedTable(JsVariableDefinition varDef) -
getHierarchicalTable
-
getFigure
-
getWidget
-
getWidget
-
registerSimpleReconnectable
-
unregisterSimpleReconnectable
-
tableServiceClient
-
consoleServiceClient
-
sessionServiceClient
-
flightServiceClient
public org.apache.arrow.flight.impl.FlightServiceGrpc.FlightServiceStub flightServiceClient() -
browserFlightServiceClient
-
inputTableServiceClient
-
objectServiceClient
-
partitionedTableServiceClient
-
storageServiceClient
-
configServiceClient
-
hierarchicalTableServiceClient
-
streamFactory
-
newTable
-
newTable
-
newTableToBytes
Internal API to write a table to a byte array, prefixed with each FlightData message size as a 32bit LE int.Note that this is _not_ the IPC format, also used as arrow flight feather v2, as this has no support for app metadata nor the rest of the surrounding FlightData protobuf. Technically we don't need that metadata for this use case, but without the rest of the wrapping we cannot reuse the rest of our usual reading/writing code.
- Parameters:
columnTypes- the types of each columndata- the chunks to write- Returns:
- an array of bytes in the specified internal format
-
mergeTables
-
getBatcher
-
newStateFromUnsolicitedTable
public ClientTableState newStateFromUnsolicitedTable(ExportedTableCreationResponse unsolicitedTable, String fetchSummary) -
newState
-
newState
AsnewState(JsTableFetch, String), for a ticket the caller already allocated so that operations could be chained on it before the state exists. -
pendingTable
Creates a state for a fetcher-produced table and presents it as a pending table: the ticket is allocated before the fetch is issued, so operations can be chained on the result immediately. -
pendingTable
public JsPendingTable<JsTable> pendingTable(JsTableFetch fetcher, String fetchSummary, JsTableReference... operands) AspendingTable(JsTableFetch, String), for a fetch whose request namesoperands' tickets. The operands are checked and held as a batch operation's are; seeMicrotaskBatchImpl.wrapWithOperands(io.deephaven.web.client.api.WorkerConnection, io.deephaven.web.client.state.ClientTableState, io.deephaven.web.client.api.JsTableReference[], java.util.function.Function<io.deephaven.web.client.state.ClientTableState, T>). -
pendingTable
public JsPendingTable<JsTable> pendingTable(String operationName, JsTableFetch fetcher, String fetchSummary) AspendingTable(JsTableFetch, String), but the fetch waits for the server to be ready. The state and its ticket exist immediately. -
pendingTable
Issues the fetch ofstateand presents it as a pending table whoseJsTableis built on the first await. A pending nobody awaits or chains on is released when the fetch completes. -
pendingTable
public JsPendingTable<JsTable> pendingTable(ClientTableState state, @Nullable Consumer<JsTable> onCreated) AspendingTable(ClientTableState), with a callback for the moment the table is built, which is when it counts as opened. -
newState
-
newState
-
getCache
-
scheduleCheck
Schedules a deferred command to check the given state for active tables. -
releaseHandle
-
releaseTicket
Releases the ticket, indicating no client using this session will reference it any more.- Parameters:
ticket- the ticket to release
-
getReviver
-
isUsable
public boolean isUsable() -
getTickets
-
getServerConfigValue
-
onOpen
-
dump
-
emptyTable
-
timeTable
-