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 classPersistentQueryControllerClient.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 longaddQueryConfiguration(PersistentQueryConfiguration config)Adds a configuration to the controller's hash table.booleanauthenticateToController(com.fishlib.auth.AuthToken authToken)Present an authentication token to the controller.booleanauthenticateToController(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.PersistentQueryDbServerConfigdetermineDispatcher(PersistentQueryDbServerConfig serverConfig, int heapSizeMB)PersistentQueryDbServerConfigdetermineDispatcher(String serverConfigName, int heapSizeMB)static voiddisallowReconnections()String[]getAllGroups()Returns the list of all groups.String[]getAllUsers()Returns the list of all users.static PersistentQueryControllerClientgetControllerClient(com.fishlib.io.logger.Logger log)String[]getGroupsForUser(com.fishlib.auth.UserContext userContext)Return the groups which a user belongs to.longgetInstanceNonce()Gets the server instance nonce from the controller.PersistentQueryConfigurationgetPersistentQueryConfiguration(com.fishlib.io.logger.Logger log, long configSerial)PersistentQueryConfigurationgetPersistentQueryConfiguration(com.fishlib.io.logger.Logger log, com.illumon.iris.controller.PersistentQueryControllerClient.Descriptor descriptor)PersistentQueryConfigurationgetPersistentQueryConfiguration(com.fishlib.io.logger.Logger log, String owner, String name)StringgetScriptBody(boolean relative, String scriptPath, long configSerial, ScriptPathLoaderState scriptLoaderState)Get a script by path for a specific serial ID and a specific state.StringgetScriptBody(boolean relative, String scriptPath, ScriptPathLoaderState scriptLoaderState)Get a script by path and state.StringgetScriptBody(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.PersistentQueryControllerConfigurationgetServerConfiguration()Gets the server configuration from the controller.String[]getUsersForGroup(String group)Return the users which belong to a group.voidhandleConnectionReestablished()booleanisAclEditor(com.fishlib.auth.UserContext userContext)Returns true if the effective user is an ACL editorbooleanisSuperUser(com.fishlib.auth.UserContext userContext)Returns true if the effective user is a superuser.voidmodifyQueryConfiguration(PersistentQueryConfiguration config)Modifies a configuration in the controller's hash table, and restart the query if it was running.voidmodifyQueryConfiguration(PersistentQueryConfiguration config, boolean restartIfRunning)Modifies a configuration in the controller's hash table.voidpublishTemporaryQueries(com.fishlib.io.logger.Logger log, PersistentQueryConfiguration... configs)voidreloadConfiguration()Reloads the controller configuration.voidremoveQueryConfiguration(PersistentQueryConfiguration config)Removes a configuration from the controller's hash table.voidremoveQueryConfigurationBySerial(long serialId)Removes a configuration from the controller's hash table by serial ID.voidrestartQueries(List<PersistentQueryConfiguration> configs)Restarts one or more persistent queries.voidrestartQueriesBySerial(long[] serialIds)Restarts one or more persistent queries.voidrestartQuery(PersistentQueryConfiguration config)Restart a persistent query.voidstopQueries(List<PersistentQueryConfiguration> configs)Stops one or more persistent queries.voidstopQuery(PersistentQueryConfiguration config)Stops a persistent query.voidstopQueryBySerial(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, waitUntilConnectedOrTimeoutMethods inherited from class com.illumon.iris.controller.ControllerHashtable
addCommandHandler, addEventHandler, removeCommandHandler, removeEventHandlerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllMethods inherited from interface com.illumon.iris.controller.PersistentQueryScriptSource
getScriptBody, getScriptDisplayPathsMethods 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:RemoteScriptSourceGet all display paths available to a specific owner and state.- Specified by:
getScriptDisplayPathsin interfaceRemoteScriptSource- Parameters:
ownerName- A specific user.scriptLoaderState- The state to get paths from orScriptPathLoaderState.NONEto get the latest version.- Returns:
- The paths available to ownerName.
-
getScriptDisplayPaths
Description copied from interface:RemoteScriptSourceGet all available display paths for a specific state.- Specified by:
getScriptDisplayPathsin interfaceRemoteScriptSource- Parameters:
scriptLoaderState- The state to get paths from orScriptPathLoaderState.NONEto get the latest version.- Returns:
- All display paths.
-
getScriptDisplayPaths
public Set<String> getScriptDisplayPaths(long configSerial, ScriptPathLoaderState scriptLoaderState)Description copied from interface:PersistentQueryScriptSourceGet all display paths available to a specific PersistentQuery serial ID and a specific state..- Specified by:
getScriptDisplayPathsin interfacePersistentQueryScriptSource- Parameters:
configSerial- Aserial ID.scriptLoaderState- A specific state to retrieve scripts from orScriptPathLoaderState.NONEto 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:RemoteScriptSourceGet a script by path and state.- Specified by:
getScriptBodyin interfaceRemoteScriptSource- Parameters:
relative- Is the path a relative path?scriptPath- The path string.scriptLoaderState- The state to get scripts from orScriptPathLoaderState.NONEto 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:PersistentQueryScriptSourceGet a script by path for a specific serial ID and a specific state.- Specified by:
getScriptBodyin 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.NONEto 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:RemoteScriptSourceGet a script by path for a specific owner and state.- Specified by:
getScriptBodyin interfaceRemoteScriptSource- Parameters:
relative- Is the path a relative path?scriptPath- The path string.ownerName- The owner.scriptLoaderState- The state to get script from orScriptPathLoaderState.NONEto 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:
handleConnectionReestablishedin interfacecom.fishlib.net.CommBase.ConnectionStatusHandler- Overrides:
handleConnectionReestablishedin 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)
-