Class ControllerClientGrpc
A client for subscribing to state from the PersistentQueryController and manipulating persistent queries.
In order to connect to the Persistent Query Controller you must first add an ControllerClientGrpc.Observer
then
authenticate(AuthToken)
. You can use the authentication client
to
create an AuthToken
for this. Once authenticated, a call to subscribe()
or subscribeToAll()
will request a complete snapshot of queries that the authenticated user is allowed to see. Until you call
shutdown()
the Persistent Query Controller will deliver updates to the queries to the ControllerClientGrpc.Observer
s, and
you may use the query manipulation methods to manage queries.
Warning:
Before authentication and subscription you must add
an ControllerClientGrpc.Observer
to handle
asynchronous events, like a successful connection or update delivery. If you instead call
authenticate(AuthToken)
and subscribe()
before adding an observer, you will miss delivery of the
initial snapshot of query configuration and state.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A basicControllerClientGrpc.Observer
implementation with do-nothing methods.static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final io.deephaven.proto.controller.grpc.ControllerApiGrpc.ControllerApiStub
protected final io.deephaven.shadow.enterprise.io.deephaven.util.RetryStrategy
-
Constructor Summary
ConstructorsConstructorDescriptionControllerClientGrpc
(@NotNull String who, @NotNull io.deephaven.shadow.core.io.grpc.ManagedChannel channel, @NotNull ScheduledExecutorService executorService, @NotNull io.deephaven.enterprise.auth.GrpcAuthenticationClientManager authenticationClient, long heartBeatPeriodMillis, long heartBeatTimeoutMillis) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addObserver
(@NotNull ControllerClientGrpc.Observer observer) Add a status listener.long
addQueryConfiguration
(@NotNull io.deephaven.proto.controller.PersistentQueryConfigMessage config) Adds a configuration to the controller's hash table.boolean
authenticate
(@NotNull io.deephaven.enterprise.auth.AuthToken token) Use the specified auth token to authenticate this client to the hashtable server.protected CompletableFuture<io.deephaven.shadow.core.com.google.protobuf.ByteString>
authenticateAsync
(long maxTimeToDeadlineMillis, @NotNull io.deephaven.enterprise.auth.AuthToken token) CompletableFuture<io.deephaven.shadow.core.com.google.protobuf.ByteString>
authenticateAsync
(@NotNull io.deephaven.enterprise.auth.AuthToken token) Use the specified auth token to authenticate this client to the hashtable server.io.deephaven.proto.controller.PQDBServerConfigMessage
determineDispatcher
(@NotNull io.deephaven.proto.controller.PQDBServerConfigMessage serverConfig, int heapSizeMB, String workerKind) io.deephaven.proto.controller.PQDBServerConfigMessage
determineDispatcher
(@NotNull String serverConfigName, int heapSizeMB, String workerKind) protected io.deephaven.shadow.core.com.google.protobuf.ByteString
getAuthCookie
(String who, io.deephaven.shadow.enterprise.io.deephaven.util.RetryBackoffContext backoffContext) io.deephaven.proto.controller.ControllerConfigurationMessage
Gets the server configuration from the controller.protected void
protected void
boolean
Check if this client can communicate with the server.boolean
isRunning
(@NotNull io.deephaven.proto.controller.PersistentQueryStatusEnum status) boolean
isTerminal
(@NotNull io.deephaven.proto.controller.PersistentQueryStatusEnum status) protected io.deephaven.shadow.enterprise.io.deephaven.util.RetryBackoffContext
makeAndStartAuthRetryBackoffContext
(long timeOfDeadlineMillis) void
modifyQueryConfiguration
(@NotNull io.deephaven.proto.controller.PersistentQueryConfigMessage config) Modifies a configuration in the controller's hash table, and restart the query if it was running.void
modifyQueryConfiguration
(@NotNull io.deephaven.proto.controller.PersistentQueryConfigMessage config, boolean restartIfRunning) Modifies a configuration in the controller's hash table.void
removeObserver
(ControllerClientGrpc.Observer observer) void
removeQueryConfiguration
(io.deephaven.proto.controller.PersistentQueryConfigMessage config) Removes a configuration from the controller's hash table.void
removeQueryConfigurationBySerial
(long serialId) Removes a configuration from the controller's hash table by serial ID.void
restartQueries
(@NotNull List<io.deephaven.proto.controller.PersistentQueryConfigMessage> configs) Restarts one or more persistent queries.void
restartQueriesBySerial
(@org.jetbrains.annotations.NotNull long[] serialIds) Restarts one or more persistent queries.void
restartQueriesBySerial
(@NotNull List<Long> serials) Restarts one or more persistent queries.void
restartQuery
(io.deephaven.proto.controller.PersistentQueryConfigMessage config) Restart a persistent query.void
Set the channel as ephemeral.protected io.deephaven.proto.controller.grpc.ControllerApiGrpc.ControllerApiStub
setupAsyncStub
(long deadlineAfterMillis) void
shutdown()
void
stopQueries
(@NotNull List<io.deephaven.proto.controller.PersistentQueryConfigMessage> configs) Stops one or more persistent queries.void
stopQuery
(io.deephaven.proto.controller.PersistentQueryConfigMessage config) Stops a persistent query.void
stopQueryBySerial
(@org.jetbrains.annotations.NotNull long[] serials) Stops one or more persistent query by serial id.void
stopQueryBySerial
(@NotNull List<Long> serials) void
Subscribe to the complete hash table.protected <ReqT,
RespT, Stub>
RespTwithRetriesAndReAuth
(String who, Function<io.deephaven.shadow.core.com.google.protobuf.ByteString, ReqT> authCookieToRequestFun, LongFunction<Stub> stubFun, Function<Stub, BiConsumer<ReqT, io.deephaven.shadow.core.io.grpc.stub.StreamObserver<RespT>>> callFun, long timeToDeadlineMillis) protected <ReqT,
RespT, Stub, V>
VwithRetriesAndReAuth
(String who, Function<io.deephaven.shadow.core.com.google.protobuf.ByteString, ReqT> authCookieToRequestFun, LongFunction<Stub> stubFun, Function<Stub, BiConsumer<ReqT, io.deephaven.shadow.core.io.grpc.stub.StreamObserver<RespT>>> callFun, Function<RespT, V> responseMapping, long timeToDeadlineMillis) Perform an RPC call with retries if necessary, including both call retries and necessary authentication retries depending on type of failure.
-
Field Details
-
asyncStub
protected final io.deephaven.proto.controller.grpc.ControllerApiGrpc.ControllerApiStub asyncStub -
authRetryStrategy
protected final io.deephaven.shadow.enterprise.io.deephaven.util.RetryStrategy authRetryStrategy
-
-
Constructor Details
-
ControllerClientGrpc
public ControllerClientGrpc(@NotNull @NotNull String who, @NotNull @NotNull io.deephaven.shadow.core.io.grpc.ManagedChannel channel, @NotNull @NotNull ScheduledExecutorService executorService, @NotNull @NotNull io.deephaven.enterprise.auth.GrpcAuthenticationClientManager authenticationClient, long heartBeatPeriodMillis, long heartBeatTimeoutMillis)
-
-
Method Details
-
setupAsyncStub
protected io.deephaven.proto.controller.grpc.ControllerApiGrpc.ControllerApiStub setupAsyncStub(long deadlineAfterMillis) -
withRetriesAndReAuth
protected <ReqT,RespT, RespT withRetriesAndReAuthStub> (String who, Function<io.deephaven.shadow.core.com.google.protobuf.ByteString, ReqT> authCookieToRequestFun, LongFunction<Stub> stubFun, Function<Stub, BiConsumer<ReqT, io.deephaven.shadow.core.io.grpc.stub.StreamObserver<RespT>>> callFun, long timeToDeadlineMillis) -
withRetriesAndReAuth
protected <ReqT,RespT, V withRetriesAndReAuthStub, V> (String who, Function<io.deephaven.shadow.core.com.google.protobuf.ByteString, ReqT> authCookieToRequestFun, LongFunction<Stub> stubFun, Function<Stub, BiConsumer<ReqT, io.deephaven.shadow.core.io.grpc.stub.StreamObserver<RespT>>> callFun, Function<RespT, V> responseMapping, long timeToDeadlineMillis) Perform an RPC call with retries if necessary, including both call retries and necessary authentication retries depending on type of failure. The implementation assumes the existence of a service configuration file at channel creation that enables retries on all stubs that this method will be used with; the retry strategy for the non-reauthentication retries (meaning the stub call itself) will be done according to the strategy defined in that service config. Authentication retries are done when the stub call fails withStatus.UNAUTHENTICATED
, and follow the strategy defined byauthRetryStrategy
- Type Parameters:
ReqT
- The type of the request for the RPC callRespT
- The type of the response for the RPC callStub
- The type for the stub where the RPC call is madeV
- The return value of theresponseMapping
and this method- Parameters:
who
- A string identifier for the caller used for loggingauthCookieToRequestFun
- A function taking an auth cookie and expected to return the request object to provide as an argument to the RPC call to makestubFun
- A function taking a time in milliseconds to deadline and expected to return a stub configured with that deadline and any other necessary configuration options for the desired retry strategy (eg, wait for ready)callFun
- A function taking a stub (the one produced viaauthCookieToRequestFun
and expected to return the RPC call to makeresponseMapping
- A function taking the RPC call's response and expected to return a value to be returned by this function. Pass the identity function to get the actual RPC return type and value.timeToDeadlineMillis
- A time in milliseconds from now to a deadline when to stop retrying- Returns:
- The result of the RPC call mapped using
responseMapping
-
authenticate
public boolean authenticate(@NotNull @NotNull io.deephaven.enterprise.auth.AuthToken token) Use the specified auth token to authenticate this client to the hashtable server.- Parameters:
token
- the token for authentication- Returns:
- true if authentication was successful.
-
authenticateAsync
public CompletableFuture<io.deephaven.shadow.core.com.google.protobuf.ByteString> authenticateAsync(@NotNull @NotNull io.deephaven.enterprise.auth.AuthToken token) Use the specified auth token to authenticate this client to the hashtable server.- Parameters:
token
- the token for authentication- Returns:
- a CompletableFuture that can be used to asynchronously wait for authentication to complete.
-
authenticateAsync
protected CompletableFuture<io.deephaven.shadow.core.com.google.protobuf.ByteString> authenticateAsync(long maxTimeToDeadlineMillis, @NotNull @NotNull io.deephaven.enterprise.auth.AuthToken token) -
makeAndStartAuthRetryBackoffContext
protected io.deephaven.shadow.enterprise.io.deephaven.util.RetryBackoffContext makeAndStartAuthRetryBackoffContext(long timeOfDeadlineMillis) -
getAuthCookie
protected io.deephaven.shadow.core.com.google.protobuf.ByteString getAuthCookie(String who, io.deephaven.shadow.enterprise.io.deephaven.util.RetryBackoffContext backoffContext) -
setEphemeral
public void setEphemeral()Set the channel as ephemeral. In this mode when a heartbeat is missed, the client halts further heartbeats, ends any active grpc stream, and generates no further connection events. -
isTerminal
public boolean isTerminal(@NotNull @NotNull io.deephaven.proto.controller.PersistentQueryStatusEnum status) -
isRunning
public boolean isRunning(@NotNull @NotNull io.deephaven.proto.controller.PersistentQueryStatusEnum status) -
addObserver
Add a status listener. If the service is already available, the listener will be invoked immediately on the thread pool.- Parameters:
observer
- the listener to add
-
removeObserver
-
isConnected
public boolean isConnected()Check if this client can communicate with the server.- Returns:
- true if it can
-
subscribeToAll
public void subscribeToAll()Subscribe to the complete hash table. -
shutdown
- Throws:
IOException
-
getConfiguration
public io.deephaven.proto.controller.ControllerConfigurationMessage getConfiguration()Gets the server configuration from the controller.- Returns:
- the currently loaded controller configuration
-
addQueryConfiguration
public long addQueryConfiguration(@NotNull @NotNull io.deephaven.proto.controller.PersistentQueryConfigMessage config) Adds a configuration to the controller's hash table.- Parameters:
config
- the configuration to add- Returns:
- the serial number of the added configuration
-
determineDispatcher
public io.deephaven.proto.controller.PQDBServerConfigMessage determineDispatcher(@NotNull @NotNull io.deephaven.proto.controller.PQDBServerConfigMessage serverConfig, int heapSizeMB, String workerKind) -
determineDispatcher
-
modifyQueryConfiguration
public void modifyQueryConfiguration(@NotNull @NotNull io.deephaven.proto.controller.PersistentQueryConfigMessage config) Modifies a configuration in the controller's hash table, and restart the query if it was running.- Parameters:
config
- the updated configuration
-
modifyQueryConfiguration
public void modifyQueryConfiguration(@NotNull @NotNull io.deephaven.proto.controller.PersistentQueryConfigMessage config, boolean restartIfRunning) Modifies a configuration in the controller's hash table.- Parameters:
config
- the updated configurationrestartIfRunning
- restart the query when it is running if set to true
-
removeQueryConfiguration
public void removeQueryConfiguration(io.deephaven.proto.controller.PersistentQueryConfigMessage config) Removes a configuration from the controller's hash table.- Parameters:
config
- the configuration to remove
-
removeQueryConfigurationBySerial
public void removeQueryConfigurationBySerial(long serialId) Removes a configuration from the controller's hash table by serial ID.- Parameters:
serialId
- the serial ID of configuration to remove
-
restartQuery
public void restartQuery(io.deephaven.proto.controller.PersistentQueryConfigMessage config) Restart a persistent query. This implementation delegates torestartQueries(List)
)}.- Parameters:
config
- the persistent query configuration to be restarted.
-
restartQueries
public void restartQueries(@NotNull @NotNull List<io.deephaven.proto.controller.PersistentQueryConfigMessage> configs) Restarts one or more persistent queries.- Parameters:
configs
- the persistent query configurations to be restarted
-
restartQueriesBySerial
public void restartQueriesBySerial(@NotNull @org.jetbrains.annotations.NotNull long[] serialIds) Restarts one or more persistent queries.- Parameters:
serialIds
- an array of serial ids to restart
-
restartQueriesBySerial
Restarts one or more persistent queries.- Parameters:
serials
- a list of serial ids to restart
-
stopQuery
public void stopQuery(io.deephaven.proto.controller.PersistentQueryConfigMessage config) Stops a persistent query.- Parameters:
config
- the persistent query configuration to be stopped.
-
stopQueries
public void stopQueries(@NotNull @NotNull List<io.deephaven.proto.controller.PersistentQueryConfigMessage> configs) Stops one or more persistent queries.- Parameters:
configs
- the persistent query configurations to be stopped
-
stopQueryBySerial
public void stopQueryBySerial(@NotNull @org.jetbrains.annotations.NotNull long[] serials) Stops one or more persistent query by serial id.- Parameters:
serials
- the serial ids of the persistent query configurations to be stopped
-
stopQueryBySerial
-
handleConnectionLost
protected void handleConnectionLost() -
handleConnectionReestablished
protected void handleConnectionReestablished()
-