Package org.apache.solr.cloud
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 filesstate.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 asClusterStateMutator
,CollectionMutator
etc.) in order to be able to later execute them on the actual content of thestate.json
files using optimistic locking (and retry a few times if the optimistic locking failed).Instances are not thread safe.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
executeStateUpdates(org.apache.solr.client.solrj.cloud.SolrCloudManager scm, org.apache.solr.common.cloud.ZkStateReader zkStateReader)
Using optimistic locking (and retries when needed) updates Zookeeper with the changes previously recorded by calls torecord(MutatingCommand, ZkNodeProps)
.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.
-
-
-
Method Detail
-
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 parameterOverseer.QUEUE_OPERATION
, but that value is ignored here in favor of the value passed incommand
.- 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 toOverseer.offerStateUpdate(byte[])
that is passed a copy of the data!
This means that ifmessage
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 torecord(MutatingCommand, ZkNodeProps)
.- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
-