lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thelabd...@apache.org
Subject svn commit: r1626829 - in /lucene/dev/branches/branch_5x/solr: CHANGES.txt core/src/java/org/apache/solr/util/SolrCLI.java
Date Mon, 22 Sep 2014 16:41:51 GMT
Author: thelabdude
Date: Mon Sep 22 16:41:50 2014
New Revision: 1626829

URL: http://svn.apache.org/r1626829
Log:
SOLR-6484: SolrCLI's healthcheck action needs to check live nodes as part of reporting the
status of a replica

Modified:
    lucene/dev/branches/branch_5x/solr/CHANGES.txt
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1626829&r1=1626828&r2=1626829&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Mon Sep 22 16:41:50 2014
@@ -164,6 +164,9 @@ Bug Fixes
 * SOLR-6481: CLUSTERSTATUS should check if the node hosting a replica is live when
   reporting replica status (Timothy Potter)
 
+* SOLR-6484: SolrCLI's healthcheck action needs to check live nodes as part of reporting
+  the status of a replica (Timothy Potter)
+
 
 Other Changes
 ----------------------

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java?rev=1626829&r1=1626828&r2=1626829&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/util/SolrCLI.java Mon
Sep 22 16:41:50 2014
@@ -56,6 +56,7 @@ import org.apache.solr.client.solrj.impl
 import org.apache.solr.client.solrj.impl.HttpSolrServer;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.ClusterState;
 import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.ZkCoreNodeProps;
@@ -869,7 +870,10 @@ public class SolrCLI {
       log.info("Running healthcheck for "+collection);
       
       ZkStateReader zkStateReader = cloudSolrServer.getZkStateReader();
-      Collection<Slice> slices = zkStateReader.getClusterState().getSlices(collection);
+
+      ClusterState clusterState = zkStateReader.getClusterState();
+      Set<String> liveNodes = clusterState.getLiveNodes();
+      Collection<Slice> slices = clusterState.getSlices(collection);
       if (slices == null)
         throw new IllegalArgumentException("Collection "+collection+" not found!");
       
@@ -908,39 +912,45 @@ public class SolrCLI {
           ZkCoreNodeProps replicaCoreProps = new ZkCoreNodeProps(r);
           String coreUrl = replicaCoreProps.getCoreUrl();
           boolean isLeader = coreUrl.equals(leaderUrl);
-          
-          // query this replica directly to get doc count and assess health
-          HttpSolrServer solr = new HttpSolrServer(coreUrl);
-          String solrUrl = solr.getBaseURL();
-          q = new SolrQuery("*:*");
-          q.setRows(0);
-          q.set("distrib", "false");          
-          try {
-            qr = solr.query(q);
-            numDocs = qr.getResults().getNumFound();
-            
-            int lastSlash = solrUrl.lastIndexOf('/');            
-            String systemInfoUrl = solrUrl.substring(0,lastSlash)+"/admin/info/system";
-            Map<String,Object> info = getJson(solr.getHttpClient(), systemInfoUrl,
2);
-            uptime = uptime(asLong("/jvm/jmx/upTimeMS", info));            
-            String usedMemory = asString("/jvm/memory/used", info);
-            String totalMemory = asString("/jvm/memory/total", info);
-            memory = usedMemory+" of "+totalMemory;
-            
-            // if we get here, we can trust the state
-            replicaStatus = replicaCoreProps.getState();                                
                                     
-          } catch (Exception exc) {
-            log.error("ERROR: " + exc + " when trying to reach: " + solrUrl);
-
-            if (checkCommunicationError(exc)) {
-              replicaStatus = "down";
-            } else {
-              replicaStatus = "error: "+exc;
-            }            
-          } finally {
-            solr.shutdown();
+
+          // if replica's node is not live, it's status is DOWN
+          String nodeName = replicaCoreProps.getNodeName();
+          if (nodeName == null || !liveNodes.contains(nodeName)) {
+            replicaStatus = ZkStateReader.DOWN;
+          } else {
+            // query this replica directly to get doc count and assess health
+            HttpSolrServer solr = new HttpSolrServer(coreUrl);
+            String solrUrl = solr.getBaseURL();
+            q = new SolrQuery("*:*");
+            q.setRows(0);
+            q.set("distrib", "false");
+            try {
+              qr = solr.query(q);
+              numDocs = qr.getResults().getNumFound();
+
+              int lastSlash = solrUrl.lastIndexOf('/');
+              String systemInfoUrl = solrUrl.substring(0,lastSlash)+"/admin/info/system";
+              Map<String,Object> info = getJson(solr.getHttpClient(), systemInfoUrl,
2);
+              uptime = uptime(asLong("/jvm/jmx/upTimeMS", info));
+              String usedMemory = asString("/jvm/memory/used", info);
+              String totalMemory = asString("/jvm/memory/total", info);
+              memory = usedMemory+" of "+totalMemory;
+
+              // if we get here, we can trust the state
+              replicaStatus = replicaCoreProps.getState();
+            } catch (Exception exc) {
+              log.error("ERROR: " + exc + " when trying to reach: " + solrUrl);
+
+              if (checkCommunicationError(exc)) {
+                replicaStatus = "down";
+              } else {
+                replicaStatus = "error: "+exc;
+              }
+            } finally {
+              solr.shutdown();
+            }
           }
-          
+
           replicaList.add(new ReplicaHealth(shardName, r.getName(), coreUrl, 
               replicaStatus, numDocs, isLeader, uptime, memory));          
         }



Mime
View raw message