Package org.apache.solr.update.processor
Class DistributedUpdateProcessor
- java.lang.Object
-
- org.apache.solr.update.processor.UpdateRequestProcessor
-
- org.apache.solr.update.processor.DistributedUpdateProcessor
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
DistributedZkUpdateProcessor
public class DistributedUpdateProcessor extends UpdateRequestProcessor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DistributedUpdateProcessor.DistribPhase
Values this processor supports for theDISTRIB_UPDATE_PARAM
.static class
DistributedUpdateProcessor.DistributedUpdatesAsyncException
static class
DistributedUpdateProcessor.LeaderRequestReplicationTracker
static class
DistributedUpdateProcessor.RollupRequestReplicationTracker
-
Field Summary
Fields Modifier and Type Field Description static String
COMMIT_END_POINT
static String
DISTRIB_FROM
static String
DISTRIB_FROM_COLLECTION
static String
DISTRIB_FROM_PARENT
static String
DISTRIB_FROM_SHARD
static String
DISTRIB_INPLACE_PREVVERSION
protected boolean
forwardToLeader
protected boolean
isIndexChanged
protected boolean
isLeader
protected boolean
isSubShardLeader
static String
LOG_REPLAY
protected int
maxRetriesOnForward
Number of times requests forwarded to some other shard's leader can be retriedprotected int
maxRetriesToFollowers
Number of times requests from leaders to followers can be retriedprotected org.apache.solr.common.cloud.Replica.Type
replicaType
protected SolrQueryRequest
req
protected SolrQueryResponse
rsp
protected static String
TEST_DISTRIB_SKIP_SERVERS
-
Fields inherited from class org.apache.solr.update.processor.UpdateRequestProcessor
next
-
-
Constructor Summary
Constructors Constructor Description DistributedUpdateProcessor(SolrQueryRequest req, SolrQueryResponse rsp, AtomicUpdateDocumentMerger docMerger, UpdateRequestProcessor next)
Specification of AtomicUpdateDocumentMerger is currently experimental.DistributedUpdateProcessor(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
bucketHash(org.apache.lucene.util.BytesRef idBytes)
protected org.apache.solr.common.cloud.Replica.Type
computeReplicaType()
protected void
doDeleteById(DeleteUpdateCommand cmd)
protected void
doDeleteByQuery(DeleteUpdateCommand cmd)
for implementing classes to setup request data(nodes, replicas)protected void
doDeleteByQuery(DeleteUpdateCommand cmd, List<SolrCmdDistributor.Node> replicas, org.apache.solr.common.cloud.DocCollection coll)
should be called by implementing class after setting up replicasprotected void
doDistribAdd(AddUpdateCommand cmd)
protected void
doDistribDeleteById(DeleteUpdateCommand cmd)
This method can be overridden to tamper with the cmd after the localDeleteById operationprotected void
doDistribDeleteByQuery(DeleteUpdateCommand cmd, List<SolrCmdDistributor.Node> replicas, org.apache.solr.common.cloud.DocCollection coll)
This runs after versionDeleteByQuery is invoked, should be used to tamper or forward DeleteCommandprotected void
doDistribFinish()
protected void
doLocalCommit(CommitUpdateCommand cmd)
protected org.apache.solr.common.params.ModifiableSolrParams
filterParams(org.apache.solr.common.params.SolrParams params)
void
finish()
protected String
getLeaderUrl(String id)
static boolean
getNonZkLeaderAssumption(SolrQueryRequest req)
Returns a boolean indicating whether or not the caller should behave as if this is the "leader" even when ZooKeeper is not enabled.void
processAdd(AddUpdateCommand cmd)
void
processCommit(CommitUpdateCommand cmd)
void
processDelete(DeleteUpdateCommand cmd)
protected boolean
shouldCloneCmdDoc()
protected boolean
versionAdd(AddUpdateCommand cmd)
protected boolean
versionDelete(DeleteUpdateCommand cmd)
protected void
versionDeleteByQuery(DeleteUpdateCommand cmd)
-
Methods inherited from class org.apache.solr.update.processor.UpdateRequestProcessor
close, doClose, processMergeIndexes, processRollback
-
-
-
-
Field Detail
-
DISTRIB_FROM_SHARD
public static final String DISTRIB_FROM_SHARD
- See Also:
- Constant Field Values
-
DISTRIB_FROM_COLLECTION
public static final String DISTRIB_FROM_COLLECTION
- See Also:
- Constant Field Values
-
DISTRIB_FROM_PARENT
public static final String DISTRIB_FROM_PARENT
- See Also:
- Constant Field Values
-
DISTRIB_FROM
public static final String DISTRIB_FROM
- See Also:
- Constant Field Values
-
DISTRIB_INPLACE_PREVVERSION
public static final String DISTRIB_INPLACE_PREVVERSION
- See Also:
- Constant Field Values
-
TEST_DISTRIB_SKIP_SERVERS
protected static final String TEST_DISTRIB_SKIP_SERVERS
- See Also:
- Constant Field Values
-
COMMIT_END_POINT
public static final String COMMIT_END_POINT
- See Also:
- Constant Field Values
-
LOG_REPLAY
public static final String LOG_REPLAY
- See Also:
- Constant Field Values
-
req
protected final SolrQueryRequest req
-
rsp
protected final SolrQueryResponse rsp
-
isLeader
protected boolean isLeader
-
forwardToLeader
protected boolean forwardToLeader
-
isSubShardLeader
protected boolean isSubShardLeader
-
isIndexChanged
protected boolean isIndexChanged
-
maxRetriesOnForward
protected final int maxRetriesOnForward
Number of times requests forwarded to some other shard's leader can be retried
-
maxRetriesToFollowers
protected final int maxRetriesToFollowers
Number of times requests from leaders to followers can be retried
-
replicaType
protected final org.apache.solr.common.cloud.Replica.Type replicaType
-
-
Constructor Detail
-
DistributedUpdateProcessor
public DistributedUpdateProcessor(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
-
DistributedUpdateProcessor
public DistributedUpdateProcessor(SolrQueryRequest req, SolrQueryResponse rsp, AtomicUpdateDocumentMerger docMerger, UpdateRequestProcessor next)
Specification of AtomicUpdateDocumentMerger is currently experimental.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Method Detail
-
computeReplicaType
protected org.apache.solr.common.cloud.Replica.Type computeReplicaType()
- Returns:
- the replica type of the collection.
-
processAdd
public void processAdd(AddUpdateCommand cmd) throws IOException
- Overrides:
processAdd
in classUpdateRequestProcessor
- Throws:
IOException
-
doDistribAdd
protected void doDistribAdd(AddUpdateCommand cmd) throws IOException
- Throws:
IOException
-
bucketHash
public static int bucketHash(org.apache.lucene.util.BytesRef idBytes)
-
versionAdd
protected boolean versionAdd(AddUpdateCommand cmd) throws IOException
- Returns:
- whether or not to drop this cmd
- Throws:
IOException
- If there is a low-level I/O error.
-
shouldCloneCmdDoc
protected boolean shouldCloneCmdDoc()
- Returns:
- whether cmd doc should be cloned before localAdd
-
processDelete
public void processDelete(DeleteUpdateCommand cmd) throws IOException
- Overrides:
processDelete
in classUpdateRequestProcessor
- Throws:
IOException
-
doDeleteById
protected void doDeleteById(DeleteUpdateCommand cmd) throws IOException
- Throws:
IOException
-
doDistribDeleteById
protected void doDistribDeleteById(DeleteUpdateCommand cmd) throws IOException
This method can be overridden to tamper with the cmd after the localDeleteById operation- Parameters:
cmd
- the delete command- Throws:
IOException
- in case post processing failed
-
filterParams
protected org.apache.solr.common.params.ModifiableSolrParams filterParams(org.apache.solr.common.params.SolrParams params)
-
doDeleteByQuery
protected void doDeleteByQuery(DeleteUpdateCommand cmd) throws IOException
for implementing classes to setup request data(nodes, replicas)- Parameters:
cmd
- the delete command being processed- Throws:
IOException
-
doDeleteByQuery
protected void doDeleteByQuery(DeleteUpdateCommand cmd, List<SolrCmdDistributor.Node> replicas, org.apache.solr.common.cloud.DocCollection coll) throws IOException
should be called by implementing class after setting up replicas- Parameters:
cmd
- delete commandreplicas
- list of Nodes replicas to pass todoDistribDeleteByQuery(DeleteUpdateCommand, List, DocCollection)
coll
- the collection in zookeeperDocCollection
, passed todoDistribDeleteByQuery(DeleteUpdateCommand, List, DocCollection)
- Throws:
IOException
-
doDistribDeleteByQuery
protected void doDistribDeleteByQuery(DeleteUpdateCommand cmd, List<SolrCmdDistributor.Node> replicas, org.apache.solr.common.cloud.DocCollection coll) throws IOException
This runs after versionDeleteByQuery is invoked, should be used to tamper or forward DeleteCommand- Parameters:
cmd
- delete commandreplicas
- list of Nodes replicascoll
- the collection in zookeeperDocCollection
.- Throws:
IOException
- in case post processing failed
-
versionDeleteByQuery
protected void versionDeleteByQuery(DeleteUpdateCommand cmd) throws IOException
- Throws:
IOException
-
getLeaderUrl
protected String getLeaderUrl(String id)
- Parameters:
id
- id of doc- Returns:
- url of leader, or null if not found.
-
versionDelete
protected boolean versionDelete(DeleteUpdateCommand cmd) throws IOException
- Throws:
IOException
-
processCommit
public void processCommit(CommitUpdateCommand cmd) throws IOException
- Overrides:
processCommit
in classUpdateRequestProcessor
- Throws:
IOException
-
doLocalCommit
protected void doLocalCommit(CommitUpdateCommand cmd) throws IOException
- Throws:
IOException
-
finish
public final void finish() throws IOException
- Overrides:
finish
in classUpdateRequestProcessor
- Throws:
IOException
-
doDistribFinish
protected void doDistribFinish() throws IOException
- Throws:
IOException
-
getNonZkLeaderAssumption
public static boolean getNonZkLeaderAssumption(SolrQueryRequest req)
Returns a boolean indicating whether or not the caller should behave as if this is the "leader" even when ZooKeeper is not enabled. (Even in non zk mode, tests may simulate updates to/from a leader)
-
-