You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by tf...@apache.org on 2017/05/12 23:39:23 UTC
[56/58] [abbrv] lucene-solr:jira/solr-10233: Rename replica types
Rename replica types
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/9e82fd45
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9e82fd45
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9e82fd45
Branch: refs/heads/jira/solr-10233
Commit: 9e82fd45a8fbd9a2662f8bb4775a8fea7fb5b8ac
Parents: 1c0e2f2
Author: Tomas Fernandez Lobbe <tf...@apache.org>
Authored: Fri May 12 14:48:38 2017 -0700
Committer: Tomas Fernandez Lobbe <tf...@apache.org>
Committed: Fri May 12 14:48:38 2017 -0700
----------------------------------------------------------------------
.../org/apache/solr/cloud/AddReplicaCmd.java | 2 +-
.../org/apache/solr/cloud/CloudDescriptor.java | 4 +-
.../apache/solr/cloud/CreateCollectionCmd.java | 24 +-
.../org/apache/solr/cloud/CreateShardCmd.java | 42 +-
.../org/apache/solr/cloud/ElectionContext.java | 6 +-
.../java/org/apache/solr/cloud/MigrateCmd.java | 8 +-
.../cloud/OverseerCollectionMessageHandler.java | 30 +-
.../org/apache/solr/cloud/RecoveryStrategy.java | 12 +-
.../java/org/apache/solr/cloud/RestoreCmd.java | 54 +-
.../org/apache/solr/cloud/SplitShardCmd.java | 2 +-
.../org/apache/solr/cloud/ZkController.java | 24 +-
.../apache/solr/cloud/rule/ReplicaAssigner.java | 2 +-
.../org/apache/solr/core/CoreContainer.java | 8 +-
.../solr/handler/admin/CollectionsHandler.java | 6 +-
.../handler/component/HttpShardHandler.java | 8 +-
.../handler/component/RealTimeGetComponent.java | 4 +-
.../solr/update/DirectUpdateHandler2.java | 2 +-
.../org/apache/solr/update/UpdateHandler.java | 2 +-
.../java/org/apache/solr/update/UpdateLog.java | 2 +-
.../processor/DistributedUpdateProcessor.java | 20 +-
.../org/apache/solr/util/TestInjection.java | 2 +-
.../AbstractCloudBackupRestoreTestCase.java | 10 +-
.../solr/cloud/BasicDistributedZk2Test.java | 2 +-
.../solr/cloud/BasicDistributedZkTest.java | 2 +-
.../cloud/ChaosMonkeyNothingIsSafeTest.java | 2 +-
...keyNothingIsSafeWithPassiveReplicasTest.java | 338 --------
...MonkeyNothingIsSafeWithPullReplicasTest.java | 338 ++++++++
...MonkeySafeLeaderWithPassiveReplicasTest.java | 251 ------
...aosMonkeySafeLeaderWithPullReplicasTest.java | 251 ++++++
.../cloud/CollectionsAPIDistributedZkTest.java | 4 +-
.../solr/cloud/CollectionsAPISolrJTest.java | 12 +-
.../org/apache/solr/cloud/ForceLeaderTest.java | 2 +-
.../apache/solr/cloud/HttpPartitionTest.java | 2 +-
.../LeaderInitiatedRecoveryOnCommitTest.java | 2 +-
...verseerCollectionConfigSetProcessorTest.java | 2 +-
.../solr/cloud/RecoveryAfterSoftCommitTest.java | 2 +-
.../org/apache/solr/cloud/ShardSplitTest.java | 2 +-
.../apache/solr/cloud/TestAppendReplica.java | 829 -------------------
.../apache/solr/cloud/TestCloudRecovery.java | 2 +-
.../apache/solr/cloud/TestCollectionAPI.java | 4 +-
.../apache/solr/cloud/TestPassiveReplica.java | 597 -------------
.../cloud/TestPassiveReplicaErrorHandling.java | 330 --------
.../org/apache/solr/cloud/TestPullReplica.java | 575 +++++++++++++
.../cloud/TestPullReplicaErrorHandling.java | 330 ++++++++
.../org/apache/solr/cloud/TestTlogReplica.java | 829 +++++++++++++++++++
.../cloud/TestTolerantUpdateProcessorCloud.java | 4 +-
.../cloud/hdfs/HdfsBasicDistributedZkTest.java | 2 +-
.../solr/update/TestInPlaceUpdatesDistrib.java | 8 +-
.../solr/client/solrj/impl/CloudSolrClient.java | 2 +-
.../solrj/request/CollectionAdminRequest.java | 74 +-
.../apache/solr/common/cloud/DocCollection.java | 36 +-
.../org/apache/solr/common/cloud/Replica.java | 24 +-
.../org/apache/solr/common/cloud/Slice.java | 2 +-
.../apache/solr/common/cloud/ZkStateReader.java | 8 +-
...ollectionAdminRequestRequiredParamsTest.java | 2 +-
.../cloud/AbstractFullDistribZkTestBase.java | 110 +--
.../java/org/apache/solr/cloud/ChaosMonkey.java | 8 +-
57 files changed, 2620 insertions(+), 2642 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/AddReplicaCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/AddReplicaCmd.java b/solr/core/src/java/org/apache/solr/cloud/AddReplicaCmd.java
index 4420a92..7338d9e 100644
--- a/solr/core/src/java/org/apache/solr/cloud/AddReplicaCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/AddReplicaCmd.java
@@ -72,7 +72,7 @@ public class AddReplicaCmd implements OverseerCollectionMessageHandler.Cmd {
String node = message.getStr(CoreAdminParams.NODE);
String shard = message.getStr(SHARD_ID_PROP);
String coreName = message.getStr(CoreAdminParams.NAME);
- Replica.Type replicaType = Replica.Type.valueOf(message.getStr(ZkStateReader.REPLICA_TYPE, Replica.Type.REALTIME.name()));
+ Replica.Type replicaType = Replica.Type.valueOf(message.getStr(ZkStateReader.REPLICA_TYPE, Replica.Type.NRT.name()));
boolean parallel = message.getBool("parallel", false);
if (StringUtils.isBlank(coreName)) {
coreName = message.getStr(CoreAdminParams.PROPERTY_PREFIX + CoreAdminParams.NAME);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java b/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java
index 8a37be5..32cb65b 100644
--- a/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java
+++ b/solr/core/src/java/org/apache/solr/cloud/CloudDescriptor.java
@@ -67,7 +67,7 @@ public class CloudDescriptor {
this.numShards = PropertiesUtil.toInteger(props.getProperty(CloudDescriptor.NUM_SHARDS), null);
String replicaTypeStr = props.getProperty(CloudDescriptor.REPLICA_TYPE);
if (Strings.isNullOrEmpty(replicaTypeStr)) {
- this.replicaType = Replica.Type.REALTIME;
+ this.replicaType = Replica.Type.NRT;
} else {
this.replicaType = Replica.Type.valueOf(replicaTypeStr);
}
@@ -79,7 +79,7 @@ public class CloudDescriptor {
}
public boolean requiresTransactionLog() {
- return this.replicaType != Replica.Type.PASSIVE;
+ return this.replicaType != Replica.Type.PULL;
}
public Replica.State getLastPublished() {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
index 2cc3310..3d1a54e 100644
--- a/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
@@ -95,9 +95,9 @@ public class CreateCollectionCmd implements Cmd {
// look at the replication factor and see if it matches reality
// if it does not, find best nodes to create more cores
- int numRealtimeReplicas = message.getInt(REALTIME_REPLICAS, message.getInt(REPLICATION_FACTOR, 1));
- int numPassiveReplicas = message.getInt(PASSIVE_REPLICAS, 0);
- int numAppendReplicas = message.getInt(APPEND_REPLICAS, 0);
+ int numNrtReplicas = message.getInt(NRT_REPLICAS, message.getInt(REPLICATION_FACTOR, 1));
+ int numPullReplicas = message.getInt(PULL_REPLICAS, 0);
+ int numTlogReplicas = message.getInt(TLOG_REPLICAS, 0);
ShardHandler shardHandler = ocmh.shardHandlerFactory.getShardHandler();
final String async = message.getStr(ASYNC);
@@ -117,8 +117,8 @@ public class CreateCollectionCmd implements Cmd {
int maxShardsPerNode = message.getInt(MAX_SHARDS_PER_NODE, 1);
- if (numRealtimeReplicas + numAppendReplicas <= 0) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, REALTIME_REPLICAS + " + " + APPEND_REPLICAS + " must be greater than 0");
+ if (numNrtReplicas + numTlogReplicas <= 0) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, NRT_REPLICAS + " + " + TLOG_REPLICAS + " must be greater than 0");
}
if (numSlices <= 0) {
@@ -136,7 +136,7 @@ public class CreateCollectionCmd implements Cmd {
positionVsNodes = new HashMap<>();
} else {
- int totalNumReplicas = numRealtimeReplicas + numAppendReplicas + numPassiveReplicas;
+ int totalNumReplicas = numNrtReplicas + numTlogReplicas + numPullReplicas;
if (totalNumReplicas > nodeList.size()) {
log.warn("Specified number of replicas of "
+ totalNumReplicas
@@ -155,14 +155,14 @@ public class CreateCollectionCmd implements Cmd {
+ ", and the number of nodes currently live or live and part of your "+CREATE_NODE_SET+" is " + nodeList.size()
+ ". This allows a maximum of " + maxShardsAllowedToCreate
+ " to be created. Value of " + NUM_SLICES + " is " + numSlices
- + ", value of " + REALTIME_REPLICAS + " is " + numRealtimeReplicas
- + ", value of " + APPEND_REPLICAS + " is " + numAppendReplicas
- + " and value of " + PASSIVE_REPLICAS + " is " + numPassiveReplicas
+ + ", value of " + NRT_REPLICAS + " is " + numNrtReplicas
+ + ", value of " + TLOG_REPLICAS + " is " + numTlogReplicas
+ + " and value of " + PULL_REPLICAS + " is " + numPullReplicas
+ ". This requires " + requestedShardsToCreate
+ " shards to be created (higher than the allowed number)");
}
- positionVsNodes = ocmh.identifyNodes(clusterState, nodeList, message, shardNames, numRealtimeReplicas, numAppendReplicas, numPassiveReplicas);
+ positionVsNodes = ocmh.identifyNodes(clusterState, nodeList, message, shardNames, numNrtReplicas, numTlogReplicas, numPullReplicas);
}
ZkStateReader zkStateReader = ocmh.zkStateReader;
@@ -202,8 +202,8 @@ public class CreateCollectionCmd implements Cmd {
Map<String, String> requestMap = new HashMap<>();
- log.debug(formatString("Creating SolrCores for new collection {0}, shardNames {1} , realtimeReplicas : {2}, appendReplicas: {3}, passiveReplicas: {4}",
- collectionName, shardNames, numRealtimeReplicas, numAppendReplicas, numPassiveReplicas));
+ log.debug(formatString("Creating SolrCores for new collection {0}, shardNames {1} , nrtReplicas : {2}, tlogReplicas: {3}, pullReplicas: {4}",
+ collectionName, shardNames, numNrtReplicas, numTlogReplicas, numPullReplicas));
Map<String,ShardRequest> coresToCreate = new LinkedHashMap<>();
for (Map.Entry<ReplicaAssigner.Position, String> e : positionVsNodes.entrySet()) {
ReplicaAssigner.Position position = e.getKey();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/CreateShardCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/CreateShardCmd.java b/solr/core/src/java/org/apache/solr/cloud/CreateShardCmd.java
index f38009c..d3eb828 100644
--- a/solr/core/src/java/org/apache/solr/cloud/CreateShardCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/CreateShardCmd.java
@@ -42,10 +42,10 @@ import org.slf4j.LoggerFactory;
import static org.apache.solr.cloud.Assign.getNodesForNewReplicas;
import static org.apache.solr.cloud.OverseerCollectionMessageHandler.COLL_CONF;
-import static org.apache.solr.common.cloud.ZkStateReader.APPEND_REPLICAS;
+import static org.apache.solr.common.cloud.ZkStateReader.TLOG_REPLICAS;
import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
-import static org.apache.solr.common.cloud.ZkStateReader.PASSIVE_REPLICAS;
-import static org.apache.solr.common.cloud.ZkStateReader.REALTIME_REPLICAS;
+import static org.apache.solr.common.cloud.ZkStateReader.PULL_REPLICAS;
+import static org.apache.solr.common.cloud.ZkStateReader.NRT_REPLICAS;
import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
@@ -72,13 +72,13 @@ public class CreateShardCmd implements Cmd {
ShardHandler shardHandler = ocmh.shardHandlerFactory.getShardHandler();
DocCollection collection = clusterState.getCollection(collectionName);
// int repFactor = message.getInt(REPLICATION_FACTOR, collection.getInt(REPLICATION_FACTOR, 1));
- int numRealtimeReplicas = message.getInt(REALTIME_REPLICAS, message.getInt(REPLICATION_FACTOR, collection.getInt(REALTIME_REPLICAS, collection.getInt(REPLICATION_FACTOR, 1))));
- int numPassiveReplicas = message.getInt(PASSIVE_REPLICAS, collection.getInt(PASSIVE_REPLICAS, 0));
- int numAppendReplicas = message.getInt(APPEND_REPLICAS, collection.getInt(APPEND_REPLICAS, 0));
- int totalReplicas = numRealtimeReplicas + numPassiveReplicas + numAppendReplicas;
+ int numNrtReplicas = message.getInt(NRT_REPLICAS, message.getInt(REPLICATION_FACTOR, collection.getInt(NRT_REPLICAS, collection.getInt(REPLICATION_FACTOR, 1))));
+ int numPullReplicas = message.getInt(PULL_REPLICAS, collection.getInt(PULL_REPLICAS, 0));
+ int numTlogReplicas = message.getInt(TLOG_REPLICAS, collection.getInt(TLOG_REPLICAS, 0));
+ int totalReplicas = numNrtReplicas + numPullReplicas + numTlogReplicas;
- if (numRealtimeReplicas + numAppendReplicas <= 0) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, REALTIME_REPLICAS + " + " + APPEND_REPLICAS + " must be greater than 0");
+ if (numNrtReplicas + numTlogReplicas <= 0) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, NRT_REPLICAS + " + " + TLOG_REPLICAS + " must be greater than 0");
}
Object createNodeSetStr = message.get(OverseerCollectionMessageHandler.CREATE_NODE_SET);
@@ -106,23 +106,23 @@ public class CreateShardCmd implements Cmd {
requestMap = new HashMap<>(totalReplicas, 1.0f);
}
- int createdRealtimeReplicas = 0, createdAppendReplicas = 0, createdPassiveReplicas = 0;
+ int createdNrtReplicas = 0, createdTlogReplicas = 0, createdPullReplicas = 0;
for (int j = 1; j <= totalReplicas; j++) {
int coreNameNumber;
Replica.Type typeToCreate;
- if (createdRealtimeReplicas < numRealtimeReplicas) {
- createdRealtimeReplicas++;
- coreNameNumber = createdRealtimeReplicas;
- typeToCreate = Replica.Type.REALTIME;
- } else if (createdAppendReplicas < numAppendReplicas) {
- createdAppendReplicas++;
- coreNameNumber = createdAppendReplicas;
- typeToCreate = Replica.Type.APPEND;
+ if (createdNrtReplicas < numNrtReplicas) {
+ createdNrtReplicas++;
+ coreNameNumber = createdNrtReplicas;
+ typeToCreate = Replica.Type.NRT;
+ } else if (createdTlogReplicas < numTlogReplicas) {
+ createdTlogReplicas++;
+ coreNameNumber = createdTlogReplicas;
+ typeToCreate = Replica.Type.TLOG;
} else {
- createdPassiveReplicas++;
- coreNameNumber = createdPassiveReplicas;
- typeToCreate = Replica.Type.PASSIVE;
+ createdPullReplicas++;
+ coreNameNumber = createdPullReplicas;
+ typeToCreate = Replica.Type.PULL;
}
String nodeName = sortedNodeList.get(((j - 1)) % sortedNodeList.size()).nodeName;
String coreName = Assign.buildCoreName(collectionName, sliceName, typeToCreate, coreNameNumber);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
index 21549bc..588262d 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
@@ -428,7 +428,7 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
try {
// we must check LIR before registering as leader
checkLIR(coreName, allReplicasInLine);
- if (replicaType == Replica.Type.APPEND) {
+ if (replicaType == Replica.Type.TLOG) {
// stop replicate from old leader
zkController.stopReplicationFromLeader(coreName);
if (weAreReplacement) {
@@ -624,7 +624,7 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
}
// on startup and after connection timeout, wait for all known shards
- if (found >= slices.getReplicas(EnumSet.of(Replica.Type.APPEND, Replica.Type.REALTIME)).size()) {
+ if (found >= slices.getReplicas(EnumSet.of(Replica.Type.TLOG, Replica.Type.NRT)).size()) {
log.info("Enough replicas found to continue.");
return true;
} else {
@@ -632,7 +632,7 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
log.info("Waiting until we see more replicas up for shard {}: total={}"
+ " found={}"
+ " timeoutin={}ms",
- shardId, slices.getReplicas(EnumSet.of(Replica.Type.APPEND, Replica.Type.REALTIME)).size(), found,
+ shardId, slices.getReplicas(EnumSet.of(Replica.Type.TLOG, Replica.Type.NRT)).size(), found,
TimeUnit.MILLISECONDS.convert(timeoutAt - System.nanoTime(), TimeUnit.NANOSECONDS));
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/MigrateCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/MigrateCmd.java b/solr/core/src/java/org/apache/solr/cloud/MigrateCmd.java
index a1a41bb..0ea5d6e 100644
--- a/solr/core/src/java/org/apache/solr/cloud/MigrateCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/MigrateCmd.java
@@ -51,7 +51,7 @@ import static org.apache.solr.cloud.OverseerCollectionMessageHandler.COLL_PROP_P
import static org.apache.solr.cloud.OverseerCollectionMessageHandler.CREATE_NODE_SET;
import static org.apache.solr.cloud.OverseerCollectionMessageHandler.NUM_SLICES;
import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
-import static org.apache.solr.common.cloud.ZkStateReader.REALTIME_REPLICAS;
+import static org.apache.solr.common.cloud.ZkStateReader.NRT_REPLICAS;
import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.ADDREPLICA;
import static org.apache.solr.common.params.CollectionParams.CollectionAction.CREATE;
@@ -208,7 +208,7 @@ public class MigrateCmd implements OverseerCollectionMessageHandler.Cmd {
Map<String, Object> props = makeMap(
Overseer.QUEUE_OPERATION, CREATE.toLower(),
NAME, tempSourceCollectionName,
- REALTIME_REPLICAS, 1,
+ NRT_REPLICAS, 1,
NUM_SLICES, 1,
COLL_CONF, configName,
CREATE_NODE_SET, sourceLeader.getNodeName());
@@ -224,7 +224,7 @@ public class MigrateCmd implements OverseerCollectionMessageHandler.Cmd {
Slice tempSourceSlice = clusterState.getCollection(tempSourceCollectionName).getSlices().iterator().next();
Replica tempSourceLeader = zkStateReader.getLeaderRetry(tempSourceCollectionName, tempSourceSlice.getName(), 120000);
- String tempCollectionReplica1 = Assign.buildCoreName(tempSourceCollectionName, tempSourceSlice.getName(), Replica.Type.REALTIME, 1);
+ String tempCollectionReplica1 = Assign.buildCoreName(tempSourceCollectionName, tempSourceSlice.getName(), Replica.Type.NRT, 1);
String coreNodeName = ocmh.waitForCoreNodeName(tempSourceCollectionName,
sourceLeader.getNodeName(), tempCollectionReplica1);
// wait for the replicas to be seen as active on temp source leader
@@ -257,7 +257,7 @@ public class MigrateCmd implements OverseerCollectionMessageHandler.Cmd {
log.info("Creating a replica of temporary collection: {} on the target leader node: {}",
tempSourceCollectionName, targetLeader.getNodeName());
- String tempCollectionReplica2 = Assign.buildCoreName(tempSourceCollectionName, tempSourceSlice.getName(), Replica.Type.REALTIME, 2);
+ String tempCollectionReplica2 = Assign.buildCoreName(tempSourceCollectionName, tempSourceSlice.getName(), Replica.Type.NRT, 2);
props = new HashMap<>();
props.put(Overseer.QUEUE_OPERATION, ADDREPLICA.toLower());
props.put(COLLECTION_PROP, tempSourceCollectionName);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionMessageHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionMessageHandler.java b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionMessageHandler.java
index 0af3460..1615a0b 100644
--- a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionMessageHandler.java
+++ b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionMessageHandler.java
@@ -159,9 +159,9 @@ public class OverseerCollectionMessageHandler implements OverseerMessageHandler
public static final Map<String, Object> COLL_PROPS = Collections.unmodifiableMap(makeMap(
ROUTER, DocRouter.DEFAULT_NAME,
ZkStateReader.REPLICATION_FACTOR, "1",
- ZkStateReader.REALTIME_REPLICAS, "1",
- ZkStateReader.APPEND_REPLICAS, "0",
- ZkStateReader.PASSIVE_REPLICAS, "0",
+ ZkStateReader.NRT_REPLICAS, "1",
+ ZkStateReader.TLOG_REPLICAS, "0",
+ ZkStateReader.PULL_REPLICAS, "0",
ZkStateReader.MAX_SHARDS_PER_NODE, "1",
ZkStateReader.AUTO_ADD_REPLICAS, "false",
DocCollection.RULE, null,
@@ -733,32 +733,32 @@ public class OverseerCollectionMessageHandler implements OverseerMessageHandler
List<String> nodeList,
ZkNodeProps message,
List<String> shardNames,
- int numRealtimeReplicas,
- int numAppendReplicas,
- int numPassiveReplicas) throws IOException {
+ int numNrtReplicas,
+ int numTlogReplicas,
+ int numPullReplicas) throws IOException {
List<Map> rulesMap = (List) message.get("rule");
if (rulesMap == null) {
int i = 0;
Map<Position, String> result = new HashMap<>();
for (String aShard : shardNames) {
- for (int j = 0; j < numRealtimeReplicas; j++){
- result.put(new Position(aShard, j, Replica.Type.REALTIME), nodeList.get(i % nodeList.size()));
+ for (int j = 0; j < numNrtReplicas; j++){
+ result.put(new Position(aShard, j, Replica.Type.NRT), nodeList.get(i % nodeList.size()));
i++;
}
- for (int j = 0; j < numAppendReplicas; j++){
- result.put(new Position(aShard, j, Replica.Type.APPEND), nodeList.get(i % nodeList.size()));
+ for (int j = 0; j < numTlogReplicas; j++){
+ result.put(new Position(aShard, j, Replica.Type.TLOG), nodeList.get(i % nodeList.size()));
i++;
}
- for (int j = 0; j < numPassiveReplicas; j++){
- result.put(new Position(aShard, j, Replica.Type.PASSIVE), nodeList.get(i % nodeList.size()));
+ for (int j = 0; j < numPullReplicas; j++){
+ result.put(new Position(aShard, j, Replica.Type.PULL), nodeList.get(i % nodeList.size()));
i++;
}
}
return result;
} else {
- if (numAppendReplicas + numPassiveReplicas != 0) {
+ if (numTlogReplicas + numPullReplicas != 0) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
- Replica.Type.APPEND + " or " + Replica.Type.PASSIVE + " replica types not supported with placement rules");
+ Replica.Type.TLOG + " or " + Replica.Type.PULL + " replica types not supported with placement rules");
}
}
@@ -767,7 +767,7 @@ public class OverseerCollectionMessageHandler implements OverseerMessageHandler
Map<String, Integer> sharVsReplicaCount = new HashMap<>();
- for (String shard : shardNames) sharVsReplicaCount.put(shard, numRealtimeReplicas);
+ for (String shard : shardNames) sharVsReplicaCount.put(shard, numNrtReplicas);
ReplicaAssigner replicaAssigner = new ReplicaAssigner(rules,
sharVsReplicaCount,
(List<Map>) message.get(SNITCH),
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
index 3c8c1f4..da75195 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
@@ -325,12 +325,12 @@ public class RecoveryStrategy implements Runnable, Closeable {
String ourUrl = ZkCoreNodeProps.getCoreUrl(baseUrl, coreName);
- boolean isLeader = leaderUrl.equals(ourUrl); //TODO: We can probably delete most of this code if we say this strategy can only be used for passive replicas
+ boolean isLeader = leaderUrl.equals(ourUrl); //TODO: We can probably delete most of this code if we say this strategy can only be used for pull replicas
if (isLeader && !cloudDesc.isLeader()) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Cloud state still says we are leader.");
}
if (cloudDesc.isLeader()) {
- assert cloudDesc.getReplicaType() != Replica.Type.PASSIVE;
+ assert cloudDesc.getReplicaType() != Replica.Type.PULL;
// we are now the leader - no one else must have been suitable
LOG.warn("We have not yet recovered - but we are now the leader!");
LOG.info("Finished recovery process.");
@@ -461,7 +461,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
}
// we temporary ignore peersync for Append replicas
- boolean firstTime = replicaType != Replica.Type.APPEND;
+ boolean firstTime = replicaType != Replica.Type.TLOG;
List<Long> recentVersions;
try (UpdateLog.RecentUpdates recentUpdates = ulog.getRecentUpdates()) {
@@ -513,7 +513,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
}
}
- if (replicaType == Replica.Type.APPEND) {
+ if (replicaType == Replica.Type.TLOG) {
zkController.stopReplicationFromLeader(coreName);
}
@@ -670,7 +670,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
if (successfulRecovery) {
LOG.info("Registering as Active after recovery.");
try {
- if (replicaType == Replica.Type.APPEND) {
+ if (replicaType == Replica.Type.TLOG) {
zkController.startReplicationFromLeader(coreName, true);
}
zkController.publish(core.getCoreDescriptor(), Replica.State.ACTIVE);
@@ -753,7 +753,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
if (testing_beforeReplayBufferingUpdates != null) {
testing_beforeReplayBufferingUpdates.run();
}
- if (replicaType == Replica.Type.APPEND) {
+ if (replicaType == Replica.Type.TLOG) {
// roll over all updates during buffering to new tlog, make RTG available
SolrQueryRequest req = new LocalSolrQueryRequest(core,
new ModifiableSolrParams());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/RestoreCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/RestoreCmd.java b/solr/core/src/java/org/apache/solr/cloud/RestoreCmd.java
index 367ee86..2fa847c 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RestoreCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RestoreCmd.java
@@ -181,10 +181,10 @@ public class RestoreCmd implements OverseerCollectionMessageHandler.Cmd {
propMap.put(COLLECTION_PROP, restoreCollectionName);
propMap.put(SHARD_ID_PROP, slice.getName());
- if (restoreCollection.getNumRealtimeReplicas() != null && restoreCollection.getNumRealtimeReplicas() >= 1) {
- propMap.put(REPLICA_TYPE, Replica.Type.REALTIME.name());
- } else if (restoreCollection.getNumAppendReplicas() != null && restoreCollection.getNumAppendReplicas() >= 1) {
- propMap.put(REPLICA_TYPE, Replica.Type.APPEND.name());
+ if (restoreCollection.getNumNrtReplicas() != null && restoreCollection.getNumNrtReplicas() >= 1) {
+ propMap.put(REPLICA_TYPE, Replica.Type.NRT.name());
+ } else if (restoreCollection.getNumTlogReplicas() != null && restoreCollection.getNumTlogReplicas() >= 1) {
+ propMap.put(REPLICA_TYPE, Replica.Type.TLOG.name());
}
// add async param
if (asyncId != null) {
@@ -225,27 +225,27 @@ public class RestoreCmd implements OverseerCollectionMessageHandler.Cmd {
restoreCollection = zkStateReader.getClusterState().getCollection(restoreCollectionName);
//Add the remaining replicas for each shard, considering it's type
- int numRealtimeReplicas = restoreCollection.getNumRealtimeReplicas() != null?
- restoreCollection.getNumRealtimeReplicas():0;
- if (numRealtimeReplicas == 0) {
- numRealtimeReplicas = restoreCollection.getReplicationFactor() != null?
+ int numNrtReplicas = restoreCollection.getNumNrtReplicas() != null?
+ restoreCollection.getNumNrtReplicas():0;
+ if (numNrtReplicas == 0) {
+ numNrtReplicas = restoreCollection.getReplicationFactor() != null?
restoreCollection.getReplicationFactor():0;
}
- int numAppendReplicas = restoreCollection.getNumAppendReplicas() != null?
- restoreCollection.getNumAppendReplicas():0;
- int numPassiveReplicas = restoreCollection.getNumPassiveReplicas() != null?
- restoreCollection.getNumPassiveReplicas():0;
+ int numTlogReplicas = restoreCollection.getNumTlogReplicas() != null?
+ restoreCollection.getNumTlogReplicas():0;
+ int numPullReplicas = restoreCollection.getNumPullReplicas() != null?
+ restoreCollection.getNumPullReplicas():0;
- int createdRealtimeReplicas = 0, createdAppendReplicas = 0, createdPassiveReplicas = 0;
+ int createdNrtReplicas = 0, createdTlogReplicas = 0, createdPullReplicas = 0;
- // We already created either a REALTIME or an APPEND replica as leader
- if (numRealtimeReplicas > 0) {
- createdRealtimeReplicas++;
- } else if (createdAppendReplicas > 0) {
- createdAppendReplicas++;
+ // We already created either a REALTIME or an TLOG replica as leader
+ if (numNrtReplicas > 0) {
+ createdNrtReplicas++;
+ } else if (createdTlogReplicas > 0) {
+ createdTlogReplicas++;
}
- int totalReplicasPerShard = numRealtimeReplicas + numAppendReplicas + numPassiveReplicas;
+ int totalReplicasPerShard = numNrtReplicas + numTlogReplicas + numPullReplicas;
if (totalReplicasPerShard > 1) {
log.info("Adding replicas to restored collection={}", restoreCollection);
@@ -253,15 +253,15 @@ public class RestoreCmd implements OverseerCollectionMessageHandler.Cmd {
for (Slice slice : restoreCollection.getSlices()) {
for (int i = 1; i < totalReplicasPerShard; i++) {
Replica.Type typeToCreate;
- if (createdRealtimeReplicas < numRealtimeReplicas) {
- createdRealtimeReplicas++;
- typeToCreate = Replica.Type.REALTIME;
- } else if (createdAppendReplicas < numAppendReplicas) {
- createdAppendReplicas++;
- typeToCreate = Replica.Type.APPEND;
+ if (createdNrtReplicas < numNrtReplicas) {
+ createdNrtReplicas++;
+ typeToCreate = Replica.Type.NRT;
+ } else if (createdTlogReplicas < numTlogReplicas) {
+ createdTlogReplicas++;
+ typeToCreate = Replica.Type.TLOG;
} else {
- createdPassiveReplicas++;
- typeToCreate = Replica.Type.PASSIVE;
+ createdPullReplicas++;
+ typeToCreate = Replica.Type.PULL;
}
log.debug("Adding replica for shard={} collection={} of type {} ", slice.getName(), restoreCollection, typeToCreate);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/SplitShardCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/SplitShardCmd.java b/solr/core/src/java/org/apache/solr/cloud/SplitShardCmd.java
index b9494ed..fe95458 100644
--- a/solr/core/src/java/org/apache/solr/cloud/SplitShardCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/SplitShardCmd.java
@@ -205,7 +205,7 @@ public class SplitShardCmd implements Cmd {
for (int i = 0; i < subRanges.size(); i++) {
String subSlice = slice + "_" + i;
subSlices.add(subSlice);
- String subShardName = Assign.buildCoreName(collectionName, subSlice, Replica.Type.REALTIME, 1);
+ String subShardName = Assign.buildCoreName(collectionName, subSlice, Replica.Type.NRT, 1);
subShardNames.add(subShardName);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/ZkController.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index 02133d6..53d6747 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -889,13 +889,13 @@ public class ZkController {
joinAtHead = replica.getBool(SliceMutator.PREFERRED_LEADER_PROP, false);
}
//TODO WHy would replica be null?
- if (replica == null || replica.getType() != Type.PASSIVE) {
+ if (replica == null || replica.getType() != Type.PULL) {
joinElection(desc, afterExpiration, joinAtHead);
- } else if (replica.getType() == Type.PASSIVE) {
+ } else if (replica.getType() == Type.PULL) {
if (joinAtHead) {
- log.warn("Replica {} was designated as preferred leader but it's type is {}, It won't join election", coreZkNodeName, Type.PASSIVE);
+ log.warn("Replica {} was designated as preferred leader but it's type is {}, It won't join election", coreZkNodeName, Type.PULL);
}
- log.debug("Replica {} skipping election because it's type is {}", coreZkNodeName, Type.PASSIVE);
+ log.debug("Replica {} skipping election because it's type is {}", coreZkNodeName, Type.PULL);
startReplicationFromLeader(coreName, false);
}
} catch (InterruptedException e) {
@@ -915,7 +915,7 @@ public class ZkController {
log.debug("We are " + ourUrl + " and leader is " + leaderUrl);
boolean isLeader = leaderUrl.equals(ourUrl);
Replica.Type replicaType = zkStateReader.getClusterState().getCollection(collection).getReplica(coreZkNodeName).getType();
- assert !(isLeader && replicaType == Type.PASSIVE): "Passive replica became leader!";
+ assert !(isLeader && replicaType == Type.PULL): "Pull replica became leader!";
try (SolrCore core = cc.getCore(desc.getName())) {
@@ -926,15 +926,15 @@ public class ZkController {
// leader election perhaps?
UpdateLog ulog = core.getUpdateHandler().getUpdateLog();
- boolean isAppendAndNotLeader = replicaType == Replica.Type.APPEND && !isLeader;
- if (isAppendAndNotLeader) {
+ boolean isTlogReplicaAndNotLeader = replicaType == Replica.Type.TLOG && !isLeader;
+ if (isTlogReplicaAndNotLeader) {
String commitVersion = ReplicateFromLeader.getCommitVersion(core);
if (commitVersion != null) {
ulog.copyOverOldUpdates(Long.parseLong(commitVersion));
}
}
// we will call register again after zk expiration and on reload
- if (!afterExpiration && !core.isReloaded() && ulog != null && !isAppendAndNotLeader) {
+ if (!afterExpiration && !core.isReloaded() && ulog != null && !isTlogReplicaAndNotLeader) {
// disable recovery in case shard is in construction state (for shard splits)
Slice slice = getClusterState().getSlice(collection, shardId);
if (slice.getState() != Slice.State.CONSTRUCTION || !isLeader) {
@@ -953,7 +953,7 @@ public class ZkController {
boolean didRecovery
= checkRecovery(recoverReloadedCores, isLeader, skipRecovery, collection, coreZkNodeName, core, cc, afterExpiration);
if (!didRecovery) {
- if (isAppendAndNotLeader) {
+ if (isTlogReplicaAndNotLeader) {
startReplicationFromLeader(coreName, true);
}
publish(desc, Replica.State.ACTIVE);
@@ -1210,7 +1210,7 @@ public class ZkController {
if (state != Replica.State.DOWN) {
final Replica.State lirState = getLeaderInitiatedRecoveryState(collection, shardId, coreNodeName);
if (lirState != null) {
- assert cd.getCloudDescriptor().getReplicaType() != Replica.Type.PASSIVE: "LIR should not happen for passive replicas!";
+ assert cd.getCloudDescriptor().getReplicaType() != Replica.Type.PULL: "LIR should not happen for pull replicas!";
if (state == Replica.State.ACTIVE) {
// trying to become active, so leader-initiated state must be recovering
if (lirState == Replica.State.RECOVERING) {
@@ -1295,14 +1295,14 @@ public class ZkController {
}
Replica replica = zkStateReader.getClusterState().getReplica(collection, coreNodeName);
- if (replica == null || replica.getType() != Type.PASSIVE) {
+ if (replica == null || replica.getType() != Type.PULL) {
ElectionContext context = electionContexts.remove(new ContextKey(collection, coreNodeName));
if (context != null) {
context.cancelElection();
}
}
-// //TODO: Do we need to stop replication for type==append?
+// //TODO: Do we need to stop replication for type==tlog?
CloudDescriptor cloudDescriptor = cd.getCloudDescriptor();
zkStateReader.unregisterCore(cloudDescriptor.getCollectionName());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/cloud/rule/ReplicaAssigner.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/rule/ReplicaAssigner.java b/solr/core/src/java/org/apache/solr/cloud/rule/ReplicaAssigner.java
index ebe29f1..506e158 100644
--- a/solr/core/src/java/org/apache/solr/cloud/rule/ReplicaAssigner.java
+++ b/solr/core/src/java/org/apache/solr/cloud/rule/ReplicaAssigner.java
@@ -190,7 +190,7 @@ public class ReplicaAssigner {
List<Position> positions = new ArrayList<>();
for (int pos : p) {
for (int j = 0; j < shardVsReplicaCount.get(shardNames.get(pos)); j++) {
- positions.add(new Position(shardNames.get(pos), j, Replica.Type.REALTIME));
+ positions.add(new Position(shardNames.get(pos), j, Replica.Type.NRT));
}
}
Collections.sort(positions);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/core/CoreContainer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 773c50c..4d15e77 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -1189,7 +1189,7 @@ public class CoreContainer {
DocCollection docCollection = getZkController().getClusterState().getCollection(cd.getCollectionName());
Replica replica = docCollection.getReplica(cd.getCloudDescriptor().getCoreNodeName());
assert replica != null;
- if (replica.getType() == Replica.Type.APPEND) { //TODO: needed here?
+ if (replica.getType() == Replica.Type.TLOG) { //TODO: needed here?
getZkController().stopReplicationFromLeader(core.getName());
if (!cd.getCloudDescriptor().isLeader()) {
getZkController().startReplicationFromLeader(newCore.getName(), true);
@@ -1280,9 +1280,9 @@ public class CoreContainer {
if (zkSys.getZkController() != null) {
// cancel recovery in cloud mode
core.getSolrCoreState().cancelRecovery();
- if (core.getCoreDescriptor().getCloudDescriptor().getReplicaType() == Replica.Type.PASSIVE
- || core.getCoreDescriptor().getCloudDescriptor().getReplicaType() == Replica.Type.APPEND) {
- // Stop replication if this is part of a passive replica before closing the code
+ if (core.getCoreDescriptor().getCloudDescriptor().getReplicaType() == Replica.Type.PULL
+ || core.getCoreDescriptor().getCloudDescriptor().getReplicaType() == Replica.Type.TLOG) {
+ // Stop replication if this is part of a pull replica before closing the code
zkSys.getZkController().stopReplicationFromLeader(name);
}
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
index e657b62..4a5cb83 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
@@ -399,9 +399,9 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
AUTO_ADD_REPLICAS,
RULE,
SNITCH,
- PASSIVE_REPLICAS,
- APPEND_REPLICAS,
- REALTIME_REPLICAS);
+ PULL_REPLICAS,
+ TLOG_REPLICAS,
+ NRT_REPLICAS);
if (props.get(STATE_FORMAT) == null) {
props.put(STATE_FORMAT, "2");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
index f2d2639..a2108be 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
@@ -350,11 +350,11 @@ public class HttpShardHandler extends ShardHandler {
String ourSlice = cloudDescriptor.getShardId();
String ourCollection = cloudDescriptor.getCollectionName();
// Some requests may only be fulfilled by replicas of type Replica.Type.REALTIME
- boolean onlyRealtimeReplicas = Boolean.TRUE == req.getContext().get("distribOnlyRealtime");
+ boolean onlyNrtReplicas = Boolean.TRUE == req.getContext().get("distribOnlyRealtime");
if (rb.slices.length == 1 && rb.slices[0] != null
&& ( rb.slices[0].equals(ourSlice) || rb.slices[0].equals(ourCollection + "_" + ourSlice) ) // handle the <collection>_<slice> format
&& cloudDescriptor.getLastPublished() == Replica.State.ACTIVE
- && (!onlyRealtimeReplicas || cloudDescriptor.getReplicaType() == Replica.Type.REALTIME)) {
+ && (!onlyNrtReplicas || cloudDescriptor.getReplicaType() == Replica.Type.NRT)) {
boolean shortCircuit = params.getBool("shortCircuit", true); // currently just a debugging parameter to check distrib search on a single node
String targetHandler = params.get(ShardParams.SHARDS_QT);
@@ -397,11 +397,11 @@ public class HttpShardHandler extends ShardHandler {
for (Replica replica : allSliceReplicas) {
if (!clusterState.liveNodesContain(replica.getNodeName())
|| replica.getState() != Replica.State.ACTIVE
- || (onlyRealtimeReplicas && replica.getType() == Replica.Type.PASSIVE)) {
+ || (onlyNrtReplicas && replica.getType() == Replica.Type.PULL)) {
continue;
}
- if (onlyRealtimeReplicas && replica.getType() == Replica.Type.APPEND) {
+ if (onlyNrtReplicas && replica.getType() == Replica.Type.TLOG) {
if (shardLeader == null) {
try {
shardLeader = zkController.getZkStateReader().getLeaderRetry(cloudDescriptor.getCollectionName(), slice.getName());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
index 18e202e..6760705 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
@@ -111,11 +111,11 @@ public class RealTimeGetComponent extends SearchComponent
if (cloudDesc != null) {
Replica.Type replicaType = cloudDesc.getReplicaType();
if (replicaType != null) {
- if (replicaType == Replica.Type.PASSIVE) {
+ if (replicaType == Replica.Type.PULL) {
throw new SolrException(ErrorCode.BAD_REQUEST,
String.format(Locale.ROOT, "%s can't handle realtime get requests. Replicas of type %s do not support these type of requests",
cloudDesc.getCoreNodeName(),
- Replica.Type.PASSIVE));
+ Replica.Type.PULL));
}
// non-leader APPEND replicas should not respond to distrib /get requests, but internal requests are OK
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index 8665109..e481109 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -122,7 +122,7 @@ public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState
indexWriterCloseWaitsForMerges = updateHandlerInfo.indexWriterCloseWaitsForMerges;
ZkController zkController = core.getCoreContainer().getZkController();
- if (zkController != null && core.getCoreDescriptor().getCloudDescriptor().getReplicaType() == Replica.Type.APPEND) {
+ if (zkController != null && core.getCoreDescriptor().getCloudDescriptor().getReplicaType() == Replica.Type.TLOG) {
commitWithinSoftCommit = false;
commitTracker.setOpenSearcher(true);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
index 5c6e33b..42abaf8 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
@@ -124,7 +124,7 @@ public abstract class UpdateHandler implements SolrInfoBean {
PluginInfo ulogPluginInfo = core.getSolrConfig().getPluginInfo(UpdateLog.class.getName());
- // If this is a replica of type passive, don't create the update log
+ // If this is a replica of type PULL, don't create the update log
boolean skipUpdateLog = core.getCoreDescriptor().getCloudDescriptor() != null && !core.getCoreDescriptor().getCloudDescriptor().requiresTransactionLog();
if (updateLog == null && ulogPluginInfo != null && !skipUpdateLog) {
String dataDir = (String)ulogPluginInfo.initArgs.get("dir");
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/update/UpdateLog.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index ddacb19..87b93f4 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -1092,7 +1092,7 @@ public static final int VERSION_IDX = 1;
/**
* Replay current tlog, so all updates will be written to index.
- * This is must do task for a append replica become a new leader.
+ * This is must do task for a tlog replica become a new leader.
* @return future of this task
*/
public Future<RecoveryInfo> recoverFromCurrentLog() {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index 52cb034..e67f982 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -328,7 +328,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
replicaType = cloudDesc.getReplicaType();
} else {
collection = null;
- replicaType = Replica.Type.REALTIME;
+ replicaType = Replica.Type.NRT;
}
boolean shouldClone = false;
@@ -679,7 +679,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
forwardToLeader = false;
List<ZkCoreNodeProps> replicaProps = zkController.getZkStateReader()
- .getReplicaProps(collection, shardId, leaderReplica.getName(), null, Replica.State.DOWN, EnumSet.of(Replica.Type.REALTIME, Replica.Type.APPEND));
+ .getReplicaProps(collection, shardId, leaderReplica.getName(), null, Replica.State.DOWN, EnumSet.of(Replica.Type.NRT, Replica.Type.TLOG));
if (replicaProps != null) {
nodes = new ArrayList<>(replicaProps.size());
for (ZkCoreNodeProps props : replicaProps) {
@@ -1189,7 +1189,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
checkDeleteByQueries = true;
}
}
- if (replicaType == Replica.Type.APPEND && (cmd.getFlags() & UpdateCommand.REPLAY) == 0) {
+ if (replicaType == Replica.Type.TLOG && (cmd.getFlags() & UpdateCommand.REPLAY) == 0) {
cmd.setFlags(cmd.getFlags() | UpdateCommand.IGNORE_INDEXWRITER);
}
}
@@ -1611,7 +1611,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
collection, myShardId);
// DBQ forwarded to Realtime and Append
List<ZkCoreNodeProps> replicaProps = zkController.getZkStateReader()
- .getReplicaProps(collection, myShardId, leaderReplica.getName(), null, Replica.State.DOWN, EnumSet.of(Replica.Type.REALTIME, Replica.Type.APPEND));
+ .getReplicaProps(collection, myShardId, leaderReplica.getName(), null, Replica.State.DOWN, EnumSet.of(Replica.Type.NRT, Replica.Type.TLOG));
if (replicaProps != null) {
final List<Node> myReplicas = new ArrayList<>(replicaProps.size());
for (ZkCoreNodeProps replicaProp : replicaProps) {
@@ -1699,7 +1699,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
return;
}
- if (replicaType == Replica.Type.APPEND && (cmd.getFlags() & UpdateCommand.REPLAY) == 0) {
+ if (replicaType == Replica.Type.TLOG && (cmd.getFlags() & UpdateCommand.REPLAY) == 0) {
// Append replica not leader, don't write the DBQ to IW
cmd.setFlags(cmd.getFlags() | UpdateCommand.IGNORE_INDEXWRITER);
}
@@ -1857,7 +1857,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
}
}
- if (replicaType == Replica.Type.APPEND && (cmd.getFlags() & UpdateCommand.REPLAY) == 0) {
+ if (replicaType == Replica.Type.TLOG && (cmd.getFlags() & UpdateCommand.REPLAY) == 0) {
cmd.setFlags(cmd.getFlags() | UpdateCommand.IGNORE_INDEXWRITER);
}
}
@@ -1884,11 +1884,11 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
zkCheck();
nodes = getCollectionUrls(req, req.getCore().getCoreDescriptor()
- .getCloudDescriptor().getCollectionName(), EnumSet.of(Replica.Type.APPEND,Replica.Type.REALTIME));
+ .getCloudDescriptor().getCollectionName(), EnumSet.of(Replica.Type.TLOG,Replica.Type.NRT));
if (nodes == null) {
- // This could happen if there are only passive replicas
+ // This could happen if there are only pull replicas
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "Unable to distribute commit operation. No replicas available of types " + Replica.Type.APPEND + " or " + Replica.Type.REALTIME);
+ "Unable to distribute commit operation. No replicas available of types " + Replica.Type.TLOG + " or " + Replica.Type.NRT);
}
if (isLeader && nodes.size() == 1) {
singleLeader = true;
@@ -1896,7 +1896,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
}
if (!zkEnabled || req.getParams().getBool(COMMIT_END_POINT, false) || singleLeader) {
- if (replicaType == Replica.Type.APPEND) { // REALTIME will always commit
+ if (replicaType == Replica.Type.TLOG) { // REALTIME will always commit
try {
Replica leaderReplica = zkController.getZkStateReader().getLeaderRetry(
collection, cloudDesc.getShardId());
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/java/org/apache/solr/util/TestInjection.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/TestInjection.java b/solr/core/src/java/org/apache/solr/util/TestInjection.java
index f3eb484..7b30151 100644
--- a/solr/core/src/java/org/apache/solr/util/TestInjection.java
+++ b/solr/core/src/java/org/apache/solr/util/TestInjection.java
@@ -388,7 +388,7 @@ public class TestInjection {
String localVersion = searcher.get().getIndexReader().getIndexCommit().getUserData().get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
if (localVersion == null && leaderVersion == 0 && !core.getUpdateHandler().getUpdateLog().hasUncommittedChanges()) return true;
if (localVersion != null && Long.parseLong(localVersion) == leaderVersion && (leaderVersion >= t || i >= 6)) {
- log.info("Waiting time for append replica to be in sync with leader: {}", System.currentTimeMillis()-currentTime);
+ log.info("Waiting time for tlog replica to be in sync with leader: {}", System.currentTimeMillis()-currentTime);
return true;
} else {
log.debug("Append replica not in sync with leader yet. Attempt: {}", i);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/test/org/apache/solr/cloud/AbstractCloudBackupRestoreTestCase.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/AbstractCloudBackupRestoreTestCase.java b/solr/core/src/test/org/apache/solr/cloud/AbstractCloudBackupRestoreTestCase.java
index d651e68..e488c53 100644
--- a/solr/core/src/test/org/apache/solr/cloud/AbstractCloudBackupRestoreTestCase.java
+++ b/solr/core/src/test/org/apache/solr/cloud/AbstractCloudBackupRestoreTestCase.java
@@ -82,12 +82,12 @@ public abstract class AbstractCloudBackupRestoreTestCase extends SolrCloudTestCa
boolean isImplicit = random().nextBoolean();
boolean doSplitShardOperation = !isImplicit && random().nextBoolean();
int replFactor = TestUtil.nextInt(random(), 1, 2);
- int numAppendReplicas = TestUtil.nextInt(random(), 0, 1);
- int numPassiveReplicas = TestUtil.nextInt(random(), 0, 1);
+ int numTlogReplicas = TestUtil.nextInt(random(), 0, 1);
+ int numPullReplicas = TestUtil.nextInt(random(), 0, 1);
CollectionAdminRequest.Create create =
- CollectionAdminRequest.createCollection(getCollectionName(), "conf1", NUM_SHARDS, replFactor, numAppendReplicas, numPassiveReplicas);
- if (NUM_SHARDS * (replFactor + numAppendReplicas + numPassiveReplicas) > cluster.getJettySolrRunners().size() || random().nextBoolean()) {
- create.setMaxShardsPerNode((int)Math.ceil(NUM_SHARDS * (replFactor + numAppendReplicas + numPassiveReplicas) / cluster.getJettySolrRunners().size()));//just to assert it survives the restoration
+ CollectionAdminRequest.createCollection(getCollectionName(), "conf1", NUM_SHARDS, replFactor, numTlogReplicas, numPullReplicas);
+ if (NUM_SHARDS * (replFactor + numTlogReplicas + numPullReplicas) > cluster.getJettySolrRunners().size() || random().nextBoolean()) {
+ create.setMaxShardsPerNode((int)Math.ceil(NUM_SHARDS * (replFactor + numTlogReplicas + numPullReplicas) / cluster.getJettySolrRunners().size()));//just to assert it survives the restoration
if (doSplitShardOperation) {
create.setMaxShardsPerNode(create.getMaxShardsPerNode() * 2);
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
index 51f9fe9..c8e92fc 100644
--- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
+++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
@@ -62,7 +62,7 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
}
@Override
- protected boolean useAppendReplicas() {
+ protected boolean useTlogReplicas() {
return onlyLeaderIndexes;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
index 162164b..18caa58 100644
--- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
@@ -119,7 +119,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
}
@Override
- protected boolean useAppendReplicas() {
+ protected boolean useTlogReplicas() {
return onlyLeaderIndexes;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
index 0130dc8..2e31520 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
@@ -98,7 +98,7 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase
}
@Override
- protected boolean useAppendReplicas() {
+ protected boolean useTlogReplicas() {
return onlyLeaderIndexes;
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPassiveReplicasTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPassiveReplicasTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPassiveReplicasTest.java
deleted file mode 100644
index 94d6e45..0000000
--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPassiveReplicasTest.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.cloud;
-
-import java.lang.invoke.MethodHandles;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.lucene.util.LuceneTestCase.Slow;
-import org.apache.solr.SolrTestCaseJ4.SuppressObjectReleaseTracker;
-import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.embedded.JettySolrRunner;
-import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.common.cloud.DocCollection;
-import org.apache.solr.common.cloud.Replica;
-import org.apache.solr.common.cloud.Slice;
-import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.core.SolrCore;
-import org.apache.solr.util.TestInjection;
-import org.apache.solr.util.TimeOut;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
-
-@Slow
-@SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")
-@ThreadLeakLingering(linger = 60000)
-@SuppressObjectReleaseTracker(bugUrl="Testing purposes")
-public class ChaosMonkeyNothingIsSafeWithPassiveReplicasTest extends AbstractFullDistribZkTestBase {
- private static final int FAIL_TOLERANCE = 100;
-
- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- private static final Integer RUN_LENGTH = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.runlength", "-1"));
-
- private final boolean useAppendReplicas = random().nextBoolean();
-
- private final int numPassiveReplicas;
- private final int numRealtimeOrAppendReplicas;
-
- protected int getPassiveReplicaCount() {
- return numPassiveReplicas;
- }
-
- @BeforeClass
- public static void beforeSuperClass() {
- schemaString = "schema15.xml"; // we need a string id
- System.setProperty("solr.autoCommit.maxTime", "15000");
- TestInjection.waitForReplicasInSync = null;
- setErrorHook();
- }
-
- @AfterClass
- public static void afterSuperClass() {
- System.clearProperty("solr.autoCommit.maxTime");
- clearErrorHook();
- TestInjection.reset();
- }
-
- protected static final String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
- protected static final RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong, rdate};
-
- private int clientSoTimeout;
-
- public String[] getFieldNames() {
- return fieldNames;
- }
-
- public RandVal[] getRandValues() {
- return randVals;
- }
-
- @Override
- public void distribSetUp() throws Exception {
- super.distribSetUp();
- // can help to hide this when testing and looking at logs
- //ignoreException("shard update error");
- useFactory("solr.StandardDirectoryFactory");
- }
-
- public ChaosMonkeyNothingIsSafeWithPassiveReplicasTest() {
- super();
- numPassiveReplicas = random().nextInt(TEST_NIGHTLY ? 2 : 1) + 1;
- numRealtimeOrAppendReplicas = random().nextInt(TEST_NIGHTLY ? 4 : 3) + 1;
- sliceCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.slicecount", "-1"));
- if (sliceCount == -1) {
- sliceCount = random().nextInt(TEST_NIGHTLY ? 3 : 2) + 1;
- }
-
- int numNodes = sliceCount * (numRealtimeOrAppendReplicas + numPassiveReplicas);
- fixShardCount(numNodes);
- log.info("Starting ChaosMonkey test with {} shards and {} nodes", sliceCount, numNodes);
-
- // None of the operations used here are particularly costly, so this should work.
- // Using this low timeout will also help us catch index stalling.
- clientSoTimeout = 5000;
- }
-
- @Override
- protected boolean useAppendReplicas() {
- return useAppendReplicas;
- }
-
- @Test
- public void test() throws Exception {
- cloudClient.setSoTimeout(clientSoTimeout);
- DocCollection docCollection = cloudClient.getZkStateReader().getClusterState().getCollection(DEFAULT_COLLECTION);
- assertEquals(this.sliceCount, docCollection.getSlices().size());
- Slice s = docCollection.getSlice("shard1");
- assertNotNull(s);
- assertEquals("Unexpected number of replicas. Collection: " + docCollection, numRealtimeOrAppendReplicas + numPassiveReplicas, s.getReplicas().size());
- assertEquals("Unexpected number of passive replicas. Collection: " + docCollection, numPassiveReplicas, s.getReplicas(EnumSet.of(Replica.Type.PASSIVE)).size());
- assertEquals(useAppendReplicas()?0:numRealtimeOrAppendReplicas, s.getReplicas(EnumSet.of(Replica.Type.REALTIME)).size());
- assertEquals(useAppendReplicas()?numRealtimeOrAppendReplicas:0, s.getReplicas(EnumSet.of(Replica.Type.APPEND)).size());
-
- boolean testSuccessful = false;
- try {
- handle.clear();
- handle.put("timestamp", SKIPVAL);
- ZkStateReader zkStateReader = cloudClient.getZkStateReader();
- // make sure we have leaders for each shard
- for (int j = 1; j < sliceCount; j++) {
- zkStateReader.getLeaderRetry(DEFAULT_COLLECTION, "shard" + j, 10000);
- } // make sure we again have leaders for each shard
-
- waitForRecoveriesToFinish(false);
-
- // we cannot do delete by query
- // as it's not supported for recovery
- del("*:*");
-
- List<StoppableThread> threads = new ArrayList<>();
- List<StoppableIndexingThread> indexTreads = new ArrayList<>();
- int threadCount = TEST_NIGHTLY ? 3 : 1;
- int i = 0;
- for (i = 0; i < threadCount; i++) {
- StoppableIndexingThread indexThread = new StoppableIndexingThread(controlClient, cloudClient, Integer.toString(i), true);
- threads.add(indexThread);
- indexTreads.add(indexThread);
- indexThread.start();
- }
-
- threadCount = 1;
- i = 0;
- for (i = 0; i < threadCount; i++) {
- StoppableSearchThread searchThread = new StoppableSearchThread(cloudClient);
- threads.add(searchThread);
- searchThread.start();
- }
-
- if (usually()) {
- StoppableCommitThread commitThread = new StoppableCommitThread(cloudClient, 1000, false);
- threads.add(commitThread);
- commitThread.start();
- }
-
- // TODO: we only do this sometimes so that we can sometimes compare against control,
- // it's currently hard to know what requests failed when using ConcurrentSolrUpdateServer
- boolean runFullThrottle = random().nextBoolean();
- if (runFullThrottle) {
- FullThrottleStoppableIndexingThread ftIndexThread =
- new FullThrottleStoppableIndexingThread(controlClient, cloudClient, clients, "ft1", true, this.clientSoTimeout);
- threads.add(ftIndexThread);
- ftIndexThread.start();
- }
-
- chaosMonkey.startTheMonkey(true, 10000);
- try {
- long runLength;
- if (RUN_LENGTH != -1) {
- runLength = RUN_LENGTH;
- } else {
- int[] runTimes;
- if (TEST_NIGHTLY) {
- runTimes = new int[] {5000, 6000, 10000, 15000, 25000, 30000,
- 30000, 45000, 90000, 120000};
- } else {
- runTimes = new int[] {5000, 7000, 15000};
- }
- runLength = runTimes[random().nextInt(runTimes.length - 1)];
- }
- ChaosMonkey.wait(runLength, DEFAULT_COLLECTION, zkStateReader);
- } finally {
- chaosMonkey.stopTheMonkey();
- }
-
- // ideally this should go into chaosMonkey
- restartZk(1000 * (5 + random().nextInt(4)));
-
- for (StoppableThread indexThread : threads) {
- indexThread.safeStop();
- }
-
- // start any downed jetties to be sure we still will end up with a leader per shard...
-
- // wait for stop...
- for (StoppableThread indexThread : threads) {
- indexThread.join();
- }
-
- // try and wait for any replications and what not to finish...
-
- ChaosMonkey.wait(2000, DEFAULT_COLLECTION, zkStateReader);
-
- // wait until there are no recoveries...
- waitForThingsToLevelOut(Integer.MAX_VALUE);//Math.round((runLength / 1000.0f / 3.0f)));
-
- // make sure we again have leaders for each shard
- for (int j = 1; j < sliceCount; j++) {
- zkStateReader.getLeaderRetry(DEFAULT_COLLECTION, "shard" + j, 30000);
- }
-
- commit();
-
- // TODO: assert we didnt kill everyone
-
- zkStateReader.updateLiveNodes();
- assertTrue(zkStateReader.getClusterState().getLiveNodes().size() > 0);
-
-
- // we expect full throttle fails, but cloud client should not easily fail
- for (StoppableThread indexThread : threads) {
- if (indexThread instanceof StoppableIndexingThread && !(indexThread instanceof FullThrottleStoppableIndexingThread)) {
- int failCount = ((StoppableIndexingThread) indexThread).getFailCount();
- assertFalse("There were too many update fails (" + failCount + " > " + FAIL_TOLERANCE
- + ") - we expect it can happen, but shouldn't easily", failCount > FAIL_TOLERANCE);
- }
- }
-
- waitForReplicationFromReplicas(DEFAULT_COLLECTION, zkStateReader, new TimeOut(30, TimeUnit.SECONDS));
- waitForAllWarmingSearchers();
-
- Set<String> addFails = getAddFails(indexTreads);
- Set<String> deleteFails = getDeleteFails(indexTreads);
- // full throttle thread can
- // have request fails
- checkShardConsistency(!runFullThrottle, true, addFails, deleteFails);
-
- long ctrlDocs = controlClient.query(new SolrQuery("*:*")).getResults()
- .getNumFound();
-
- // ensure we have added more than 0 docs
- long cloudClientDocs = cloudClient.query(new SolrQuery("*:*"))
- .getResults().getNumFound();
-
- assertTrue("Found " + ctrlDocs + " control docs", cloudClientDocs > 0);
-
- if (VERBOSE) System.out.println("control docs:"
- + controlClient.query(new SolrQuery("*:*")).getResults()
- .getNumFound() + "\n\n");
-
- // try and make a collection to make sure the overseer has survived the expiration and session loss
-
- // sometimes we restart zookeeper as well
- if (random().nextBoolean()) {
- restartZk(1000 * (5 + random().nextInt(4)));
- }
-
- try (CloudSolrClient client = createCloudClient("collection1")) {
- // We don't really know how many live nodes we have at this point, so "maxShardsPerNode" needs to be > 1
- createCollection(null, "testcollection",
- 1, 1, 10, client, null, "conf1");
- }
- List<Integer> numShardsNumReplicas = new ArrayList<>(2);
- numShardsNumReplicas.add(1);
- numShardsNumReplicas.add(1 + getPassiveReplicaCount());
- checkForCollection("testcollection", numShardsNumReplicas, null);
-
- testSuccessful = true;
- } finally {
- if (!testSuccessful) {
- logReplicaTypesReplicationInfo(DEFAULT_COLLECTION, cloudClient.getZkStateReader());
- printLayout();
- }
- }
- }
-
- private void waitForAllWarmingSearchers() throws InterruptedException {
- for (JettySolrRunner jetty:jettys) {
- if (!jetty.isRunning()) {
- continue;
- }
- for (SolrCore core:jetty.getCoreContainer().getCores()) {
- waitForWarming(core);
- }
- }
- }
-
- private Set<String> getAddFails(List<StoppableIndexingThread> threads) {
- Set<String> addFails = new HashSet<String>();
- for (StoppableIndexingThread thread : threads) {
- addFails.addAll(thread.getAddFails());
-// addFails.addAll(thread.getAddFailsMinRf());
- }
- return addFails;
- }
-
- private Set<String> getDeleteFails(List<StoppableIndexingThread> threads) {
- Set<String> deleteFails = new HashSet<String>();
- for (StoppableIndexingThread thread : threads) {
- deleteFails.addAll(thread.getDeleteFails());
-// deleteFails.addAll(thread.getDeleteFailsMinRf());
- }
- return deleteFails;
- }
-
- // skip the randoms - they can deadlock...
- @Override
- protected void indexr(Object... fields) throws Exception {
- SolrInputDocument doc = getDoc(fields);
- indexDoc(doc);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9e82fd45/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPullReplicasTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPullReplicasTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPullReplicasTest.java
new file mode 100644
index 0000000..8c4c781
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeWithPullReplicasTest.java
@@ -0,0 +1,338 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.cloud;
+
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.solr.SolrTestCaseJ4.SuppressObjectReleaseTracker;
+import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.util.TestInjection;
+import org.apache.solr.util.TimeOut;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
+
+@Slow
+@SuppressSSL(bugUrl = "https://issues.apache.org/jira/browse/SOLR-5776")
+@ThreadLeakLingering(linger = 60000)
+@SuppressObjectReleaseTracker(bugUrl="Testing purposes")
+public class ChaosMonkeyNothingIsSafeWithPullReplicasTest extends AbstractFullDistribZkTestBase {
+ private static final int FAIL_TOLERANCE = 100;
+
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ private static final Integer RUN_LENGTH = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.runlength", "-1"));
+
+ private final boolean useTlogReplicas = random().nextBoolean();
+
+ private final int numPullReplicas;
+ private final int numRealtimeOrTlogReplicas;
+
+ protected int getPullReplicaCount() {
+ return numPullReplicas;
+ }
+
+ @BeforeClass
+ public static void beforeSuperClass() {
+ schemaString = "schema15.xml"; // we need a string id
+ System.setProperty("solr.autoCommit.maxTime", "15000");
+ TestInjection.waitForReplicasInSync = null;
+ setErrorHook();
+ }
+
+ @AfterClass
+ public static void afterSuperClass() {
+ System.clearProperty("solr.autoCommit.maxTime");
+ clearErrorHook();
+ TestInjection.reset();
+ }
+
+ protected static final String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
+ protected static final RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong, rdate};
+
+ private int clientSoTimeout;
+
+ public String[] getFieldNames() {
+ return fieldNames;
+ }
+
+ public RandVal[] getRandValues() {
+ return randVals;
+ }
+
+ @Override
+ public void distribSetUp() throws Exception {
+ super.distribSetUp();
+ // can help to hide this when testing and looking at logs
+ //ignoreException("shard update error");
+ useFactory("solr.StandardDirectoryFactory");
+ }
+
+ public ChaosMonkeyNothingIsSafeWithPullReplicasTest() {
+ super();
+ numPullReplicas = random().nextInt(TEST_NIGHTLY ? 2 : 1) + 1;
+ numRealtimeOrTlogReplicas = random().nextInt(TEST_NIGHTLY ? 4 : 3) + 1;
+ sliceCount = Integer.parseInt(System.getProperty("solr.tests.cloud.cm.slicecount", "-1"));
+ if (sliceCount == -1) {
+ sliceCount = random().nextInt(TEST_NIGHTLY ? 3 : 2) + 1;
+ }
+
+ int numNodes = sliceCount * (numRealtimeOrTlogReplicas + numPullReplicas);
+ fixShardCount(numNodes);
+ log.info("Starting ChaosMonkey test with {} shards and {} nodes", sliceCount, numNodes);
+
+ // None of the operations used here are particularly costly, so this should work.
+ // Using this low timeout will also help us catch index stalling.
+ clientSoTimeout = 5000;
+ }
+
+ @Override
+ protected boolean useTlogReplicas() {
+ return useTlogReplicas;
+ }
+
+ @Test
+ public void test() throws Exception {
+ cloudClient.setSoTimeout(clientSoTimeout);
+ DocCollection docCollection = cloudClient.getZkStateReader().getClusterState().getCollection(DEFAULT_COLLECTION);
+ assertEquals(this.sliceCount, docCollection.getSlices().size());
+ Slice s = docCollection.getSlice("shard1");
+ assertNotNull(s);
+ assertEquals("Unexpected number of replicas. Collection: " + docCollection, numRealtimeOrTlogReplicas + numPullReplicas, s.getReplicas().size());
+ assertEquals("Unexpected number of pull replicas. Collection: " + docCollection, numPullReplicas, s.getReplicas(EnumSet.of(Replica.Type.PULL)).size());
+ assertEquals(useTlogReplicas()?0:numRealtimeOrTlogReplicas, s.getReplicas(EnumSet.of(Replica.Type.NRT)).size());
+ assertEquals(useTlogReplicas()?numRealtimeOrTlogReplicas:0, s.getReplicas(EnumSet.of(Replica.Type.TLOG)).size());
+
+ boolean testSuccessful = false;
+ try {
+ handle.clear();
+ handle.put("timestamp", SKIPVAL);
+ ZkStateReader zkStateReader = cloudClient.getZkStateReader();
+ // make sure we have leaders for each shard
+ for (int j = 1; j < sliceCount; j++) {
+ zkStateReader.getLeaderRetry(DEFAULT_COLLECTION, "shard" + j, 10000);
+ } // make sure we again have leaders for each shard
+
+ waitForRecoveriesToFinish(false);
+
+ // we cannot do delete by query
+ // as it's not supported for recovery
+ del("*:*");
+
+ List<StoppableThread> threads = new ArrayList<>();
+ List<StoppableIndexingThread> indexTreads = new ArrayList<>();
+ int threadCount = TEST_NIGHTLY ? 3 : 1;
+ int i = 0;
+ for (i = 0; i < threadCount; i++) {
+ StoppableIndexingThread indexThread = new StoppableIndexingThread(controlClient, cloudClient, Integer.toString(i), true);
+ threads.add(indexThread);
+ indexTreads.add(indexThread);
+ indexThread.start();
+ }
+
+ threadCount = 1;
+ i = 0;
+ for (i = 0; i < threadCount; i++) {
+ StoppableSearchThread searchThread = new StoppableSearchThread(cloudClient);
+ threads.add(searchThread);
+ searchThread.start();
+ }
+
+ if (usually()) {
+ StoppableCommitThread commitThread = new StoppableCommitThread(cloudClient, 1000, false);
+ threads.add(commitThread);
+ commitThread.start();
+ }
+
+ // TODO: we only do this sometimes so that we can sometimes compare against control,
+ // it's currently hard to know what requests failed when using ConcurrentSolrUpdateServer
+ boolean runFullThrottle = random().nextBoolean();
+ if (runFullThrottle) {
+ FullThrottleStoppableIndexingThread ftIndexThread =
+ new FullThrottleStoppableIndexingThread(controlClient, cloudClient, clients, "ft1", true, this.clientSoTimeout);
+ threads.add(ftIndexThread);
+ ftIndexThread.start();
+ }
+
+ chaosMonkey.startTheMonkey(true, 10000);
+ try {
+ long runLength;
+ if (RUN_LENGTH != -1) {
+ runLength = RUN_LENGTH;
+ } else {
+ int[] runTimes;
+ if (TEST_NIGHTLY) {
+ runTimes = new int[] {5000, 6000, 10000, 15000, 25000, 30000,
+ 30000, 45000, 90000, 120000};
+ } else {
+ runTimes = new int[] {5000, 7000, 15000};
+ }
+ runLength = runTimes[random().nextInt(runTimes.length - 1)];
+ }
+ ChaosMonkey.wait(runLength, DEFAULT_COLLECTION, zkStateReader);
+ } finally {
+ chaosMonkey.stopTheMonkey();
+ }
+
+ // ideally this should go into chaosMonkey
+ restartZk(1000 * (5 + random().nextInt(4)));
+
+ for (StoppableThread indexThread : threads) {
+ indexThread.safeStop();
+ }
+
+ // start any downed jetties to be sure we still will end up with a leader per shard...
+
+ // wait for stop...
+ for (StoppableThread indexThread : threads) {
+ indexThread.join();
+ }
+
+ // try and wait for any replications and what not to finish...
+
+ ChaosMonkey.wait(2000, DEFAULT_COLLECTION, zkStateReader);
+
+ // wait until there are no recoveries...
+ waitForThingsToLevelOut(Integer.MAX_VALUE);//Math.round((runLength / 1000.0f / 3.0f)));
+
+ // make sure we again have leaders for each shard
+ for (int j = 1; j < sliceCount; j++) {
+ zkStateReader.getLeaderRetry(DEFAULT_COLLECTION, "shard" + j, 30000);
+ }
+
+ commit();
+
+ // TODO: assert we didnt kill everyone
+
+ zkStateReader.updateLiveNodes();
+ assertTrue(zkStateReader.getClusterState().getLiveNodes().size() > 0);
+
+
+ // we expect full throttle fails, but cloud client should not easily fail
+ for (StoppableThread indexThread : threads) {
+ if (indexThread instanceof StoppableIndexingThread && !(indexThread instanceof FullThrottleStoppableIndexingThread)) {
+ int failCount = ((StoppableIndexingThread) indexThread).getFailCount();
+ assertFalse("There were too many update fails (" + failCount + " > " + FAIL_TOLERANCE
+ + ") - we expect it can happen, but shouldn't easily", failCount > FAIL_TOLERANCE);
+ }
+ }
+
+ waitForReplicationFromReplicas(DEFAULT_COLLECTION, zkStateReader, new TimeOut(30, TimeUnit.SECONDS));
+ waitForAllWarmingSearchers();
+
+ Set<String> addFails = getAddFails(indexTreads);
+ Set<String> deleteFails = getDeleteFails(indexTreads);
+ // full throttle thread can
+ // have request fails
+ checkShardConsistency(!runFullThrottle, true, addFails, deleteFails);
+
+ long ctrlDocs = controlClient.query(new SolrQuery("*:*")).getResults()
+ .getNumFound();
+
+ // ensure we have added more than 0 docs
+ long cloudClientDocs = cloudClient.query(new SolrQuery("*:*"))
+ .getResults().getNumFound();
+
+ assertTrue("Found " + ctrlDocs + " control docs", cloudClientDocs > 0);
+
+ if (VERBOSE) System.out.println("control docs:"
+ + controlClient.query(new SolrQuery("*:*")).getResults()
+ .getNumFound() + "\n\n");
+
+ // try and make a collection to make sure the overseer has survived the expiration and session loss
+
+ // sometimes we restart zookeeper as well
+ if (random().nextBoolean()) {
+ restartZk(1000 * (5 + random().nextInt(4)));
+ }
+
+ try (CloudSolrClient client = createCloudClient("collection1")) {
+ // We don't really know how many live nodes we have at this point, so "maxShardsPerNode" needs to be > 1
+ createCollection(null, "testcollection",
+ 1, 1, 10, client, null, "conf1");
+ }
+ List<Integer> numShardsNumReplicas = new ArrayList<>(2);
+ numShardsNumReplicas.add(1);
+ numShardsNumReplicas.add(1 + getPullReplicaCount());
+ checkForCollection("testcollection", numShardsNumReplicas, null);
+
+ testSuccessful = true;
+ } finally {
+ if (!testSuccessful) {
+ logReplicaTypesReplicationInfo(DEFAULT_COLLECTION, cloudClient.getZkStateReader());
+ printLayout();
+ }
+ }
+ }
+
+ private void waitForAllWarmingSearchers() throws InterruptedException {
+ for (JettySolrRunner jetty:jettys) {
+ if (!jetty.isRunning()) {
+ continue;
+ }
+ for (SolrCore core:jetty.getCoreContainer().getCores()) {
+ waitForWarming(core);
+ }
+ }
+ }
+
+ private Set<String> getAddFails(List<StoppableIndexingThread> threads) {
+ Set<String> addFails = new HashSet<String>();
+ for (StoppableIndexingThread thread : threads) {
+ addFails.addAll(thread.getAddFails());
+// addFails.addAll(thread.getAddFailsMinRf());
+ }
+ return addFails;
+ }
+
+ private Set<String> getDeleteFails(List<StoppableIndexingThread> threads) {
+ Set<String> deleteFails = new HashSet<String>();
+ for (StoppableIndexingThread thread : threads) {
+ deleteFails.addAll(thread.getDeleteFails());
+// deleteFails.addAll(thread.getDeleteFailsMinRf());
+ }
+ return deleteFails;
+ }
+
+ // skip the randoms - they can deadlock...
+ @Override
+ protected void indexr(Object... fields) throws Exception {
+ SolrInputDocument doc = getDoc(fields);
+ indexDoc(doc);
+ }
+
+}