Package com.illumon.iris.controller
Class PersistentQueryControllerClient
java.lang.Object
com.illumon.iris.controller.ControllerHashtable
com.illumon.iris.controller.ControllerHashtableClient
com.illumon.iris.controller.PersistentQueryControllerClient
- All Implemented Interfaces:
com.fishlib.net.api.CommandHandler
,com.fishlib.net.api.ConnectionStatusHandlerEx
,com.fishlib.net.CommBase.ConnectionStatusHandler
,ControllerHashtableEventSource
,PersistentQueryScriptSource
,RemoteScriptSource
,Map<Long,PersistentQueryInfo>
public class PersistentQueryControllerClient extends ControllerHashtableClient implements PersistentQueryScriptSource
Client for subscribing to state from the PersistentQueryController and manipulating persistent queries.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PersistentQueryControllerClient.AuthenticateToControllerTimeoutException
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PersistentQueryControllerClient(com.fishlib.io.logger.Logger log, com.fishlib.io.sched.Scheduler scheduler, com.fishlib.net.CommBase.ConnectionStatusHandler connectionStatusHandler, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, boolean async)
PersistentQueryControllerClient(com.fishlib.io.logger.Logger log, com.fishlib.io.sched.Scheduler scheduler, com.fishlib.net.CommBase.ConnectionStatusHandler connectionStatusHandler, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, boolean async, com.fishlib.base.hash.IndexableMap<Long,PersistentQueryInfo> map)
PersistentQueryControllerClient(com.fishlib.io.logger.Logger log, com.fishlib.io.sched.Scheduler scheduler, com.fishlib.net.CommBase.ConnectionStatusHandler connectionStatusHandler, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, boolean async, com.fishlib.base.hash.IndexableMap<Long,PersistentQueryInfo> map, com.fishlib.net.api.DynamicCommClientPolicy commClientPolicy)
PersistentQueryControllerClient(com.fishlib.io.logger.Logger log, com.fishlib.io.sched.Scheduler scheduler, com.fishlib.net.CommBase.ConnectionStatusHandler connectionStatusHandler, com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, boolean async, com.fishlib.net.api.DynamicCommClientPolicy commClientPolicy)
-
Method Summary
Modifier and Type Method Description long
addQueryConfiguration(PersistentQueryConfiguration config)
Adds a configuration to the controller's hash table.boolean
authenticateToController(com.fishlib.auth.AuthToken authToken)
Present an authentication token to the controller.boolean
authenticateToController(com.fishlib.auth.AuthToken authToken, long timeoutPeriodMillis)
Authenticate to the controller, waiting for the connection to be established and retrying if the connection is dropped before the authentication RPC returns a result.PersistentQueryDbServerConfig
determineDispatcher(PersistentQueryDbServerConfig serverConfig, int heapSizeMB)
PersistentQueryDbServerConfig
determineDispatcher(String serverConfigName, int heapSizeMB)
static void
disallowReconnections()
String[]
getAllGroups()
Returns the list of all groups.String[]
getAllUsers()
Returns the list of all users.static PersistentQueryControllerClient
getControllerClient(com.fishlib.io.logger.Logger log)
String[]
getGroupsForUser(com.fishlib.auth.UserContext userContext)
Return the groups which a user belongs to.long
getInstanceNonce()
Gets the server instance nonce from the controller.PersistentQueryConfiguration
getPersistentQueryConfiguration(com.fishlib.io.logger.Logger log, long configSerial)
PersistentQueryConfiguration
getPersistentQueryConfiguration(com.fishlib.io.logger.Logger log, com.illumon.iris.controller.PersistentQueryControllerClient.Descriptor descriptor)
PersistentQueryConfiguration
getPersistentQueryConfiguration(com.fishlib.io.logger.Logger log, String owner, String name)
String
getScriptBody(boolean relative, String scriptPath, long configSerial, ScriptPathLoaderState scriptLoaderState)
Get a script by path for a specific serial ID and a specific state.String
getScriptBody(boolean relative, String scriptPath, ScriptPathLoaderState scriptLoaderState)
Get a script by path and state.String
getScriptBody(boolean relative, String scriptPath, String ownerName, ScriptPathLoaderState scriptLoaderState)
Get a script by path for a specific owner and state.Set<String>
getScriptDisplayPaths(long configSerial, ScriptPathLoaderState scriptLoaderState)
Get all display paths available to a specific PersistentQuery serial ID and a specific state..Set<String>
getScriptDisplayPaths(ScriptPathLoaderState scriptLoaderState)
Get all available display paths for a specific state.Set<String>
getScriptDisplayPaths(String ownerName, ScriptPathLoaderState scriptLoaderState)
Get all display paths available to a specific owner and state.PersistentQueryControllerConfiguration
getServerConfiguration()
Gets the server configuration from the controller.String[]
getUsersForGroup(String group)
Return the users which belong to a group.void
handleConnectionReestablished()
boolean
isAclEditor(com.fishlib.auth.UserContext userContext)
Returns true if the effective user is an ACL editorboolean
isSuperUser(com.fishlib.auth.UserContext userContext)
Returns true if the effective user is a superuser.void
modifyQueryConfiguration(PersistentQueryConfiguration config)
Modifies a configuration in the controller's hash table, and restart the query if it was running.void
modifyQueryConfiguration(PersistentQueryConfiguration config, boolean restartIfRunning)
Modifies a configuration in the controller's hash table.void
publishTemporaryQueries(com.fishlib.io.logger.Logger log, PersistentQueryConfiguration... configs)
void
reloadConfiguration()
Reloads the controller configuration.void
removeQueryConfiguration(PersistentQueryConfiguration 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(List<PersistentQueryConfiguration> configs)
Restarts one or more persistent queries.void
restartQueriesBySerial(long[] serialIds)
Restarts one or more persistent queries.void
restartQuery(PersistentQueryConfiguration config)
Restart a persistent query.void
stopQueries(List<PersistentQueryConfiguration> configs)
Stops one or more persistent queries.void
stopQuery(PersistentQueryConfiguration config)
Stops a persistent query.void
stopQueryBySerial(long[] serials)
Stops one or more persistent query by serial id.Methods inherited from class com.illumon.iris.controller.ControllerHashtableClient
addEventHandlerAndGetData, addReloadCommandListener, clear, containsKey, containsValue, disconnect, entrySet, get, getComm, getData, getUnderlyingMap, handleClientDeath, handleCommand, handleConnectionLost, handleInitialConnection, isEmpty, keySet, put, putAll, remove, size, subscribeToAll, values, waitUntilConnectedOrTimeout
Methods inherited from class com.illumon.iris.controller.ControllerHashtable
addCommandHandler, addEventHandler, removeCommandHandler, removeEventHandler
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
Methods inherited from interface com.illumon.iris.controller.PersistentQueryScriptSource
getScriptBody, getScriptDisplayPaths
Methods inherited from interface com.illumon.iris.controller.RemoteScriptSource
getScriptBody, getScriptBody, getScriptDisplayPaths, getScriptDisplayPaths
-
Constructor Details
-
PersistentQueryControllerClient
public PersistentQueryControllerClient(com.fishlib.io.logger.Logger log, com.fishlib.io.sched.Scheduler scheduler, @Nullable com.fishlib.net.CommBase.ConnectionStatusHandler connectionStatusHandler, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, boolean async) throws IOException- Throws:
IOException
-
PersistentQueryControllerClient
public PersistentQueryControllerClient(com.fishlib.io.logger.Logger log, com.fishlib.io.sched.Scheduler scheduler, @Nullable com.fishlib.net.CommBase.ConnectionStatusHandler connectionStatusHandler, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, boolean async, @Nullable com.fishlib.net.api.DynamicCommClientPolicy commClientPolicy) throws IOException- Throws:
IOException
-
PersistentQueryControllerClient
public PersistentQueryControllerClient(com.fishlib.io.logger.Logger log, com.fishlib.io.sched.Scheduler scheduler, @Nullable com.fishlib.net.CommBase.ConnectionStatusHandler connectionStatusHandler, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, boolean async, com.fishlib.base.hash.IndexableMap<Long,PersistentQueryInfo> map) throws IOException- Throws:
IOException
-
PersistentQueryControllerClient
public PersistentQueryControllerClient(com.fishlib.io.logger.Logger log, com.fishlib.io.sched.Scheduler scheduler, @Nullable com.fishlib.net.CommBase.ConnectionStatusHandler connectionStatusHandler, @Nullable com.fishlib.net.ConnectionMonitor.Params connectionMonitorParams, boolean async, com.fishlib.base.hash.IndexableMap<Long,PersistentQueryInfo> map, @Nullable com.fishlib.net.api.DynamicCommClientPolicy commClientPolicy) throws IOException- Throws:
IOException
-
-
Method Details
-
disallowReconnections
public static void disallowReconnections() -
addQueryConfiguration
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(PersistentQueryDbServerConfig serverConfig, int heapSizeMB) -
determineDispatcher
-
modifyQueryConfiguration
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(PersistentQueryConfiguration 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
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
-
restartQueries
Restarts one or more persistent queries.- Parameters:
configs
- the persistent query configurations to be restarted
-
restartQueriesBySerial
public void restartQueriesBySerial(@NotNull long[] serialIds)Restarts one or more persistent queries.- Parameters:
serialIds
- an array of serial ids to restart
-
restartQuery
Restart a persistent query. This implementation delegates torestartQueries(List)
)}.- Parameters:
config
- the persistent query configuration to be restarted.
-
stopQuery
Stops a persistent query.- Parameters:
config
- the persistent query configuration to be stopped.
-
stopQueries
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
-
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. -
getServerConfiguration
Gets the server configuration from the controller.- Returns:
- the currently loaded controller configuration
-
getInstanceNonce
public long getInstanceNonce()Gets the server instance nonce from the controller.- Returns:
- the currently controller instance nonce
-
getScriptDisplayPaths
public Set<String> getScriptDisplayPaths(String ownerName, ScriptPathLoaderState scriptLoaderState)Description copied from interface:RemoteScriptSource
Get all display paths available to a specific owner and state.- Specified by:
getScriptDisplayPaths
in interfaceRemoteScriptSource
- Parameters:
ownerName
- A specific user.scriptLoaderState
- The state to get paths from orScriptPathLoaderState.NONE
to get the latest version.- Returns:
- The paths available to ownerName.
-
getScriptDisplayPaths
Description copied from interface:RemoteScriptSource
Get all available display paths for a specific state.- Specified by:
getScriptDisplayPaths
in interfaceRemoteScriptSource
- Parameters:
scriptLoaderState
- The state to get paths from orScriptPathLoaderState.NONE
to get the latest version.- Returns:
- All display paths.
-
getScriptDisplayPaths
public Set<String> getScriptDisplayPaths(long configSerial, ScriptPathLoaderState 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 interfacePersistentQueryScriptSource
- Parameters:
configSerial
- Aserial ID
.scriptLoaderState
- A specific state to retrieve scripts from orScriptPathLoaderState.NONE
to get the latest version.- Returns:
- The paths available to the serial ID.
-
getScriptBody
public String getScriptBody(boolean relative, String scriptPath, ScriptPathLoaderState scriptLoaderState)Description copied from interface:RemoteScriptSource
Get a script by path and state.- Specified by:
getScriptBody
in interfaceRemoteScriptSource
- Parameters:
relative
- Is the path a relative path?scriptPath
- The path string.scriptLoaderState
- The state to get scripts from orScriptPathLoaderState.NONE
to get the latest version.- Returns:
- The contents of the script.
-
getScriptBody
public String getScriptBody(boolean relative, String scriptPath, long configSerial, ScriptPathLoaderState scriptLoaderState)Description copied from interface:PersistentQueryScriptSource
Get a script by path for a specific serial ID and a specific state.- Specified by:
getScriptBody
in interfacePersistentQueryScriptSource
- Parameters:
relative
- Is the path a relative path?scriptPath
- The path string.configSerial
- The Serial ID.scriptLoaderState
- A specific state to retrieve scripts from orScriptPathLoaderState.NONE
to get the latest version.- Returns:
- The contents of the script.
-
getScriptBody
public String getScriptBody(boolean relative, String scriptPath, String ownerName, ScriptPathLoaderState scriptLoaderState)Description copied from interface:RemoteScriptSource
Get a script by path for a specific owner and state.- Specified by:
getScriptBody
in interfaceRemoteScriptSource
- Parameters:
relative
- Is the path a relative path?scriptPath
- The path string.ownerName
- The owner.scriptLoaderState
- The state to get script from orScriptPathLoaderState.NONE
to get the latest version.- Returns:
- The contents of the script.
-
authenticateToController
public boolean authenticateToController(com.fishlib.auth.AuthToken authToken)Present an authentication token to the controller.- Parameters:
authToken
- the token to present to the controller- Returns:
- true if authentication succeeded
-
authenticateToController
public boolean authenticateToController(com.fishlib.auth.AuthToken authToken, long timeoutPeriodMillis)Authenticate to the controller, waiting for the connection to be established and retrying if the connection is dropped before the authentication RPC returns a result.- Parameters:
authToken
- the token to present to the controllertimeoutPeriodMillis
- if the client is disconnected, we will wait for reconnection and retry for at most this long. Note it doesn't make sense to wait for longer than the validity of the provided token.- Returns:
- true if authentication succeeded
- Throws:
PersistentQueryControllerClient.AuthenticateToControllerTimeoutException
- if the timeout period is exceeded while retrying.UncheckedIOException
- if the RPC results in an error that is not due to not-connected state.
-
getGroupsForUser
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
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(com.fishlib.auth.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(com.fishlib.auth.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.
-
getAllGroups
Returns the list of all groups.- Returns:
- an array of all group names
-
getAllUsers
Returns the list of all users.- Returns:
- an array of all user names
-
handleConnectionReestablished
public void handleConnectionReestablished()- Specified by:
handleConnectionReestablished
in interfacecom.fishlib.net.CommBase.ConnectionStatusHandler
- Overrides:
handleConnectionReestablished
in classControllerHashtableClient
-
getPersistentQueryConfiguration
public PersistentQueryConfiguration getPersistentQueryConfiguration(com.fishlib.io.logger.Logger log, long configSerial) -
getPersistentQueryConfiguration
public PersistentQueryConfiguration getPersistentQueryConfiguration(com.fishlib.io.logger.Logger log, String owner, String name) -
getPersistentQueryConfiguration
public PersistentQueryConfiguration getPersistentQueryConfiguration(com.fishlib.io.logger.Logger log, com.illumon.iris.controller.PersistentQueryControllerClient.Descriptor descriptor) -
getControllerClient
@NotNull public static PersistentQueryControllerClient getControllerClient(com.fishlib.io.logger.Logger log) -
publishTemporaryQueries
public void publishTemporaryQueries(com.fishlib.io.logger.Logger log, PersistentQueryConfiguration... configs)
-