Class PersistentQueryControllerClient

java.lang.Object
com.illumon.iris.controller.ControllerHashtable
com.illumon.iris.controller.PersistentQueryControllerClient
All Implemented Interfaces:
ControllerHashtableEventSource, PersistentQueryScriptSource, RemoteScriptSource, Map<Long,PersistentQueryInfo>

public class PersistentQueryControllerClient extends ControllerHashtable implements PersistentQueryScriptSource
Client for subscribing to state from the PersistentQueryController and manipulating persistent queries.
  • Field Details

    • DEFAULT_HEARTBEAT_PERIOD_MILLIS

      public static final long DEFAULT_HEARTBEAT_PERIOD_MILLIS
    • DEFAULT_HEARTBEAT_TIMEOUT_MILLIS

      public static final long DEFAULT_HEARTBEAT_TIMEOUT_MILLIS
    • log

      protected final com.fishlib.io.logger.Logger log
    • grpcClient

      protected final io.deephaven.enterprise.controller.client.ControllerClientGrpc grpcClient
  • Constructor Details

    • PersistentQueryControllerClient

      public PersistentQueryControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, @NotNull io.grpc.ManagedChannel channel)
    • PersistentQueryControllerClient

      public PersistentQueryControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, @NotNull io.grpc.ManagedChannel channel, @NotNull ScheduledExecutorService executorService)
    • PersistentQueryControllerClient

      public PersistentQueryControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, @NotNull io.grpc.ManagedChannel channel, @NotNull ScheduledExecutorService executorService, long heartBeatPeriodMillis, long heartBeatTimeoutMillis)
    • PersistentQueryControllerClient

      public PersistentQueryControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, @NotNull io.grpc.ManagedChannel channel, @NotNull ScheduledExecutorService executorService, @NotNull AuthenticationClient authClient)
    • PersistentQueryControllerClient

      public PersistentQueryControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, @NotNull io.grpc.ManagedChannel channel, @NotNull ScheduledExecutorService executorService, @NotNull AuthenticationClient authClient, long heartBeatPeriodMillis, long heartBeatTimeoutMillis)
    • PersistentQueryControllerClient

      public PersistentQueryControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, @NotNull io.grpc.ManagedChannel channel, @NotNull TokenFactoryFactory.TokenFactory tokenFactory)
    • PersistentQueryControllerClient

      public PersistentQueryControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, @NotNull io.grpc.ManagedChannel channel, @NotNull ScheduledExecutorService executorService, @NotNull TokenFactoryFactory.TokenFactory tokenFactory)
    • PersistentQueryControllerClient

      public PersistentQueryControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, @NotNull io.grpc.ManagedChannel channel, @NotNull ScheduledExecutorService executorService, @NotNull TokenFactoryFactory.TokenFactory tokenFactory, long heartBeatPeriodMillis, long heartBeatTimeoutMillis)
  • Method Details

    • addQueryConfiguration

      public long addQueryConfiguration(@NotNull PersistentQueryConfiguration 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 PersistentQueryDbServerConfig determineDispatcher(@NotNull PersistentQueryDbServerConfig serverConfig, int heapSizeMB, String workerKind)
    • determineDispatcher

      public PersistentQueryDbServerConfig determineDispatcher(@NotNull String serverConfigName, int heapSizeMB, String workerKind)
    • modifyQueryConfiguration

      public void modifyQueryConfiguration(@NotNull PersistentQueryConfiguration 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 PersistentQueryConfiguration config, boolean restartIfRunning)
      Modifies a configuration in the controller's hash table.
      Parameters:
      config - the updated configuration
      restartIfRunning - restart the query when it is running if set to true
    • removeQueryConfiguration

      public void removeQueryConfiguration(PersistentQueryConfiguration 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(PersistentQueryConfiguration config)
      Restart a persistent query. This implementation delegates to restartQueries(List) )}.
      Parameters:
      config - the persistent query configuration to be restarted.
    • restartQueries

      public void restartQueries(@NotNull List<PersistentQueryConfiguration> configs)
      Restarts one or more persistent queries.
      Parameters:
      configs - the persistent query configurations to be restarted
    • restartReplicas

      public void restartReplicas(@NotNull List<ReplicaSpecifier> replicas)
    • restartQueriesBySerial

      public void restartQueriesBySerial(@NotNull long[] serialIds)
      Restarts one or more persistent queries.
      Parameters:
      serialIds - an array of serial ids to restart
    • restartQueriesBySerial

      public void restartQueriesBySerial(@NotNull List<Long> serials)
      Restarts one or more persistent queries.
      Parameters:
      serials - a list of serial ids to restart
    • stopQuery

      public void stopQuery(PersistentQueryConfiguration config)
      Stops a persistent query.
      Parameters:
      config - the persistent query configuration to be stopped.
    • stopQueries

      public void stopQueries(@NotNull List<PersistentQueryConfiguration> configs)
      Stops one or more persistent queries.
      Parameters:
      configs - the persistent query configurations to be stopped
    • stopQueryBySerial

      public void stopQueryBySerial(@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

      public void stopQueryBySerial(@NotNull List<Long> serials)
    • reloadConfiguration

      public void reloadConfiguration()

      Reloads the controller configuration.

      This function causes the PersistentQueryController to reload parts of its configuration without requiring a controller restart. The controller will broadcast the updated configuration to all connected clients.

      Note that not all properties or configuration parameters may be reloaded.
    • selectionProviderStatus

      public String selectionProviderStatus()
      Gets the information for the desired selection provider.
    • selectionProviderAdmin

      public String selectionProviderAdmin(@NotNull String command)
      Executes an admin command on the given server.
    • getServerConfiguration

      public PersistentQueryControllerConfiguration getServerConfiguration()
      Gets the server configuration from the controller.
      Returns:
      the currently loaded controller configuration
    • getScriptDisplayPathsByOwner

      public Set<String> getScriptDisplayPathsByOwner(@NotNull String ownerName, @Nullable String scriptLoaderStateJson)
      Description copied from interface: RemoteScriptSource
      Get all display paths available to a specific owner and state.
      Specified by:
      getScriptDisplayPathsByOwner in interface RemoteScriptSource
      Parameters:
      ownerName - A specific user.
      scriptLoaderStateJson - The JSON encoded state produced by ScriptPathLoaderState.encodeJSON() to get paths from or null to get the latest version.
      Returns:
      The paths available to ownerName.
    • getScriptDisplayPaths

      public Set<String> getScriptDisplayPaths(@Nullable String scriptLoaderStateJson)
      Description copied from interface: RemoteScriptSource
      Get all available display paths for a specific state.
      Specified by:
      getScriptDisplayPaths in interface RemoteScriptSource
      Parameters:
      scriptLoaderStateJson - The JSON encoded state produced by ScriptPathLoaderState.encodeJSON() to get paths from or null to get the latest version.
      Returns:
      All display paths.
    • getScriptDisplayPaths

      @NotNull public Set<String> getScriptDisplayPaths(long configSerial, @Nullable String scriptLoaderState)
      Description copied from interface: PersistentQueryScriptSource
      Get all display paths available to a specific PersistentQuery serial ID and a specific state.
      Specified by:
      getScriptDisplayPaths in interface PersistentQueryScriptSource
      Parameters:
      configSerial - the query serial
      scriptLoaderState - an optional loader state
      Returns:
      The paths available to the serial ID.
    • getScriptRelativePaths

      public Set<String> getScriptRelativePaths(@Nullable String scriptLoaderStateJson)
      Description copied from interface: RemoteScriptSource
      Get all available relative paths for a specific state.
      Specified by:
      getScriptRelativePaths in interface RemoteScriptSource
      Parameters:
      scriptLoaderStateJson - The JSON encoded state produced by ScriptPathLoaderState.encodeJSON() to get paths from or null to get the latest version.
      Returns:
      All relative paths.
    • getScriptRelativePathsByOwner

      public Set<String> getScriptRelativePathsByOwner(@NotNull String ownerName, @Nullable String scriptLoaderStateJson)
      Description copied from interface: RemoteScriptSource
      Get all relative paths available to a specific owner and state.
      Specified by:
      getScriptRelativePathsByOwner in interface RemoteScriptSource
      Parameters:
      ownerName - A specific user.
      scriptLoaderStateJson - The JSON encoded state produced by ScriptPathLoaderState.encodeJSON() to get paths from or null to get the latest version.
      Returns:
      The paths available to ownerName.
    • getScriptBody

      public String getScriptBody(boolean relative, @NotNull String scriptPath, @Nullable String scriptLoaderStateJson)
      Description copied from interface: RemoteScriptSource
      Get a script by path and state.
      Specified by:
      getScriptBody in interface RemoteScriptSource
      Parameters:
      relative - Is the path a relative path?
      scriptPath - The path string.
      scriptLoaderStateJson - The JSON encoded state produced by ScriptPathLoaderState.encodeJSON() to get the script from or null to get the latest version.
      Returns:
      The contents of the script.
    • getScriptBody

      @Nullable public String getScriptBody(boolean relative, long configSerial, @NotNull String scriptPath, @Nullable String scriptLoaderStateJson)
      Description copied from interface: PersistentQueryScriptSource
      Get a script by path for a specific serial ID and a specific state.
      Specified by:
      getScriptBody in interface PersistentQueryScriptSource
      Parameters:
      relative - Is the path a relative path?
      configSerial - The Serial ID.
      scriptPath - The path string.
      scriptLoaderStateJson - A specific state to retrieve scripts from or ScriptPathLoaderState.NONE to get the latest version.
      Returns:
      The contents of the script.
    • getScriptBodyByOwner

      public String getScriptBodyByOwner(boolean relative, @NotNull String scriptPath, @NotNull String ownerName, @Nullable String scriptLoaderStateJson)
      Description copied from interface: RemoteScriptSource
      Get a script by path for a specific owner and state.
      Specified by:
      getScriptBodyByOwner in interface RemoteScriptSource
      Parameters:
      relative - Is the path a relative path?
      scriptPath - The path string.
      ownerName - The owner.
      scriptLoaderStateJson - The JSON encoded state produced by ScriptPathLoaderState.encodeJSON() to get script from or null to get the latest version.
      Returns:
      The contents of the script.
    • getGroupsForUser

      public String[] getGroupsForUser(UserContext userContext)
      Return the groups which a user belongs to.
      Parameters:
      userContext - the userContext to get membership for
      Returns:
      an array of group names that the effective user belongs to
    • getUsersForGroup

      public String[] getUsersForGroup(String group)
      Return the users which belong to a group.
      Parameters:
      group - the group to get membership for
      Returns:
      an array of user names that belong to the group
    • isSuperUser

      public boolean isSuperUser(@NotNull UserContext userContext)
      Returns true if the effective user is a superuser.
      Parameters:
      userContext - the usercontext to query
      Returns:
      true if the user is a member of the iris-superusers group.
    • isAclEditor

      public boolean isAclEditor(@NotNull UserContext userContext)
      Returns true if the effective user is an ACL editor
      Parameters:
      userContext - the usercontext to query
      Returns:
      true if the user is a member of the iris-acleditors group.
    • isSchemaManager

      public boolean isSchemaManager(@NotNull UserContext userContext)
      Returns true if the effective user is a Schema manager
      Parameters:
      userContext - the usercontext to query
      Returns:
      true if the user is a member of the iris-schemamanagers group.
    • isQueryManager

      public boolean isQueryManager(@NotNull UserContext userContext)
      Returns true if the effective user is an Query Manager
      Parameters:
      userContext - the usercontext to query
      Returns:
      true if the user is a member of the iris-querymanagers group.
    • getAllGroups

      public String[] getAllGroups()
      Returns the list of all groups.
      Returns:
      an array of all group names
    • getAllUsers

      public String[] getAllUsers()
      Returns the list of all users.
      Returns:
      an array of all user names
    • getPersistentQueryConfiguration

      public PersistentQueryConfiguration getPersistentQueryConfiguration(long configSerial)
    • getPersistentQueryConfiguration

      public PersistentQueryConfiguration getPersistentQueryConfiguration(@NotNull String owner, @NotNull String name)
    • getPersistentQueryConfiguration

      public PersistentQueryConfiguration getPersistentQueryConfiguration(long configSerial, @Nullable String owner, @Nullable String name)
    • publishTemporaryQueries

      public void publishTemporaryQueries(@NotNull com.fishlib.io.logger.Logger log, @NotNull PersistentQueryConfiguration... configs)
    • updateQueryStatus

      public void updateQueryStatus(@NotNull PersistentQueryState.StatusUpdate update) throws IOException
      Throws:
      IOException
    • getControllerClient

      @NotNull public static PersistentQueryControllerClient getControllerClient(@NotNull com.fishlib.io.logger.Logger log)
    • getControllerClient

      @NotNull public static PersistentQueryControllerClient getControllerClient(@NotNull com.fishlib.io.logger.Logger log, boolean doSubscription)
    • getControllerClient

      @NotNull public static PersistentQueryControllerClient getControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log)
    • getControllerClient

      @NotNull public static PersistentQueryControllerClient getControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, boolean doSubscription)
    • getControllerClient

      @NotNull public static PersistentQueryControllerClient getControllerClient(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, boolean doSubscription, @NotNull TokenFactoryFactory tokenFactoryFactory)
    • getManagedChannel

      public static io.grpc.ManagedChannel getManagedChannel(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log)
    • getManagedChannel

      public static io.grpc.ManagedChannel getManagedChannel(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log, @NotNull String resolver)
    • getManagedChannelForEnvoy

      public static io.grpc.ManagedChannel getManagedChannelForEnvoy(@NotNull String who, @NotNull com.fishlib.io.logger.Logger log)
    • addServiceStatusListener

      public void addServiceStatusListener(@NotNull ServiceStatusListener listener)
      Add a status listener. If the service is already available, the listener will be invoked immediately on the thread pool.
      Parameters:
      listener - the listener to add
    • removeServiceStatusListener

      public void removeServiceStatusListener(@NotNull ServiceStatusListener listener)
    • addReloadConfigurationListener

      public void addReloadConfigurationListener(Consumer<PersistentQueryControllerConfiguration> reloadListener)
    • removeReloadConfigurationListener

      public void removeReloadConfigurationListener(@NotNull Consumer<PersistentQueryControllerConfiguration> reloadListener)
    • isConnected

      public boolean isConnected()
      Check if this client can communicate with the server.
      Returns:
      true if it can
    • authenticate

      public boolean authenticate(@NotNull 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.
    • subscribeToAll

      public int subscribeToAll()
      Subscribe to the complete hash table.
    • subscribeWithFilter

      public void subscribeWithFilter(@NotNull List<SubscriptionFilter> filters)
      Subscribe to a subset of the hash table narrowed by the supplied filter list. See the proto comment on SubscribeRequest.filters for the semantics: filters are OR-combined and the server may decide to ignore the filter (older controllers will), so callers must still apply the same filter logic locally to guarantee correctness. An empty list is equivalent to subscribeToAll().
      Parameters:
      filters - the filter list narrowing the subscription.
    • shutdown

      public void shutdown() throws IOException
      Throws:
      IOException
    • 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.