incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject git commit: AMBARI-2610. HBase ha status sometimes shows as passive even though hbase master is running. (smohanty)
Date Wed, 10 Jul 2013 17:50:08 GMT
Updated Branches:
  refs/heads/trunk f18c274dd -> 635ff2af1


AMBARI-2610. HBase ha status sometimes shows as passive even though hbase master is running.
(smohanty)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/635ff2af
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/635ff2af
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/635ff2af

Branch: refs/heads/trunk
Commit: 635ff2af1772579d8c1cf365f1e46471e385ce48
Parents: f18c274
Author: Sumit Mohanty <smohanty@hortonworks.com>
Authored: Wed Jul 10 10:49:59 2013 -0700
Committer: Sumit Mohanty <smohanty@hortonworks.com>
Committed: Wed Jul 10 10:49:59 2013 -0700

----------------------------------------------------------------------
 .../svccomphost/HBaseMasterPortScanner.java     | 28 +++++++++++++-------
 .../svccomphost/HBaseMasterPortScannerTest.java |  2 ++
 2 files changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/635ff2af/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/HBaseMasterPortScanner.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/HBaseMasterPortScanner.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/HBaseMasterPortScanner.java
index 162713f..cdcd800 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/HBaseMasterPortScanner.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/HBaseMasterPortScanner.java
@@ -34,6 +34,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.State;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -275,20 +276,29 @@ public class HBaseMasterPortScanner implements Runnable {
     LOG.info("Set result of HBASE_MASTER scan");
   }
   
-  private boolean validateScanResults(Map<ServiceComponentHost, Boolean> scanResuls){
+  private boolean validateScanResults(Map<ServiceComponentHost, Boolean> scanResuls)
{
     boolean res = false;
     int activeMasters = 0;
+    int startedComponents = 0;
     for (Map.Entry<ServiceComponentHost, Boolean> entry : scanResuls.entrySet()) {
-      activeMasters += (entry.getValue()) ? 1 : 0;
+      activeMasters += (entry.getValue() && entry.getKey().getState() == State.STARTED)
? 1 : 0;
+      startedComponents += (entry.getKey().getState() == State.STARTED) ? 1 : 0;
     }
-    if(activeMasters == 0 || activeMasters > 1) {
-      res = false;
+    if (startedComponents > 0) {
+      if (activeMasters == 0 || activeMasters > 1) {
+        res = false;
+      } else {
+        res = true;
+      }
+    } else {
+      if (activeMasters > 0) {
+        res = false;
+      } else {
+        res = true;
+      }
     }
-    else {
-      res = true;
-    } 
-    LOG.info("Results of HBASE_MASTER scan are "+ ((res) ? "valid" : "invalid"));
-    return res;  
+    LOG.info("Results of HBASE_MASTER scan are " + ((res) ? "valid" : "invalid"));
+    return res;
   }
   
   protected boolean scan(String hostname) {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/635ff2af/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/HBaseMasterPortScannerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/HBaseMasterPortScannerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/HBaseMasterPortScannerTest.java
index 8d83d25..a88b037 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/HBaseMasterPortScannerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/HBaseMasterPortScannerTest.java
@@ -43,6 +43,7 @@ import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.ServiceFactory;
 import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.State;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -121,6 +122,7 @@ public class HBaseMasterPortScannerTest {
       service.getServiceComponent(HBASE_MASTER).addServiceComponentHost(hostname).persist();
       if (hostname.equals("127.0.0.1")) {
         serviceComponentHost = service.getServiceComponent(HBASE_MASTER).getServiceComponentHost(hostname);
+        serviceComponentHost.setState(State.STARTED);
       }
     }
     when(timerMock.purge()).thenReturn(0);


Mime
View raw message