Class DistributedClusterStateUpdater.StateChangeRecorder

java.lang.Object
org.apache.solr.cloud.DistributedClusterStateUpdater.StateChangeRecorder
Enclosing class:
DistributedClusterStateUpdater

public static class DistributedClusterStateUpdater.StateChangeRecorder extends Object
Class handling the distributed updates of collection's Zookeeper files state.json based on multiple updates applied to a single collection (as is sometimes done by *Cmd classes implementing the Collection API commands).

Previously these updates were sent one by one to Overseer and then grouped by org.apache.solr.cloud.Overseer.ClusterStateUpdater.

Records desired changes to state.json files in Zookeeper (as are done by the family of mutator classes such as ClusterStateMutator, CollectionMutator etc.) in order to be able to later execute them on the actual content of the state.json files using optimistic locking (and retry a few times if the optimistic locking failed).

Instances are not thread safe.

  • Method Details

    • record

      public void record(DistributedClusterStateUpdater.MutatingCommand command, org.apache.solr.common.cloud.ZkNodeProps message)
      Records a mutation method and its parameters so that it can be executed later to modify the corresponding Zookeeper state. Note the message is identical to the one used for communicating with Overseer (at least initially) so it also contains the action in parameter Overseer.QUEUE_OPERATION, but that value is ignored here in favor of the value passed in command.
      Parameters:
      message - the parameters associated with the command that are kept in the recorded mutations to be played later. Note that this call usually replaces a call to Overseer.offerStateUpdate(byte[]) that is passed a copy of the data!
      This means that if message passed in here is reused before the recorded commands are replayed, things will break! Need to make sure all places calling this method do not reuse the data passed in (otherwise need to make a copy).
    • executeStateUpdates

      public void executeStateUpdates(org.apache.solr.client.solrj.cloud.SolrCloudManager scm, org.apache.solr.common.cloud.ZkStateReader zkStateReader) throws org.apache.zookeeper.KeeperException, InterruptedException
      Using optimistic locking (and retries when needed) updates Zookeeper with the changes previously recorded by calls to record(MutatingCommand, ZkNodeProps).
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException