Class AffinityPlacementFactory
- All Implemented Interfaces:
ConfigurablePlugin<AffinityPlacementConfig>,PlacementPluginFactory<AffinityPlacementConfig>
AffinityPlacementFactory.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. Replace localhost: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.
See AffinityPlacementFactory.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 ClassesModifier and TypeClassDescriptionstatic classSeeAffinityPlacementFactoryfor 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
ConstructorsConstructorDescriptionEmpty public constructor is used to instantiate this factory. -
Method Summary
Modifier and TypeMethodDescriptionvoidDefault implementation is a no-op.Returns an instance of the plugin that will be repeatedly (and concurrently) called to compute placement.Return the configuration of the plugin.
-
Constructor Details
-
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 Details
-
createPluginInstance
Description copied from interface:PlacementPluginFactoryReturns 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:
createPluginInstancein interfacePlacementPluginFactory<AffinityPlacementConfig>
-
configure
Description copied from interface:PlacementPluginFactoryDefault implementation is a no-op. Override to provide meaningful behavior if needed.- Specified by:
configurein interfaceConfigurablePlugin<AffinityPlacementConfig>- Specified by:
configurein interfacePlacementPluginFactory<AffinityPlacementConfig>- Parameters:
cfg- value deserialized from JSON, not null.
-
getConfig
Description copied from interface:PlacementPluginFactoryReturn the configuration of the plugin. Default implementation returns null.- Specified by:
getConfigin interfacePlacementPluginFactory<AffinityPlacementConfig>
-