Package com.illumon.iris.controller
Interface IServerSelectionProvider
- All Known Implementing Classes:
SimpleServerSelectionProvider
public interface IServerSelectionProvider
Interface for persistent query and console server selection implementations. These provide customer-implemented
server-selection algorithms.
Implementations must have a constructor that takes:
- log - a
Logger
that can be used for logging - serverGroupProvider - a
IrisGroupProvider
that can be used to determine allowed servers
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Exception to be thrown when resources can't be determined.static class
Information about a server group. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addWorkerForSerial
(PersistentQueryDbServerConfig serverConfig, long serial, String workerProcessInfoId) Add a worker for the given persistent query serial number.adminCommand
(UserContext userContext, String command) Issue an administrative command to the selection provider.determineServer
(String serverGroupName, UserContext UserContext, int heapSizeMB, String workerKind, String description, PersistentQueryConfiguration configuration) Determine the server (dispatcher) on which to request the worker.void
generateReloadableConfigurationElement
(org.jdom2.Element baseElement, com.fishlib.configuration.Configuration config) Generate anElement
with this server selection provider's configuration.generateStateInformation
(UserContext userContext) Return information about the selection provider, which can be used for debugging or monitoring.List the available server groups.void
Install the verified configuration.void
removeWorkerForSerial
(PersistentQueryDbServerConfig serverConfig, long serial, String workerProcessInfoId) Remove a worker for the given persistent query serial number.void
setServerUsage
(PersistentQueryDbServerConfig serverConfig, int usageMB, int availableMB, int workerCount) Set the current server usage.void
updateServerAvailability
(PersistentQueryDbServerConfig serverConfig, boolean available) Update whether a server is available or not.void
updateServerInfo
(PersistentQueryDbServerConfig serverConfig, String json) Update the server info JSON for a server based on the dispatcher's actual configuration.void
updateServerMaxHeapGB
(PersistentQueryDbServerConfig serverConfig, double maxHeapSizeGB) Update the max per-worker heap size in GB for a server based on the dispatcher's actual configuration.void
updateServerTotalHeapMB
(PersistentQueryDbServerConfig serverConfig, int totalHeapMB) Update the total heap available for a server.void
updateWorkerStatus
(PersistentQueryDbServerConfig serverConfig, long serial, String workerProcessInfoId, PersistentQueryState.Status status) Set the status of a worker for the given persistent query serial number.void
verifyConfiguration
(org.jdom2.Element element, List<PersistentQueryDbServerConfig> serverConfigs) Given theElement
generated bygenerateReloadableConfigurationElement(org.jdom2.Element, com.fishlib.configuration.Configuration)
, validate and prepare the configuration for use.
-
Method Details
-
getServerGroups
List the available server groups. Each server group will be added to ths list of servers available for query server selection.- Returns:
- the set of available server groups
-
determineServer
@NotNull PersistentQueryDbServerConfig determineServer(@NotNull String serverGroupName, @NotNull UserContext UserContext, int heapSizeMB, @NotNull String workerKind, String description, @Nullable PersistentQueryConfiguration configuration) throws IServerSelectionProvider.ResourcesUnavailableException Determine the server (dispatcher) on which to request the worker.- Parameters:
serverGroupName
- the user-chosen host or server groupUserContext
- the user context when available (internally-generated starts may not have a user context)heapSizeMB
- the requested heap size in MBworkerKind
- the kind of worker that will be createddescription
- a text description of the requested workerconfiguration
- the configuration for a persistent query, or null for consoles or other non-PQ workers- Returns:
- a PersistentQueryDbServerConfig that represents the server (dispatcher) on which to request the worker
- Throws:
IServerSelectionProvider.ResourcesUnavailableException
- if a server can't be determined
-
updateServerTotalHeapMB
Update the total heap available for a server. This will be determined by the controller after getting a connection to each dispatcher.- Parameters:
serverConfig
- the server configurationtotalHeapMB
- the total available heap for the dispatcher
-
setServerUsage
void setServerUsage(@NotNull PersistentQueryDbServerConfig serverConfig, int usageMB, int availableMB, int workerCount) Set the current server usage. This may be on an initial dispatcher connection or after a reconnection, or whenever the utilization changes.- Parameters:
serverConfig
- the server configurationusageMB
- the usage in MBavailableMB
- the server's availability as reported by the dispatcherworkerCount
- the current number of workers running on that server
-
addWorkerForSerial
void addWorkerForSerial(@NotNull PersistentQueryDbServerConfig serverConfig, long serial, String workerProcessInfoId) Add a worker for the given persistent query serial number.The server selection provider may use the worker count per PQ to more evenly distribute replicas across the cluster so that the failure of one query node is less likely to make all replicas of a query unavailable.
- Parameters:
serverConfig
- the server configurationserial
- the serial number of the persistent query that is starting a new workerworkerProcessInfoId
- the process info ID of the worker
-
removeWorkerForSerial
void removeWorkerForSerial(@NotNull PersistentQueryDbServerConfig serverConfig, long serial, String workerProcessInfoId) Remove a worker for the given persistent query serial number.The server selection provider may use the worker count per PQ to more evenly distribute replicas across the cluster so that the failure of one query node is less likely to make all replicas of a query unavailable.
- Parameters:
serverConfig
- the server configurationserial
- the serial number of the persistent query that has removed a workerworkerProcessInfoId
- the process info ID of the worker
-
updateWorkerStatus
void updateWorkerStatus(PersistentQueryDbServerConfig serverConfig, long serial, @NotNull String workerProcessInfoId, @NotNull PersistentQueryState.Status status) Set the status of a worker for the given persistent query serial number.The server selection provider may use this information to `guess` about server health.
- Parameters:
serverConfig
- the server configurationserial
- the serial number of the persistent query that has removed a workerworkerProcessInfoId
- the process info ID of the workerstatus
- the most recent status transition for the worker
-
updateServerAvailability
void updateServerAvailability(@NotNull PersistentQueryDbServerConfig serverConfig, boolean available) Update whether a server is available or not.- Parameters:
serverConfig
- the server configurationavailable
- if true, the server is available; if false, it is not
-
updateServerMaxHeapGB
Update the max per-worker heap size in GB for a server based on the dispatcher's actual configuration.- Parameters:
serverConfig
- the server configurationmaxHeapSizeGB
- the new maximum size
-
updateServerInfo
Update the server info JSON for a server based on the dispatcher's actual configuration.- Parameters:
serverConfig
- the server configurationjson
- the server's JSON server info configuration
-
generateReloadableConfigurationElement
void generateReloadableConfigurationElement(org.jdom2.Element baseElement, com.fishlib.configuration.Configuration config) Generate anElement
with this server selection provider's configuration. This element will be used to load the configuration indirectly. This element may be generated in a different process than the controller.- Parameters:
baseElement
- theElement
config
- theConfiguration
to be used to generate theElement
-
verifyConfiguration
void verifyConfiguration(@NotNull org.jdom2.Element element, List<PersistentQueryDbServerConfig> serverConfigs) throws ConfigurationVerificationException Given theElement
generated bygenerateReloadableConfigurationElement(org.jdom2.Element, com.fishlib.configuration.Configuration)
, validate and prepare the configuration for use.- Parameters:
element
- the generatedElement
containing the configurationserverConfigs
- the available dispatchers as determined by the controller- Throws:
ConfigurationVerificationException
- if the provided element can't be used for any reason
-
installConfiguration
void installConfiguration()Install the verified configuration. This will be called afterverifyConfiguration(org.jdom2.Element, java.util.List<com.illumon.iris.controller.PersistentQueryDbServerConfig>)
is successfully called and indicates that the verified configuration should now be used. -
generateStateInformation
Return information about the selection provider, which can be used for debugging or monitoring.The state format is defined by the selection provider, but the suggested format is JSON for simple parsing with jq or other tools.
- Parameters:
userContext
- the user requesting the state- Returns:
- a string representation of the internal state of this selection provider.
-
adminCommand
Issue an administrative command to the selection provider.- Parameters:
userContext
- the user requesting the commandcommand
- the administrative command- Returns:
- a string representation of the result
-