hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject hbase git commit: HBASE-15066 Small improvements to Canary tool
Date Wed, 10 Feb 2016 07:29:01 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 96e86af8f -> 2c239e058


HBASE-15066 Small improvements to Canary tool

Conflicts:
	hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java


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

Branch: refs/heads/0.98
Commit: 2c239e05895ee708c71f15d995b92b661a6b38f7
Parents: 96e86af
Author: Enis Soztutar <enis@apache.org>
Authored: Wed Jan 6 02:47:19 2016 -0800
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Tue Feb 9 23:27:44 2016 -0800

----------------------------------------------------------------------
 bin/hbase                                       |  4 ++
 .../org/apache/hadoop/hbase/tool/Canary.java    | 68 ++++++++++++++++----
 src/main/asciidoc/_chapters/ops_mgt.adoc        | 20 +++---
 3 files changed, 70 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2c239e05/bin/hbase
----------------------------------------------------------------------
diff --git a/bin/hbase b/bin/hbase
index 81c9165..0041a47 100755
--- a/bin/hbase
+++ b/bin/hbase
@@ -98,6 +98,7 @@ if [ $# = 0 ]; then
   echo "  mapredcp        Dump CLASSPATH entries required by mapreduce"
   echo "  pe              Run PerformanceEvaluation"
   echo "  ltt             Run LoadTestTool"
+  echo "  canary          Run the Canary tool"
   echo "  version         Print the version"
   echo "  CLASSNAME       Run the class named CLASSNAME"
   exit 1
@@ -361,6 +362,9 @@ elif [ "$COMMAND" = "pe" ] ; then
 elif [ "$COMMAND" = "ltt" ] ; then
   CLASS='org.apache.hadoop.hbase.util.LoadTestTool'
   HBASE_OPTS="$HBASE_OPTS $HBASE_LTT_OPTS"
+elif [ "$COMMAND" = "canary" ] ; then
+  CLASS='org.apache.hadoop.hbase.tool.Canary'
+  HBASE_OPTS="$HBASE_OPTS $HBASE_CANARY_OPTS"
 elif [ "$COMMAND" = "version" ] ; then
   CLASS='org.apache.hadoop.hbase.util.VersionInfo'
 else

http://git-wip-us.apache.org/repos/asf/hbase/blob/2c239e05/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
index 339ce43..8ca4ff5 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
@@ -194,6 +194,10 @@ public final class Canary implements Tool {
       HTableInterface table = null;
       HTableDescriptor tableDesc = null;
       try {
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(String.format("reading table descriptor for table %s",
+            region.getTable()));
+        }
         table = connection.getTable(region.getTable());
         tableDesc = table.getTableDescriptor();
       } catch (IOException e) {
@@ -230,20 +234,24 @@ public final class Canary implements Tool {
           scan.setFilter(new FirstKeyOnlyFilter());
           scan.addFamily(column.getName());
           scan.setMaxResultSize(1L);
+          scan.setSmall(true);
         }
 
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(String.format("reading from table %s region %s column family %s and key
%s",
+            tableDesc.getTableName(), region.getRegionNameAsString(), column.getNameAsString(),
+            Bytes.toStringBinary(startKey)));
+        }
         try {
+          stopWatch.start();
           if (startKey.length > 0) {
-            stopWatch.start();
             table.get(get);
-            stopWatch.stop();
-            sink.publishReadTiming(region, column, stopWatch.getTime());
           } else {
-            stopWatch.start();
             rs = table.getScanner(scan);
-            stopWatch.stop();
-            sink.publishReadTiming(region, column, stopWatch.getTime());
+            rs.next();
           }
+          stopWatch.stop();
+          sink.publishReadTiming(region, column, stopWatch.getTime());
         } catch (Exception e) {
           sink.publishReadFailure(region, column, e);
         } finally {
@@ -284,6 +292,12 @@ public final class Canary implements Tool {
           byte[] value = new byte[writeValueSize];
           Bytes.random(value);
           put.add(column.getName(), HConstants.EMPTY_BYTE_ARRAY, value);
+
+          if (LOG.isDebugEnabled()) {
+            LOG.debug(String.format("writing to table %s region %s column family %s and key
%s",
+              tableDesc.getTableName(), region.getRegionNameAsString(), column.getNameAsString(),
+              Bytes.toStringBinary(rowToCheck)));
+          }
           try {
             long startTime = System.currentTimeMillis();
             table.put(put);
@@ -333,6 +347,11 @@ public final class Canary implements Tool {
         table = connection.getTable(tableName);
         startKey = region.getStartKey();
         // Can't do a get on empty start row so do a Scan of first element if any instead.
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(String.format("reading from region server %s table %s region %s and key
%s",
+            serverName, region.getTable(), region.getRegionNameAsString(),
+            Bytes.toStringBinary(startKey)));
+        }
         if (startKey.length > 0) {
           get = new Get(startKey);
           get.setCacheBlocks(false);
@@ -346,8 +365,10 @@ public final class Canary implements Tool {
           scan.setFilter(new FirstKeyOnlyFilter());
           scan.setCaching(1);
           scan.setMaxResultSize(1L);
+          scan.setSmall(true);
           stopWatch.start();
           ResultScanner s = table.getScanner(scan);
+          s.next();
           s.close();
           stopWatch.stop();
         }
@@ -591,8 +612,8 @@ public final class Canary implements Tool {
     System.err.println("      which means to enable regionserver mode");
     System.err.println("   -daemon        Continuous check at defined intervals.");
     System.err.println("   -interval <N>  Interval between checks (sec)");
-    System.err.println("   -e             Use region/regionserver as regular expression");
-    System.err.println("      which means the region/regionserver is regular expression pattern");
+    System.err.println("   -e             Use table/regionserver as regular expression");
+    System.err.println("      which means the table/regionserver is regular expression pattern");
     System.err.println("   -f <B>         stop whole program if first error occurs,"
+
         " default is true");
     System.err.println("   -t <N>         timeout for a check, default is 600000 (milisecs)");
@@ -671,6 +692,7 @@ public final class Canary implements Tool {
       this.executor = executor;
     }
 
+    @Override
     public abstract void run();
 
     protected boolean initAdmin() {
@@ -773,11 +795,17 @@ public final class Canary implements Tool {
         HTableDescriptor[] tds = null;
         Set<String> tmpTables = new TreeSet<String>();
         try {
+          if (LOG.isDebugEnabled()) {
+            LOG.debug(String.format("reading list of tables"));
+          }
+          tds = this.admin.listTables(pattern);
+          if (tds == null) {
+            tds = new HTableDescriptor[0];
+          }
           for (String monitorTarget : monitorTargets) {
             pattern = Pattern.compile(monitorTarget);
-            tds = this.admin.listTables(pattern);
-            if (tds != null) {
-              for (HTableDescriptor td : tds) {
+            for (HTableDescriptor td : tds) {
+              if (pattern.matcher(td.getNameAsString()).matches()) {
                 tmpTables.add(td.getNameAsString());
               }
             }
@@ -806,6 +834,9 @@ public final class Canary implements Tool {
      * canary entry point to monitor all the tables.
      */
     private List<Future<Void>> sniff(TaskType taskType) throws Exception {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug(String.format("reading list of tables"));
+      }
       List<Future<Void>> taskFutures = new LinkedList<Future<Void>>();
       for (HTableDescriptor table : admin.listTables()) {
         if (admin.isTableEnabled(table.getTableName())
@@ -853,7 +884,7 @@ public final class Canary implements Tool {
       int numberOfRegions = (int)(numberOfServers * regionsLowerLimit);
       LOG.info("Number of live regionservers: " + numberOfServers + ", "
           + "pre-splitting the canary table into " + numberOfRegions + " regions "
-          + "(current  lower limi of regions per server is " + regionsLowerLimit
+          + "(current lower limit of regions per server is " + regionsLowerLimit
           + " and you can change it by config: "
           + HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY + " )");
       HTableDescriptor desc = new HTableDescriptor(writeTableName);
@@ -887,6 +918,10 @@ public final class Canary implements Tool {
    */
   private static List<Future<Void>> sniff(final HConnection connection, final
Sink sink,
     String tableName, ExecutorService executor, TaskType taskType) throws Exception {
+    if (LOG.isDebugEnabled()) {
+      LOG.debug(String.format("checking table is enabled and getting table descriptor for
table %s",
+        tableName));
+    }
     HBaseAdmin admin = new HBaseAdmin(connection);
     try {
       if (admin.isTableEnabled(TableName.valueOf(tableName))) {
@@ -906,6 +941,9 @@ public final class Canary implements Tool {
    */
   private static List<Future<Void>> sniff(final HConnection connection, final
Sink sink,
       TableName tableName, ExecutorService executor, TaskType taskType) throws Exception
{
+    if (LOG.isDebugEnabled()) {
+      LOG.debug(String.format("reading list of regions for table %s", tableName));
+    }
     HTableInterface table = null;
     try {
       table = connection.getTable(tableName);
@@ -1007,6 +1045,9 @@ public final class Canary implements Tool {
       List<String> foundTableNames = new ArrayList<String>();
       TableName[] tableNames = null;
 
+      if (LOG.isDebugEnabled()) {
+        LOG.debug(String.format("reading list of tables"));
+      }
       try {
         tableNames = this.admin.listTableNames();
       } catch (IOException e) {
@@ -1068,6 +1109,9 @@ public final class Canary implements Tool {
       Map<String, List<HRegionInfo>> rsAndRMap = new HashMap<String, List<HRegionInfo>>();
       HTableInterface table = null;
       try {
+        if (LOG.isDebugEnabled()) {
+          LOG.debug(String.format("reading list of tables and locations"));
+        }
         HTableDescriptor[] tableDescs = this.admin.listTables();
         List<HRegionInfo> regions = null;
         for (HTableDescriptor tableDesc : tableDescs) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/2c239e05/src/main/asciidoc/_chapters/ops_mgt.adoc
----------------------------------------------------------------------
diff --git a/src/main/asciidoc/_chapters/ops_mgt.adoc b/src/main/asciidoc/_chapters/ops_mgt.adoc
index 57e377d..7089a16 100644
--- a/src/main/asciidoc/_chapters/ops_mgt.adoc
+++ b/src/main/asciidoc/_chapters/ops_mgt.adoc
@@ -79,7 +79,7 @@ There is a Canary class can help users to canary-test the HBase cluster
status,
 To see the usage, use the `--help` parameter.
 
 ----
-$ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -help
+$ ${HBASE_HOME}/bin/hbase canary -help
 
 Usage: bin/hbase org.apache.hadoop.hbase.tool.Canary [opts] [table1 [table2]...] | [regionserver1
[regionserver2]..]
  where [opts] are:
@@ -127,7 +127,7 @@ Following are some examples based on the previous given case.
 ==== Canary test for every column family (store) of every region of every table
 
 ----
-$ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary
+$ ${HBASE_HOME}/bin/hbase canary
 
 3/12/09 03:26:32 INFO tool.Canary: read from region test-01,,1386230156732.0e3c7d77ffb6361ea1b996ac1042ca9a.
column family cf1 in 2ms
 13/12/09 03:26:32 INFO tool.Canary: read from region test-01,,1386230156732.0e3c7d77ffb6361ea1b996ac1042ca9a.
column family cf2 in 2ms
@@ -148,7 +148,7 @@ This is a default behavior of the this tool does.
 You can also test one or more specific tables.
 
 ----
-$ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary test-01 test-02
+$ ${HBASE_HOME}/bin/hbase canary test-01 test-02
 ----
 
 ==== Canary test with RegionServer granularity
@@ -156,7 +156,7 @@ $ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary test-01
test-02
 This will pick one small piece of data from each RegionServer, and can also put your RegionServer
name as input options for canary-test specific RegionServer.
 
 ----
-$ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -regionserver
+$ ${HBASE_HOME}/bin/hbase canary -regionserver
 
 13/12/09 06:05:17 INFO tool.Canary: Read from table:test-01 on region server:rs2 in 72ms
 13/12/09 06:05:17 INFO tool.Canary: Read from table:test-02 on region server:rs3 in 34ms
@@ -168,7 +168,7 @@ $ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -regionserver
 This will test both table test-01 and test-02.
 
 ----
-$ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -e test-0[1-2]
+$ ${HBASE_HOME}/bin/hbase canary -e test-0[1-2]
 ----
 
 ==== Run canary test as daemon mode
@@ -177,13 +177,13 @@ Run repeatedly with interval defined in option `-interval` whose default
value i
 This daemon will stop itself and return non-zero error code if any error occurs, due to the
default value of option -f is true.
 
 ----
-$ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -daemon
+$ ${HBASE_HOME}/bin/hbase canary -daemon
 ----
 
 Run repeatedly with internal 5 seconds and will not stop itself even if errors occur in the
test.
 
 ----
-$ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -daemon -interval 50000 -f
false
+$ ${HBASE_HOME}/bin/hbase canary -daemon -interval 50000 -f false
 ----
 
 ==== Force timeout if canary test stuck
@@ -193,7 +193,7 @@ Because of this we provide a timeout option to kill the canary test and
return a
 This run sets the timeout value to 60 seconds, the default value is 600 seconds.
 
 ----
-$ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -t 600000
+$ ${HBASE_HOME}/bin/hbase canary -t 600000
 ----
 
 ==== Enable write sniffing in canary
@@ -204,12 +204,12 @@ When the write sniffing is enabled, the canary tool will create a hbase
table an
 regions of the table distributed on all region servers. In each sniffing period, the canary
will
 try to put data to these regions to check the write availability of each region server.
 ----
-$ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -writeSniffing
+$ ${HBASE_HOME}/bin/hbase canary -writeSniffing
 ----
 
 The default write table is `hbase:canary` and can be specified by the option `-writeTable`.
 ----
-$ ${HBASE_HOME}/bin/hbase org.apache.hadoop.hbase.tool.Canary -writeSniffing -writeTable
ns:canary
+$ ${HBASE_HOME}/bin/hbase canary -writeSniffing -writeTable ns:canary
 ----
 
 The default value size of each put is 10 bytes and you can set it by the config key:


Mime
View raw message