Class AffinityPlacementFactory
- java.lang.Object
-
- org.apache.solr.cluster.placement.plugins.AffinityPlacementFactory
-
- All Implemented Interfaces:
ConfigurablePlugin<AffinityPlacementConfig>
,PlacementPluginFactory<AffinityPlacementConfig>
public class AffinityPlacementFactory extends Object implements PlacementPluginFactory<AffinityPlacementConfig>
This factory is instantiated by config from its class name. Using it is the only way to create instances ofAffinityPlacementFactory.AffinityPlacementPlugin
.In order to configure this plugin to be used for placement decisions, the following
curl
command (or something equivalent) has to be executed once the cluster is already running in order to set the appropriate Zookeeper stored configuration. Replacelocalhost:8983
by one of your servers' IP address and port.curl -X POST -H 'Content-type:application/json' -d '{ "add": { "name": ".placement-plugin", "class": "org.apache.solr.cluster.placement.plugins.AffinityPlacementFactory", "config": { "minimalFreeDiskGB": 10, "prioritizedFreeDiskGB": 50 } } }' http://localhost:8983/api/cluster/plugin
In order to delete the placement-plugin section (and to fallback to either Legacy or rule based placement if configured for a collection), execute:
curl -X POST -H 'Content-type:application/json' -d '{ "remove" : ".placement-plugin" }' http://localhost:8983/api/cluster/plugin
AffinityPlacementFactory.AffinityPlacementPlugin
implements placing replicas in a way that replicate past Autoscaling config defined here.This specification is doing the following:
Spread replicas per shard as evenly as possible across multiple availability zones (given by a sys prop), assign replicas based on replica type to specific kinds of nodes (another sys prop), and avoid having more than one replica per shard on the same node.
Only after these constraints are satisfied do minimize cores per node or disk usage.This plugin achieves this by creating a
AffinityPlacementFactory.AffinityPlacementPlugin.AffinityNode
that weights nodes very high if they are unbalanced with respect to AvailabilityZone and SpreadDomain. SeeAffinityPlacementFactory.AffinityPlacementPlugin.AffinityNode
for more information on how this weighting helps the plugin correctly place and balance replicas.This code is a realistic placement computation, based on a few assumptions. The code is written in such a way to make it relatively easy to adapt it to (somewhat) different assumptions. Additional configuration options could be introduced to allow configuration base option selection as well...
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AffinityPlacementFactory.AffinityPlacementPlugin
SeeAffinityPlacementFactory
for instructions on how to configure a cluster to use this plugin and details on what the plugin does.-
Nested classes/interfaces inherited from interface org.apache.solr.cluster.placement.PlacementPluginFactory
PlacementPluginFactory.NoConfig
-
-
Field Summary
-
Fields inherited from interface org.apache.solr.cluster.placement.PlacementPluginFactory
PLUGIN_NAME
-
-
Constructor Summary
Constructors Constructor Description AffinityPlacementFactory()
Empty public constructor is used to instantiate this factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(AffinityPlacementConfig cfg)
Default implementation is a no-op.PlacementPlugin
createPluginInstance()
Returns an instance of the plugin that will be repeatedly (and concurrently) called to compute placement.AffinityPlacementConfig
getConfig()
Return the configuration of the plugin.
-
-
-
Constructor Detail
-
AffinityPlacementFactory
public AffinityPlacementFactory()
Empty public constructor is used to instantiate this factory. Using a factory pattern to allow the factory to do one time costly operations if needed, and to only have to instantiate a default constructor class by name, rather than having to call a constructor with more parameters (if we were to instantiate the plugin class directly without going through a factory).
-
-
Method Detail
-
createPluginInstance
public PlacementPlugin createPluginInstance()
Description copied from interface:PlacementPluginFactory
Returns an instance of the plugin that will be repeatedly (and concurrently) called to compute placement. Multiple instances of a plugin can be used in parallel (for example if configuration has to change, but plugin instances with the previous configuration are still being used).- Specified by:
createPluginInstance
in interfacePlacementPluginFactory<AffinityPlacementConfig>
-
configure
public void configure(AffinityPlacementConfig cfg)
Description copied from interface:PlacementPluginFactory
Default implementation is a no-op. Override to provide meaningful behavior if needed.- Specified by:
configure
in interfaceConfigurablePlugin<AffinityPlacementConfig>
- Specified by:
configure
in interfacePlacementPluginFactory<AffinityPlacementConfig>
- Parameters:
cfg
- value deserialized from JSON, not null.
-
getConfig
public AffinityPlacementConfig getConfig()
Description copied from interface:PlacementPluginFactory
Return the configuration of the plugin. Default implementation returns null.- Specified by:
getConfig
in interfacePlacementPluginFactory<AffinityPlacementConfig>
-
-