Class 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 of 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...