diff --git a/solr/core/src/java/org/apache/solr/cloud/Overseer.java b/solr/core/src/java/org/apache/solr/cloud/Overseer.java index 9df6a2d7e83..dd01368b863 100644 --- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java +++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java @@ -38,6 +38,7 @@ import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.impl.ClusterStateProvider; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.response.CollectionAdminResponse; +import org.apache.solr.cloud.api.collections.CreateCollectionCmd; import org.apache.solr.cloud.api.collections.OverseerCollectionMessageHandler; import org.apache.solr.cloud.autoscaling.OverseerTriggerThread; import org.apache.solr.cloud.overseer.ClusterStateMutator; @@ -79,8 +80,61 @@ import org.slf4j.LoggerFactory; import com.codahale.metrics.Timer; /** - * Cluster leader. Responsible for processing state updates, node assignments, creating/deleting - * collections, shards, replicas and setting various properties. + *
Cluster leader. Responsible for processing state updates, node assignments, creating/deleting + * collections, shards, replicas and setting various properties.
+ * + *The Overseer is a single elected node in the SolrCloud cluster that is in charge of interactions with + * ZooKeeper that require global synchronization. It also hosts the Collection API implementation and the + * Autoscaling framework.
+ * + *The Overseer deals with:
+ *state.json
files in ZooKeeper, see {@link ClusterStateUpdater},The nodes in the cluster communicate with the Overseer over queues implemented in ZooKeeper. There are essentially + * two queues:
+ *state.json
file of a
+ * Collection in ZooKeeper. This queue is in Zookeeper at /overseer/queue
,/overseer/collection-queue-work
.An example of the steps involved in the Overseer processing a Collection creation API call:
+ *CREATE
action and reaches a node of the cluster,/overseer/collection-queue-work
+ * queue in ZooKeepeer,state.json
file for the collection in ZooKeeper.
+ * This is done by enqueuing a message in /overseer/queue
,state.json
file in ZooKeeper for the Collection. All the work of the cluster state updater
+ * (creations, updates, deletes) is done sequentially for the whole cluster by a single thread.This class is responsible for dequeueing state change requests from the ZooKeeper queue at /overseer/queue
+ * and executing the requested cluster change (essentially writing or updating state.json
for a collection).
The cluster state updater is a single thread dequeueing and executing requests.
+ */ private class ClusterStateUpdater implements Runnable, Closeable { private final ZkStateReader reader; diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java b/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java index 465888ff765..53d799b9f57 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkDistributedQueue.java @@ -51,9 +51,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * A ZK-based distributed queue. Optimized for single-consumer, + *A ZK-based distributed queue. Optimized for single-consumer, * multiple-producer: if there are multiple consumers on the same ZK queue, - * the results should be correct but inefficient + * the results should be correct but inefficient.
+ * + *This implementation (with help from subclass {@link OverseerTaskQueue}) is used for the
+ * /overseer/collection-queue-work
queue used for Collection and Config Set API calls to the Overseer.
Implementation note: In order to enqueue a message into this queue, a {@link CreateMode#EPHEMERAL_SEQUENTIAL} response node is created
+ * and watched at /overseer/collection-queue-work/qnr-monotonically_increasng_id
, then a corresponding
+ * {@link CreateMode#PERSISTENT} request node reusing the same id is created at /overseer/collection-queue-work/qn-response_id
.
(Mostly) Collection API actions that can be sent by nodes to the Overseer over the /overseer/collection-queue-work
+ * ZooKeeper queue.
Some of these actions are also used over the cluster state update queue at /overseer/queue
and have a
+ * different (though related) meaning there. These actions are:
+ * {@link #CREATE}, {@link #DELETE}, {@link #CREATESHARD}, {@link #DELETESHARD}, {@link #ADDREPLICA}, {@link #ADDREPLICAPROP},
+ * {@link #DELETEREPLICAPROP}, {@link #BALANCESHARDUNIQUE}, {@link #MODIFYCOLLECTION} and {@link #MIGRATESTATEFORMAT}.