Package com.illumon.iris.controller
Class SimpleServerSelectionProvider
java.lang.Object
com.illumon.iris.controller.SimpleServerSelectionProvider
- All Implemented Interfaces:
IServerSelectionProvider
public class SimpleServerSelectionProvider extends Object implements IServerSelectionProvider
Simple implementation of
IServerSelectionProvider
. This performs round-robin based on server availability and
current usage, selecting from available server with the requested available heap, based on lowest heap utilization percentage
and worker count. In its current form it is probably not suitable for production use because more intelligence is needed for
small and large heap requests.
It is driven by the following properties. All properties are required for all groups, unless indicated as optional.
PROP_ACTIVE_GROUPS
specifies the names of the active groups. This drives the rest of the properties - these group names are used to derive the other property names.- All other properties start with
PROP_PREFIX
followed by the group name, and the property being specified. PROP_SERVER_CLASS_SUFFIX
specifies the server class for this group. Only servers of this class will be chosen when a server is requested. Typical values are Query and Merge. If this isn't supplied, then the value specified by the propertyPersistentQueryDbServerConfig.DEFAULT_SERVER_CLASS_PROP
will be used.PROP_SERVERS_SUFFIX
is optional and specifies the servers in this group. If it's not specified, all servers of the specified class will be in this group.PROP_MAX_HEAP_PER_WORKER_SUFFIX
specifies the maximum heap in MB allowed per worker for this group. If it's not specified or is 0, then the value fromPROP_DEFAULT_TOTAL_HEAP_SUFFIX
will be used.PROP_DEFAULT_TOTAL_HEAP_SUFFIX
specifies the default total heap for each server for this group. This will be updated by the controller after it gets a connection to each dispatcher.
SimpleServerSelectionProvider.ActiveGroups=AutoQuery,AutoMerge
SimpleServerSelectionProvider.Group.AutoQuery.ServerClass=Query
# No servers specified by an AutoQuery.Servers property, so all query servers will be in this group
SimpleServerSelectionProvider.Group.AutoQuery.MaxHeapMBPerWorker=32768
SimpleServerSelectionProvider.Group.AutoQuery.DefaultHeapMBPerServer=65536
SimpleServerSelectionProvider.Group.AutoMerge.ServerClass=Merge
SimpleServerSelectionProvider.Group.AutoMerge.Servers=Merge_Server_1,Merge_Server_2
SimpleServerSelectionProvider.Group.AutoMerge.MaxHeapMBPerWorker=32768
SimpleServerSelectionProvider.Group.AutoMerge.DefaultHeapMBPerServer=65536
This implementation is fully reloadable.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.controller.IServerSelectionProvider
IServerSelectionProvider.ResourcesUnavailableException, IServerSelectionProvider.ServerGroup
-
Constructor Summary
Constructors Constructor Description SimpleServerSelectionProvider(com.fishlib.io.logger.Logger log, IrisGroupProvider irisGroupProvider)
Required constructor for the controller to create a SimpleServerSelectionProvider instance. -
Method Summary
Modifier and Type Method Description PersistentQueryDbServerConfig
determineServer(String serverGroupName, com.fishlib.auth.UserContext userContext, int heapSizeMB, String description, boolean isPersistentQuery)
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.Set<IServerSelectionProvider.ServerGroup>
getServerGroups()
List the available server groups.void
installConfiguration()
Install the verified configuration.void
setServerUsage(PersistentQueryDbServerConfig serverConfig, int usageMB, int workerCount)
Set the current server usage.void
updateServerAvailability(PersistentQueryDbServerConfig serverConfig, boolean available)
Update whether a server is available or not.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
updateServers()
void
updateServerTotalHeapMB(PersistentQueryDbServerConfig serverConfig, int totalHeapMB)
Update the total heap available for a server.void
verifyConfiguration(org.jdom2.Element element, List<PersistentQueryDbServerConfig> serverConfigs)
Given theElement
generated byIServerSelectionProvider.generateReloadableConfigurationElement(org.jdom2.Element, com.fishlib.configuration.Configuration)
, validate and prepare the configuration for use.
-
Constructor Details
-
SimpleServerSelectionProvider
public SimpleServerSelectionProvider(@NotNull com.fishlib.io.logger.Logger log, @Nullable IrisGroupProvider irisGroupProvider)Required constructor for the controller to create a SimpleServerSelectionProvider instance.- Parameters:
log
- theLogger
irisGroupProvider
- theIrisGroupProvider
which is used to get group membership, may be null if the provider is just being used to generate the configuration element
-
-
Method Details
-
generateReloadableConfigurationElement
public void generateReloadableConfigurationElement(@NotNull org.jdom2.Element baseElement, @NotNull com.fishlib.configuration.Configuration config)Description copied from interface:IServerSelectionProvider
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.- Specified by:
generateReloadableConfigurationElement
in interfaceIServerSelectionProvider
- Parameters:
baseElement
- theElement
config
- theConfiguration
to be used to generate theElement
-
verifyConfiguration
public void verifyConfiguration(@NotNull org.jdom2.Element element, List<PersistentQueryDbServerConfig> serverConfigs) throws ConfigurationVerificationExceptionDescription copied from interface:IServerSelectionProvider
Given theElement
generated byIServerSelectionProvider.generateReloadableConfigurationElement(org.jdom2.Element, com.fishlib.configuration.Configuration)
, validate and prepare the configuration for use.- Specified by:
verifyConfiguration
in interfaceIServerSelectionProvider
- 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
public void installConfiguration()Description copied from interface:IServerSelectionProvider
Install the verified configuration. This will be called afterIServerSelectionProvider.verifyConfiguration(org.jdom2.Element, java.util.List<com.illumon.iris.controller.PersistentQueryDbServerConfig>)
is successfully called and indicates that the verified configuration should now be used.- Specified by:
installConfiguration
in interfaceIServerSelectionProvider
-
updateServerTotalHeapMB
public void updateServerTotalHeapMB(@NotNull PersistentQueryDbServerConfig serverConfig, int totalHeapMB)Description copied from interface:IServerSelectionProvider
Update the total heap available for a server. This will be determined by the controller after getting a connection to each dispatcher.- Specified by:
updateServerTotalHeapMB
in interfaceIServerSelectionProvider
- Parameters:
serverConfig
- the server configurationtotalHeapMB
- the total available heap for the dispatcher
-
getServerGroups
Description copied from interface:IServerSelectionProvider
List the available server groups. Each server group will be added to ths list of servers available for query server selection.- Specified by:
getServerGroups
in interfaceIServerSelectionProvider
- Returns:
- the list of available server groups
-
updateServers
public void updateServers() -
determineServer
@NotNull public PersistentQueryDbServerConfig determineServer(@NotNull String serverGroupName, @NotNull com.fishlib.auth.UserContext userContext, int heapSizeMB, String description, boolean isPersistentQuery) throws IServerSelectionProvider.ResourcesUnavailableExceptionDescription copied from interface:IServerSelectionProvider
Determine the server (dispatcher) on which to request the worker.- Specified by:
determineServer
in interfaceIServerSelectionProvider
- 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 MBdescription
- a text description of the requested workerisPersistentQuery
- true if the worker is for a persistent query, false otherwise- Returns:
- a PersistentQueryDbServerConfig that represents the server (dispatcher) on which to request the worker
- Throws:
IServerSelectionProvider.ResourcesUnavailableException
- if a server can't be determined
-
setServerUsage
public void setServerUsage(@NotNull PersistentQueryDbServerConfig serverConfig, int usageMB, int workerCount)Description copied from interface:IServerSelectionProvider
Set the current server usage. This may be on an initial dispatcher connection or after a reconnection, or whenever the utilization changes.- Specified by:
setServerUsage
in interfaceIServerSelectionProvider
- Parameters:
serverConfig
- the server configurationusageMB
- the usage in MBworkerCount
- the current number of workers running on that server
-
updateServerAvailability
public void updateServerAvailability(@NotNull PersistentQueryDbServerConfig serverConfig, boolean available)Description copied from interface:IServerSelectionProvider
Update whether a server is available or not.- Specified by:
updateServerAvailability
in interfaceIServerSelectionProvider
- Parameters:
serverConfig
- the server configurationavailable
- if true, the server is available; if false, it is not
-
updateServerMaxHeapGB
public void updateServerMaxHeapGB(PersistentQueryDbServerConfig serverConfig, double maxHeapSizeGB)Description copied from interface:IServerSelectionProvider
Update the max per-worker heap size in GB for a server based on the dispatcher's actual configuration.- Specified by:
updateServerMaxHeapGB
in interfaceIServerSelectionProvider
- Parameters:
serverConfig
- the server configurationmaxHeapSizeGB
- the new maximum size
-