hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecl...@apache.org
Subject hbase git commit: HBASE-12680 Move signal related code from ClusterManager to HBaseClusterManager and change ClusterManager to an interface
Date Mon, 15 Dec 2014 17:12:03 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 f0afcd2cc -> 80c71e259


HBASE-12680 Move signal related code from ClusterManager to HBaseClusterManager and change
ClusterManager to an interface

Summary: The reason of this change is to make us write implementation of ClusterManager not
using ssh/unix signals.

Test Plan: The compilation is OK.

Reviewers: eclark, manukranthk

Differential Revision: https://reviews.facebook.net/D30201

Signed-off-by: Elliott Clark <eclark@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/80c71e25
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/80c71e25
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/80c71e25

Branch: refs/heads/branch-1
Commit: 80c71e259c801f7518670270d2a79f20b988ea9b
Parents: f0afcd2
Author: Yi Deng <daviddengcn@gmail.com>
Authored: Fri Dec 12 14:08:48 2014 -0800
Committer: Elliott Clark <eclark@apache.org>
Committed: Mon Dec 15 09:09:36 2014 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/ClusterManager.java | 49 ++++++--------------
 .../hadoop/hbase/HBaseClusterManager.java       | 28 +++++++++--
 2 files changed, 37 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/80c71e25/hbase-it/src/test/java/org/apache/hadoop/hbase/ClusterManager.java
----------------------------------------------------------------------
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/ClusterManager.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/ClusterManager.java
index 836fbe8..dd96e43 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/ClusterManager.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/ClusterManager.java
@@ -20,10 +20,8 @@ package org.apache.hadoop.hbase;
 
 import java.io.IOException;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configurable;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
-import org.apache.hadoop.conf.Configured;
 
 
 /**
@@ -32,16 +30,7 @@ import org.apache.hadoop.conf.Configured;
  * functionality for carrying out deployment-specific tasks.
  */
 @InterfaceAudience.Private
-public abstract class ClusterManager extends Configured {
-  protected static final Log LOG = LogFactory.getLog(ClusterManager.class);
-
-  private static final String SIGKILL = "SIGKILL";
-  private static final String SIGSTOP = "SIGSTOP";
-  private static final String SIGCONT = "SIGCONT";
-
-  public ClusterManager() {
-  }
-
+interface ClusterManager extends Configurable {
   /**
    * Type of the service daemon
    */
@@ -72,50 +61,38 @@ public abstract class ClusterManager extends Configured {
   /**
    * Start the service on the given host
    */
-  public abstract void start(ServiceType service, String hostname) throws IOException;
+  void start(ServiceType service, String hostname) throws IOException;
 
   /**
    * Stop the service on the given host
    */
-  public abstract void stop(ServiceType service, String hostname) throws IOException;
-
-  /**
-   * Restart the service on the given host
-   */
-  public abstract void restart(ServiceType service, String hostname) throws IOException;
+  void stop(ServiceType service, String hostname) throws IOException;
 
   /**
-   * Send the given posix signal to the service
+   * Restarts the service on the given host
    */
-  public abstract void signal(ServiceType service, String signal,
-      String hostname) throws IOException;
+  void restart(ServiceType service, String hostname) throws IOException;
 
   /**
-   * Kill the service running on given host
+   * Kills the service running on the given host
    */
-  public void kill(ServiceType service, String hostname) throws IOException {
-    signal(service, SIGKILL, hostname);
-  }
+  void kill(ServiceType service, String hostname) throws IOException;
 
   /**
-   * Suspend the service running on given host
+   * Suspends the service running on the given host
    */
-  public void suspend(ServiceType service, String hostname) throws IOException {
-    signal(service, SIGSTOP, hostname);
-  }
+  void suspend(ServiceType service, String hostname) throws IOException;
 
   /**
-   * Resume the services running on given hosts
+   * Resumes the services running on the given host
    */
-  public void resume(ServiceType service, String hostname) throws IOException {
-    signal(service, SIGCONT, hostname);
-  }
+  void resume(ServiceType service, String hostname) throws IOException;
 
   /**
    * Returns whether the service is running on the remote host. This only checks whether
the
    * service still has a pid.
    */
-  public abstract boolean isRunning(ServiceType service, String hostname) throws IOException;
+  boolean isRunning(ServiceType service, String hostname) throws IOException;
 
   /* TODO: further API ideas:
    *

http://git-wip-us.apache.org/repos/asf/hbase/blob/80c71e25/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
----------------------------------------------------------------------
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
index 8203088..e396178 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/HBaseClusterManager.java
@@ -24,7 +24,10 @@ import java.util.Map;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
 import org.apache.hadoop.hbase.HBaseClusterManager.CommandProvider.Operation;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.util.RetryCounter;
@@ -37,10 +40,15 @@ import org.apache.hadoop.util.Shell;
  * to manage the cluster. Assumes Unix-like commands are available like 'ps',
  * 'kill', etc. Also assumes the user running the test has enough "power" to start &
stop
  * servers on the remote machines (for example, the test user could be the same user as the
- * user the daemon isrunning as)
+ * user the daemon is running as)
  */
 @InterfaceAudience.Private
-public class HBaseClusterManager extends ClusterManager {
+public class HBaseClusterManager extends Configured implements ClusterManager {
+  private static final String SIGKILL = "SIGKILL";
+  private static final String SIGSTOP = "SIGSTOP";
+  private static final String SIGCONT = "SIGCONT";
+
+  protected static final Log LOG = LogFactory.getLog(HBaseClusterManager.class);
   private String sshUserName;
   private String sshOptions;
 
@@ -181,7 +189,6 @@ public class HBaseClusterManager extends ClusterManager {
   }
 
   public HBaseClusterManager() {
-    super();
   }
 
   protected CommandProvider getCommandProvider(ServiceType service) {
@@ -263,7 +270,6 @@ public class HBaseClusterManager extends ClusterManager {
     exec(hostname, service, Operation.RESTART);
   }
 
-  @Override
   public void signal(ServiceType service, String signal, String hostname) throws IOException
{
     execWithRetries(hostname, getCommandProvider(service).signalCommand(service, signal));
   }
@@ -275,4 +281,18 @@ public class HBaseClusterManager extends ClusterManager {
     return ret.length() > 0;
   }
 
+  @Override
+  public void kill(ServiceType service, String hostname) throws IOException {
+    signal(service, SIGKILL, hostname);
+  }
+
+  @Override
+  public void suspend(ServiceType service, String hostname) throws IOException {
+    signal(service, SIGSTOP, hostname);
+  }
+
+  @Override
+  public void resume(ServiceType service, String hostname) throws IOException {
+    signal(service, SIGCONT, hostname);
+  }
 }


Mime
View raw message