lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject svn commit: r1671240 [2/2] - in /lucene/dev/trunk/solr: ./ core/src/java/org/apache/solr/cloud/ core/src/java/org/apache/solr/cloud/overseer/ core/src/java/org/apache/solr/core/ core/src/java/org/apache/solr/handler/ core/src/java/org/apache/solr/handl...
Date Sat, 04 Apr 2015 07:02:21 GMT
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyShardSplitTest.java Sat Apr  4 07:02:20 2015
@@ -209,9 +209,7 @@ public class ChaosMonkeyShardSplitTest e
       Collection<Replica> replicas = slice.getReplicas();
       boolean allActive = true;
       for (Replica replica : replicas) {
-        if (!clusterState.liveNodesContain(replica.getNodeName())
-            || !replica.get(ZkStateReader.STATE_PROP).equals(
-            ZkStateReader.ACTIVE)) {
+        if (!clusterState.liveNodesContain(replica.getNodeName()) || replica.getState() != Replica.State.ACTIVE) {
           allActive = false;
           break;
         }

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java Sat Apr  4 07:02:20 2015
@@ -282,7 +282,9 @@ public class CustomCollectionTest extend
         attempts++;
         int activeReplicaCount = 0;
         for (Replica x : zkStateReader.getClusterState().getCollection(collectionName).getSlice("x").getReplicas()) {
-          if(ZkStateReader.ACTIVE.equals(x.getStr(ZkStateReader.STATE_PROP))) activeReplicaCount++;
+          if (x.getState() == Replica.State.ACTIVE) {
+            activeReplicaCount++;
+          }
         }
         Thread.sleep(500);
         if(activeReplicaCount >= replicationFactor) break;

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java Sat Apr  4 07:02:20 2015
@@ -107,8 +107,7 @@ public class DeleteInactiveReplicaTest e
       while (System.currentTimeMillis() < endAt) {
         testcoll = client.getZkStateReader()
             .getClusterState().getCollection(collectionName);
-        if (!ZkStateReader.ACTIVE.equals(testcoll.getSlice(shard1.getName())
-            .getReplica(replica1.getName()).getStr(ZkStateReader.STATE_PROP))) {
+        if (testcoll.getSlice(shard1.getName()).getReplica(replica1.getName()).getState() != Replica.State.ACTIVE) {
           success = true;
         }
         if (success) break;

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteLastCustomShardedReplicaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteLastCustomShardedReplicaTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteLastCustomShardedReplicaTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteLastCustomShardedReplicaTest.java Sat Apr  4 07:02:20 2015
@@ -25,6 +25,7 @@ import org.apache.solr.common.cloud.DocC
 import org.apache.solr.common.cloud.ImplicitDocRouter;
 import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.ZkNodeProps;
+import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.params.MapSolrParams;
 import org.apache.solr.common.params.SolrParams;
 import org.junit.BeforeClass;
@@ -36,9 +37,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import static org.apache.solr.cloud.OverseerCollectionProcessor.MAX_SHARDS_PER_NODE;
 import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.REPLICATION_FACTOR;
 import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARDS_PROP;
 import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
 import static org.apache.solr.common.params.CollectionParams.CollectionAction.DELETEREPLICA;
@@ -83,8 +82,8 @@ public class DeleteLastCustomShardedRepl
 
     Map<String, Object> props = ZkNodeProps.makeMap(
         "router.name", ImplicitDocRouter.NAME,
-        REPLICATION_FACTOR, replicationFactor,
-        MAX_SHARDS_PER_NODE, maxShardsPerNode,
+        ZkStateReader.REPLICATION_FACTOR, replicationFactor,
+        ZkStateReader.MAX_SHARDS_PER_NODE, maxShardsPerNode,
         NUM_SLICES, 1,
         SHARDS_PROP,"a,b");
 

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java Sat Apr  4 07:02:20 2015
@@ -95,7 +95,7 @@ public class DeleteReplicaTest extends A
         if (slice.getState() == Slice.State.ACTIVE) {
           shard1 = slice;
           for (Replica replica : shard1.getReplicas()) {
-            if (ZkStateReader.ACTIVE.equals(replica.getStr(ZkStateReader.STATE_PROP))) {
+            if (replica.getState() == Replica.State.ACTIVE) {
               replica1 = replica;
               break;
             }

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java Sat Apr  4 07:02:20 2015
@@ -129,8 +129,7 @@ public class HttpPartitionTest extends A
     createCollectionRetry(testCollectionName, 1, 2, 1);
     cloudClient.setDefaultCollection(testCollectionName);
 
-    Replica leader =
-        cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, shardId);
+    Replica leader = cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, shardId);
     JettySolrRunner leaderJetty = getJettyOnPort(getReplicaPort(leader));
 
     CoreContainer cores = ((SolrDispatchFilter)leaderJetty.getDispatchFilter().getFilter()).getCores();
@@ -148,7 +147,7 @@ public class HttpPartitionTest extends A
     assertTrue(zkController.isReplicaInRecoveryHandling(replicaUrl));
     Map<String,Object> lirStateMap = zkController.getLeaderInitiatedRecoveryStateObject(testCollectionName, shardId, notLeader.getName());
     assertNotNull(lirStateMap);
-    assertEquals(ZkStateReader.DOWN, lirStateMap.get("state"));
+    assertSame(Replica.State.DOWN, Replica.State.getState((String) lirStateMap.get(ZkStateReader.STATE_PROP)));
     zkController.removeReplicaFromLeaderInitiatedRecoveryHandling(replicaUrl);
     assertTrue(!zkController.isReplicaInRecoveryHandling(replicaUrl));
 
@@ -158,7 +157,7 @@ public class HttpPartitionTest extends A
     zkClient.setData(znodePath, "down".getBytes(StandardCharsets.UTF_8), true);
     lirStateMap = zkController.getLeaderInitiatedRecoveryStateObject(testCollectionName, shardId, notLeader.getName());
     assertNotNull(lirStateMap);
-    assertEquals(ZkStateReader.DOWN, lirStateMap.get("state"));
+    assertSame(Replica.State.DOWN, Replica.State.getState((String) lirStateMap.get(ZkStateReader.STATE_PROP)));
     zkClient.delete(znodePath, -1, false);
 
     // try to clean up
@@ -425,8 +424,8 @@ public class HttpPartitionTest extends A
     for (Slice shard : cs.getActiveSlices(testCollectionName)) {
       if (shard.getName().equals(shardId)) {
         for (Replica replica : shard.getReplicas()) {
-          String replicaState = replica.getStr(ZkStateReader.STATE_PROP);
-          if (ZkStateReader.ACTIVE.equals(replicaState) || ZkStateReader.RECOVERING.equals(replicaState)) {
+          final Replica.State state = replica.getState();
+          if (state == Replica.State.ACTIVE || state == Replica.State.RECOVERING) {
             activeReplicas.put(replica.getName(), replica);
           }
         }
@@ -529,9 +528,9 @@ public class HttpPartitionTest extends A
         if (!replicasToCheck.contains(replica.getName()))
           continue;
 
-        String replicaState = replica.getStr(ZkStateReader.STATE_PROP);
-        if (!ZkStateReader.ACTIVE.equals(replicaState)) {
-          log.info("Replica " + replica.getName() + " is currently " + replicaState);
+        final Replica.State state = replica.getState();
+        if (state != Replica.State.ACTIVE) {
+          log.info("Replica " + replica.getName() + " is currently " + state);
           allReplicasUp = false;
         }
       }

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderInitiatedRecoveryOnCommitTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderInitiatedRecoveryOnCommitTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderInitiatedRecoveryOnCommitTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderInitiatedRecoveryOnCommitTest.java Sat Apr  4 07:02:20 2015
@@ -93,7 +93,7 @@ public class LeaderInitiatedRecoveryOnCo
 
     cloudClient.getZkStateReader().updateClusterState(true); // get the latest state
     leader = cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1");
-    assertEquals("Leader was not active", ZkStateReader.ACTIVE, leader.getStr(ZkStateReader.STATE_PROP));
+    assertSame("Leader was not active", Replica.State.ACTIVE, leader.getState());
 
     leaderProxy.reopen();
     Thread.sleep(sleepMsBeforeHealPartition);
@@ -136,7 +136,7 @@ public class LeaderInitiatedRecoveryOnCo
 
     cloudClient.getZkStateReader().updateClusterState(true); // get the latest state
     leader = cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1");
-    assertEquals("Leader was not active", ZkStateReader.ACTIVE, leader.getStr(ZkStateReader.STATE_PROP));
+    assertSame("Leader was not active", Replica.State.ACTIVE, leader.getState());
 
     leaderProxy.reopen();
     Thread.sleep(sleepMsBeforeHealPartition);

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java Sat Apr  4 07:02:20 2015
@@ -17,6 +17,23 @@ package org.apache.solr.cloud;
  * limitations under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.xml.parsers.ParserConfigurationException;
+
 import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.cloud.overseer.OverseerAction;
@@ -47,22 +64,6 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.xml.sax.SAXException;
 
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicInteger;
-
 @Slow
 public class OverseerTest extends SolrTestCaseJ4 {
 
@@ -116,7 +117,7 @@ public class OverseerTest extends SolrTe
       zkClient.close();
     }
     
-    public String publishState(String collection, String coreName, String coreNodeName, String stateName, int numShards)
+    public String publishState(String collection, String coreName, String coreNodeName, Replica.State stateName, int numShards)
         throws KeeperException, InterruptedException, IOException {
       if (stateName == null) {
         ElectionContext ec = electionContext.remove(coreName);
@@ -133,14 +134,13 @@ public class OverseerTest extends SolrTe
          return null;
       } else {
         ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION, OverseerAction.STATE.toLower(),
-        ZkStateReader.STATE_PROP, stateName,
+        ZkStateReader.STATE_PROP, stateName.toString(),
         ZkStateReader.NODE_NAME_PROP, nodeName,
         ZkStateReader.CORE_NAME_PROP, coreName,
         ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName,
         ZkStateReader.COLLECTION_PROP, collection,
         ZkStateReader.NUM_SHARDS_PROP, Integer.toString(numShards),
-        ZkStateReader.BASE_URL_PROP, "http://" + nodeName
-            + "/solr/");
+        ZkStateReader.BASE_URL_PROP, "http://" + nodeName + "/solr/");
         DistributedQueue q = Overseer.getInQueue(zkClient);
         q.offer(ZkStateReader.toJSON(m));
       }
@@ -250,7 +250,7 @@ public class OverseerTest extends SolrTe
       final int numShards=6;
       
       for (int i = 0; i < numShards; i++) {
-        assertNotNull("shard got no id?", zkController.publishState(collection, "core" + (i+1), "node" + (i+1), ZkStateReader.ACTIVE, 3));
+        assertNotNull("shard got no id?", zkController.publishState(collection, "core" + (i+1), "node" + (i+1), Replica.State.ACTIVE, 3));
       }
       Map<String,Replica> rmap = reader.getClusterState().getSlice("collection1", "shard1").getReplicasMap();
       assertEquals(rmap.toString(), 2, rmap.size());
@@ -305,7 +305,7 @@ public class OverseerTest extends SolrTe
       final int numShards=3;
       
       for (int i = 0; i < numShards; i++) {
-        assertNotNull("shard got no id?", zkController.publishState(collection, "core" + (i+1), "node" + (i+1), ZkStateReader.ACTIVE, 3));
+        assertNotNull("shard got no id?", zkController.publishState(collection, "core" + (i+1), "node" + (i+1), Replica.State.ACTIVE, 3));
       }
 
       assertEquals(1, reader.getClusterState().getSlice(collection, "shard1").getReplicasMap().size());
@@ -319,12 +319,12 @@ public class OverseerTest extends SolrTe
       
       // publish a bad queue item
       String emptyCollectionName = "";
-      zkController.publishState(emptyCollectionName, "core0", "node0", ZkStateReader.ACTIVE, 1);
+      zkController.publishState(emptyCollectionName, "core0", "node0", Replica.State.ACTIVE, 1);
       zkController.publishState(emptyCollectionName, "core0", "node0", null, 1);
       
       // make sure the Overseer is still processing items
       for (int i = 0; i < numShards; i++) {
-        assertNotNull("shard got no id?", zkController.publishState("collection2", "core" + (i+1), "node" + (i+1), ZkStateReader.ACTIVE, 3));
+        assertNotNull("shard got no id?", zkController.publishState("collection2", "core" + (i+1), "node" + (i+1), Replica.State.ACTIVE, 3));
       }
 
       assertEquals(1, reader.getClusterState().getSlice("collection2", "shard1").getReplicasMap().size());
@@ -398,7 +398,7 @@ public class OverseerTest extends SolrTe
             final String coreName = "core" + slot;
             
             try {
-              ids[slot]=controllers[slot % nodeCount].publishState(collection, coreName, "node" + slot, ZkStateReader.ACTIVE, sliceCount);
+              ids[slot]=controllers[slot % nodeCount].publishState(collection, coreName, "node" + slot, Replica.State.ACTIVE, sliceCount);
             } catch (Throwable e) {
               e.printStackTrace();
               fail("register threw exception:" + e.getClass());
@@ -552,15 +552,14 @@ public class OverseerTest extends SolrTe
           ZkStateReader.COLLECTION_PROP, "collection1",
           ZkStateReader.CORE_NAME_PROP, "core1",
           ZkStateReader.ROLES_PROP, "",
-          ZkStateReader.STATE_PROP, ZkStateReader.RECOVERING);
+          ZkStateReader.STATE_PROP, Replica.State.RECOVERING.toString());
       
       q.offer(ZkStateReader.toJSON(m));
       
       waitForCollections(reader, "collection1");
 
-      assertEquals(reader.getClusterState().toString(), ZkStateReader.RECOVERING,
-          reader.getClusterState().getSlice("collection1", "shard1").getReplicasMap()
-              .get("core_node1").getStr(ZkStateReader.STATE_PROP));
+      assertSame(reader.getClusterState().toString(), Replica.State.RECOVERING,
+          reader.getClusterState().getSlice("collection1", "shard1").getReplica("core_node1").getState());
 
       //publish node state (active)
       m = new ZkNodeProps(Overseer.QUEUE_OPERATION, "state",
@@ -569,11 +568,11 @@ public class OverseerTest extends SolrTe
           ZkStateReader.COLLECTION_PROP, "collection1",
           ZkStateReader.CORE_NAME_PROP, "core1",
           ZkStateReader.ROLES_PROP, "",
-          ZkStateReader.STATE_PROP, ZkStateReader.ACTIVE);
+          ZkStateReader.STATE_PROP, Replica.State.ACTIVE.toString());
 
       q.offer(ZkStateReader.toJSON(m));
 
-      verifyStatus(reader, ZkStateReader.ACTIVE);
+      verifyStatus(reader, Replica.State.ACTIVE);
 
     } finally {
 
@@ -585,14 +584,14 @@ public class OverseerTest extends SolrTe
     }
   }
 
-  private void verifyStatus(ZkStateReader reader, String expectedState) throws InterruptedException {
+  private void verifyStatus(ZkStateReader reader, Replica.State expectedState) throws InterruptedException {
     int maxIterations = 100;
-    String coreState = null;
+    Replica.State coreState = null;
     while(maxIterations-->0) {
       Slice slice = reader.getClusterState().getSlice("collection1", "shard1");
       if(slice!=null) {
-        coreState = slice.getReplicasMap().get("core_node1").getStr(ZkStateReader.STATE_PROP);
-        if(coreState.equals(expectedState)) {
+        coreState = slice.getReplicasMap().get("core_node1").getState();
+        if(coreState == expectedState) {
           return;
         }
       }
@@ -646,33 +645,30 @@ public class OverseerTest extends SolrTe
       overseerClient = electNewOverseer(server.getZkAddress());
       
       Thread.sleep(1000);
-      mockController.publishState(collection, "core1", "core_node1",
-          ZkStateReader.RECOVERING, 1);
+      mockController.publishState(collection, "core1", "core_node1", Replica.State.RECOVERING, 1);
       
       waitForCollections(reader, collection);
-      verifyStatus(reader, ZkStateReader.RECOVERING);
+      verifyStatus(reader, Replica.State.RECOVERING);
       
       int version = getClusterStateVersion(zkClient);
       
-      mockController.publishState(collection, "core1", "core_node1", ZkStateReader.ACTIVE,
-          1);
+      mockController.publishState(collection, "core1", "core_node1", Replica.State.ACTIVE, 1);
       
       while (version == getClusterStateVersion(zkClient));
       
-      verifyStatus(reader, ZkStateReader.ACTIVE);
+      verifyStatus(reader, Replica.State.ACTIVE);
       version = getClusterStateVersion(zkClient);
       overseerClient.close();
       Thread.sleep(1000); // wait for overseer to get killed
       
-      mockController.publishState(collection, "core1", "core_node1",
-          ZkStateReader.RECOVERING, 1);
+      mockController.publishState(collection, "core1", "core_node1", Replica.State.RECOVERING, 1);
       version = getClusterStateVersion(zkClient);
       
       overseerClient = electNewOverseer(server.getZkAddress());
       
       while (version == getClusterStateVersion(zkClient));
       
-      verifyStatus(reader, ZkStateReader.RECOVERING);
+      verifyStatus(reader, Replica.State.RECOVERING);
       
       assertEquals("Live nodes count does not match", 1, reader
           .getClusterState().getLiveNodes().size());
@@ -765,16 +761,16 @@ public class OverseerTest extends SolrTe
       for (int i = 0; i < atLeast(4); i++) {
         killCounter.incrementAndGet(); //for each round allow 1 kill
         mockController = new MockZKController(server.getZkAddress(), "node1");
-        mockController.publishState(collection, "core1", "node1", "state1",1);
+        mockController.publishState(collection, "core1", "node1", Replica.State.ACTIVE,1);
         if(mockController2!=null) {
           mockController2.close();
           mockController2 = null;
         }
-        mockController.publishState(collection, "core1", "node1","state2",1);
+        mockController.publishState(collection, "core1", "node1",Replica.State.RECOVERING,1);
         mockController2 = new MockZKController(server.getZkAddress(), "node2");
-        mockController.publishState(collection, "core1", "node1", "state1",1);
+        mockController.publishState(collection, "core1", "node1", Replica.State.ACTIVE,1);
         verifyShardLeader(reader, "collection1", "shard1", "core1");
-        mockController2.publishState(collection, "core4", "node2", "state2" ,1);
+        mockController2.publishState(collection, "core4", "node2", Replica.State.ACTIVE ,1);
         mockController.close();
         mockController = null;
         verifyShardLeader(reader, "collection1", "shard1", "core4");
@@ -820,18 +816,18 @@ public class OverseerTest extends SolrTe
       
       overseerClient = electNewOverseer(server.getZkAddress());
 
-      mockController.publishState(collection, "core1", "core_node1", ZkStateReader.RECOVERING, 1);
+      mockController.publishState(collection, "core1", "core_node1", Replica.State.RECOVERING, 1);
 
       waitForCollections(reader, "collection1");
       
-      verifyStatus(reader, ZkStateReader.RECOVERING);
+      verifyStatus(reader, Replica.State.RECOVERING);
 
       mockController.close();
 
       int version = getClusterStateVersion(controllerClient);
       
       mockController = new MockZKController(server.getZkAddress(), "node1");
-      mockController.publishState(collection, "core1", "core_node1", ZkStateReader.RECOVERING, 1);
+      mockController.publishState(collection, "core1", "core_node1", Replica.State.RECOVERING, 1);
 
       while (version == getClusterStateVersion(controllerClient));
       
@@ -884,7 +880,7 @@ public class OverseerTest extends SolrTe
       
       overseerClient = electNewOverseer(server.getZkAddress());
 
-      mockController.publishState(collection, "core1", "node1", ZkStateReader.RECOVERING, 12);
+      mockController.publishState(collection, "core1", "node1", Replica.State.RECOVERING, 12);
 
       waitForCollections(reader, "collection1");
       
@@ -941,7 +937,7 @@ public class OverseerTest extends SolrTe
 
       for (int i = 0, j = 0, k = 0; i < MAX_STATE_CHANGES; i++, j++, k++) {
         ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION, OverseerAction.STATE.toLower(),
-            ZkStateReader.STATE_PROP, ZkStateReader.RECOVERING,
+            ZkStateReader.STATE_PROP, Replica.State.RECOVERING.toString(),
             ZkStateReader.NODE_NAME_PROP,  "node1",
             ZkStateReader.CORE_NAME_PROP, "core" + k,
             ZkStateReader.CORE_NODE_NAME_PROP, "node1",
@@ -958,7 +954,7 @@ public class OverseerTest extends SolrTe
 
       // let's publish a sentinel collection which we'll use to wait for overseer to complete operations
       ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION, OverseerAction.STATE.toLower(),
-          ZkStateReader.STATE_PROP, ZkStateReader.ACTIVE,
+          ZkStateReader.STATE_PROP, Replica.State.ACTIVE.toString(),
           ZkStateReader.NODE_NAME_PROP, "node1",
           ZkStateReader.CORE_NAME_PROP, "core1",
           ZkStateReader.CORE_NODE_NAME_PROP, "node1",
@@ -1062,7 +1058,7 @@ public class OverseerTest extends SolrTe
           ZkStateReader.COLLECTION_PROP, "collection1",
           ZkStateReader.CORE_NAME_PROP, "core1",
           ZkStateReader.ROLES_PROP, "",
-          ZkStateReader.STATE_PROP, ZkStateReader.RECOVERING);
+          ZkStateReader.STATE_PROP, Replica.State.RECOVERING.toString());
       queue.offer(ZkStateReader.toJSON(m));
       m = new ZkNodeProps(Overseer.QUEUE_OPERATION, "state",
           ZkStateReader.BASE_URL_PROP, "http://127.0.0.1/solr",
@@ -1071,7 +1067,7 @@ public class OverseerTest extends SolrTe
           ZkStateReader.COLLECTION_PROP, "collection1",
           ZkStateReader.CORE_NAME_PROP, "core2",
           ZkStateReader.ROLES_PROP, "",
-          ZkStateReader.STATE_PROP, ZkStateReader.RECOVERING);
+          ZkStateReader.STATE_PROP, Replica.State.RECOVERING.toString());
       queue.offer(ZkStateReader.toJSON(m));
       
       overseerClient = electNewOverseer(server.getZkAddress());
@@ -1085,7 +1081,7 @@ public class OverseerTest extends SolrTe
           ZkStateReader.COLLECTION_PROP, "collection1",
           ZkStateReader.CORE_NAME_PROP, "core3",
           ZkStateReader.ROLES_PROP, "",
-          ZkStateReader.STATE_PROP, ZkStateReader.RECOVERING);
+          ZkStateReader.STATE_PROP, Replica.State.RECOVERING.toString());
       queue.offer(ZkStateReader.toJSON(m));
       
       for(int i=0;i<100;i++) {

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java Sat Apr  4 07:02:20 2015
@@ -219,7 +219,7 @@ public class SharedFSAutoReplicaFailover
     for (Slice slice : slices) {
       for (Replica replica : slice.getReplicas()) {
         boolean live = cloudClient.getZkStateReader().getClusterState().liveNodesContain(replica.getNodeName());
-        boolean active = replica.getStr(ZkStateReader.STATE_PROP).equals(ZkStateReader.ACTIVE);
+        boolean active = replica.getState() == Replica.State.ACTIVE;
         if (live && active) {
           liveAndActive++;
         }

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverUtilsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverUtilsTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverUtilsTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverUtilsTest.java Sat Apr  4 07:02:20 2015
@@ -298,22 +298,22 @@ public class SharedFSAutoReplicaFailover
             node = "1";
           }
           
-          String state = ZkStateReader.ACTIVE;
+          Replica.State state = Replica.State.ACTIVE;
           String stateCode = m.group(3);
 
           if (stateCode != null) {
             switch (stateCode.charAt(0)) {
               case 'S':
-                state = ZkStateReader.ACTIVE;
+                state = Replica.State.ACTIVE;
                 break;
               case 'R':
-                state = ZkStateReader.RECOVERING;
+                state = Replica.State.RECOVERING;
                 break;
               case 'D':
-                state = ZkStateReader.DOWN;
+                state = Replica.State.DOWN;
                 break;
               case 'F':
-                state = ZkStateReader.RECOVERY_FAILED;
+                state = Replica.State.RECOVERY_FAILED;
                 break;
               default:
                 throw new IllegalArgumentException(
@@ -330,7 +330,7 @@ public class SharedFSAutoReplicaFailover
           
           replicaPropMap.put(ZkStateReader.NODE_NAME_PROP, nodeName);
           replicaPropMap.put(ZkStateReader.BASE_URL_PROP, "http://baseUrl" + node);
-          replicaPropMap.put(ZkStateReader.STATE_PROP, state);
+          replicaPropMap.put(ZkStateReader.STATE_PROP, state.toString());
           
           replica = new Replica(replicaName, replicaPropMap);
           

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java Sat Apr  4 07:02:20 2015
@@ -243,9 +243,7 @@ public class SyncSliceTest extends Abstr
       Collection<Replica> replicas = slice.getReplicas();
       boolean allActive = true;
       for (Replica replica : replicas) {
-        if (!clusterState.liveNodesContain(replica.getNodeName())
-            || !replica.get(ZkStateReader.STATE_PROP).equals(
-                ZkStateReader.ACTIVE)) {
+        if (!clusterState.liveNodesContain(replica.getNodeName()) || replica.getState() != Replica.State.ACTIVE) {
           allActive = false;
           break;
         }

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java Sat Apr  4 07:02:20 2015
@@ -1008,7 +1008,7 @@ public class CloudSolrClient extends Sol
           ZkCoreNodeProps coreNodeProps = new ZkCoreNodeProps(nodeProps);
           String node = coreNodeProps.getNodeName();
           if (!liveNodes.contains(coreNodeProps.getNodeName())
-              || !coreNodeProps.getState().equals(ZkStateReader.ACTIVE)) continue;
+              || Replica.State.getState(coreNodeProps.getState()) != Replica.State.ACTIVE) continue;
           if (nodes.put(node, nodeProps) == null) {
             if (!sendToLeaders || coreNodeProps.isLeader()) {
               String url;

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java Sat Apr  4 07:02:20 2015
@@ -21,6 +21,7 @@ import org.apache.solr.client.solrj.Solr
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.response.CoreAdminResponse;
+import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
@@ -164,7 +165,7 @@ public class CoreAdminRequest extends So
   public static class WaitForState extends CoreAdminRequest {
     protected String nodeName;
     protected String coreNodeName;
-    protected String state;
+    protected Replica.State state;
     protected Boolean checkLive;
     protected Boolean onlyIfLeader;
     protected Boolean onlyIfLeaderActive;
@@ -189,11 +190,11 @@ public class CoreAdminRequest extends So
       this.coreNodeName = coreNodeName;
     }
 
-    public String getState() {
+    public Replica.State getState() {
       return state;
     }
 
-    public void setState(String state) {
+    public void setState(Replica.State state) {
       this.state = state;
     }
 
@@ -236,7 +237,7 @@ public class CoreAdminRequest extends So
       }
       
       if (state != null) {
-        params.set( "state", state);
+        params.set(ZkStateReader.STATE_PROP, state.toString());
       }
       
       if (checkLive != null) {

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterStateUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterStateUtil.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterStateUtil.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterStateUtil.java Sat Apr  4 07:02:20 2015
@@ -79,10 +79,9 @@ public class ClusterStateUtil {
               Collection<Replica> replicas = slice.getReplicas();
               for (Replica replica : replicas) {
                 // on a live node?
-                boolean live = clusterState.liveNodesContain(replica
-                    .getNodeName());
-                String state = replica.getStr(ZkStateReader.STATE_PROP);
-                if (!live || !state.equals(ZkStateReader.ACTIVE)) {
+                final boolean live = clusterState.liveNodesContain(replica.getNodeName());
+                final boolean isActive = replica.getState() == Replica.State.ACTIVE;
+                if (!live || !isActive) {
                   // fail
                   success = false;
                 }

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java Sat Apr  4 07:02:20 2015
@@ -17,21 +17,87 @@ package org.apache.solr.common.cloud;
  * limitations under the License.
  */
 
-import org.noggit.JSONUtil;
+import static org.apache.solr.common.cloud.ZkStateReader.*;
 
+import java.util.Locale;
 import java.util.Map;
 
-import static org.apache.solr.common.cloud.ZkStateReader.BASE_URL_PROP;
-import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
+import org.noggit.JSONUtil;
 
 public class Replica extends ZkNodeProps {
+  
+  /**
+   * The replica's state. In general, if the node the replica is hosted on is
+   * not under {@code /live_nodes} in ZK, the replica's state should be
+   * discarded.
+   */
+  public enum State {
+    
+    /**
+     * The replica is ready to receive updates and queries.
+     * <p>
+     * <b>NOTE</b>: when the node the replica is hosted on crashes, the
+     * replica's state may remain ACTIVE in ZK. To determine if the replica is
+     * truly active, you must also verify that its {@link Replica#getNodeName()
+     * node} is under {@code /live_nodes} in ZK (or use
+     * {@link ClusterState#liveNodesContain(String)}).
+     * </p>
+     */
+    ACTIVE,
+    
+    /**
+     * The first state before {@link State#RECOVERING}. A node in this state
+     * should be actively trying to move to {@link State#RECOVERING}.
+     * <p>
+     * <b>NOTE</b>: a replica's state may appear DOWN in ZK also when the node
+     * it's hosted on gracefully shuts down. This is a best effort though, and
+     * should not be relied on.
+     * </p>
+     */
+    DOWN,
+    
+    /**
+     * The node is recovering from the leader. This might involve peer-sync,
+     * full replication or finding out things are already in sync.
+     */
+    RECOVERING,
+    
+    /**
+     * Recovery attempts have not worked, something is not right.
+     * <p>
+     * <b>NOTE</b>: This state doesn't matter if the node is not part of
+     * {@code /live_nodes} in ZK; in that case the node is not part of the
+     * cluster and it's state should be discarded.
+     * </p>
+     */
+    RECOVERY_FAILED;
+    
+    @Override
+    public String toString() {
+      return super.toString().toLowerCase(Locale.ROOT);
+    }
+    
+    /** Converts the state string to a State instance. */
+    public static State getState(String stateStr) {
+      return stateStr == null ? null : State.valueOf(stateStr.toUpperCase(Locale.ROOT));
+    }
+  }
+
   private final String name;
   private final String nodeName;
+  private final State state;
 
   public Replica(String name, Map<String,Object> propMap) {
     super(propMap);
     this.name = name;
-    nodeName = (String)propMap.get(ZkStateReader.NODE_NAME_PROP);
+    this.nodeName = (String) propMap.get(ZkStateReader.NODE_NAME_PROP);
+    if (propMap.get(ZkStateReader.STATE_PROP) != null) {
+      this.state = State.getState((String) propMap.get(ZkStateReader.STATE_PROP));
+    } else {
+      this.state = State.ACTIVE;                         //Default to ACTIVE
+      propMap.put(ZkStateReader.STATE_PROP, state.toString());
+    }
+
   }
 
   public String getName() {
@@ -45,6 +111,11 @@ public class Replica extends ZkNodeProps
   public String getNodeName() {
     return nodeName;
   }
+  
+  /** Returns the {@link State} of this replica. */
+  public State getState() {
+    return state;
+  }
 
   @Override
   public String toString() {

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java Sat Apr  4 07:02:20 2015
@@ -86,12 +86,6 @@ public class ZkStateReader implements Cl
 
   public static final String ROLES = "/roles.json";
 
-  public static final String RECOVERING = "recovering";
-  public static final String RECOVERY_FAILED = "recovery_failed";
-  public static final String ACTIVE = "active";
-  public static final String DOWN = "down";
-  public static final String SYNC = "sync";
-
   public static final String CONFIGS_ZKNODE = "/configs";
   public final static String CONFIGNAME_PROP="configName";
 
@@ -696,18 +690,17 @@ public class ZkStateReader implements Cl
   }
 
 
-  public List<ZkCoreNodeProps> getReplicaProps(String collection,
-      String shardId, String thisCoreNodeName) {
+  public List<ZkCoreNodeProps> getReplicaProps(String collection, String shardId, String thisCoreNodeName) {
     return getReplicaProps(collection, shardId, thisCoreNodeName, null);
   }
   
-  public List<ZkCoreNodeProps> getReplicaProps(String collection,
-      String shardId, String thisCoreNodeName, String mustMatchStateFilter) {
+  public List<ZkCoreNodeProps> getReplicaProps(String collection, String shardId, String thisCoreNodeName,
+      Replica.State mustMatchStateFilter) {
     return getReplicaProps(collection, shardId, thisCoreNodeName, mustMatchStateFilter, null);
   }
   
-  public List<ZkCoreNodeProps> getReplicaProps(String collection,
-      String shardId, String thisCoreNodeName, String mustMatchStateFilter, String mustNotMatchStateFilter) {
+  public List<ZkCoreNodeProps> getReplicaProps(String collection, String shardId, String thisCoreNodeName,
+      Replica.State mustMatchStateFilter, Replica.State mustNotMatchStateFilter) {
     assert thisCoreNodeName != null;
     ClusterState clusterState = this.clusterState;
     if (clusterState == null) {
@@ -733,8 +726,8 @@ public class ZkStateReader implements Cl
       String coreNodeName = entry.getValue().getName();
       
       if (clusterState.liveNodesContain(nodeProps.getNodeName()) && !coreNodeName.equals(thisCoreNodeName)) {
-        if (mustMatchStateFilter == null || mustMatchStateFilter.equals(nodeProps.getState())) {
-          if (mustNotMatchStateFilter == null || !mustNotMatchStateFilter.equals(nodeProps.getState())) {
+        if (mustMatchStateFilter == null || mustMatchStateFilter == Replica.State.getState(nodeProps.getState())) {
+          if (mustNotMatchStateFilter == null || mustNotMatchStateFilter != Replica.State.getState(nodeProps.getState())) {
             nodes.add(nodeProps);
           }
         }

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java Sat Apr  4 07:02:20 2015
@@ -154,11 +154,9 @@ public abstract class AbstractDistribZkT
               + shard.getValue().getStr(ZkStateReader.STATE_PROP)
               + " live:"
               + clusterState.liveNodesContain(shard.getValue().getNodeName()));
-          String state = shard.getValue().getStr(ZkStateReader.STATE_PROP);
-          if ((state.equals(ZkStateReader.RECOVERING) || state
-              .equals(ZkStateReader.SYNC) || state.equals(ZkStateReader.DOWN))
-              && clusterState.liveNodesContain(shard.getValue().getStr(
-              ZkStateReader.NODE_NAME_PROP))) {
+          final Replica.State state = shard.getValue().getState();
+          if ((state == Replica.State.RECOVERING || state == Replica.State.DOWN)
+              && clusterState.liveNodesContain(shard.getValue().getStr(ZkStateReader.NODE_NAME_PROP))) {
             sawLiveRecovering = true;
           }
         }
@@ -199,9 +197,9 @@ public abstract class AbstractDistribZkT
         Map<String,Replica> shards = entry.getValue().getReplicasMap();
         for (Map.Entry<String,Replica> shard : shards.entrySet()) {
 
-          String state = shard.getValue().getStr(ZkStateReader.STATE_PROP);
-          if (!state.equals(ZkStateReader.ACTIVE)) {
-            fail("Not all shards are ACTIVE - found a shard that is: " + state);
+          final Replica.State state = shard.getValue().getState();
+          if (state != Replica.State.ACTIVE) {
+            fail("Not all shards are ACTIVE - found a shard that is: " + state.toString());
           }
         }
       }

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Sat Apr  4 07:02:20 2015
@@ -1079,7 +1079,7 @@ public abstract class AbstractFullDistri
     for (CloudJettyRunner cjetty : solrJetties) {
       ZkNodeProps props = cjetty.info;
       String nodeName = props.getStr(ZkStateReader.NODE_NAME_PROP);
-      boolean active = props.getStr(ZkStateReader.STATE_PROP).equals(ZkStateReader.ACTIVE);
+      boolean active = Replica.State.getState(props.getStr(ZkStateReader.STATE_PROP)) == Replica.State.ACTIVE;
       boolean live = zkStateReader.getClusterState().liveNodesContain(nodeName);
       if (active && live) {
         shardClients.add(cjetty.client.solrClient);
@@ -1169,8 +1169,7 @@ public abstract class AbstractFullDistri
       if (verbose) System.err.println(" live:" + live);
       if (verbose) System.err.println(" num:" + num + "\n");
 
-      boolean active = props.getStr(ZkStateReader.STATE_PROP).equals(
-          ZkStateReader.ACTIVE);
+      boolean active = Replica.State.getState(props.getStr(ZkStateReader.STATE_PROP)) == Replica.State.ACTIVE;
       if (active && live) {
         if (lastNum > -1 && lastNum != num && failMessage == null) {
           failMessage = shard + " is not consistent.  Got " + lastNum + " from " + lastJetty.url + "lastClient"
@@ -1315,8 +1314,7 @@ public abstract class AbstractFullDistri
           CloudJettyRunner cjetty = shardToJetty.get(s).get(i);
           ZkNodeProps props = cjetty.info;
           SolrClient client = cjetty.client.solrClient;
-          boolean active = props.getStr(ZkStateReader.STATE_PROP).equals(
-              ZkStateReader.ACTIVE);
+          boolean active = Replica.State.getState(props.getStr(ZkStateReader.STATE_PROP)) == Replica.State.ACTIVE;
           if (active) {
             SolrQuery query = new SolrQuery("*:*");
             query.set("distrib", false);
@@ -1400,11 +1398,9 @@ public abstract class AbstractFullDistri
       }
       ZkStateReader zkStateReader = cloudClient.getZkStateReader();
       long count = 0;
-      String currentState = cjetty.info.getStr(ZkStateReader.STATE_PROP);
-      if (currentState != null
-          && currentState.equals(ZkStateReader.ACTIVE)
-          && zkStateReader.getClusterState().liveNodesContain(
-              cjetty.info.getStr(ZkStateReader.NODE_NAME_PROP))) {
+      final Replica.State currentState = Replica.State.getState(cjetty.info.getStr(ZkStateReader.STATE_PROP));
+      if (currentState == Replica.State.ACTIVE
+          && zkStateReader.getClusterState().liveNodesContain(cjetty.info.getStr(ZkStateReader.NODE_NAME_PROP))) {
         SolrQuery query = new SolrQuery("*:*");
         query.set("distrib", false);
         count = client.solrClient.query(query).getResults().getNumFound();
@@ -1591,9 +1587,9 @@ public abstract class AbstractFullDistri
       String shardNames = (String) collectionProps.get(SHARDS_PROP);
       numShards = StrUtils.splitSmart(shardNames,',').size();
     }
-    Integer replicationFactor = (Integer) collectionProps.get(REPLICATION_FACTOR);
+    Integer replicationFactor = (Integer) collectionProps.get(ZkStateReader.REPLICATION_FACTOR);
     if(replicationFactor==null){
-      replicationFactor = (Integer) OverseerCollectionProcessor.COLL_PROPS.get(REPLICATION_FACTOR);
+      replicationFactor = (Integer) OverseerCollectionProcessor.COLL_PROPS.get(ZkStateReader.REPLICATION_FACTOR);
     }
 
     if (confSetName != null) {
@@ -1634,9 +1630,9 @@ public abstract class AbstractFullDistri
     return createCollection(collectionInfos, collectionName,
         ZkNodeProps.makeMap(
         NUM_SLICES, numShards,
-        REPLICATION_FACTOR, replicationFactor,
+        ZkStateReader.REPLICATION_FACTOR, replicationFactor,
         CREATE_NODE_SET, createNodeSetStr,
-        MAX_SHARDS_PER_NODE, maxShardsPerNode),
+        ZkStateReader.MAX_SHARDS_PER_NODE, maxShardsPerNode),
         client);
   }
 
@@ -1646,9 +1642,9 @@ public abstract class AbstractFullDistri
     return createCollection(collectionInfos, collectionName,
         ZkNodeProps.makeMap(
         NUM_SLICES, numShards,
-        REPLICATION_FACTOR, replicationFactor,
+        ZkStateReader.REPLICATION_FACTOR, replicationFactor,
         CREATE_NODE_SET, createNodeSetStr,
-        MAX_SHARDS_PER_NODE, maxShardsPerNode),
+        ZkStateReader.MAX_SHARDS_PER_NODE, maxShardsPerNode),
         client, configName);
   }
 
@@ -1861,8 +1857,8 @@ public abstract class AbstractFullDistri
         .getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
 
     Map<String, Object> props = makeMap(
-        REPLICATION_FACTOR, replicationFactor,
-        MAX_SHARDS_PER_NODE, maxShardsPerNode,
+        ZkStateReader.REPLICATION_FACTOR, replicationFactor,
+        ZkStateReader.MAX_SHARDS_PER_NODE, maxShardsPerNode,
         NUM_SLICES, numShards);
     Map<String,List<Integer>> collectionInfos = new HashMap<>();
     createCollection(collectionInfos, collName, props, client);
@@ -1903,9 +1899,8 @@ public abstract class AbstractFullDistri
 
       // ensure all replicas are "active" and identify the non-leader replica
       for (Replica replica : replicas) {
-        String replicaState = replica.getStr(ZkStateReader.STATE_PROP);
-        if (!ZkStateReader.ACTIVE.equals(replicaState)) {
-          log.info("Replica " + replica.getName() + " is currently " + replicaState);
+        if (replica.getState() != Replica.State.ACTIVE) {
+          log.info("Replica {} is currently {}", replica.getName(), replica.getState());
           allReplicasUp = false;
         }
 

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java?rev=1671240&r1=1671239&r2=1671240&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java Sat Apr  4 07:02:20 2015
@@ -21,6 +21,7 @@ import org.apache.lucene.util.LuceneTest
 import org.apache.solr.client.solrj.SolrClient;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.cloud.AbstractFullDistribZkTestBase.CloudJettyRunner;
+import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.common.cloud.ZkNodeProps;
@@ -398,8 +399,7 @@ public class ChaosMonkey {
     return cjetty;
   }
 
-  private int checkIfKillIsLegal(String slice, int numActive)
-      throws KeeperException, InterruptedException {
+  private int checkIfKillIsLegal(String slice, int numActive) throws KeeperException, InterruptedException {
     for (CloudJettyRunner cloudJetty : shardToJetty.get(slice)) {
       
       // get latest cloud state
@@ -413,11 +413,11 @@ public class ChaosMonkey {
         throw new RuntimeException("shard name " + cloudJetty.coreNodeName + " not found in " + theShards.getReplicasMap().keySet());
       }
       
-      String state = props.getStr(ZkStateReader.STATE_PROP);
-      String nodeName = props.getStr(ZkStateReader.NODE_NAME_PROP);
+      final Replica.State state = Replica.State.getState(props.getStr(ZkStateReader.STATE_PROP));
+      final String nodeName = props.getStr(ZkStateReader.NODE_NAME_PROP);
       
       if (cloudJetty.jetty.isRunning()
-          && state.equals(ZkStateReader.ACTIVE)
+          && state == Replica.State.ACTIVE
           && zkStateReader.getClusterState().liveNodesContain(nodeName)) {
         numActive++;
       }



Mime
View raw message