hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [hbase-site] branch asf-site updated: Published site at c58e80fbe6db6426e652ec363149b92f9e33fbb0.
Date Sat, 02 Nov 2019 14:43:38 GMT
This is an automated email from the ASF dual-hosted git repository.

git-site-role pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/hbase-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 7b036a3  Published site at c58e80fbe6db6426e652ec363149b92f9e33fbb0.
7b036a3 is described below

commit 7b036a31382975590e8d619f7fe04c910d746c9b
Author: jenkins <builds@apache.org>
AuthorDate: Sat Nov 2 14:43:30 2019 +0000

    Published site at c58e80fbe6db6426e652ec363149b92f9e33fbb0.
---
 acid-semantics.html                                |    2 +-
 apache_hbase_reference_guide.pdf                   |    4 +-
 book.html                                          |    2 +-
 bulk-loads.html                                    |    2 +-
 checkstyle-aggregate.html                          |   28 +-
 coc.html                                           |    2 +-
 dependencies.html                                  |    2 +-
 dependency-convergence.html                        |    2 +-
 dependency-info.html                               |    2 +-
 dependency-management.html                         |    2 +-
 devapidocs/constant-values.html                    |    4 +-
 .../hadoop/hbase/tool/CanaryTool.Monitor.html      |   38 +-
 .../hbase/tool/CanaryTool.RegionMonitor.html       |   40 +-
 .../hbase/tool/CanaryTool.RegionServerMonitor.html |   20 +-
 .../hbase/tool/CanaryTool.RegionServerTask.html    |   16 +-
 .../hadoop/hbase/tool/CanaryTool.RegionTask.html   |    2 +-
 .../hbase/tool/CanaryTool.RegionTaskResult.html    |   52 +-
 .../hbase/tool/CanaryTool.ZookeeperMonitor.html    |   14 +-
 .../org/apache/hadoop/hbase/tool/CanaryTool.html   |   92 +-
 .../src-html/org/apache/hadoop/hbase/Version.html  |    4 +-
 .../hadoop/hbase/tool/CanaryTool.Monitor.html      | 2773 ++++++++++----------
 .../hbase/tool/CanaryTool.RegionMonitor.html       | 2773 ++++++++++----------
 .../hbase/tool/CanaryTool.RegionServerMonitor.html | 2773 ++++++++++----------
 .../tool/CanaryTool.RegionServerStdOutSink.html    | 2773 ++++++++++----------
 .../hbase/tool/CanaryTool.RegionServerTask.html    | 2773 ++++++++++----------
 .../hbase/tool/CanaryTool.RegionStdOutSink.html    | 2773 ++++++++++----------
 .../hbase/tool/CanaryTool.RegionTask.TaskType.html | 2773 ++++++++++----------
 .../hadoop/hbase/tool/CanaryTool.RegionTask.html   | 2773 ++++++++++----------
 .../hbase/tool/CanaryTool.RegionTaskResult.html    | 2773 ++++++++++----------
 .../apache/hadoop/hbase/tool/CanaryTool.Sink.html  | 2773 ++++++++++----------
 .../hadoop/hbase/tool/CanaryTool.StdOutSink.html   | 2773 ++++++++++----------
 .../hbase/tool/CanaryTool.ZookeeperMonitor.html    | 2773 ++++++++++----------
 .../hbase/tool/CanaryTool.ZookeeperStdOutSink.html | 2773 ++++++++++----------
 .../hbase/tool/CanaryTool.ZookeeperTask.html       | 2773 ++++++++++----------
 .../org/apache/hadoop/hbase/tool/CanaryTool.html   | 2773 ++++++++++----------
 downloads.html                                     |    2 +-
 export_control.html                                |    2 +-
 index.html                                         |    2 +-
 issue-tracking.html                                |    2 +-
 mail-lists.html                                    |    2 +-
 metrics.html                                       |    2 +-
 old_news.html                                      |    2 +-
 plugin-management.html                             |    2 +-
 plugins.html                                       |    2 +-
 poweredbyhbase.html                                |    2 +-
 project-info.html                                  |    2 +-
 project-reports.html                               |    2 +-
 project-summary.html                               |    2 +-
 pseudo-distributed.html                            |    2 +-
 replication.html                                   |    2 +-
 resources.html                                     |    2 +-
 source-repository.html                             |    2 +-
 sponsors.html                                      |    2 +-
 supportingprojects.html                            |    2 +-
 team-list.html                                     |    2 +-
 55 files changed, 21050 insertions(+), 20915 deletions(-)

diff --git a/acid-semantics.html b/acid-semantics.html
index 8421fc8..18d3e25 100644
--- a/acid-semantics.html
+++ b/acid-semantics.html
@@ -443,7 +443,7 @@
         <div class="row">
             <p>Copyright &copy;2007&#x2013;2019
 <a href="https://www.apache.org/">The Apache Software Foundation</a>.
-All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-01</li>
+All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-02</li>
 </p>
         </div>
         <p id="poweredBy" class="pull-right"><a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
diff --git a/apache_hbase_reference_guide.pdf b/apache_hbase_reference_guide.pdf
index 7b2f665..ab246e3 100644
--- a/apache_hbase_reference_guide.pdf
+++ b/apache_hbase_reference_guide.pdf
@@ -5,8 +5,8 @@
 /Author (Apache HBase Team)
 /Creator (Asciidoctor PDF 1.5.0.alpha.15, based on Prawn 2.2.2)
 /Producer (Apache HBase Team)
-/ModDate (D:20191101144128+00'00')
-/CreationDate (D:20191101144128+00'00')
+/ModDate (D:20191102144025+00'00')
+/CreationDate (D:20191102144025+00'00')
 >>
 endobj
 2 0 obj
diff --git a/book.html b/book.html
index f22e07d..f9ed6e2 100644
--- a/book.html
+++ b/book.html
@@ -43890,7 +43890,7 @@ org/apache/hadoop/hbase/security/access/AccessControlClient.revoke:(Lorg/apache/
 <div id="footer">
 <div id="footer-text">
 Version 3.0.0-SNAPSHOT<br>
-Last updated 2019-11-01 14:30:06 UTC
+Last updated 2019-11-02 14:30:00 UTC
 </div>
 </div>
 </body>
diff --git a/bulk-loads.html b/bulk-loads.html
index 362ddc4..496701d 100644
--- a/bulk-loads.html
+++ b/bulk-loads.html
@@ -148,7 +148,7 @@
         <div class="row">
             <p>Copyright &copy;2007&#x2013;2019
 <a href="https://www.apache.org/">The Apache Software Foundation</a>.
-All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-01</li>
+All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-02</li>
 </p>
         </div>
         <p id="poweredBy" class="pull-right"><a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
diff --git a/checkstyle-aggregate.html b/checkstyle-aggregate.html
index e9828b9..cae6d4e 100644
--- a/checkstyle-aggregate.html
+++ b/checkstyle-aggregate.html
@@ -82991,79 +82991,79 @@
 <td>whitespace</td>
 <td>ParenPad</td>
 <td>')' is preceded with whitespace.</td>
-<td>549</td></tr>
+<td>550</td></tr>
 <tr class="b">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>sizes</td>
 <td>MethodLength</td>
 <td>Method length is 155 lines (max allowed is 150).</td>
-<td>741</td></tr>
+<td>742</td></tr>
 <tr class="a">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>blocks</td>
 <td>NeedBraces</td>
 <td>'if' construct must use '{}'s.</td>
-<td>975</td></tr>
+<td>976</td></tr>
 <tr class="b">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>sizes</td>
 <td>LineLength</td>
 <td>Line is longer than 100 characters (found 108).</td>
-<td>1244</td></tr>
+<td>1245</td></tr>
 <tr class="a">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>blocks</td>
 <td>NeedBraces</td>
 <td>'if' construct must use '{}'s.</td>
-<td>1254</td></tr>
+<td>1255</td></tr>
 <tr class="b">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>blocks</td>
 <td>NeedBraces</td>
 <td>'if' construct must use '{}'s.</td>
-<td>1259</td></tr>
+<td>1260</td></tr>
 <tr class="a">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>sizes</td>
 <td>LineLength</td>
 <td>Line is longer than 100 characters (found 103).</td>
-<td>1385</td></tr>
+<td>1386</td></tr>
 <tr class="b">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>sizes</td>
 <td>LineLength</td>
 <td>Line is longer than 100 characters (found 104).</td>
-<td>1418</td></tr>
+<td>1419</td></tr>
 <tr class="a">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>sizes</td>
 <td>LineLength</td>
 <td>Line is longer than 100 characters (found 103).</td>
-<td>1490</td></tr>
+<td>1491</td></tr>
 <tr class="b">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>javadoc</td>
 <td>NonEmptyAtclauseDescription</td>
 <td>At-clause should have a non-empty description.</td>
-<td>1555</td></tr>
+<td>1556</td></tr>
 <tr class="a">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>sizes</td>
 <td>LineLength</td>
 <td>Line is longer than 100 characters (found 102).</td>
-<td>1620</td></tr>
+<td>1625</td></tr>
 <tr class="b">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>blocks</td>
 <td>NeedBraces</td>
 <td>'if' construct must use '{}'s.</td>
-<td>1714</td></tr>
+<td>1719</td></tr>
 <tr class="a">
 <td><img src="images/icon_error_sml.gif" alt="" />&#160;Error</td>
 <td>sizes</td>
 <td>LineLength</td>
 <td>Line is longer than 100 characters (found 121).</td>
-<td>1732</td></tr></table></div>
+<td>1737</td></tr></table></div>
 <div class="section">
 <h3 id="org.apache.hadoop.hbase.tool.MapreduceTestingShim.java">org/apache/hadoop/hbase/tool/MapreduceTestingShim.java</h3>
 <table border="0" class="table table-striped">
@@ -92276,7 +92276,7 @@
         <div class="row">
             <p>Copyright &copy;2007&#x2013;2019
 <a href="https://www.apache.org/">The Apache Software Foundation</a>.
-All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-01</li>
+All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-02</li>
 </p>
         </div>
         <p id="poweredBy" class="pull-right"><a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
diff --git a/coc.html b/coc.html
index 6c75ad1..bf936d3 100644
--- a/coc.html
+++ b/coc.html
@@ -217,7 +217,7 @@ email to <a class="externalLink" href="mailto:private@hbase.apache.org">the priv
         <div class="row">
             <p>Copyright &copy;2007&#x2013;2019
 <a href="https://www.apache.org/">The Apache Software Foundation</a>.
-All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-01</li>
+All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-02</li>
 </p>
         </div>
         <p id="poweredBy" class="pull-right"><a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
diff --git a/dependencies.html b/dependencies.html
index d38ffb9..9344962 100644
--- a/dependencies.html
+++ b/dependencies.html
@@ -289,7 +289,7 @@
         <div class="row">
             <p>Copyright &copy;2007&#x2013;2019
 <a href="https://www.apache.org/">The Apache Software Foundation</a>.
-All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-01</li>
+All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-02</li>
 </p>
         </div>
         <p id="poweredBy" class="pull-right"><a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
diff --git a/dependency-convergence.html b/dependency-convergence.html
index 34f701b..8e48cc4 100644
--- a/dependency-convergence.html
+++ b/dependency-convergence.html
@@ -534,7 +534,7 @@
         <div class="row">
             <p>Copyright &copy;2007&#x2013;2019
 <a href="https://www.apache.org/">The Apache Software Foundation</a>.
-All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-01</li>
+All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-02</li>
 </p>
         </div>
         <p id="poweredBy" class="pull-right"><a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
diff --git a/dependency-info.html b/dependency-info.html
index 71fe341..0039f7c 100644
--- a/dependency-info.html
+++ b/dependency-info.html
@@ -170,7 +170,7 @@
         <div class="row">
             <p>Copyright &copy;2007&#x2013;2019
 <a href="https://www.apache.org/">The Apache Software Foundation</a>.
-All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-01</li>
+All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-02</li>
 </p>
         </div>
         <p id="poweredBy" class="pull-right"><a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
diff --git a/dependency-management.html b/dependency-management.html
index f8091d2..8c61d27 100644
--- a/dependency-management.html
+++ b/dependency-management.html
@@ -898,7 +898,7 @@
         <div class="row">
             <p>Copyright &copy;2007&#x2013;2019
 <a href="https://www.apache.org/">The Apache Software Foundation</a>.
-All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-01</li>
+All rights reserved.        <li id="publishDate" class="pull-right">Last Published: 2019-11-02</li>
 </p>
         </div>
         <p id="poweredBy" class="pull-right"><a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
diff --git a/devapidocs/constant-values.html b/devapidocs/constant-values.html
index 43ae105..07df015 100644
--- a/devapidocs/constant-values.html
+++ b/devapidocs/constant-values.html
@@ -4053,14 +4053,14 @@
 <!--   -->
 </a><code>public&nbsp;static&nbsp;final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
 <td><code><a href="org/apache/hadoop/hbase/Version.html#date">date</a></code></td>
-<td class="colLast"><code>"Fri Nov  1 14:36:53 UTC 2019"</code></td>
+<td class="colLast"><code>"Sat Nov  2 14:35:46 UTC 2019"</code></td>
 </tr>
 <tr class="rowColor">
 <td class="colFirst"><a name="org.apache.hadoop.hbase.Version.revision">
 <!--   -->
 </a><code>public&nbsp;static&nbsp;final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
 <td><code><a href="org/apache/hadoop/hbase/Version.html#revision">revision</a></code></td>
-<td class="colLast"><code>"b8a4504a2609d6d6d26e0b839a368912b3276feb"</code></td>
+<td class="colLast"><code>"c58e80fbe6db6426e652ec363149b92f9e33fbb0"</code></td>
 </tr>
 <tr class="altColor">
 <td class="colFirst"><a name="org.apache.hadoop.hbase.Version.srcChecksum">
diff --git a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html
index d7cfb74..af93bd8 100644
--- a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html
+++ b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html
@@ -121,7 +121,7 @@ var activeTableTab = "activeTableTab";
 </dl>
 <hr>
 <br>
-<pre>public abstract static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1213">CanaryTool.Monitor</a>
+<pre>public abstract static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1214">CanaryTool.Monitor</a>
 extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>
 implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html?is-external=true" title="class or interface in java.lang">Runnable</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</a></pre>
 <div class="block">A Monitor super-class can be extended by users</div>
@@ -281,7 +281,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>connection</h4>
-<pre>protected&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1214">connection</a></pre>
+<pre>protected&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1215">connection</a></pre>
 </li>
 </ul>
 <a name="admin">
@@ -290,7 +290,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>admin</h4>
-<pre>protected&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/Admin.html" title="interface in org.apache.hadoop.hbase.client">Admin</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1215">admin</a></pre>
+<pre>protected&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/Admin.html" title="interface in org.apache.hadoop.hbase.client">Admin</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1216">admin</a></pre>
 </li>
 </ul>
 <a name="targets">
@@ -299,7 +299,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>targets</h4>
-<pre>protected&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[] <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1220">targets</a></pre>
+<pre>protected&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[] <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1221">targets</a></pre>
 <div class="block">'Target' dependent on 'mode'. Could be Tables or RegionServers or ZNodes.
  Passed on the command-line as arguments.</div>
 </li>
@@ -310,7 +310,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>useRegExp</h4>
-<pre>protected&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1221">useRegExp</a></pre>
+<pre>protected&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1222">useRegExp</a></pre>
 </li>
 </ul>
 <a name="treatFailureAsError">
@@ -319,7 +319,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>treatFailureAsError</h4>
-<pre>protected&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1222">treatFailureAsError</a></pre>
+<pre>protected&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1223">treatFailureAsError</a></pre>
 </li>
 </ul>
 <a name="initialized">
@@ -328,7 +328,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>initialized</h4>
-<pre>protected&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1223">initialized</a></pre>
+<pre>protected&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1224">initialized</a></pre>
 </li>
 </ul>
 <a name="done">
@@ -337,7 +337,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>done</h4>
-<pre>protected&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1225">done</a></pre>
+<pre>protected&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1226">done</a></pre>
 </li>
 </ul>
 <a name="errorCode">
@@ -346,7 +346,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>errorCode</h4>
-<pre>protected&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1226">errorCode</a></pre>
+<pre>protected&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1227">errorCode</a></pre>
 </li>
 </ul>
 <a name="allowedFailures">
@@ -355,7 +355,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>allowedFailures</h4>
-<pre>protected&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1227">allowedFailures</a></pre>
+<pre>protected&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1228">allowedFailures</a></pre>
 </li>
 </ul>
 <a name="sink">
@@ -364,7 +364,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>sink</h4>
-<pre>protected&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1228">sink</a></pre>
+<pre>protected&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1229">sink</a></pre>
 </li>
 </ul>
 <a name="executor">
@@ -373,7 +373,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockListLast">
 <li class="blockList">
 <h4>executor</h4>
-<pre>protected&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1229">executor</a></pre>
+<pre>protected&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1230">executor</a></pre>
 </li>
 </ul>
 </li>
@@ -390,7 +390,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockListLast">
 <li class="blockList">
 <h4>Monitor</h4>
-<pre>protected&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1257">Monitor</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
+<pre>protected&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1258">Monitor</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
                   <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;monitorTargets,
                   boolean&nbsp;useRegExp,
                   <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a>&nbsp;sink,
@@ -413,7 +413,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>isDone</h4>
-<pre>public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1231">isDone</a>()</pre>
+<pre>public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1232">isDone</a>()</pre>
 </li>
 </ul>
 <a name="hasError--">
@@ -422,7 +422,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>hasError</h4>
-<pre>public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1235">hasError</a>()</pre>
+<pre>public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1236">hasError</a>()</pre>
 </li>
 </ul>
 <a name="finalCheckForErrors--">
@@ -431,7 +431,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>finalCheckForErrors</h4>
-<pre>public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1239">finalCheckForErrors</a>()</pre>
+<pre>public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1240">finalCheckForErrors</a>()</pre>
 </li>
 </ul>
 <a name="close--">
@@ -440,7 +440,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>close</h4>
-<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1253">close</a>()
+<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1254">close</a>()
            throws <a href="https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
@@ -458,7 +458,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockList">
 <li class="blockList">
 <h4>run</h4>
-<pre>public abstract&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1271">run</a>()</pre>
+<pre>public abstract&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1272">run</a>()</pre>
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
 <dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html?is-external=true#run--" title="class or interface in java.lang">run</a></code>&nbsp;in interface&nbsp;<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html?is-external=true" title="class or interface in java.lang">Runnable</a></code></dd>
@@ -471,7 +471,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable
 <ul class="blockListLast">
 <li class="blockList">
 <h4>initAdmin</h4>
-<pre>protected&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1273">initAdmin</a>()</pre>
+<pre>protected&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html#line.1274">initAdmin</a>()</pre>
 </li>
 </ul>
 </li>
diff --git a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html
index ed91194..751a9e9 100644
--- a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html
+++ b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html
@@ -122,7 +122,7 @@ var activeTableTab = "activeTableTab";
 </dl>
 <hr>
 <br>
-<pre>private static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1292">CanaryTool.RegionMonitor</a>
+<pre>private static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1293">CanaryTool.RegionMonitor</a>
 extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.Monitor</a></pre>
 <div class="block">A monitor for region mode.</div>
 </li>
@@ -302,7 +302,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>DEFAULT_WRITE_TABLE_CHECK_PERIOD</h4>
-<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1294">DEFAULT_WRITE_TABLE_CHECK_PERIOD</a></pre>
+<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1295">DEFAULT_WRITE_TABLE_CHECK_PERIOD</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.RegionMonitor.DEFAULT_WRITE_TABLE_CHECK_PERIOD">Constant Field Values</a></dd>
@@ -315,7 +315,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>DEFAULT_WRITE_DATA_TTL</h4>
-<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1296">DEFAULT_WRITE_DATA_TTL</a></pre>
+<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1297">DEFAULT_WRITE_DATA_TTL</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.RegionMonitor.DEFAULT_WRITE_DATA_TTL">Constant Field Values</a></dd>
@@ -328,7 +328,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>lastCheckTime</h4>
-<pre>private&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1298">lastCheckTime</a></pre>
+<pre>private&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1299">lastCheckTime</a></pre>
 </li>
 </ul>
 <a name="writeSniffing">
@@ -337,7 +337,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>writeSniffing</h4>
-<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1299">writeSniffing</a></pre>
+<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1300">writeSniffing</a></pre>
 </li>
 </ul>
 <a name="writeTableName">
@@ -346,7 +346,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>writeTableName</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/TableName.html" title="class in org.apache.hadoop.hbase">TableName</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1300">writeTableName</a></pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/TableName.html" title="class in org.apache.hadoop.hbase">TableName</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1301">writeTableName</a></pre>
 </li>
 </ul>
 <a name="writeDataTTL">
@@ -355,7 +355,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>writeDataTTL</h4>
-<pre>private&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1301">writeDataTTL</a></pre>
+<pre>private&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1302">writeDataTTL</a></pre>
 </li>
 </ul>
 <a name="regionsLowerLimit">
@@ -364,7 +364,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>regionsLowerLimit</h4>
-<pre>private&nbsp;float <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1302">regionsLowerLimit</a></pre>
+<pre>private&nbsp;float <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1303">regionsLowerLimit</a></pre>
 </li>
 </ul>
 <a name="regionsUpperLimit">
@@ -373,7 +373,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>regionsUpperLimit</h4>
-<pre>private&nbsp;float <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1303">regionsUpperLimit</a></pre>
+<pre>private&nbsp;float <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1304">regionsUpperLimit</a></pre>
 </li>
 </ul>
 <a name="checkPeriod">
@@ -382,7 +382,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>checkPeriod</h4>
-<pre>private&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1304">checkPeriod</a></pre>
+<pre>private&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1305">checkPeriod</a></pre>
 </li>
 </ul>
 <a name="rawScanEnabled">
@@ -391,7 +391,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>rawScanEnabled</h4>
-<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1305">rawScanEnabled</a></pre>
+<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1306">rawScanEnabled</a></pre>
 </li>
 </ul>
 <a name="configuredReadTableTimeouts">
@@ -400,7 +400,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>configuredReadTableTimeouts</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html?is-external=true" title="class or interface in java.util">HashMap</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html?is-external=true" title="class or interface in java.lang">Long</a>&gt; <a href="../../../../../src-html/org/apache [...]
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html?is-external=true" title="class or interface in java.util">HashMap</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html?is-external=true" title="class or interface in java.lang">Long</a>&gt; <a href="../../../../../src-html/org/apache [...]
 <div class="block">This is a timeout per table. If read of each region in the table aggregated takes longer
  than what is configured here, we log an ERROR rather than just an INFO.</div>
 </li>
@@ -411,7 +411,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockListLast">
 <li class="blockList">
 <h4>configuredWriteTableTimeout</h4>
-<pre>private&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1313">configuredWriteTableTimeout</a></pre>
+<pre>private&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1314">configuredWriteTableTimeout</a></pre>
 </li>
 </ul>
 </li>
@@ -428,7 +428,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockListLast">
 <li class="blockList">
 <h4>RegionMonitor</h4>
-<pre>public&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1315">RegionMonitor</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
+<pre>public&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1316">RegionMonitor</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
                      <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;monitorTargets,
                      boolean&nbsp;useRegExp,
                      <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a>&nbsp;sink,
@@ -455,7 +455,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>getSink</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.RegionStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.RegionStdOutSink</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1339">getSink</a>()</pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.RegionStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.RegionStdOutSink</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1340">getSink</a>()</pre>
 </li>
 </ul>
 <a name="run--">
@@ -464,7 +464,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>run</h4>
-<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1347">run</a>()</pre>
+<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1348">run</a>()</pre>
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
 <dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html?is-external=true#run--" title="class or interface in java.lang">run</a></code>&nbsp;in interface&nbsp;<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html?is-external=true" title="class or interface in java.lang">Runnable</a></code></dd>
@@ -479,7 +479,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>generateMonitorTables</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1437">generateMonitorTables</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;monitorTargets)
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1438">generateMonitorTables</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;monitorTargets)
                                 throws <a href="https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
 <dl>
 <dt><span class="returnLabel">Returns:</span></dt>
@@ -495,7 +495,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>sniff</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html?is-external=true" title="class or interface in java.util.concurrent">Future</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&gt;&gt;&nbsp;<a href="../../ [...]
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html?is-external=true" title="class or interface in java.util.concurrent">Future</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&gt;&gt;&nbsp;<a href="../../ [...]
                                  <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.RegionStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.RegionStdOutSink</a>&nbsp;regionSink)
                           throws <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</a></pre>
 <dl>
@@ -510,7 +510,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>checkWriteTableDistribution</h4>
-<pre>private&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1497">checkWriteTableDistribution</a>()
+<pre>private&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1498">checkWriteTableDistribution</a>()
                                   throws <a href="https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
 <dl>
 <dt><span class="throwsLabel">Throws:</span></dt>
@@ -524,7 +524,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockListLast">
 <li class="blockList">
 <h4>createWriteTable</h4>
-<pre>private&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1536">createWriteTable</a>(int&nbsp;numberOfServers)
+<pre>private&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html#line.1537">createWriteTable</a>(int&nbsp;numberOfServers)
                        throws <a href="https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
 <dl>
 <dt><span class="throwsLabel">Throws:</span></dt>
diff --git a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html
index 3721890..f4506d3 100644
--- a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html
+++ b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html
@@ -122,7 +122,7 @@ var activeTableTab = "activeTableTab";
 </dl>
 <hr>
 <br>
-<pre>private static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1667">CanaryTool.RegionServerMonitor</a>
+<pre>private static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1672">CanaryTool.RegionServerMonitor</a>
 extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.Monitor</a></pre>
 <div class="block">A monitor for regionserver mode</div>
 </li>
@@ -257,7 +257,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockListLast">
 <li class="blockList">
 <h4>allRegions</h4>
-<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1668">allRegions</a></pre>
+<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1673">allRegions</a></pre>
 </li>
 </ul>
 </li>
@@ -274,7 +274,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockListLast">
 <li class="blockList">
 <h4>RegionServerMonitor</h4>
-<pre>public&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1670">RegionServerMonitor</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
+<pre>public&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1675">RegionServerMonitor</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
                            <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;monitorTargets,
                            boolean&nbsp;useRegExp,
                            <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a>&nbsp;sink,
@@ -298,7 +298,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>getSink</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.RegionServerStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.RegionServerStdOutSink</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1678">getSink</a>()</pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.RegionServerStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.RegionServerStdOutSink</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1683">getSink</a>()</pre>
 </li>
 </ul>
 <a name="run--">
@@ -307,7 +307,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>run</h4>
-<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1686">run</a>()</pre>
+<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1691">run</a>()</pre>
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
 <dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html?is-external=true#run--" title="class or interface in java.lang">run</a></code>&nbsp;in interface&nbsp;<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html?is-external=true" title="class or interface in java.lang">Runnable</a></code></dd>
@@ -322,7 +322,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>checkNoTableNames</h4>
-<pre>private&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1702">checkNoTableNames</a>()</pre>
+<pre>private&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1707">checkNoTableNames</a>()</pre>
 </li>
 </ul>
 <a name="monitorRegionServers-java.util.Map-org.apache.hadoop.hbase.tool.CanaryTool.RegionServerStdOutSink-">
@@ -331,7 +331,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>monitorRegionServers</h4>
-<pre>private&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1732">monitorRegionServers</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/ap [...]
+<pre>private&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html#line.1737">monitorRegionServers</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/ap [...]
                                   <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.RegionServerStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.RegionServerStdOutSink</a>&nbsp;regionServerSink)</pre>
 </li>
 </ul>
@@ -341,7 +341,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>filterRegionServerByName</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../org/apache/hadoop/hbase/clie [...]
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../org/apache/hadoop/hbase/clie [...]
 </li>
 </ul>
 <a name="getAllRegionServerByName--">
@@ -350,7 +350,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>getAllRegionServerByName</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../org/apache/hadoop/hbase/clie [...]
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../org/apache/hadoop/hbase/clie [...]
 </li>
 </ul>
 <a name="doFilterRegionServerByName-java.util.Map-">
@@ -359,7 +359,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockListLast">
 <li class="blockList">
 <h4>doFilterRegionServerByName</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../org/apache/hadoop/hbase/clie [...]
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="../../../../../org/apache/hadoop/hbase/clie [...]
 </li>
 </ul>
 </li>
diff --git a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html
index 8b05fa5..869d412 100644
--- a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html
+++ b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html
@@ -117,7 +117,7 @@ var activeTableTab = "activeTableTab";
 </dl>
 <hr>
 <br>
-<pre>static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.559">CanaryTool.RegionServerTask</a>
+<pre>static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.560">CanaryTool.RegionServerTask</a>
 extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>
 implements <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Callable.html?is-external=true" title="class or interface in java.util.concurrent">Callable</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&gt;</pre>
 <div class="block">Run a single RegionServer Task and then exit.
@@ -228,7 +228,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurre
 <ul class="blockList">
 <li class="blockList">
 <h4>connection</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.560">connection</a></pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.561">connection</a></pre>
 </li>
 </ul>
 <a name="serverName">
@@ -237,7 +237,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurre
 <ul class="blockList">
 <li class="blockList">
 <h4>serverName</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.561">serverName</a></pre>
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.562">serverName</a></pre>
 </li>
 </ul>
 <a name="region">
@@ -246,7 +246,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurre
 <ul class="blockList">
 <li class="blockList">
 <h4>region</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/RegionInfo.html" title="interface in org.apache.hadoop.hbase.client">RegionInfo</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.562">region</a></pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/RegionInfo.html" title="interface in org.apache.hadoop.hbase.client">RegionInfo</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.563">region</a></pre>
 </li>
 </ul>
 <a name="sink">
@@ -255,7 +255,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurre
 <ul class="blockList">
 <li class="blockList">
 <h4>sink</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.RegionServerStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.RegionServerStdOutSink</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.563">sink</a></pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.RegionServerStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.RegionServerStdOutSink</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.564">sink</a></pre>
 </li>
 </ul>
 <a name="successes">
@@ -264,7 +264,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurre
 <ul class="blockListLast">
 <li class="blockList">
 <h4>successes</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html?is-external=true" title="class or interface in java.util.concurrent.atomic">AtomicLong</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.564">successes</a></pre>
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html?is-external=true" title="class or interface in java.util.concurrent.atomic">AtomicLong</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.565">successes</a></pre>
 </li>
 </ul>
 </li>
@@ -281,7 +281,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurre
 <ul class="blockListLast">
 <li class="blockList">
 <h4>RegionServerTask</h4>
-<pre><a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.566">RegionServerTask</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
+<pre><a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.567">RegionServerTask</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
                  <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;serverName,
                  <a href="../../../../../org/apache/hadoop/hbase/client/RegionInfo.html" title="interface in org.apache.hadoop.hbase.client">RegionInfo</a>&nbsp;region,
                  <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.RegionServerStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.RegionServerStdOutSink</a>&nbsp;sink,
@@ -302,7 +302,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurre
 <ul class="blockListLast">
 <li class="blockList">
 <h4>call</h4>
-<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.576">call</a>()</pre>
+<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerTask.html#line.577">call</a>()</pre>
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
 <dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Callable.html?is-external=true#call--" title="class or interface in java.util.concurrent">call</a></code>&nbsp;in interface&nbsp;<code><a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Callable.html?is-external=true" title="class or interface in java.util.concurrent">Callable</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or [...]
diff --git a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionTask.html b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionTask.html
index 24f763b..2912efd 100644
--- a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionTask.html
+++ b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionTask.html
@@ -383,7 +383,7 @@ implements <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurre
 <ul class="blockListLast">
 <li class="blockList">
 <h4>write</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTask.html#line.515">write</a>()</pre>
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTask.html#line.516">write</a>()</pre>
 <div class="block">Check writes for the canary table</div>
 </li>
 </ul>
diff --git a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html
index a2541cd..629251e 100644
--- a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html
+++ b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html
@@ -113,7 +113,7 @@ var activeTableTab = "activeTableTab";
 </dl>
 <hr>
 <br>
-<pre>public static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1051">CanaryTool.RegionTaskResult</a>
+<pre>public static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1052">CanaryTool.RegionTaskResult</a>
 extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
 <div class="block">Canary region mode-specific data structure which stores information about each region
  to be scanned</div>
@@ -294,7 +294,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>region</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/RegionInfo.html" title="interface in org.apache.hadoop.hbase.client">RegionInfo</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1052">region</a></pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/RegionInfo.html" title="interface in org.apache.hadoop.hbase.client">RegionInfo</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1053">region</a></pre>
 </li>
 </ul>
 <a name="tableName">
@@ -303,7 +303,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>tableName</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/TableName.html" title="class in org.apache.hadoop.hbase">TableName</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1053">tableName</a></pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/TableName.html" title="class in org.apache.hadoop.hbase">TableName</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1054">tableName</a></pre>
 </li>
 </ul>
 <a name="serverName">
@@ -312,7 +312,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>serverName</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/ServerName.html" title="class in org.apache.hadoop.hbase">ServerName</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1054">serverName</a></pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/ServerName.html" title="class in org.apache.hadoop.hbase">ServerName</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1055">serverName</a></pre>
 </li>
 </ul>
 <a name="column">
@@ -321,7 +321,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>column</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/ColumnFamilyDescriptor.html" title="interface in org.apache.hadoop.hbase.client">ColumnFamilyDescriptor</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1055">column</a></pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/ColumnFamilyDescriptor.html" title="interface in org.apache.hadoop.hbase.client">ColumnFamilyDescriptor</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1056">column</a></pre>
 </li>
 </ul>
 <a name="readLatency">
@@ -330,7 +330,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>readLatency</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html?is-external=true" title="class or interface in java.util.concurrent.atomic">AtomicLong</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1056">readLatency</a></pre>
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html?is-external=true" title="class or interface in java.util.concurrent.atomic">AtomicLong</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1057">readLatency</a></pre>
 </li>
 </ul>
 <a name="writeLatency">
@@ -339,7 +339,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>writeLatency</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html?is-external=true" title="class or interface in java.util.concurrent.atomic">AtomicLong</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1057">writeLatency</a></pre>
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html?is-external=true" title="class or interface in java.util.concurrent.atomic">AtomicLong</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1058">writeLatency</a></pre>
 </li>
 </ul>
 <a name="readSuccess">
@@ -348,7 +348,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>readSuccess</h4>
-<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1058">readSuccess</a></pre>
+<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1059">readSuccess</a></pre>
 </li>
 </ul>
 <a name="writeSuccess">
@@ -357,7 +357,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockListLast">
 <li class="blockList">
 <h4>writeSuccess</h4>
-<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1059">writeSuccess</a></pre>
+<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1060">writeSuccess</a></pre>
 </li>
 </ul>
 </li>
@@ -374,7 +374,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockListLast">
 <li class="blockList">
 <h4>RegionTaskResult</h4>
-<pre>public&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1061">RegionTaskResult</a>(<a href="../../../../../org/apache/hadoop/hbase/client/RegionInfo.html" title="interface in org.apache.hadoop.hbase.client">RegionInfo</a>&nbsp;region,
+<pre>public&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1062">RegionTaskResult</a>(<a href="../../../../../org/apache/hadoop/hbase/client/RegionInfo.html" title="interface in org.apache.hadoop.hbase.client">RegionInfo</a>&nbsp;region,
                         <a href="../../../../../org/apache/hadoop/hbase/TableName.html" title="class in org.apache.hadoop.hbase">TableName</a>&nbsp;tableName,
                         <a href="../../../../../org/apache/hadoop/hbase/ServerName.html" title="class in org.apache.hadoop.hbase">ServerName</a>&nbsp;serverName,
                         <a href="../../../../../org/apache/hadoop/hbase/client/ColumnFamilyDescriptor.html" title="interface in org.apache.hadoop.hbase.client">ColumnFamilyDescriptor</a>&nbsp;column)</pre>
@@ -394,7 +394,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>getRegionInfo</h4>
-<pre>public&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/RegionInfo.html" title="interface in org.apache.hadoop.hbase.client">RegionInfo</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1069">getRegionInfo</a>()</pre>
+<pre>public&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/RegionInfo.html" title="interface in org.apache.hadoop.hbase.client">RegionInfo</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1070">getRegionInfo</a>()</pre>
 </li>
 </ul>
 <a name="getRegionNameAsString--">
@@ -403,7 +403,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>getRegionNameAsString</h4>
-<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1073">getRegionNameAsString</a>()</pre>
+<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1074">getRegionNameAsString</a>()</pre>
 </li>
 </ul>
 <a name="getTableName--">
@@ -412,7 +412,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>getTableName</h4>
-<pre>public&nbsp;<a href="../../../../../org/apache/hadoop/hbase/TableName.html" title="class in org.apache.hadoop.hbase">TableName</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1077">getTableName</a>()</pre>
+<pre>public&nbsp;<a href="../../../../../org/apache/hadoop/hbase/TableName.html" title="class in org.apache.hadoop.hbase">TableName</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1078">getTableName</a>()</pre>
 </li>
 </ul>
 <a name="getTableNameAsString--">
@@ -421,7 +421,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>getTableNameAsString</h4>
-<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1081">getTableNameAsString</a>()</pre>
+<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1082">getTableNameAsString</a>()</pre>
 </li>
 </ul>
 <a name="getServerName--">
@@ -430,7 +430,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>getServerName</h4>
-<pre>public&nbsp;<a href="../../../../../org/apache/hadoop/hbase/ServerName.html" title="class in org.apache.hadoop.hbase">ServerName</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1085">getServerName</a>()</pre>
+<pre>public&nbsp;<a href="../../../../../org/apache/hadoop/hbase/ServerName.html" title="class in org.apache.hadoop.hbase">ServerName</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1086">getServerName</a>()</pre>
 </li>
 </ul>
 <a name="getServerNameAsString--">
@@ -439,7 +439,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>getServerNameAsString</h4>
-<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1089">getServerNameAsString</a>()</pre>
+<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1090">getServerNameAsString</a>()</pre>
 </li>
 </ul>
 <a name="getColumnFamily--">
@@ -448,7 +448,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>getColumnFamily</h4>
-<pre>public&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/ColumnFamilyDescriptor.html" title="interface in org.apache.hadoop.hbase.client">ColumnFamilyDescriptor</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1093">getColumnFamily</a>()</pre>
+<pre>public&nbsp;<a href="../../../../../org/apache/hadoop/hbase/client/ColumnFamilyDescriptor.html" title="interface in org.apache.hadoop.hbase.client">ColumnFamilyDescriptor</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1094">getColumnFamily</a>()</pre>
 </li>
 </ul>
 <a name="getColumnFamilyNameAsString--">
@@ -457,7 +457,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>getColumnFamilyNameAsString</h4>
-<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1097">getColumnFamilyNameAsString</a>()</pre>
+<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1098">getColumnFamilyNameAsString</a>()</pre>
 </li>
 </ul>
 <a name="getReadLatency--">
@@ -466,7 +466,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>getReadLatency</h4>
-<pre>public&nbsp;long&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1101">getReadLatency</a>()</pre>
+<pre>public&nbsp;long&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1102">getReadLatency</a>()</pre>
 </li>
 </ul>
 <a name="setReadLatency-long-">
@@ -475,7 +475,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>setReadLatency</h4>
-<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1108">setReadLatency</a>(long&nbsp;readLatency)</pre>
+<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1109">setReadLatency</a>(long&nbsp;readLatency)</pre>
 </li>
 </ul>
 <a name="getWriteLatency--">
@@ -484,7 +484,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>getWriteLatency</h4>
-<pre>public&nbsp;long&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1116">getWriteLatency</a>()</pre>
+<pre>public&nbsp;long&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1117">getWriteLatency</a>()</pre>
 </li>
 </ul>
 <a name="setWriteLatency-long-">
@@ -493,7 +493,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>setWriteLatency</h4>
-<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1123">setWriteLatency</a>(long&nbsp;writeLatency)</pre>
+<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1124">setWriteLatency</a>(long&nbsp;writeLatency)</pre>
 </li>
 </ul>
 <a name="isReadSuccess--">
@@ -502,7 +502,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>isReadSuccess</h4>
-<pre>public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1131">isReadSuccess</a>()</pre>
+<pre>public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1132">isReadSuccess</a>()</pre>
 </li>
 </ul>
 <a name="setReadSuccess--">
@@ -511,7 +511,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>setReadSuccess</h4>
-<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1135">setReadSuccess</a>()</pre>
+<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1136">setReadSuccess</a>()</pre>
 </li>
 </ul>
 <a name="isWriteSuccess--">
@@ -520,7 +520,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockList">
 <li class="blockList">
 <h4>isWriteSuccess</h4>
-<pre>public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1139">isWriteSuccess</a>()</pre>
+<pre>public&nbsp;boolean&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1140">isWriteSuccess</a>()</pre>
 </li>
 </ul>
 <a name="setWriteSuccess--">
@@ -529,7 +529,7 @@ extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
 <ul class="blockListLast">
 <li class="blockList">
 <h4>setWriteSuccess</h4>
-<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1143">setWriteSuccess</a>()</pre>
+<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionTaskResult.html#line.1144">setWriteSuccess</a>()</pre>
 </li>
 </ul>
 </li>
diff --git a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html
index 954aa2d..609c03e 100644
--- a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html
+++ b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html
@@ -122,7 +122,7 @@ var activeTableTab = "activeTableTab";
 </dl>
 <hr>
 <br>
-<pre>private static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1597">CanaryTool.ZookeeperMonitor</a>
+<pre>private static class <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1602">CanaryTool.ZookeeperMonitor</a>
 extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.Monitor</a></pre>
 </li>
 </ul>
@@ -244,7 +244,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>hosts</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&gt; <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1598">hosts</a></pre>
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&gt; <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1603">hosts</a></pre>
 </li>
 </ul>
 <a name="znode">
@@ -253,7 +253,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>znode</h4>
-<pre>private final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1599">znode</a></pre>
+<pre>private final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1604">znode</a></pre>
 </li>
 </ul>
 <a name="timeout">
@@ -262,7 +262,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockListLast">
 <li class="blockList">
 <h4>timeout</h4>
-<pre>private final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1600">timeout</a></pre>
+<pre>private final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1605">timeout</a></pre>
 </li>
 </ul>
 </li>
@@ -279,7 +279,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockListLast">
 <li class="blockList">
 <h4>ZookeeperMonitor</h4>
-<pre>protected&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1602">ZookeeperMonitor</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
+<pre>protected&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1607">ZookeeperMonitor</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
                            <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;monitorTargets,
                            boolean&nbsp;useRegExp,
                            <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a>&nbsp;sink,
@@ -302,7 +302,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockList">
 <li class="blockList">
 <h4>run</h4>
-<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1625">run</a>()</pre>
+<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1630">run</a>()</pre>
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
 <dd><code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html?is-external=true#run--" title="class or interface in java.lang">run</a></code>&nbsp;in interface&nbsp;<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html?is-external=true" title="class or interface in java.lang">Runnable</a></code></dd>
@@ -317,7 +317,7 @@ extends <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.
 <ul class="blockListLast">
 <li class="blockList">
 <h4>getSink</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.ZookeeperStdOutSink</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1655">getSink</a>()</pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperStdOutSink.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.ZookeeperStdOutSink</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.ZookeeperMonitor.html#line.1660">getSink</a>()</pre>
 </li>
 </ul>
 </li>
diff --git a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.html b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.html
index b5abe6d..7a6d3b1 100644
--- a/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.html
+++ b/devapidocs/org/apache/hadoop/hbase/tool/CanaryTool.html
@@ -532,7 +532,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>USAGE_EXIT_CODE</h4>
-<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.644">USAGE_EXIT_CODE</a></pre>
+<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.645">USAGE_EXIT_CODE</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.USAGE_EXIT_CODE">Constant Field Values</a></dd>
@@ -545,7 +545,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>INIT_ERROR_EXIT_CODE</h4>
-<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.645">INIT_ERROR_EXIT_CODE</a></pre>
+<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.646">INIT_ERROR_EXIT_CODE</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.INIT_ERROR_EXIT_CODE">Constant Field Values</a></dd>
@@ -558,7 +558,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>TIMEOUT_ERROR_EXIT_CODE</h4>
-<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.646">TIMEOUT_ERROR_EXIT_CODE</a></pre>
+<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.647">TIMEOUT_ERROR_EXIT_CODE</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.TIMEOUT_ERROR_EXIT_CODE">Constant Field Values</a></dd>
@@ -571,7 +571,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>ERROR_EXIT_CODE</h4>
-<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.647">ERROR_EXIT_CODE</a></pre>
+<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.648">ERROR_EXIT_CODE</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.ERROR_EXIT_CODE">Constant Field Values</a></dd>
@@ -584,7 +584,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>FAILURE_EXIT_CODE</h4>
-<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.648">FAILURE_EXIT_CODE</a></pre>
+<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.649">FAILURE_EXIT_CODE</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.FAILURE_EXIT_CODE">Constant Field Values</a></dd>
@@ -597,7 +597,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>DEFAULT_INTERVAL</h4>
-<pre>private static final&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.650">DEFAULT_INTERVAL</a></pre>
+<pre>private static final&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.651">DEFAULT_INTERVAL</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.DEFAULT_INTERVAL">Constant Field Values</a></dd>
@@ -610,7 +610,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>DEFAULT_TIMEOUT</h4>
-<pre>private static final&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.652">DEFAULT_TIMEOUT</a></pre>
+<pre>private static final&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.653">DEFAULT_TIMEOUT</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.DEFAULT_TIMEOUT">Constant Field Values</a></dd>
@@ -623,7 +623,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>MAX_THREADS_NUM</h4>
-<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.653">MAX_THREADS_NUM</a></pre>
+<pre>private static final&nbsp;int <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.654">MAX_THREADS_NUM</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.MAX_THREADS_NUM">Constant Field Values</a></dd>
@@ -636,7 +636,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>LOG</h4>
-<pre>private static final&nbsp;org.slf4j.Logger <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.655">LOG</a></pre>
+<pre>private static final&nbsp;org.slf4j.Logger <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.656">LOG</a></pre>
 </li>
 </ul>
 <a name="DEFAULT_WRITE_TABLE_NAME">
@@ -645,7 +645,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>DEFAULT_WRITE_TABLE_NAME</h4>
-<pre>public static final&nbsp;<a href="../../../../../org/apache/hadoop/hbase/TableName.html" title="class in org.apache.hadoop.hbase">TableName</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.657">DEFAULT_WRITE_TABLE_NAME</a></pre>
+<pre>public static final&nbsp;<a href="../../../../../org/apache/hadoop/hbase/TableName.html" title="class in org.apache.hadoop.hbase">TableName</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.658">DEFAULT_WRITE_TABLE_NAME</a></pre>
 </li>
 </ul>
 <a name="CANARY_TABLE_FAMILY_NAME">
@@ -654,7 +654,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>CANARY_TABLE_FAMILY_NAME</h4>
-<pre>private static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.660">CANARY_TABLE_FAMILY_NAME</a></pre>
+<pre>private static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.661">CANARY_TABLE_FAMILY_NAME</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.CANARY_TABLE_FAMILY_NAME">Constant Field Values</a></dd>
@@ -667,7 +667,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>conf</h4>
-<pre>private&nbsp;org.apache.hadoop.conf.Configuration <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.662">conf</a></pre>
+<pre>private&nbsp;org.apache.hadoop.conf.Configuration <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.663">conf</a></pre>
 </li>
 </ul>
 <a name="interval">
@@ -676,7 +676,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>interval</h4>
-<pre>private&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.663">interval</a></pre>
+<pre>private&nbsp;long <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.664">interval</a></pre>
 </li>
 </ul>
 <a name="sink">
@@ -685,7 +685,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>sink</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.664">sink</a></pre>
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.665">sink</a></pre>
 </li>
 </ul>
 <a name="regionServerMode">
@@ -694,7 +694,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>regionServerMode</h4>
-<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.669">regionServerMode</a></pre>
+<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.670">regionServerMode</a></pre>
 <div class="block">True if we are to run in 'regionServer' mode.</div>
 </li>
 </ul>
@@ -704,7 +704,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>zookeeperMode</h4>
-<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.674">zookeeperMode</a></pre>
+<pre>private&nbsp;boolean <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.675">zookeeperMode</a></pre>
 <div class="block">True if we are to run in zookeeper 'mode'.</div>
 </li>
 </ul>
@@ -714,7 +714,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>configuredReadTableTimeouts</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html?is-external=true" title="class or interface in java.util">HashMap</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html?is-external=true" title="class or interface in java.lang">Long</a>&gt; <a href="../../../../../src-html/org/apache [...]
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html?is-external=true" title="class or interface in java.util">HashMap</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Long.html?is-external=true" title="class or interface in java.lang">Long</a>&gt; <a href="../../../../../src-html/org/apache [...]
 <div class="block">This is a Map of table to timeout. The timeout is for reading all regions in the table; i.e.
  we aggregate time to fetch each region and it needs to be less than this value else we
  log an ERROR.</div>
@@ -726,7 +726,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>HBASE_CANARY_REGIONSERVER_ALL_REGIONS</h4>
-<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.683">HBASE_CANARY_REGIONSERVER_ALL_REGIONS</a></pre>
+<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.684">HBASE_CANARY_REGIONSERVER_ALL_REGIONS</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.HBASE_CANARY_REGIONSERVER_ALL_REGIONS">Constant Field Values</a></dd>
@@ -739,7 +739,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>HBASE_CANARY_REGION_WRITE_SNIFFING</h4>
-<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.686">HBASE_CANARY_REGION_WRITE_SNIFFING</a></pre>
+<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.687">HBASE_CANARY_REGION_WRITE_SNIFFING</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.HBASE_CANARY_REGION_WRITE_SNIFFING">Constant Field Values</a></dd>
@@ -752,7 +752,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT</h4>
-<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.688">HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT</a></pre>
+<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.689">HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT">Constant Field Values</a></dd>
@@ -765,7 +765,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>HBASE_CANARY_REGION_WRITE_TABLE_NAME</h4>
-<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.690">HBASE_CANARY_REGION_WRITE_TABLE_NAME</a></pre>
+<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.691">HBASE_CANARY_REGION_WRITE_TABLE_NAME</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.HBASE_CANARY_REGION_WRITE_TABLE_NAME">Constant Field Values</a></dd>
@@ -778,7 +778,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>HBASE_CANARY_REGION_READ_TABLE_TIMEOUT</h4>
-<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.692">HBASE_CANARY_REGION_READ_TABLE_TIMEOUT</a></pre>
+<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.693">HBASE_CANARY_REGION_READ_TABLE_TIMEOUT</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.HBASE_CANARY_REGION_READ_TABLE_TIMEOUT">Constant Field Values</a></dd>
@@ -791,7 +791,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES</h4>
-<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.695">HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES</a></pre>
+<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.696">HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES">Constant Field Values</a></dd>
@@ -804,7 +804,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>HBASE_CANARY_USE_REGEX</h4>
-<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.698">HBASE_CANARY_USE_REGEX</a></pre>
+<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.699">HBASE_CANARY_USE_REGEX</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.HBASE_CANARY_USE_REGEX">Constant Field Values</a></dd>
@@ -817,7 +817,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>HBASE_CANARY_TIMEOUT</h4>
-<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.699">HBASE_CANARY_TIMEOUT</a></pre>
+<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.700">HBASE_CANARY_TIMEOUT</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.HBASE_CANARY_TIMEOUT">Constant Field Values</a></dd>
@@ -830,7 +830,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>HBASE_CANARY_FAIL_ON_ERROR</h4>
-<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.700">HBASE_CANARY_FAIL_ON_ERROR</a></pre>
+<pre>public static final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.701">HBASE_CANARY_FAIL_ON_ERROR</a></pre>
 <dl>
 <dt><span class="seeLabel">See Also:</span></dt>
 <dd><a href="../../../../../constant-values.html#org.apache.hadoop.hbase.tool.CanaryTool.HBASE_CANARY_FAIL_ON_ERROR">Constant Field Values</a></dd>
@@ -843,7 +843,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockListLast">
 <li class="blockList">
 <h4>executor</h4>
-<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.703">executor</a></pre>
+<pre>private&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a> <a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.704">executor</a></pre>
 </li>
 </ul>
 </li>
@@ -860,7 +860,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>CanaryTool</h4>
-<pre>public&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.705">CanaryTool</a>()</pre>
+<pre>public&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.706">CanaryTool</a>()</pre>
 </li>
 </ul>
 <a name="CanaryTool-java.util.concurrent.ExecutorService-">
@@ -869,7 +869,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>CanaryTool</h4>
-<pre>public&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.709">CanaryTool</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a>&nbsp;executor)</pre>
+<pre>public&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.710">CanaryTool</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a>&nbsp;executor)</pre>
 </li>
 </ul>
 <a name="CanaryTool-java.util.concurrent.ExecutorService-org.apache.hadoop.hbase.tool.CanaryTool.Sink-">
@@ -878,7 +878,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>CanaryTool</h4>
-<pre><a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.714">CanaryTool</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a>&nbsp;executor,
+<pre><a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.715">CanaryTool</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a>&nbsp;executor,
            <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a>&nbsp;sink)</pre>
 </li>
 </ul>
@@ -888,7 +888,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>CanaryTool</h4>
-<pre><a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.719">CanaryTool</a>(org.apache.hadoop.conf.Configuration&nbsp;conf,
+<pre><a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.720">CanaryTool</a>(org.apache.hadoop.conf.Configuration&nbsp;conf,
            <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a>&nbsp;executor)</pre>
 </li>
 </ul>
@@ -898,7 +898,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockListLast">
 <li class="blockList">
 <h4>CanaryTool</h4>
-<pre><a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.723">CanaryTool</a>(org.apache.hadoop.conf.Configuration&nbsp;conf,
+<pre><a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.724">CanaryTool</a>(org.apache.hadoop.conf.Configuration&nbsp;conf,
            <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a>&nbsp;executor,
            <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a>&nbsp;sink)</pre>
 </li>
@@ -981,7 +981,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>getConf</h4>
-<pre>public&nbsp;org.apache.hadoop.conf.Configuration&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.729">getConf</a>()</pre>
+<pre>public&nbsp;org.apache.hadoop.conf.Configuration&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.730">getConf</a>()</pre>
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
 <dd><code>getConf</code>&nbsp;in interface&nbsp;<code>org.apache.hadoop.conf.Configurable</code></dd>
@@ -994,7 +994,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>setConf</h4>
-<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.734">setConf</a>(org.apache.hadoop.conf.Configuration&nbsp;conf)</pre>
+<pre>public&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.735">setConf</a>(org.apache.hadoop.conf.Configuration&nbsp;conf)</pre>
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
 <dd><code>setConf</code>&nbsp;in interface&nbsp;<code>org.apache.hadoop.conf.Configurable</code></dd>
@@ -1007,7 +1007,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>parseArgs</h4>
-<pre>private&nbsp;int&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.741">parseArgs</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;args)</pre>
+<pre>private&nbsp;int&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.742">parseArgs</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;args)</pre>
 </li>
 </ul>
 <a name="run-java.lang.String:A-">
@@ -1016,7 +1016,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>run</h4>
-<pre>public&nbsp;int&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.898">run</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;args)
+<pre>public&nbsp;int&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.899">run</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;args)
         throws <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</a></pre>
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
@@ -1032,7 +1032,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>runMonitor</h4>
-<pre>private&nbsp;int&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.917">runMonitor</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;monitorTargets)
+<pre>private&nbsp;int&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.918">runMonitor</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;monitorTargets)
                 throws <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</a></pre>
 <dl>
 <dt><span class="throwsLabel">Throws:</span></dt>
@@ -1046,7 +1046,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>getReadFailures</h4>
-<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&gt;&nbsp;<a href="../../../../../src-html/org/apache [...]
+<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&gt;&nbsp;<a href="../../../../../src-html/org/apache [...]
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
 <dd><code><a href="../../../../../org/apache/hadoop/hbase/tool/Canary.html#getReadFailures--">getReadFailures</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/hadoop/hbase/tool/Canary.html" title="interface in org.apache.hadoop.hbase.tool">Canary</a></code></dd>
@@ -1059,7 +1059,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>getWriteFailures</h4>
-<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&gt;&nbsp;<a href="../../../../../src-html/org/apache [...]
+<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&gt;&nbsp;<a href="../../../../../src-html/org/apache [...]
 <dl>
 <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
 <dd><code><a href="../../../../../org/apache/hadoop/hbase/tool/Canary.html#getWriteFailures--">getWriteFailures</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../org/apache/hadoop/hbase/tool/Canary.html" title="interface in org.apache.hadoop.hbase.tool">Canary</a></code></dd>
@@ -1072,7 +1072,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>printUsageAndExit</h4>
-<pre>private&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.998">printUsageAndExit</a>()</pre>
+<pre>private&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.999">printUsageAndExit</a>()</pre>
 </li>
 </ul>
 <a name="getSink-org.apache.hadoop.conf.Configuration-java.lang.Class-">
@@ -1081,7 +1081,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>getSink</h4>
-<pre><a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1040">getSink</a>(org.apache.hadoop.conf.Configuration&nbsp;configuration,
+<pre><a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1041">getSink</a>(org.apache.hadoop.conf.Configuration&nbsp;configuration,
                         <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html?is-external=true" title="class or interface in java.lang">Class</a>&nbsp;clazz)</pre>
 </li>
 </ul>
@@ -1091,7 +1091,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>newMonitor</h4>
-<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.Monitor</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1153">newMonitor</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
+<pre>private&nbsp;<a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html" title="class in org.apache.hadoop.hbase.tool">CanaryTool.Monitor</a>&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1154">newMonitor</a>(<a href="../../../../../org/apache/hadoop/hbase/client/Connection.html" title="interface in org.apache.hadoop.hbase.client">Connection</a>&nbsp;connection,
                                       <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;monitorTargets)</pre>
 <div class="block">A Factory method for <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html" title="class in org.apache.hadoop.hbase.tool"><code>CanaryTool.Monitor</code></a>.
  Makes a RegionServerMonitor, or a ZooKeeperMonitor, or a RegionMonitor.</div>
@@ -1107,7 +1107,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>populateReadTableTimeoutsMap</h4>
-<pre>private&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1192">populateReadTableTimeoutsMap</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;configuredReadTableTimeoutsStr)</pre>
+<pre>private&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1193">populateReadTableTimeoutsMap</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;configuredReadTableTimeoutsStr)</pre>
 </li>
 </ul>
 <a name="sniff-org.apache.hadoop.hbase.client.Admin-org.apache.hadoop.hbase.tool.CanaryTool.Sink-java.lang.String-java.util.concurrent.ExecutorService-org.apache.hadoop.hbase.tool.CanaryTool.RegionTask.TaskType-boolean-java.util.concurrent.atomic.LongAdder-">
@@ -1116,7 +1116,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>sniff</h4>
-<pre>private static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html?is-external=true" title="class or interface in java.util.concurrent">Future</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&gt;&gt;&nbsp;<a href= [...]
+<pre>private static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html?is-external=true" title="class or interface in java.util.concurrent">Future</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&gt;&gt;&nbsp;<a href= [...]
                                         <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a>&nbsp;sink,
                                         <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;tableName,
                                         <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a>&nbsp;executor,
@@ -1137,7 +1137,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockList">
 <li class="blockList">
 <h4>sniff</h4>
-<pre>private static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html?is-external=true" title="class or interface in java.util.concurrent">Future</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&gt;&gt;&nbsp;<a href= [...]
+<pre>private static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html?is-external=true" title="class or interface in java.util.concurrent">Future</a>&lt;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html?is-external=true" title="class or interface in java.lang">Void</a>&gt;&gt;&nbsp;<a href= [...]
                                         <a href="../../../../../org/apache/hadoop/hbase/tool/CanaryTool.Sink.html" title="interface in org.apache.hadoop.hbase.tool">CanaryTool.Sink</a>&nbsp;sink,
                                         <a href="../../../../../org/apache/hadoop/hbase/client/TableDescriptor.html" title="interface in org.apache.hadoop.hbase.client">TableDescriptor</a>&nbsp;tableDesc,
                                         <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html?is-external=true" title="class or interface in java.util.concurrent">ExecutorService</a>&nbsp;executor,
@@ -1157,7 +1157,7 @@ implements org.apache.hadoop.util.Tool, <a href="../../../../../org/apache/hadoo
 <ul class="blockListLast">
 <li class="blockList">
 <h4>main</h4>
-<pre>public static&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1865">main</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;args)
+<pre>public static&nbsp;void&nbsp;<a href="../../../../../src-html/org/apache/hadoop/hbase/tool/CanaryTool.html#line.1874">main</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>[]&nbsp;args)
                  throws <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html?is-external=true" title="class or interface in java.lang">Exception</a></pre>
 <dl>
 <dt><span class="throwsLabel">Throws:</span></dt>
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/Version.html b/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
index 541240f..dc886e5 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/Version.html
@@ -18,9 +18,9 @@
 <span class="sourceLineNo">010</span>  justification="Intentional; to be modified in test")<a name="line.10"></a>
 <span class="sourceLineNo">011</span>public class Version {<a name="line.11"></a>
 <span class="sourceLineNo">012</span>  public static final String version = new String("3.0.0-SNAPSHOT");<a name="line.12"></a>
-<span class="sourceLineNo">013</span>  public static final String revision = "b8a4504a2609d6d6d26e0b839a368912b3276feb";<a name="line.13"></a>
+<span class="sourceLineNo">013</span>  public static final String revision = "c58e80fbe6db6426e652ec363149b92f9e33fbb0";<a name="line.13"></a>
 <span class="sourceLineNo">014</span>  public static final String user = "jenkins";<a name="line.14"></a>
-<span class="sourceLineNo">015</span>  public static final String date = "Fri Nov  1 14:36:53 UTC 2019";<a name="line.15"></a>
+<span class="sourceLineNo">015</span>  public static final String date = "Sat Nov  2 14:35:46 UTC 2019";<a name="line.15"></a>
 <span class="sourceLineNo">016</span>  public static final String url = "git://jenkins-websites-he-de.apache.org/home/jenkins/jenkins-slave/workspace/hbase_generate_website/hbase";<a name="line.16"></a>
 <span class="sourceLineNo">017</span>  public static final String srcChecksum = "(stdin)=";<a name="line.17"></a>
 <span class="sourceLineNo">018</span>}<a name="line.18"></a>
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html b/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html
index 5e57151..4b34be0 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.Monitor.html
@@ -500,1392 +500,1401 @@
 <span class="sourceLineNo">492</span>          sink.publishReadTiming(serverName, region, column, stopWatch.getTime());<a name="line.492"></a>
 <span class="sourceLineNo">493</span>        } catch (Exception e) {<a name="line.493"></a>
 <span class="sourceLineNo">494</span>          sink.publishReadFailure(serverName, region, column, e);<a name="line.494"></a>
-<span class="sourceLineNo">495</span>          sink.updateReadFailures(region.getRegionNameAsString(), serverName.getHostname());<a name="line.495"></a>
-<span class="sourceLineNo">496</span>        } finally {<a name="line.496"></a>
-<span class="sourceLineNo">497</span>          if (rs != null) {<a name="line.497"></a>
-<span class="sourceLineNo">498</span>            rs.close();<a name="line.498"></a>
-<span class="sourceLineNo">499</span>          }<a name="line.499"></a>
-<span class="sourceLineNo">500</span>          scan = null;<a name="line.500"></a>
-<span class="sourceLineNo">501</span>          get = null;<a name="line.501"></a>
-<span class="sourceLineNo">502</span>        }<a name="line.502"></a>
-<span class="sourceLineNo">503</span>      }<a name="line.503"></a>
-<span class="sourceLineNo">504</span>      try {<a name="line.504"></a>
-<span class="sourceLineNo">505</span>        table.close();<a name="line.505"></a>
-<span class="sourceLineNo">506</span>      } catch (IOException e) {<a name="line.506"></a>
-<span class="sourceLineNo">507</span>        LOG.error("Close table failed", e);<a name="line.507"></a>
-<span class="sourceLineNo">508</span>      }<a name="line.508"></a>
-<span class="sourceLineNo">509</span>      return null;<a name="line.509"></a>
-<span class="sourceLineNo">510</span>    }<a name="line.510"></a>
-<span class="sourceLineNo">511</span><a name="line.511"></a>
-<span class="sourceLineNo">512</span>    /**<a name="line.512"></a>
-<span class="sourceLineNo">513</span>     * Check writes for the canary table<a name="line.513"></a>
-<span class="sourceLineNo">514</span>     */<a name="line.514"></a>
-<span class="sourceLineNo">515</span>    private Void write() {<a name="line.515"></a>
-<span class="sourceLineNo">516</span>      Table table = null;<a name="line.516"></a>
-<span class="sourceLineNo">517</span>      TableDescriptor tableDesc = null;<a name="line.517"></a>
-<span class="sourceLineNo">518</span>      try {<a name="line.518"></a>
-<span class="sourceLineNo">519</span>        table = connection.getTable(region.getTable());<a name="line.519"></a>
-<span class="sourceLineNo">520</span>        tableDesc = table.getDescriptor();<a name="line.520"></a>
-<span class="sourceLineNo">521</span>        byte[] rowToCheck = region.getStartKey();<a name="line.521"></a>
-<span class="sourceLineNo">522</span>        if (rowToCheck.length == 0) {<a name="line.522"></a>
-<span class="sourceLineNo">523</span>          rowToCheck = new byte[]{0x0};<a name="line.523"></a>
-<span class="sourceLineNo">524</span>        }<a name="line.524"></a>
-<span class="sourceLineNo">525</span>        int writeValueSize =<a name="line.525"></a>
-<span class="sourceLineNo">526</span>            connection.getConfiguration().getInt(HConstants.HBASE_CANARY_WRITE_VALUE_SIZE_KEY, 10);<a name="line.526"></a>
-<span class="sourceLineNo">527</span>        for (ColumnFamilyDescriptor column : tableDesc.getColumnFamilies()) {<a name="line.527"></a>
-<span class="sourceLineNo">528</span>          Put put = new Put(rowToCheck);<a name="line.528"></a>
-<span class="sourceLineNo">529</span>          byte[] value = new byte[writeValueSize];<a name="line.529"></a>
-<span class="sourceLineNo">530</span>          Bytes.random(value);<a name="line.530"></a>
-<span class="sourceLineNo">531</span>          put.addColumn(column.getName(), HConstants.EMPTY_BYTE_ARRAY, value);<a name="line.531"></a>
-<span class="sourceLineNo">532</span><a name="line.532"></a>
-<span class="sourceLineNo">533</span>          LOG.debug("Writing to {} {} {} {}",<a name="line.533"></a>
-<span class="sourceLineNo">534</span>            tableDesc.getTableName(), region.getRegionNameAsString(), column.getNameAsString(),<a name="line.534"></a>
-<span class="sourceLineNo">535</span>            Bytes.toStringBinary(rowToCheck));<a name="line.535"></a>
-<span class="sourceLineNo">536</span>          try {<a name="line.536"></a>
-<span class="sourceLineNo">537</span>            long startTime = System.currentTimeMillis();<a name="line.537"></a>
-<span class="sourceLineNo">538</span>            table.put(put);<a name="line.538"></a>
-<span class="sourceLineNo">539</span>            long time = System.currentTimeMillis() - startTime;<a name="line.539"></a>
-<span class="sourceLineNo">540</span>            this.readWriteLatency.add(time);<a name="line.540"></a>
-<span class="sourceLineNo">541</span>            sink.publishWriteTiming(serverName, region, column, time);<a name="line.541"></a>
-<span class="sourceLineNo">542</span>          } catch (Exception e) {<a name="line.542"></a>
-<span class="sourceLineNo">543</span>            sink.publishWriteFailure(serverName, region, column, e);<a name="line.543"></a>
-<span class="sourceLineNo">544</span>          }<a name="line.544"></a>
-<span class="sourceLineNo">545</span>        }<a name="line.545"></a>
-<span class="sourceLineNo">546</span>        table.close();<a name="line.546"></a>
-<span class="sourceLineNo">547</span>      } catch (IOException e) {<a name="line.547"></a>
-<span class="sourceLineNo">548</span>        sink.publishWriteFailure(serverName, region, e);<a name="line.548"></a>
-<span class="sourceLineNo">549</span>        sink.updateWriteFailures(region.getRegionNameAsString(), serverName.getHostname() );<a name="line.549"></a>
-<span class="sourceLineNo">550</span>      }<a name="line.550"></a>
-<span class="sourceLineNo">551</span>      return null;<a name="line.551"></a>
-<span class="sourceLineNo">552</span>    }<a name="line.552"></a>
-<span class="sourceLineNo">553</span>  }<a name="line.553"></a>
-<span class="sourceLineNo">554</span><a name="line.554"></a>
-<span class="sourceLineNo">555</span>  /**<a name="line.555"></a>
-<span class="sourceLineNo">556</span>   * Run a single RegionServer Task and then exit.<a name="line.556"></a>
-<span class="sourceLineNo">557</span>   * Get one row from a region on the regionserver and output latency or the failure.<a name="line.557"></a>
-<span class="sourceLineNo">558</span>   */<a name="line.558"></a>
-<span class="sourceLineNo">559</span>  static class RegionServerTask implements Callable&lt;Void&gt; {<a name="line.559"></a>
-<span class="sourceLineNo">560</span>    private Connection connection;<a name="line.560"></a>
-<span class="sourceLineNo">561</span>    private String serverName;<a name="line.561"></a>
-<span class="sourceLineNo">562</span>    private RegionInfo region;<a name="line.562"></a>
-<span class="sourceLineNo">563</span>    private RegionServerStdOutSink sink;<a name="line.563"></a>
-<span class="sourceLineNo">564</span>    private AtomicLong successes;<a name="line.564"></a>
-<span class="sourceLineNo">565</span><a name="line.565"></a>
-<span class="sourceLineNo">566</span>    RegionServerTask(Connection connection, String serverName, RegionInfo region,<a name="line.566"></a>
-<span class="sourceLineNo">567</span>        RegionServerStdOutSink sink, AtomicLong successes) {<a name="line.567"></a>
-<span class="sourceLineNo">568</span>      this.connection = connection;<a name="line.568"></a>
-<span class="sourceLineNo">569</span>      this.serverName = serverName;<a name="line.569"></a>
-<span class="sourceLineNo">570</span>      this.region = region;<a name="line.570"></a>
-<span class="sourceLineNo">571</span>      this.sink = sink;<a name="line.571"></a>
-<span class="sourceLineNo">572</span>      this.successes = successes;<a name="line.572"></a>
-<span class="sourceLineNo">573</span>    }<a name="line.573"></a>
-<span class="sourceLineNo">574</span><a name="line.574"></a>
-<span class="sourceLineNo">575</span>    @Override<a name="line.575"></a>
-<span class="sourceLineNo">576</span>    public Void call() {<a name="line.576"></a>
-<span class="sourceLineNo">577</span>      TableName tableName = null;<a name="line.577"></a>
-<span class="sourceLineNo">578</span>      Table table = null;<a name="line.578"></a>
-<span class="sourceLineNo">579</span>      Get get = null;<a name="line.579"></a>
-<span class="sourceLineNo">580</span>      byte[] startKey = null;<a name="line.580"></a>
-<span class="sourceLineNo">581</span>      Scan scan = null;<a name="line.581"></a>
-<span class="sourceLineNo">582</span>      StopWatch stopWatch = new StopWatch();<a name="line.582"></a>
-<span class="sourceLineNo">583</span>      // monitor one region on every region server<a name="line.583"></a>
-<span class="sourceLineNo">584</span>      stopWatch.reset();<a name="line.584"></a>
-<span class="sourceLineNo">585</span>      try {<a name="line.585"></a>
-<span class="sourceLineNo">586</span>        tableName = region.getTable();<a name="line.586"></a>
-<span class="sourceLineNo">587</span>        table = connection.getTable(tableName);<a name="line.587"></a>
-<span class="sourceLineNo">588</span>        startKey = region.getStartKey();<a name="line.588"></a>
-<span class="sourceLineNo">589</span>        // Can't do a get on empty start row so do a Scan of first element if any instead.<a name="line.589"></a>
-<span class="sourceLineNo">590</span>        LOG.debug("Reading from {} {} {} {}",<a name="line.590"></a>
-<span class="sourceLineNo">591</span>          serverName, region.getTable(), region.getRegionNameAsString(),<a name="line.591"></a>
-<span class="sourceLineNo">592</span>          Bytes.toStringBinary(startKey));<a name="line.592"></a>
-<span class="sourceLineNo">593</span>        if (startKey.length &gt; 0) {<a name="line.593"></a>
-<span class="sourceLineNo">594</span>          get = new Get(startKey);<a name="line.594"></a>
-<span class="sourceLineNo">595</span>          get.setCacheBlocks(false);<a name="line.595"></a>
-<span class="sourceLineNo">596</span>          get.setFilter(new FirstKeyOnlyFilter());<a name="line.596"></a>
-<span class="sourceLineNo">597</span>          stopWatch.start();<a name="line.597"></a>
-<span class="sourceLineNo">598</span>          table.get(get);<a name="line.598"></a>
-<span class="sourceLineNo">599</span>          stopWatch.stop();<a name="line.599"></a>
-<span class="sourceLineNo">600</span>        } else {<a name="line.600"></a>
-<span class="sourceLineNo">601</span>          scan = new Scan();<a name="line.601"></a>
-<span class="sourceLineNo">602</span>          scan.setCacheBlocks(false);<a name="line.602"></a>
-<span class="sourceLineNo">603</span>          scan.setFilter(new FirstKeyOnlyFilter());<a name="line.603"></a>
-<span class="sourceLineNo">604</span>          scan.setCaching(1);<a name="line.604"></a>
-<span class="sourceLineNo">605</span>          scan.setMaxResultSize(1L);<a name="line.605"></a>
-<span class="sourceLineNo">606</span>          scan.setOneRowLimit();<a name="line.606"></a>
-<span class="sourceLineNo">607</span>          stopWatch.start();<a name="line.607"></a>
-<span class="sourceLineNo">608</span>          ResultScanner s = table.getScanner(scan);<a name="line.608"></a>
-<span class="sourceLineNo">609</span>          s.next();<a name="line.609"></a>
-<span class="sourceLineNo">610</span>          s.close();<a name="line.610"></a>
-<span class="sourceLineNo">611</span>          stopWatch.stop();<a name="line.611"></a>
-<span class="sourceLineNo">612</span>        }<a name="line.612"></a>
-<span class="sourceLineNo">613</span>        successes.incrementAndGet();<a name="line.613"></a>
-<span class="sourceLineNo">614</span>        sink.publishReadTiming(tableName.getNameAsString(), serverName, stopWatch.getTime());<a name="line.614"></a>
-<span class="sourceLineNo">615</span>      } catch (TableNotFoundException tnfe) {<a name="line.615"></a>
-<span class="sourceLineNo">616</span>        LOG.error("Table may be deleted", tnfe);<a name="line.616"></a>
-<span class="sourceLineNo">617</span>        // This is ignored because it doesn't imply that the regionserver is dead<a name="line.617"></a>
-<span class="sourceLineNo">618</span>      } catch (TableNotEnabledException tnee) {<a name="line.618"></a>
-<span class="sourceLineNo">619</span>        // This is considered a success since we got a response.<a name="line.619"></a>
-<span class="sourceLineNo">620</span>        successes.incrementAndGet();<a name="line.620"></a>
-<span class="sourceLineNo">621</span>        LOG.debug("The targeted table was disabled.  Assuming success.");<a name="line.621"></a>
-<span class="sourceLineNo">622</span>      } catch (DoNotRetryIOException dnrioe) {<a name="line.622"></a>
-<span class="sourceLineNo">623</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.623"></a>
-<span class="sourceLineNo">624</span>        LOG.error(dnrioe.toString(), dnrioe);<a name="line.624"></a>
-<span class="sourceLineNo">625</span>      } catch (IOException e) {<a name="line.625"></a>
-<span class="sourceLineNo">626</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.626"></a>
-<span class="sourceLineNo">627</span>        LOG.error(e.toString(), e);<a name="line.627"></a>
-<span class="sourceLineNo">628</span>      } finally {<a name="line.628"></a>
-<span class="sourceLineNo">629</span>        if (table != null) {<a name="line.629"></a>
-<span class="sourceLineNo">630</span>          try {<a name="line.630"></a>
-<span class="sourceLineNo">631</span>            table.close();<a name="line.631"></a>
-<span class="sourceLineNo">632</span>          } catch (IOException e) {/* DO NOTHING */<a name="line.632"></a>
-<span class="sourceLineNo">633</span>            LOG.error("Close table failed", e);<a name="line.633"></a>
-<span class="sourceLineNo">634</span>          }<a name="line.634"></a>
-<span class="sourceLineNo">635</span>        }<a name="line.635"></a>
-<span class="sourceLineNo">636</span>        scan = null;<a name="line.636"></a>
-<span class="sourceLineNo">637</span>        get = null;<a name="line.637"></a>
-<span class="sourceLineNo">638</span>        startKey = null;<a name="line.638"></a>
-<span class="sourceLineNo">639</span>      }<a name="line.639"></a>
-<span class="sourceLineNo">640</span>      return null;<a name="line.640"></a>
-<span class="sourceLineNo">641</span>    }<a name="line.641"></a>
-<span class="sourceLineNo">642</span>  }<a name="line.642"></a>
-<span class="sourceLineNo">643</span><a name="line.643"></a>
-<span class="sourceLineNo">644</span>  private static final int USAGE_EXIT_CODE = 1;<a name="line.644"></a>
-<span class="sourceLineNo">645</span>  private static final int INIT_ERROR_EXIT_CODE = 2;<a name="line.645"></a>
-<span class="sourceLineNo">646</span>  private static final int TIMEOUT_ERROR_EXIT_CODE = 3;<a name="line.646"></a>
-<span class="sourceLineNo">647</span>  private static final int ERROR_EXIT_CODE = 4;<a name="line.647"></a>
-<span class="sourceLineNo">648</span>  private static final int FAILURE_EXIT_CODE = 5;<a name="line.648"></a>
-<span class="sourceLineNo">649</span><a name="line.649"></a>
-<span class="sourceLineNo">650</span>  private static final long DEFAULT_INTERVAL = 60000;<a name="line.650"></a>
-<span class="sourceLineNo">651</span><a name="line.651"></a>
-<span class="sourceLineNo">652</span>  private static final long DEFAULT_TIMEOUT = 600000; // 10 mins<a name="line.652"></a>
-<span class="sourceLineNo">653</span>  private static final int MAX_THREADS_NUM = 16; // #threads to contact regions<a name="line.653"></a>
-<span class="sourceLineNo">654</span><a name="line.654"></a>
-<span class="sourceLineNo">655</span>  private static final Logger LOG = LoggerFactory.getLogger(Canary.class);<a name="line.655"></a>
-<span class="sourceLineNo">656</span><a name="line.656"></a>
-<span class="sourceLineNo">657</span>  public static final TableName DEFAULT_WRITE_TABLE_NAME = TableName.valueOf(<a name="line.657"></a>
-<span class="sourceLineNo">658</span>    NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "canary");<a name="line.658"></a>
-<span class="sourceLineNo">659</span><a name="line.659"></a>
-<span class="sourceLineNo">660</span>  private static final String CANARY_TABLE_FAMILY_NAME = "Test";<a name="line.660"></a>
-<span class="sourceLineNo">661</span><a name="line.661"></a>
-<span class="sourceLineNo">662</span>  private Configuration conf = null;<a name="line.662"></a>
-<span class="sourceLineNo">663</span>  private long interval = 0;<a name="line.663"></a>
-<span class="sourceLineNo">664</span>  private Sink sink = null;<a name="line.664"></a>
-<span class="sourceLineNo">665</span><a name="line.665"></a>
-<span class="sourceLineNo">666</span>  /**<a name="line.666"></a>
-<span class="sourceLineNo">667</span>   * True if we are to run in 'regionServer' mode.<a name="line.667"></a>
-<span class="sourceLineNo">668</span>   */<a name="line.668"></a>
-<span class="sourceLineNo">669</span>  private boolean regionServerMode = false;<a name="line.669"></a>
-<span class="sourceLineNo">670</span><a name="line.670"></a>
-<span class="sourceLineNo">671</span>  /**<a name="line.671"></a>
-<span class="sourceLineNo">672</span>   * True if we are to run in zookeeper 'mode'.<a name="line.672"></a>
-<span class="sourceLineNo">673</span>   */<a name="line.673"></a>
-<span class="sourceLineNo">674</span>  private boolean zookeeperMode = false;<a name="line.674"></a>
-<span class="sourceLineNo">675</span><a name="line.675"></a>
-<span class="sourceLineNo">676</span>  /**<a name="line.676"></a>
-<span class="sourceLineNo">677</span>   * This is a Map of table to timeout. The timeout is for reading all regions in the table; i.e.<a name="line.677"></a>
-<span class="sourceLineNo">678</span>   * we aggregate time to fetch each region and it needs to be less than this value else we<a name="line.678"></a>
-<span class="sourceLineNo">679</span>   * log an ERROR.<a name="line.679"></a>
-<span class="sourceLineNo">680</span>   */<a name="line.680"></a>
-<span class="sourceLineNo">681</span>  private HashMap&lt;String, Long&gt; configuredReadTableTimeouts = new HashMap&lt;&gt;();<a name="line.681"></a>
-<span class="sourceLineNo">682</span><a name="line.682"></a>
-<span class="sourceLineNo">683</span>  public static final String HBASE_CANARY_REGIONSERVER_ALL_REGIONS<a name="line.683"></a>
-<span class="sourceLineNo">684</span>          = "hbase.canary.regionserver_all_regions";<a name="line.684"></a>
-<span class="sourceLineNo">685</span><a name="line.685"></a>
-<span class="sourceLineNo">686</span>  public static final String HBASE_CANARY_REGION_WRITE_SNIFFING<a name="line.686"></a>
-<span class="sourceLineNo">687</span>          = "hbase.canary.region.write.sniffing";<a name="line.687"></a>
-<span class="sourceLineNo">688</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT<a name="line.688"></a>
-<span class="sourceLineNo">689</span>          = "hbase.canary.region.write.table.timeout";<a name="line.689"></a>
-<span class="sourceLineNo">690</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_NAME<a name="line.690"></a>
-<span class="sourceLineNo">691</span>          = "hbase.canary.region.write.table.name";<a name="line.691"></a>
-<span class="sourceLineNo">692</span>  public static final String HBASE_CANARY_REGION_READ_TABLE_TIMEOUT<a name="line.692"></a>
-<span class="sourceLineNo">693</span>          = "hbase.canary.region.read.table.timeout";<a name="line.693"></a>
-<span class="sourceLineNo">694</span><a name="line.694"></a>
-<span class="sourceLineNo">695</span>  public static final String HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES<a name="line.695"></a>
-<span class="sourceLineNo">696</span>          = "hbase.canary.zookeeper.permitted.failures";<a name="line.696"></a>
-<span class="sourceLineNo">697</span><a name="line.697"></a>
-<span class="sourceLineNo">698</span>  public static final String HBASE_CANARY_USE_REGEX = "hbase.canary.use.regex";<a name="line.698"></a>
-<span class="sourceLineNo">699</span>  public static final String HBASE_CANARY_TIMEOUT = "hbase.canary.timeout";<a name="line.699"></a>
-<span class="sourceLineNo">700</span>  public static final String HBASE_CANARY_FAIL_ON_ERROR = "hbase.canary.fail.on.error";<a name="line.700"></a>
-<span class="sourceLineNo">701</span><a name="line.701"></a>
+<span class="sourceLineNo">495</span>          sink.updateReadFailures(region == null? "NULL": region.getRegionNameAsString(),<a name="line.495"></a>
+<span class="sourceLineNo">496</span>              serverName == null? "NULL": serverName.getHostname());<a name="line.496"></a>
+<span class="sourceLineNo">497</span>        } finally {<a name="line.497"></a>
+<span class="sourceLineNo">498</span>          if (rs != null) {<a name="line.498"></a>
+<span class="sourceLineNo">499</span>            rs.close();<a name="line.499"></a>
+<span class="sourceLineNo">500</span>          }<a name="line.500"></a>
+<span class="sourceLineNo">501</span>          scan = null;<a name="line.501"></a>
+<span class="sourceLineNo">502</span>          get = null;<a name="line.502"></a>
+<span class="sourceLineNo">503</span>        }<a name="line.503"></a>
+<span class="sourceLineNo">504</span>      }<a name="line.504"></a>
+<span class="sourceLineNo">505</span>      try {<a name="line.505"></a>
+<span class="sourceLineNo">506</span>        table.close();<a name="line.506"></a>
+<span class="sourceLineNo">507</span>      } catch (IOException e) {<a name="line.507"></a>
+<span class="sourceLineNo">508</span>        LOG.error("Close table failed", e);<a name="line.508"></a>
+<span class="sourceLineNo">509</span>      }<a name="line.509"></a>
+<span class="sourceLineNo">510</span>      return null;<a name="line.510"></a>
+<span class="sourceLineNo">511</span>    }<a name="line.511"></a>
+<span class="sourceLineNo">512</span><a name="line.512"></a>
+<span class="sourceLineNo">513</span>    /**<a name="line.513"></a>
+<span class="sourceLineNo">514</span>     * Check writes for the canary table<a name="line.514"></a>
+<span class="sourceLineNo">515</span>     */<a name="line.515"></a>
+<span class="sourceLineNo">516</span>    private Void write() {<a name="line.516"></a>
+<span class="sourceLineNo">517</span>      Table table = null;<a name="line.517"></a>
+<span class="sourceLineNo">518</span>      TableDescriptor tableDesc = null;<a name="line.518"></a>
+<span class="sourceLineNo">519</span>      try {<a name="line.519"></a>
+<span class="sourceLineNo">520</span>        table = connection.getTable(region.getTable());<a name="line.520"></a>
+<span class="sourceLineNo">521</span>        tableDesc = table.getDescriptor();<a name="line.521"></a>
+<span class="sourceLineNo">522</span>        byte[] rowToCheck = region.getStartKey();<a name="line.522"></a>
+<span class="sourceLineNo">523</span>        if (rowToCheck.length == 0) {<a name="line.523"></a>
+<span class="sourceLineNo">524</span>          rowToCheck = new byte[]{0x0};<a name="line.524"></a>
+<span class="sourceLineNo">525</span>        }<a name="line.525"></a>
+<span class="sourceLineNo">526</span>        int writeValueSize =<a name="line.526"></a>
+<span class="sourceLineNo">527</span>            connection.getConfiguration().getInt(HConstants.HBASE_CANARY_WRITE_VALUE_SIZE_KEY, 10);<a name="line.527"></a>
+<span class="sourceLineNo">528</span>        for (ColumnFamilyDescriptor column : tableDesc.getColumnFamilies()) {<a name="line.528"></a>
+<span class="sourceLineNo">529</span>          Put put = new Put(rowToCheck);<a name="line.529"></a>
+<span class="sourceLineNo">530</span>          byte[] value = new byte[writeValueSize];<a name="line.530"></a>
+<span class="sourceLineNo">531</span>          Bytes.random(value);<a name="line.531"></a>
+<span class="sourceLineNo">532</span>          put.addColumn(column.getName(), HConstants.EMPTY_BYTE_ARRAY, value);<a name="line.532"></a>
+<span class="sourceLineNo">533</span><a name="line.533"></a>
+<span class="sourceLineNo">534</span>          LOG.debug("Writing to {} {} {} {}",<a name="line.534"></a>
+<span class="sourceLineNo">535</span>            tableDesc.getTableName(), region.getRegionNameAsString(), column.getNameAsString(),<a name="line.535"></a>
+<span class="sourceLineNo">536</span>            Bytes.toStringBinary(rowToCheck));<a name="line.536"></a>
+<span class="sourceLineNo">537</span>          try {<a name="line.537"></a>
+<span class="sourceLineNo">538</span>            long startTime = System.currentTimeMillis();<a name="line.538"></a>
+<span class="sourceLineNo">539</span>            table.put(put);<a name="line.539"></a>
+<span class="sourceLineNo">540</span>            long time = System.currentTimeMillis() - startTime;<a name="line.540"></a>
+<span class="sourceLineNo">541</span>            this.readWriteLatency.add(time);<a name="line.541"></a>
+<span class="sourceLineNo">542</span>            sink.publishWriteTiming(serverName, region, column, time);<a name="line.542"></a>
+<span class="sourceLineNo">543</span>          } catch (Exception e) {<a name="line.543"></a>
+<span class="sourceLineNo">544</span>            sink.publishWriteFailure(serverName, region, column, e);<a name="line.544"></a>
+<span class="sourceLineNo">545</span>          }<a name="line.545"></a>
+<span class="sourceLineNo">546</span>        }<a name="line.546"></a>
+<span class="sourceLineNo">547</span>        table.close();<a name="line.547"></a>
+<span class="sourceLineNo">548</span>      } catch (IOException e) {<a name="line.548"></a>
+<span class="sourceLineNo">549</span>        sink.publishWriteFailure(serverName, region, e);<a name="line.549"></a>
+<span class="sourceLineNo">550</span>        sink.updateWriteFailures(region.getRegionNameAsString(), serverName.getHostname() );<a name="line.550"></a>
+<span class="sourceLineNo">551</span>      }<a name="line.551"></a>
+<span class="sourceLineNo">552</span>      return null;<a name="line.552"></a>
+<span class="sourceLineNo">553</span>    }<a name="line.553"></a>
+<span class="sourceLineNo">554</span>  }<a name="line.554"></a>
+<span class="sourceLineNo">555</span><a name="line.555"></a>
+<span class="sourceLineNo">556</span>  /**<a name="line.556"></a>
+<span class="sourceLineNo">557</span>   * Run a single RegionServer Task and then exit.<a name="line.557"></a>
+<span class="sourceLineNo">558</span>   * Get one row from a region on the regionserver and output latency or the failure.<a name="line.558"></a>
+<span class="sourceLineNo">559</span>   */<a name="line.559"></a>
+<span class="sourceLineNo">560</span>  static class RegionServerTask implements Callable&lt;Void&gt; {<a name="line.560"></a>
+<span class="sourceLineNo">561</span>    private Connection connection;<a name="line.561"></a>
+<span class="sourceLineNo">562</span>    private String serverName;<a name="line.562"></a>
+<span class="sourceLineNo">563</span>    private RegionInfo region;<a name="line.563"></a>
+<span class="sourceLineNo">564</span>    private RegionServerStdOutSink sink;<a name="line.564"></a>
+<span class="sourceLineNo">565</span>    private AtomicLong successes;<a name="line.565"></a>
+<span class="sourceLineNo">566</span><a name="line.566"></a>
+<span class="sourceLineNo">567</span>    RegionServerTask(Connection connection, String serverName, RegionInfo region,<a name="line.567"></a>
+<span class="sourceLineNo">568</span>        RegionServerStdOutSink sink, AtomicLong successes) {<a name="line.568"></a>
+<span class="sourceLineNo">569</span>      this.connection = connection;<a name="line.569"></a>
+<span class="sourceLineNo">570</span>      this.serverName = serverName;<a name="line.570"></a>
+<span class="sourceLineNo">571</span>      this.region = region;<a name="line.571"></a>
+<span class="sourceLineNo">572</span>      this.sink = sink;<a name="line.572"></a>
+<span class="sourceLineNo">573</span>      this.successes = successes;<a name="line.573"></a>
+<span class="sourceLineNo">574</span>    }<a name="line.574"></a>
+<span class="sourceLineNo">575</span><a name="line.575"></a>
+<span class="sourceLineNo">576</span>    @Override<a name="line.576"></a>
+<span class="sourceLineNo">577</span>    public Void call() {<a name="line.577"></a>
+<span class="sourceLineNo">578</span>      TableName tableName = null;<a name="line.578"></a>
+<span class="sourceLineNo">579</span>      Table table = null;<a name="line.579"></a>
+<span class="sourceLineNo">580</span>      Get get = null;<a name="line.580"></a>
+<span class="sourceLineNo">581</span>      byte[] startKey = null;<a name="line.581"></a>
+<span class="sourceLineNo">582</span>      Scan scan = null;<a name="line.582"></a>
+<span class="sourceLineNo">583</span>      StopWatch stopWatch = new StopWatch();<a name="line.583"></a>
+<span class="sourceLineNo">584</span>      // monitor one region on every region server<a name="line.584"></a>
+<span class="sourceLineNo">585</span>      stopWatch.reset();<a name="line.585"></a>
+<span class="sourceLineNo">586</span>      try {<a name="line.586"></a>
+<span class="sourceLineNo">587</span>        tableName = region.getTable();<a name="line.587"></a>
+<span class="sourceLineNo">588</span>        table = connection.getTable(tableName);<a name="line.588"></a>
+<span class="sourceLineNo">589</span>        startKey = region.getStartKey();<a name="line.589"></a>
+<span class="sourceLineNo">590</span>        // Can't do a get on empty start row so do a Scan of first element if any instead.<a name="line.590"></a>
+<span class="sourceLineNo">591</span>        LOG.debug("Reading from {} {} {} {}",<a name="line.591"></a>
+<span class="sourceLineNo">592</span>          serverName, region.getTable(), region.getRegionNameAsString(),<a name="line.592"></a>
+<span class="sourceLineNo">593</span>          Bytes.toStringBinary(startKey));<a name="line.593"></a>
+<span class="sourceLineNo">594</span>        if (startKey.length &gt; 0) {<a name="line.594"></a>
+<span class="sourceLineNo">595</span>          get = new Get(startKey);<a name="line.595"></a>
+<span class="sourceLineNo">596</span>          get.setCacheBlocks(false);<a name="line.596"></a>
+<span class="sourceLineNo">597</span>          get.setFilter(new FirstKeyOnlyFilter());<a name="line.597"></a>
+<span class="sourceLineNo">598</span>          stopWatch.start();<a name="line.598"></a>
+<span class="sourceLineNo">599</span>          table.get(get);<a name="line.599"></a>
+<span class="sourceLineNo">600</span>          stopWatch.stop();<a name="line.600"></a>
+<span class="sourceLineNo">601</span>        } else {<a name="line.601"></a>
+<span class="sourceLineNo">602</span>          scan = new Scan();<a name="line.602"></a>
+<span class="sourceLineNo">603</span>          scan.setCacheBlocks(false);<a name="line.603"></a>
+<span class="sourceLineNo">604</span>          scan.setFilter(new FirstKeyOnlyFilter());<a name="line.604"></a>
+<span class="sourceLineNo">605</span>          scan.setCaching(1);<a name="line.605"></a>
+<span class="sourceLineNo">606</span>          scan.setMaxResultSize(1L);<a name="line.606"></a>
+<span class="sourceLineNo">607</span>          scan.setOneRowLimit();<a name="line.607"></a>
+<span class="sourceLineNo">608</span>          stopWatch.start();<a name="line.608"></a>
+<span class="sourceLineNo">609</span>          ResultScanner s = table.getScanner(scan);<a name="line.609"></a>
+<span class="sourceLineNo">610</span>          s.next();<a name="line.610"></a>
+<span class="sourceLineNo">611</span>          s.close();<a name="line.611"></a>
+<span class="sourceLineNo">612</span>          stopWatch.stop();<a name="line.612"></a>
+<span class="sourceLineNo">613</span>        }<a name="line.613"></a>
+<span class="sourceLineNo">614</span>        successes.incrementAndGet();<a name="line.614"></a>
+<span class="sourceLineNo">615</span>        sink.publishReadTiming(tableName.getNameAsString(), serverName, stopWatch.getTime());<a name="line.615"></a>
+<span class="sourceLineNo">616</span>      } catch (TableNotFoundException tnfe) {<a name="line.616"></a>
+<span class="sourceLineNo">617</span>        LOG.error("Table may be deleted", tnfe);<a name="line.617"></a>
+<span class="sourceLineNo">618</span>        // This is ignored because it doesn't imply that the regionserver is dead<a name="line.618"></a>
+<span class="sourceLineNo">619</span>      } catch (TableNotEnabledException tnee) {<a name="line.619"></a>
+<span class="sourceLineNo">620</span>        // This is considered a success since we got a response.<a name="line.620"></a>
+<span class="sourceLineNo">621</span>        successes.incrementAndGet();<a name="line.621"></a>
+<span class="sourceLineNo">622</span>        LOG.debug("The targeted table was disabled.  Assuming success.");<a name="line.622"></a>
+<span class="sourceLineNo">623</span>      } catch (DoNotRetryIOException dnrioe) {<a name="line.623"></a>
+<span class="sourceLineNo">624</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.624"></a>
+<span class="sourceLineNo">625</span>        LOG.error(dnrioe.toString(), dnrioe);<a name="line.625"></a>
+<span class="sourceLineNo">626</span>      } catch (IOException e) {<a name="line.626"></a>
+<span class="sourceLineNo">627</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.627"></a>
+<span class="sourceLineNo">628</span>        LOG.error(e.toString(), e);<a name="line.628"></a>
+<span class="sourceLineNo">629</span>      } finally {<a name="line.629"></a>
+<span class="sourceLineNo">630</span>        if (table != null) {<a name="line.630"></a>
+<span class="sourceLineNo">631</span>          try {<a name="line.631"></a>
+<span class="sourceLineNo">632</span>            table.close();<a name="line.632"></a>
+<span class="sourceLineNo">633</span>          } catch (IOException e) {/* DO NOTHING */<a name="line.633"></a>
+<span class="sourceLineNo">634</span>            LOG.error("Close table failed", e);<a name="line.634"></a>
+<span class="sourceLineNo">635</span>          }<a name="line.635"></a>
+<span class="sourceLineNo">636</span>        }<a name="line.636"></a>
+<span class="sourceLineNo">637</span>        scan = null;<a name="line.637"></a>
+<span class="sourceLineNo">638</span>        get = null;<a name="line.638"></a>
+<span class="sourceLineNo">639</span>        startKey = null;<a name="line.639"></a>
+<span class="sourceLineNo">640</span>      }<a name="line.640"></a>
+<span class="sourceLineNo">641</span>      return null;<a name="line.641"></a>
+<span class="sourceLineNo">642</span>    }<a name="line.642"></a>
+<span class="sourceLineNo">643</span>  }<a name="line.643"></a>
+<span class="sourceLineNo">644</span><a name="line.644"></a>
+<span class="sourceLineNo">645</span>  private static final int USAGE_EXIT_CODE = 1;<a name="line.645"></a>
+<span class="sourceLineNo">646</span>  private static final int INIT_ERROR_EXIT_CODE = 2;<a name="line.646"></a>
+<span class="sourceLineNo">647</span>  private static final int TIMEOUT_ERROR_EXIT_CODE = 3;<a name="line.647"></a>
+<span class="sourceLineNo">648</span>  private static final int ERROR_EXIT_CODE = 4;<a name="line.648"></a>
+<span class="sourceLineNo">649</span>  private static final int FAILURE_EXIT_CODE = 5;<a name="line.649"></a>
+<span class="sourceLineNo">650</span><a name="line.650"></a>
+<span class="sourceLineNo">651</span>  private static final long DEFAULT_INTERVAL = 60000;<a name="line.651"></a>
+<span class="sourceLineNo">652</span><a name="line.652"></a>
+<span class="sourceLineNo">653</span>  private static final long DEFAULT_TIMEOUT = 600000; // 10 mins<a name="line.653"></a>
+<span class="sourceLineNo">654</span>  private static final int MAX_THREADS_NUM = 16; // #threads to contact regions<a name="line.654"></a>
+<span class="sourceLineNo">655</span><a name="line.655"></a>
+<span class="sourceLineNo">656</span>  private static final Logger LOG = LoggerFactory.getLogger(Canary.class);<a name="line.656"></a>
+<span class="sourceLineNo">657</span><a name="line.657"></a>
+<span class="sourceLineNo">658</span>  public static final TableName DEFAULT_WRITE_TABLE_NAME = TableName.valueOf(<a name="line.658"></a>
+<span class="sourceLineNo">659</span>    NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "canary");<a name="line.659"></a>
+<span class="sourceLineNo">660</span><a name="line.660"></a>
+<span class="sourceLineNo">661</span>  private static final String CANARY_TABLE_FAMILY_NAME = "Test";<a name="line.661"></a>
+<span class="sourceLineNo">662</span><a name="line.662"></a>
+<span class="sourceLineNo">663</span>  private Configuration conf = null;<a name="line.663"></a>
+<span class="sourceLineNo">664</span>  private long interval = 0;<a name="line.664"></a>
+<span class="sourceLineNo">665</span>  private Sink sink = null;<a name="line.665"></a>
+<span class="sourceLineNo">666</span><a name="line.666"></a>
+<span class="sourceLineNo">667</span>  /**<a name="line.667"></a>
+<span class="sourceLineNo">668</span>   * True if we are to run in 'regionServer' mode.<a name="line.668"></a>
+<span class="sourceLineNo">669</span>   */<a name="line.669"></a>
+<span class="sourceLineNo">670</span>  private boolean regionServerMode = false;<a name="line.670"></a>
+<span class="sourceLineNo">671</span><a name="line.671"></a>
+<span class="sourceLineNo">672</span>  /**<a name="line.672"></a>
+<span class="sourceLineNo">673</span>   * True if we are to run in zookeeper 'mode'.<a name="line.673"></a>
+<span class="sourceLineNo">674</span>   */<a name="line.674"></a>
+<span class="sourceLineNo">675</span>  private boolean zookeeperMode = false;<a name="line.675"></a>
+<span class="sourceLineNo">676</span><a name="line.676"></a>
+<span class="sourceLineNo">677</span>  /**<a name="line.677"></a>
+<span class="sourceLineNo">678</span>   * This is a Map of table to timeout. The timeout is for reading all regions in the table; i.e.<a name="line.678"></a>
+<span class="sourceLineNo">679</span>   * we aggregate time to fetch each region and it needs to be less than this value else we<a name="line.679"></a>
+<span class="sourceLineNo">680</span>   * log an ERROR.<a name="line.680"></a>
+<span class="sourceLineNo">681</span>   */<a name="line.681"></a>
+<span class="sourceLineNo">682</span>  private HashMap&lt;String, Long&gt; configuredReadTableTimeouts = new HashMap&lt;&gt;();<a name="line.682"></a>
+<span class="sourceLineNo">683</span><a name="line.683"></a>
+<span class="sourceLineNo">684</span>  public static final String HBASE_CANARY_REGIONSERVER_ALL_REGIONS<a name="line.684"></a>
+<span class="sourceLineNo">685</span>          = "hbase.canary.regionserver_all_regions";<a name="line.685"></a>
+<span class="sourceLineNo">686</span><a name="line.686"></a>
+<span class="sourceLineNo">687</span>  public static final String HBASE_CANARY_REGION_WRITE_SNIFFING<a name="line.687"></a>
+<span class="sourceLineNo">688</span>          = "hbase.canary.region.write.sniffing";<a name="line.688"></a>
+<span class="sourceLineNo">689</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT<a name="line.689"></a>
+<span class="sourceLineNo">690</span>          = "hbase.canary.region.write.table.timeout";<a name="line.690"></a>
+<span class="sourceLineNo">691</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_NAME<a name="line.691"></a>
+<span class="sourceLineNo">692</span>          = "hbase.canary.region.write.table.name";<a name="line.692"></a>
+<span class="sourceLineNo">693</span>  public static final String HBASE_CANARY_REGION_READ_TABLE_TIMEOUT<a name="line.693"></a>
+<span class="sourceLineNo">694</span>          = "hbase.canary.region.read.table.timeout";<a name="line.694"></a>
+<span class="sourceLineNo">695</span><a name="line.695"></a>
+<span class="sourceLineNo">696</span>  public static final String HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES<a name="line.696"></a>
+<span class="sourceLineNo">697</span>          = "hbase.canary.zookeeper.permitted.failures";<a name="line.697"></a>
+<span class="sourceLineNo">698</span><a name="line.698"></a>
+<span class="sourceLineNo">699</span>  public static final String HBASE_CANARY_USE_REGEX = "hbase.canary.use.regex";<a name="line.699"></a>
+<span class="sourceLineNo">700</span>  public static final String HBASE_CANARY_TIMEOUT = "hbase.canary.timeout";<a name="line.700"></a>
+<span class="sourceLineNo">701</span>  public static final String HBASE_CANARY_FAIL_ON_ERROR = "hbase.canary.fail.on.error";<a name="line.701"></a>
 <span class="sourceLineNo">702</span><a name="line.702"></a>
-<span class="sourceLineNo">703</span>  private ExecutorService executor; // threads to retrieve data from regionservers<a name="line.703"></a>
-<span class="sourceLineNo">704</span><a name="line.704"></a>
-<span class="sourceLineNo">705</span>  public CanaryTool() {<a name="line.705"></a>
-<span class="sourceLineNo">706</span>    this(new ScheduledThreadPoolExecutor(1));<a name="line.706"></a>
-<span class="sourceLineNo">707</span>  }<a name="line.707"></a>
-<span class="sourceLineNo">708</span><a name="line.708"></a>
-<span class="sourceLineNo">709</span>  public CanaryTool(ExecutorService executor) {<a name="line.709"></a>
-<span class="sourceLineNo">710</span>    this(executor, null);<a name="line.710"></a>
-<span class="sourceLineNo">711</span>  }<a name="line.711"></a>
-<span class="sourceLineNo">712</span><a name="line.712"></a>
-<span class="sourceLineNo">713</span>  @VisibleForTesting<a name="line.713"></a>
-<span class="sourceLineNo">714</span>  CanaryTool(ExecutorService executor, Sink sink) {<a name="line.714"></a>
-<span class="sourceLineNo">715</span>    this.executor = executor;<a name="line.715"></a>
-<span class="sourceLineNo">716</span>    this.sink = sink;<a name="line.716"></a>
-<span class="sourceLineNo">717</span>  }<a name="line.717"></a>
-<span class="sourceLineNo">718</span><a name="line.718"></a>
-<span class="sourceLineNo">719</span>  CanaryTool(Configuration conf, ExecutorService executor) {<a name="line.719"></a>
-<span class="sourceLineNo">720</span>    this(conf, executor, null);<a name="line.720"></a>
-<span class="sourceLineNo">721</span>  }<a name="line.721"></a>
-<span class="sourceLineNo">722</span><a name="line.722"></a>
-<span class="sourceLineNo">723</span>  CanaryTool(Configuration conf, ExecutorService executor, Sink sink) {<a name="line.723"></a>
-<span class="sourceLineNo">724</span>    this(executor, sink);<a name="line.724"></a>
-<span class="sourceLineNo">725</span>    setConf(conf);<a name="line.725"></a>
-<span class="sourceLineNo">726</span>  }<a name="line.726"></a>
-<span class="sourceLineNo">727</span><a name="line.727"></a>
-<span class="sourceLineNo">728</span>  @Override<a name="line.728"></a>
-<span class="sourceLineNo">729</span>  public Configuration getConf() {<a name="line.729"></a>
-<span class="sourceLineNo">730</span>    return conf;<a name="line.730"></a>
-<span class="sourceLineNo">731</span>  }<a name="line.731"></a>
-<span class="sourceLineNo">732</span><a name="line.732"></a>
-<span class="sourceLineNo">733</span>  @Override<a name="line.733"></a>
-<span class="sourceLineNo">734</span>  public void setConf(Configuration conf) {<a name="line.734"></a>
-<span class="sourceLineNo">735</span>    if (conf == null) {<a name="line.735"></a>
-<span class="sourceLineNo">736</span>      conf = HBaseConfiguration.create();<a name="line.736"></a>
-<span class="sourceLineNo">737</span>    }<a name="line.737"></a>
-<span class="sourceLineNo">738</span>    this.conf = conf;<a name="line.738"></a>
-<span class="sourceLineNo">739</span>  }<a name="line.739"></a>
-<span class="sourceLineNo">740</span><a name="line.740"></a>
-<span class="sourceLineNo">741</span>  private int parseArgs(String[] args) {<a name="line.741"></a>
-<span class="sourceLineNo">742</span>    int index = -1;<a name="line.742"></a>
-<span class="sourceLineNo">743</span>    long permittedFailures = 0;<a name="line.743"></a>
-<span class="sourceLineNo">744</span>    boolean regionServerAllRegions = false, writeSniffing = false;<a name="line.744"></a>
-<span class="sourceLineNo">745</span>    String readTableTimeoutsStr = null;<a name="line.745"></a>
-<span class="sourceLineNo">746</span><a name="line.746"></a>
-<span class="sourceLineNo">747</span>    // Process command line args<a name="line.747"></a>
-<span class="sourceLineNo">748</span>    for (int i = 0; i &lt; args.length; i++) {<a name="line.748"></a>
-<span class="sourceLineNo">749</span>      String cmd = args[i];<a name="line.749"></a>
-<span class="sourceLineNo">750</span><a name="line.750"></a>
-<span class="sourceLineNo">751</span>      if (cmd.startsWith("-")) {<a name="line.751"></a>
-<span class="sourceLineNo">752</span>        if (index &gt;= 0) {<a name="line.752"></a>
-<span class="sourceLineNo">753</span>          // command line args must be in the form: [opts] [table 1 [table 2 ...]]<a name="line.753"></a>
-<span class="sourceLineNo">754</span>          System.err.println("Invalid command line options");<a name="line.754"></a>
-<span class="sourceLineNo">755</span>          printUsageAndExit();<a name="line.755"></a>
-<span class="sourceLineNo">756</span>        }<a name="line.756"></a>
-<span class="sourceLineNo">757</span><a name="line.757"></a>
-<span class="sourceLineNo">758</span>        if (cmd.equals("-help") || cmd.equals("-h")) {<a name="line.758"></a>
-<span class="sourceLineNo">759</span>          // user asked for help, print the help and quit.<a name="line.759"></a>
-<span class="sourceLineNo">760</span>          printUsageAndExit();<a name="line.760"></a>
-<span class="sourceLineNo">761</span>        } else if (cmd.equals("-daemon") &amp;&amp; interval == 0) {<a name="line.761"></a>
-<span class="sourceLineNo">762</span>          // user asked for daemon mode, set a default interval between checks<a name="line.762"></a>
-<span class="sourceLineNo">763</span>          interval = DEFAULT_INTERVAL;<a name="line.763"></a>
-<span class="sourceLineNo">764</span>        } else if (cmd.equals("-interval")) {<a name="line.764"></a>
-<span class="sourceLineNo">765</span>          // user has specified an interval for canary breaths (-interval N)<a name="line.765"></a>
-<span class="sourceLineNo">766</span>          i++;<a name="line.766"></a>
-<span class="sourceLineNo">767</span><a name="line.767"></a>
-<span class="sourceLineNo">768</span>          if (i == args.length) {<a name="line.768"></a>
-<span class="sourceLineNo">769</span>            System.err.println("-interval takes a numeric seconds value argument.");<a name="line.769"></a>
-<span class="sourceLineNo">770</span>            printUsageAndExit();<a name="line.770"></a>
-<span class="sourceLineNo">771</span>          }<a name="line.771"></a>
-<span class="sourceLineNo">772</span><a name="line.772"></a>
-<span class="sourceLineNo">773</span>          try {<a name="line.773"></a>
-<span class="sourceLineNo">774</span>            interval = Long.parseLong(args[i]) * 1000;<a name="line.774"></a>
-<span class="sourceLineNo">775</span>          } catch (NumberFormatException e) {<a name="line.775"></a>
-<span class="sourceLineNo">776</span>            System.err.println("-interval needs a numeric value argument.");<a name="line.776"></a>
-<span class="sourceLineNo">777</span>            printUsageAndExit();<a name="line.777"></a>
-<span class="sourceLineNo">778</span>          }<a name="line.778"></a>
-<span class="sourceLineNo">779</span>        } else if (cmd.equals("-zookeeper")) {<a name="line.779"></a>
-<span class="sourceLineNo">780</span>          this.zookeeperMode = true;<a name="line.780"></a>
-<span class="sourceLineNo">781</span>        } else if(cmd.equals("-regionserver")) {<a name="line.781"></a>
-<span class="sourceLineNo">782</span>          this.regionServerMode = true;<a name="line.782"></a>
-<span class="sourceLineNo">783</span>        } else if(cmd.equals("-allRegions")) {<a name="line.783"></a>
-<span class="sourceLineNo">784</span>          conf.setBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, true);<a name="line.784"></a>
-<span class="sourceLineNo">785</span>          regionServerAllRegions = true;<a name="line.785"></a>
-<span class="sourceLineNo">786</span>        } else if(cmd.equals("-writeSniffing")) {<a name="line.786"></a>
-<span class="sourceLineNo">787</span>          writeSniffing = true;<a name="line.787"></a>
-<span class="sourceLineNo">788</span>          conf.setBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, true);<a name="line.788"></a>
-<span class="sourceLineNo">789</span>        } else if(cmd.equals("-treatFailureAsError") || cmd.equals("-failureAsError")) {<a name="line.789"></a>
-<span class="sourceLineNo">790</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.790"></a>
-<span class="sourceLineNo">791</span>        } else if (cmd.equals("-e")) {<a name="line.791"></a>
-<span class="sourceLineNo">792</span>          conf.setBoolean(HBASE_CANARY_USE_REGEX, true);<a name="line.792"></a>
-<span class="sourceLineNo">793</span>        } else if (cmd.equals("-t")) {<a name="line.793"></a>
-<span class="sourceLineNo">794</span>          i++;<a name="line.794"></a>
-<span class="sourceLineNo">795</span><a name="line.795"></a>
-<span class="sourceLineNo">796</span>          if (i == args.length) {<a name="line.796"></a>
-<span class="sourceLineNo">797</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.797"></a>
-<span class="sourceLineNo">798</span>            printUsageAndExit();<a name="line.798"></a>
-<span class="sourceLineNo">799</span>          }<a name="line.799"></a>
-<span class="sourceLineNo">800</span>          long timeout = 0;<a name="line.800"></a>
-<span class="sourceLineNo">801</span>          try {<a name="line.801"></a>
-<span class="sourceLineNo">802</span>            timeout = Long.parseLong(args[i]);<a name="line.802"></a>
-<span class="sourceLineNo">803</span>          } catch (NumberFormatException e) {<a name="line.803"></a>
-<span class="sourceLineNo">804</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.804"></a>
-<span class="sourceLineNo">805</span>            printUsageAndExit();<a name="line.805"></a>
-<span class="sourceLineNo">806</span>          }<a name="line.806"></a>
-<span class="sourceLineNo">807</span>          conf.setLong(HBASE_CANARY_TIMEOUT, timeout);<a name="line.807"></a>
-<span class="sourceLineNo">808</span>        } else if(cmd.equals("-writeTableTimeout")) {<a name="line.808"></a>
-<span class="sourceLineNo">809</span>          i++;<a name="line.809"></a>
-<span class="sourceLineNo">810</span><a name="line.810"></a>
-<span class="sourceLineNo">811</span>          if (i == args.length) {<a name="line.811"></a>
-<span class="sourceLineNo">812</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.812"></a>
-<span class="sourceLineNo">813</span>            printUsageAndExit();<a name="line.813"></a>
-<span class="sourceLineNo">814</span>          }<a name="line.814"></a>
-<span class="sourceLineNo">815</span>          long configuredWriteTableTimeout = 0;<a name="line.815"></a>
-<span class="sourceLineNo">816</span>          try {<a name="line.816"></a>
-<span class="sourceLineNo">817</span>            configuredWriteTableTimeout = Long.parseLong(args[i]);<a name="line.817"></a>
-<span class="sourceLineNo">818</span>          } catch (NumberFormatException e) {<a name="line.818"></a>
-<span class="sourceLineNo">819</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.819"></a>
-<span class="sourceLineNo">820</span>            printUsageAndExit();<a name="line.820"></a>
-<span class="sourceLineNo">821</span>          }<a name="line.821"></a>
-<span class="sourceLineNo">822</span>          conf.setLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, configuredWriteTableTimeout);<a name="line.822"></a>
-<span class="sourceLineNo">823</span>        } else if (cmd.equals("-writeTable")) {<a name="line.823"></a>
-<span class="sourceLineNo">824</span>          i++;<a name="line.824"></a>
-<span class="sourceLineNo">825</span><a name="line.825"></a>
-<span class="sourceLineNo">826</span>          if (i == args.length) {<a name="line.826"></a>
-<span class="sourceLineNo">827</span>            System.err.println("-writeTable takes a string tablename value argument.");<a name="line.827"></a>
-<span class="sourceLineNo">828</span>            printUsageAndExit();<a name="line.828"></a>
-<span class="sourceLineNo">829</span>          }<a name="line.829"></a>
-<span class="sourceLineNo">830</span>          conf.set(HBASE_CANARY_REGION_WRITE_TABLE_NAME, args[i]);<a name="line.830"></a>
-<span class="sourceLineNo">831</span>        } else if (cmd.equals("-f")) {<a name="line.831"></a>
-<span class="sourceLineNo">832</span>          i++;<a name="line.832"></a>
-<span class="sourceLineNo">833</span><a name="line.833"></a>
-<span class="sourceLineNo">834</span>          if (i == args.length) {<a name="line.834"></a>
-<span class="sourceLineNo">835</span>            System.err<a name="line.835"></a>
-<span class="sourceLineNo">836</span>                .println("-f needs a boolean value argument (true|false).");<a name="line.836"></a>
-<span class="sourceLineNo">837</span>            printUsageAndExit();<a name="line.837"></a>
-<span class="sourceLineNo">838</span>          }<a name="line.838"></a>
-<span class="sourceLineNo">839</span><a name="line.839"></a>
-<span class="sourceLineNo">840</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, Boolean.parseBoolean(args[i]));<a name="line.840"></a>
-<span class="sourceLineNo">841</span>        } else if (cmd.equals("-readTableTimeouts")) {<a name="line.841"></a>
-<span class="sourceLineNo">842</span>          i++;<a name="line.842"></a>
-<span class="sourceLineNo">843</span><a name="line.843"></a>
-<span class="sourceLineNo">844</span>          if (i == args.length) {<a name="line.844"></a>
-<span class="sourceLineNo">845</span>            System.err.println("-readTableTimeouts needs a comma-separated list of read " +<a name="line.845"></a>
-<span class="sourceLineNo">846</span>                "millisecond timeouts per table (without spaces).");<a name="line.846"></a>
-<span class="sourceLineNo">847</span>            printUsageAndExit();<a name="line.847"></a>
-<span class="sourceLineNo">848</span>          }<a name="line.848"></a>
-<span class="sourceLineNo">849</span>          readTableTimeoutsStr = args[i];<a name="line.849"></a>
-<span class="sourceLineNo">850</span>          conf.set(HBASE_CANARY_REGION_READ_TABLE_TIMEOUT, readTableTimeoutsStr);<a name="line.850"></a>
-<span class="sourceLineNo">851</span>        } else if (cmd.equals("-permittedZookeeperFailures")) {<a name="line.851"></a>
-<span class="sourceLineNo">852</span>          i++;<a name="line.852"></a>
-<span class="sourceLineNo">853</span><a name="line.853"></a>
-<span class="sourceLineNo">854</span>          if (i == args.length) {<a name="line.854"></a>
-<span class="sourceLineNo">855</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.855"></a>
-<span class="sourceLineNo">856</span>            printUsageAndExit();<a name="line.856"></a>
-<span class="sourceLineNo">857</span>          }<a name="line.857"></a>
-<span class="sourceLineNo">858</span>          try {<a name="line.858"></a>
-<span class="sourceLineNo">859</span>            permittedFailures = Long.parseLong(args[i]);<a name="line.859"></a>
-<span class="sourceLineNo">860</span>          } catch (NumberFormatException e) {<a name="line.860"></a>
-<span class="sourceLineNo">861</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.861"></a>
-<span class="sourceLineNo">862</span>            printUsageAndExit();<a name="line.862"></a>
-<span class="sourceLineNo">863</span>          }<a name="line.863"></a>
-<span class="sourceLineNo">864</span>          conf.setLong(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, permittedFailures);<a name="line.864"></a>
-<span class="sourceLineNo">865</span>        } else {<a name="line.865"></a>
-<span class="sourceLineNo">866</span>          // no options match<a name="line.866"></a>
-<span class="sourceLineNo">867</span>          System.err.println(cmd + " options is invalid.");<a name="line.867"></a>
-<span class="sourceLineNo">868</span>          printUsageAndExit();<a name="line.868"></a>
-<span class="sourceLineNo">869</span>        }<a name="line.869"></a>
-<span class="sourceLineNo">870</span>      } else if (index &lt; 0) {<a name="line.870"></a>
-<span class="sourceLineNo">871</span>        // keep track of first table name specified by the user<a name="line.871"></a>
-<span class="sourceLineNo">872</span>        index = i;<a name="line.872"></a>
-<span class="sourceLineNo">873</span>      }<a name="line.873"></a>
-<span class="sourceLineNo">874</span>    }<a name="line.874"></a>
-<span class="sourceLineNo">875</span>    if (regionServerAllRegions &amp;&amp; !this.regionServerMode) {<a name="line.875"></a>
-<span class="sourceLineNo">876</span>      System.err.println("-allRegions can only be specified in regionserver mode.");<a name="line.876"></a>
-<span class="sourceLineNo">877</span>      printUsageAndExit();<a name="line.877"></a>
-<span class="sourceLineNo">878</span>    }<a name="line.878"></a>
-<span class="sourceLineNo">879</span>    if (this.zookeeperMode) {<a name="line.879"></a>
-<span class="sourceLineNo">880</span>      if (this.regionServerMode || regionServerAllRegions || writeSniffing) {<a name="line.880"></a>
-<span class="sourceLineNo">881</span>        System.err.println("-zookeeper is exclusive and cannot be combined with "<a name="line.881"></a>
-<span class="sourceLineNo">882</span>            + "other modes.");<a name="line.882"></a>
-<span class="sourceLineNo">883</span>        printUsageAndExit();<a name="line.883"></a>
-<span class="sourceLineNo">884</span>      }<a name="line.884"></a>
-<span class="sourceLineNo">885</span>    }<a name="line.885"></a>
-<span class="sourceLineNo">886</span>    if (permittedFailures != 0 &amp;&amp; !this.zookeeperMode) {<a name="line.886"></a>
-<span class="sourceLineNo">887</span>      System.err.println("-permittedZookeeperFailures requires -zookeeper mode.");<a name="line.887"></a>
-<span class="sourceLineNo">888</span>      printUsageAndExit();<a name="line.888"></a>
-<span class="sourceLineNo">889</span>    }<a name="line.889"></a>
-<span class="sourceLineNo">890</span>    if (readTableTimeoutsStr != null &amp;&amp; (this.regionServerMode || this.zookeeperMode)) {<a name="line.890"></a>
-<span class="sourceLineNo">891</span>      System.err.println("-readTableTimeouts can only be configured in region mode.");<a name="line.891"></a>
-<span class="sourceLineNo">892</span>      printUsageAndExit();<a name="line.892"></a>
-<span class="sourceLineNo">893</span>    }<a name="line.893"></a>
-<span class="sourceLineNo">894</span>    return index;<a name="line.894"></a>
-<span class="sourceLineNo">895</span>  }<a name="line.895"></a>
-<span class="sourceLineNo">896</span><a name="line.896"></a>
-<span class="sourceLineNo">897</span>  @Override<a name="line.897"></a>
-<span class="sourceLineNo">898</span>  public int run(String[] args) throws Exception {<a name="line.898"></a>
-<span class="sourceLineNo">899</span>    int index = parseArgs(args);<a name="line.899"></a>
-<span class="sourceLineNo">900</span>    String[] monitorTargets = null;<a name="line.900"></a>
-<span class="sourceLineNo">901</span><a name="line.901"></a>
-<span class="sourceLineNo">902</span>    if (index &gt;= 0) {<a name="line.902"></a>
-<span class="sourceLineNo">903</span>      int length = args.length - index;<a name="line.903"></a>
-<span class="sourceLineNo">904</span>      monitorTargets = new String[length];<a name="line.904"></a>
-<span class="sourceLineNo">905</span>      System.arraycopy(args, index, monitorTargets, 0, length);<a name="line.905"></a>
-<span class="sourceLineNo">906</span>    }<a name="line.906"></a>
-<span class="sourceLineNo">907</span><a name="line.907"></a>
-<span class="sourceLineNo">908</span>    if (zookeeperMode) {<a name="line.908"></a>
-<span class="sourceLineNo">909</span>      return checkZooKeeper();<a name="line.909"></a>
-<span class="sourceLineNo">910</span>    } else if (regionServerMode) {<a name="line.910"></a>
-<span class="sourceLineNo">911</span>      return checkRegionServers(monitorTargets);<a name="line.911"></a>
-<span class="sourceLineNo">912</span>    } else {<a name="line.912"></a>
-<span class="sourceLineNo">913</span>      return checkRegions(monitorTargets);<a name="line.913"></a>
-<span class="sourceLineNo">914</span>    }<a name="line.914"></a>
-<span class="sourceLineNo">915</span>  }<a name="line.915"></a>
-<span class="sourceLineNo">916</span><a name="line.916"></a>
-<span class="sourceLineNo">917</span>  private int runMonitor(String[] monitorTargets) throws Exception {<a name="line.917"></a>
-<span class="sourceLineNo">918</span>    ChoreService choreService = null;<a name="line.918"></a>
-<span class="sourceLineNo">919</span><a name="line.919"></a>
-<span class="sourceLineNo">920</span>    // Launches chore for refreshing kerberos credentials if security is enabled.<a name="line.920"></a>
-<span class="sourceLineNo">921</span>    // Please see http://hbase.apache.org/book.html#_running_canary_in_a_kerberos_enabled_cluster<a name="line.921"></a>
-<span class="sourceLineNo">922</span>    // for more details.<a name="line.922"></a>
-<span class="sourceLineNo">923</span>    final ScheduledChore authChore = AuthUtil.getAuthChore(conf);<a name="line.923"></a>
-<span class="sourceLineNo">924</span>    if (authChore != null) {<a name="line.924"></a>
-<span class="sourceLineNo">925</span>      choreService = new ChoreService("CANARY_TOOL");<a name="line.925"></a>
-<span class="sourceLineNo">926</span>      choreService.scheduleChore(authChore);<a name="line.926"></a>
-<span class="sourceLineNo">927</span>    }<a name="line.927"></a>
-<span class="sourceLineNo">928</span><a name="line.928"></a>
-<span class="sourceLineNo">929</span>    // Start to prepare the stuffs<a name="line.929"></a>
-<span class="sourceLineNo">930</span>    Monitor monitor = null;<a name="line.930"></a>
-<span class="sourceLineNo">931</span>    Thread monitorThread;<a name="line.931"></a>
-<span class="sourceLineNo">932</span>    long startTime = 0;<a name="line.932"></a>
-<span class="sourceLineNo">933</span>    long currentTimeLength = 0;<a name="line.933"></a>
-<span class="sourceLineNo">934</span>    boolean failOnError = conf.getBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.934"></a>
-<span class="sourceLineNo">935</span>    long timeout = conf.getLong(HBASE_CANARY_TIMEOUT, DEFAULT_TIMEOUT);<a name="line.935"></a>
-<span class="sourceLineNo">936</span>    // Get a connection to use in below.<a name="line.936"></a>
-<span class="sourceLineNo">937</span>    try (Connection connection = ConnectionFactory.createConnection(this.conf)) {<a name="line.937"></a>
-<span class="sourceLineNo">938</span>      do {<a name="line.938"></a>
-<span class="sourceLineNo">939</span>        // Do monitor !!<a name="line.939"></a>
-<span class="sourceLineNo">940</span>        try {<a name="line.940"></a>
-<span class="sourceLineNo">941</span>          monitor = this.newMonitor(connection, monitorTargets);<a name="line.941"></a>
-<span class="sourceLineNo">942</span>          monitorThread = new Thread(monitor, "CanaryMonitor-" + System.currentTimeMillis());<a name="line.942"></a>
-<span class="sourceLineNo">943</span>          startTime = System.currentTimeMillis();<a name="line.943"></a>
-<span class="sourceLineNo">944</span>          monitorThread.start();<a name="line.944"></a>
-<span class="sourceLineNo">945</span>          while (!monitor.isDone()) {<a name="line.945"></a>
-<span class="sourceLineNo">946</span>            // wait for 1 sec<a name="line.946"></a>
-<span class="sourceLineNo">947</span>            Thread.sleep(1000);<a name="line.947"></a>
-<span class="sourceLineNo">948</span>            // exit if any error occurs<a name="line.948"></a>
-<span class="sourceLineNo">949</span>            if (failOnError &amp;&amp; monitor.hasError()) {<a name="line.949"></a>
-<span class="sourceLineNo">950</span>              monitorThread.interrupt();<a name="line.950"></a>
-<span class="sourceLineNo">951</span>              if (monitor.initialized) {<a name="line.951"></a>
-<span class="sourceLineNo">952</span>                return monitor.errorCode;<a name="line.952"></a>
-<span class="sourceLineNo">953</span>              } else {<a name="line.953"></a>
-<span class="sourceLineNo">954</span>                return INIT_ERROR_EXIT_CODE;<a name="line.954"></a>
-<span class="sourceLineNo">955</span>              }<a name="line.955"></a>
-<span class="sourceLineNo">956</span>            }<a name="line.956"></a>
-<span class="sourceLineNo">957</span>            currentTimeLength = System.currentTimeMillis() - startTime;<a name="line.957"></a>
-<span class="sourceLineNo">958</span>            if (currentTimeLength &gt; timeout) {<a name="line.958"></a>
-<span class="sourceLineNo">959</span>              LOG.error("The monitor is running too long (" + currentTimeLength<a name="line.959"></a>
-<span class="sourceLineNo">960</span>                  + ") after timeout limit:" + timeout<a name="line.960"></a>
-<span class="sourceLineNo">961</span>                  + " will be killed itself !!");<a name="line.961"></a>
-<span class="sourceLineNo">962</span>              if (monitor.initialized) {<a name="line.962"></a>
-<span class="sourceLineNo">963</span>                return TIMEOUT_ERROR_EXIT_CODE;<a name="line.963"></a>
-<span class="sourceLineNo">964</span>              } else {<a name="line.964"></a>
-<span class="sourceLineNo">965</span>                return INIT_ERROR_EXIT_CODE;<a name="line.965"></a>
-<span class="sourceLineNo">966</span>              }<a name="line.966"></a>
-<span class="sourceLineNo">967</span>            }<a name="line.967"></a>
-<span class="sourceLineNo">968</span>          }<a name="line.968"></a>
-<span class="sourceLineNo">969</span><a name="line.969"></a>
-<span class="sourceLineNo">970</span>          if (failOnError &amp;&amp; monitor.finalCheckForErrors()) {<a name="line.970"></a>
-<span class="sourceLineNo">971</span>            monitorThread.interrupt();<a name="line.971"></a>
-<span class="sourceLineNo">972</span>            return monitor.errorCode;<a name="line.972"></a>
-<span class="sourceLineNo">973</span>          }<a name="line.973"></a>
-<span class="sourceLineNo">974</span>        } finally {<a name="line.974"></a>
-<span class="sourceLineNo">975</span>          if (monitor != null) monitor.close();<a name="line.975"></a>
-<span class="sourceLineNo">976</span>        }<a name="line.976"></a>
-<span class="sourceLineNo">977</span><a name="line.977"></a>
-<span class="sourceLineNo">978</span>        Thread.sleep(interval);<a name="line.978"></a>
-<span class="sourceLineNo">979</span>      } while (interval &gt; 0);<a name="line.979"></a>
-<span class="sourceLineNo">980</span>    } // try-with-resources close<a name="line.980"></a>
-<span class="sourceLineNo">981</span><a name="line.981"></a>
-<span class="sourceLineNo">982</span>    if (choreService != null) {<a name="line.982"></a>
-<span class="sourceLineNo">983</span>      choreService.shutdown();<a name="line.983"></a>
-<span class="sourceLineNo">984</span>    }<a name="line.984"></a>
-<span class="sourceLineNo">985</span>    return monitor.errorCode;<a name="line.985"></a>
-<span class="sourceLineNo">986</span>  }<a name="line.986"></a>
-<span class="sourceLineNo">987</span><a name="line.987"></a>
-<span class="sourceLineNo">988</span>  @Override<a name="line.988"></a>
-<span class="sourceLineNo">989</span>  public Map&lt;String, String&gt; getReadFailures()  {<a name="line.989"></a>
-<span class="sourceLineNo">990</span>    return sink.getReadFailures();<a name="line.990"></a>
-<span class="sourceLineNo">991</span>  }<a name="line.991"></a>
-<span class="sourceLineNo">992</span><a name="line.992"></a>
-<span class="sourceLineNo">993</span>  @Override<a name="line.993"></a>
-<span class="sourceLineNo">994</span>  public Map&lt;String, String&gt; getWriteFailures()  {<a name="line.994"></a>
-<span class="sourceLineNo">995</span>    return sink.getWriteFailures();<a name="line.995"></a>
-<span class="sourceLineNo">996</span>  }<a name="line.996"></a>
-<span class="sourceLineNo">997</span><a name="line.997"></a>
-<span class="sourceLineNo">998</span>  private void printUsageAndExit() {<a name="line.998"></a>
-<span class="sourceLineNo">999</span>    System.err.println(<a name="line.999"></a>
-<span class="sourceLineNo">1000</span>      "Usage: canary [OPTIONS] [&lt;TABLE1&gt; [&lt;TABLE2]...] | [&lt;REGIONSERVER1&gt; [&lt;REGIONSERVER2]..]");<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>    System.err.println("Where [OPTIONS] are:");<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>    System.err.println(" -h,-help        show this help and exit.");<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>    System.err.println(" -regionserver   set 'regionserver mode'; gets row from random region on " +<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>        "server");<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>    System.err.println(" -allRegions     get from ALL regions when 'regionserver mode', not just " +<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>        "random one.");<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>    System.err.println(" -zookeeper      set 'zookeeper mode'; grab zookeeper.znode.parent on " +<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>        "each ensemble member");<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>    System.err.println(" -daemon         continuous check at defined intervals.");<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>    System.err.println(" -interval &lt;N&gt;   interval between checks in seconds");<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>    System.err.println(" -e              consider table/regionserver argument as regular " +<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>        "expression");<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>    System.err.println(" -f &lt;B&gt;          exit on first error; default=true");<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>    System.err.println(" -failureAsError treat read/write failure as error");<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>    System.err.println(" -t &lt;N&gt;          timeout for canary-test run; default=600000ms");<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>    System.err.println(" -writeSniffing  enable write sniffing");<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span>    System.err.println(" -writeTable     the table used for write sniffing; default=hbase:canary");<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>    System.err.println(" -writeTableTimeout &lt;N&gt;  timeout for writeTable; default=600000ms");<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>    System.err.println(" -readTableTimeouts &lt;tableName&gt;=&lt;read timeout&gt;," +<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span>        "&lt;tableName&gt;=&lt;read timeout&gt;,...");<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>    System.err.println("                comma-separated list of table read timeouts " +<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>        "(no spaces);");<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>    System.err.println("                logs 'ERROR' if takes longer. default=600000ms");<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>    System.err.println(" -permittedZookeeperFailures &lt;N&gt;  Ignore first N failures attempting to ");<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>    System.err.println("                connect to individual zookeeper nodes in ensemble");<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>    System.err.println("");<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>    System.err.println(" -D&lt;configProperty&gt;=&lt;value&gt; to assign or override configuration params");<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>    System.err.println(" -Dhbase.canary.read.raw.enabled=&lt;true/false&gt; Set to enable/disable " +<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>        "raw scan; default=false");<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span>    System.err.println("");<a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>    System.err.println("Canary runs in one of three modes: region (default), regionserver, or " +<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>        "zookeeper.");<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>    System.err.println("To sniff/probe all regions, pass no arguments.");<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>    System.err.println("To sniff/probe all regions of a table, pass tablename.");<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>    System.err.println("To sniff/probe regionservers, pass -regionserver, etc.");<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>    System.err.println("See http://hbase.apache.org/book.html#_canary for Canary documentation.");<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>    System.exit(USAGE_EXIT_CODE);<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>  }<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span><a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>  Sink getSink(Configuration configuration, Class clazz) {<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>    // In test context, this.sink might be set. Use it if non-null. For testing.<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>    return this.sink != null? this.sink:<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>        (Sink)ReflectionUtils.newInstance(configuration.getClass("hbase.canary.sink.class",<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>            clazz, Sink.class));<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>  }<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span><a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>  /**<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>   * Canary region mode-specific data structure which stores information about each region<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>   * to be scanned<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>   */<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>  public static class RegionTaskResult {<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>    private RegionInfo region;<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>    private TableName tableName;<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>    private ServerName serverName;<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>    private ColumnFamilyDescriptor column;<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>    private AtomicLong readLatency = null;<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>    private AtomicLong writeLatency = null;<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>    private boolean readSuccess = false;<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>    private boolean writeSuccess = false;<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span><a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>    public RegionTaskResult(RegionInfo region, TableName tableName, ServerName serverName,<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>        ColumnFamilyDescriptor column) {<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>      this.region = region;<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>      this.tableName = tableName;<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>      this.serverName = serverName;<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>      this.column = column;<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>    }<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span><a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>    public RegionInfo getRegionInfo() {<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>      return this.region;<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span>    }<a name="line.1071"></a>
-<span class="sourceLineNo">1072</span><a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>    public String getRegionNameAsString() {<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>      return this.region.getRegionNameAsString();<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span>    }<a name="line.1075"></a>
-<span class="sourceLineNo">1076</span><a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>    public TableName getTableName() {<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span>      return this.tableName;<a name="line.1078"></a>
-<span class="sourceLineNo">1079</span>    }<a name="line.1079"></a>
-<span class="sourceLineNo">1080</span><a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>    public String getTableNameAsString() {<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>      return this.tableName.getNameAsString();<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span>    }<a name="line.1083"></a>
-<span class="sourceLineNo">1084</span><a name="line.1084"></a>
-<span class="sourceLineNo">1085</span>    public ServerName getServerName() {<a name="line.1085"></a>
-<span class="sourceLineNo">1086</span>      return this.serverName;<a name="line.1086"></a>
-<span class="sourceLineNo">1087</span>    }<a name="line.1087"></a>
-<span class="sourceLineNo">1088</span><a name="line.1088"></a>
-<span class="sourceLineNo">1089</span>    public String getServerNameAsString() {<a name="line.1089"></a>
-<span class="sourceLineNo">1090</span>      return this.serverName.getServerName();<a name="line.1090"></a>
-<span class="sourceLineNo">1091</span>    }<a name="line.1091"></a>
-<span class="sourceLineNo">1092</span><a name="line.1092"></a>
-<span class="sourceLineNo">1093</span>    public ColumnFamilyDescriptor getColumnFamily() {<a name="line.1093"></a>
-<span class="sourceLineNo">1094</span>      return this.column;<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>    }<a name="line.1095"></a>
-<span class="sourceLineNo">1096</span><a name="line.1096"></a>
-<span class="sourceLineNo">1097</span>    public String getColumnFamilyNameAsString() {<a name="line.1097"></a>
-<span class="sourceLineNo">1098</span>      return this.column.getNameAsString();<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span>    }<a name="line.1099"></a>
-<span class="sourceLineNo">1100</span><a name="line.1100"></a>
-<span class="sourceLineNo">1101</span>    public long getReadLatency() {<a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>      if (this.readLatency == null) {<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>        return -1;<a name="line.1103"></a>
-<span class="sourceLineNo">1104</span>      }<a name="line.1104"></a>
-<span class="sourceLineNo">1105</span>      return this.readLatency.get();<a name="line.1105"></a>
-<span class="sourceLineNo">1106</span>    }<a name="line.1106"></a>
-<span class="sourceLineNo">1107</span><a name="line.1107"></a>
-<span class="sourceLineNo">1108</span>    public void setReadLatency(long readLatency) {<a name="line.1108"></a>
-<span class="sourceLineNo">1109</span>      if (this.readLatency != null) {<a name="line.1109"></a>
-<span class="sourceLineNo">1110</span>        this.readLatency.set(readLatency);<a name="line.1110"></a>
-<span class="sourceLineNo">1111</span>      } else {<a name="line.1111"></a>
-<span class="sourceLineNo">1112</span>        this.readLatency = new AtomicLong(readLatency);<a name="line.1112"></a>
-<span class="sourceLineNo">1113</span>      }<a name="line.1113"></a>
-<span class="sourceLineNo">1114</span>    }<a name="line.1114"></a>
-<span class="sourceLineNo">1115</span><a name="line.1115"></a>
-<span class="sourceLineNo">1116</span>    public long getWriteLatency() {<a name="line.1116"></a>
-<span class="sourceLineNo">1117</span>      if (this.writeLatency == null) {<a name="line.1117"></a>
-<span class="sourceLineNo">1118</span>        return -1;<a name="line.1118"></a>
-<span class="sourceLineNo">1119</span>      }<a name="line.1119"></a>
-<span class="sourceLineNo">1120</span>      return this.writeLatency.get();<a name="line.1120"></a>
-<span class="sourceLineNo">1121</span>    }<a name="line.1121"></a>
-<span class="sourceLineNo">1122</span><a name="line.1122"></a>
-<span class="sourceLineNo">1123</span>    public void setWriteLatency(long writeLatency) {<a name="line.1123"></a>
-<span class="sourceLineNo">1124</span>      if (this.writeLatency != null) {<a name="line.1124"></a>
-<span class="sourceLineNo">1125</span>        this.writeLatency.set(writeLatency);<a name="line.1125"></a>
-<span class="sourceLineNo">1126</span>      } else {<a name="line.1126"></a>
-<span class="sourceLineNo">1127</span>        this.writeLatency = new AtomicLong(writeLatency);<a name="line.1127"></a>
-<span class="sourceLineNo">1128</span>      }<a name="line.1128"></a>
-<span class="sourceLineNo">1129</span>    }<a name="line.1129"></a>
-<span class="sourceLineNo">1130</span><a name="line.1130"></a>
-<span class="sourceLineNo">1131</span>    public boolean isReadSuccess() {<a name="line.1131"></a>
-<span class="sourceLineNo">1132</span>      return this.readSuccess;<a name="line.1132"></a>
-<span class="sourceLineNo">1133</span>    }<a name="line.1133"></a>
-<span class="sourceLineNo">1134</span><a name="line.1134"></a>
-<span class="sourceLineNo">1135</span>    public void setReadSuccess() {<a name="line.1135"></a>
-<span class="sourceLineNo">1136</span>      this.readSuccess = true;<a name="line.1136"></a>
-<span class="sourceLineNo">1137</span>    }<a name="line.1137"></a>
-<span class="sourceLineNo">1138</span><a name="line.1138"></a>
-<span class="sourceLineNo">1139</span>    public boolean isWriteSuccess() {<a name="line.1139"></a>
-<span class="sourceLineNo">1140</span>      return this.writeSuccess;<a name="line.1140"></a>
-<span class="sourceLineNo">1141</span>    }<a name="line.1141"></a>
-<span class="sourceLineNo">1142</span><a name="line.1142"></a>
-<span class="sourceLineNo">1143</span>    public void setWriteSuccess() {<a name="line.1143"></a>
-<span class="sourceLineNo">1144</span>      this.writeSuccess = true;<a name="line.1144"></a>
-<span class="sourceLineNo">1145</span>    }<a name="line.1145"></a>
-<span class="sourceLineNo">1146</span>  }<a name="line.1146"></a>
-<span class="sourceLineNo">1147</span><a name="line.1147"></a>
-<span class="sourceLineNo">1148</span>  /**<a name="line.1148"></a>
-<span class="sourceLineNo">1149</span>   * A Factory method for {@link Monitor}.<a name="line.1149"></a>
-<span class="sourceLineNo">1150</span>   * Makes a RegionServerMonitor, or a ZooKeeperMonitor, or a RegionMonitor.<a name="line.1150"></a>
-<span class="sourceLineNo">1151</span>   * @return a Monitor instance<a name="line.1151"></a>
-<span class="sourceLineNo">1152</span>   */<a name="line.1152"></a>
-<span class="sourceLineNo">1153</span>  private Monitor newMonitor(final Connection connection, String[] monitorTargets) {<a name="line.1153"></a>
-<span class="sourceLineNo">1154</span>    Monitor monitor;<a name="line.1154"></a>
-<span class="sourceLineNo">1155</span>    boolean useRegExp = conf.getBoolean(HBASE_CANARY_USE_REGEX, false);<a name="line.1155"></a>
-<span class="sourceLineNo">1156</span>    boolean regionServerAllRegions<a name="line.1156"></a>
-<span class="sourceLineNo">1157</span>            = conf.getBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, false);<a name="line.1157"></a>
-<span class="sourceLineNo">1158</span>    boolean failOnError<a name="line.1158"></a>
-<span class="sourceLineNo">1159</span>            = conf.getBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.1159"></a>
-<span class="sourceLineNo">1160</span>    int permittedFailures<a name="line.1160"></a>
-<span class="sourceLineNo">1161</span>            = conf.getInt(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, 0);<a name="line.1161"></a>
-<span class="sourceLineNo">1162</span>    boolean writeSniffing<a name="line.1162"></a>
-<span class="sourceLineNo">1163</span>            = conf.getBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, false);<a name="line.1163"></a>
-<span class="sourceLineNo">1164</span>    String writeTableName = conf.get(HBASE_CANARY_REGION_WRITE_TABLE_NAME,<a name="line.1164"></a>
-<span class="sourceLineNo">1165</span>            DEFAULT_WRITE_TABLE_NAME.getNameAsString());<a name="line.1165"></a>
-<span class="sourceLineNo">1166</span>    long configuredWriteTableTimeout<a name="line.1166"></a>
-<span class="sourceLineNo">1167</span>            = conf.getLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, DEFAULT_TIMEOUT);<a name="line.1167"></a>
-<span class="sourceLineNo">1168</span><a name="line.1168"></a>
-<span class="sourceLineNo">1169</span>    if (this.regionServerMode) {<a name="line.1169"></a>
-<span class="sourceLineNo">1170</span>      monitor =<a name="line.1170"></a>
-<span class="sourceLineNo">1171</span>          new RegionServerMonitor(connection, monitorTargets, useRegExp,<a name="line.1171"></a>
-<span class="sourceLineNo">1172</span>              getSink(connection.getConfiguration(), RegionServerStdOutSink.class),<a name="line.1172"></a>
-<span class="sourceLineNo">1173</span>              this.executor, regionServerAllRegions,<a name="line.1173"></a>
-<span class="sourceLineNo">1174</span>              failOnError, permittedFailures);<a name="line.1174"></a>
-<span class="sourceLineNo">1175</span><a name="line.1175"></a>
-<span class="sourceLineNo">1176</span>    } else if (this.zookeeperMode) {<a name="line.1176"></a>
-<span class="sourceLineNo">1177</span>      monitor =<a name="line.1177"></a>
-<span class="sourceLineNo">1178</span>          new ZookeeperMonitor(connection, monitorTargets, useRegExp,<a name="line.1178"></a>
-<span class="sourceLineNo">1179</span>              getSink(connection.getConfiguration(), ZookeeperStdOutSink.class),<a name="line.1179"></a>
-<span class="sourceLineNo">1180</span>              this.executor, failOnError, permittedFailures);<a name="line.1180"></a>
-<span class="sourceLineNo">1181</span>    } else {<a name="line.1181"></a>
-<span class="sourceLineNo">1182</span>      monitor =<a name="line.1182"></a>
-<span class="sourceLineNo">1183</span>          new RegionMonitor(connection, monitorTargets, useRegExp,<a name="line.1183"></a>
-<span class="sourceLineNo">1184</span>              getSink(connection.getConfiguration(), RegionStdOutSink.class),<a name="line.1184"></a>
-<span class="sourceLineNo">1185</span>              this.executor, writeSniffing,<a name="line.1185"></a>
-<span class="sourceLineNo">1186</span>              TableName.valueOf(writeTableName), failOnError, configuredReadTableTimeouts,<a name="line.1186"></a>
-<span class="sourceLineNo">1187</span>              configuredWriteTableTimeout, permittedFailures);<a name="line.1187"></a>
-<span class="sourceLineNo">1188</span>    }<a name="line.1188"></a>
-<span class="sourceLineNo">1189</span>    return monitor;<a name="line.1189"></a>
-<span class="sourceLineNo">1190</span>  }<a name="line.1190"></a>
-<span class="sourceLineNo">1191</span><a name="line.1191"></a>
-<span class="sourceLineNo">1192</span>  private void populateReadTableTimeoutsMap(String configuredReadTableTimeoutsStr) {<a name="line.1192"></a>
-<span class="sourceLineNo">1193</span>    String[] tableTimeouts = configuredReadTableTimeoutsStr.split(",");<a name="line.1193"></a>
-<span class="sourceLineNo">1194</span>    for (String tT : tableTimeouts) {<a name="line.1194"></a>
-<span class="sourceLineNo">1195</span>      String[] nameTimeout = tT.split("=");<a name="line.1195"></a>
-<span class="sourceLineNo">1196</span>      if (nameTimeout.length &lt; 2) {<a name="line.1196"></a>
-<span class="sourceLineNo">1197</span>        throw new IllegalArgumentException("Each -readTableTimeouts argument must be of the form " +<a name="line.1197"></a>
-<span class="sourceLineNo">1198</span>            "&lt;tableName&gt;=&lt;read timeout&gt; (without spaces).");<a name="line.1198"></a>
-<span class="sourceLineNo">1199</span>      }<a name="line.1199"></a>
-<span class="sourceLineNo">1200</span>      long timeoutVal;<a name="line.1200"></a>
-<span class="sourceLineNo">1201</span>      try {<a name="line.1201"></a>
-<span class="sourceLineNo">1202</span>        timeoutVal = Long.parseLong(nameTimeout[1]);<a name="line.1202"></a>
-<span class="sourceLineNo">1203</span>      } catch (NumberFormatException e) {<a name="line.1203"></a>
-<span class="sourceLineNo">1204</span>        throw new IllegalArgumentException("-readTableTimeouts read timeout for each table" +<a name="line.1204"></a>
-<span class="sourceLineNo">1205</span>            " must be a numeric value argument.");<a name="line.1205"></a>
-<span class="sourceLineNo">1206</span>      }<a name="line.1206"></a>
-<span class="sourceLineNo">1207</span>      configuredReadTableTimeouts.put(nameTimeout[0], timeoutVal);<a name="line.1207"></a>
-<span class="sourceLineNo">1208</span>    }<a name="line.1208"></a>
-<span class="sourceLineNo">1209</span>  }<a name="line.1209"></a>
-<span class="sourceLineNo">1210</span>  /**<a name="line.1210"></a>
-<span class="sourceLineNo">1211</span>   * A Monitor super-class can be extended by users<a name="line.1211"></a>
-<span class="sourceLineNo">1212</span>   */<a name="line.1212"></a>
-<span class="sourceLineNo">1213</span>  public static abstract class Monitor implements Runnable, Closeable {<a name="line.1213"></a>
-<span class="sourceLineNo">1214</span>    protected Connection connection;<a name="line.1214"></a>
-<span class="sourceLineNo">1215</span>    protected Admin admin;<a name="line.1215"></a>
-<span class="sourceLineNo">1216</span>    /**<a name="line.1216"></a>
-<span class="sourceLineNo">1217</span>     * 'Target' dependent on 'mode'. Could be Tables or RegionServers or ZNodes.<a name="line.1217"></a>
-<span class="sourceLineNo">1218</span>     * Passed on the command-line as arguments.<a name="line.1218"></a>
-<span class="sourceLineNo">1219</span>     */<a name="line.1219"></a>
-<span class="sourceLineNo">1220</span>    protected String[] targets;<a name="line.1220"></a>
-<span class="sourceLineNo">1221</span>    protected boolean useRegExp;<a name="line.1221"></a>
-<span class="sourceLineNo">1222</span>    protected boolean treatFailureAsError;<a name="line.1222"></a>
-<span class="sourceLineNo">1223</span>    protected boolean initialized = false;<a name="line.1223"></a>
-<span class="sourceLineNo">1224</span><a name="line.1224"></a>
-<span class="sourceLineNo">1225</span>    protected boolean done = false;<a name="line.1225"></a>
-<span class="sourceLineNo">1226</span>    protected int errorCode = 0;<a name="line.1226"></a>
-<span class="sourceLineNo">1227</span>    protected long allowedFailures = 0;<a name="line.1227"></a>
-<span class="sourceLineNo">1228</span>    protected Sink sink;<a name="line.1228"></a>
-<span class="sourceLineNo">1229</span>    protected ExecutorService executor;<a name="line.1229"></a>
-<span class="sourceLineNo">1230</span><a name="line.1230"></a>
-<span class="sourceLineNo">1231</span>    public boolean isDone() {<a name="line.1231"></a>
-<span class="sourceLineNo">1232</span>      return done;<a name="line.1232"></a>
-<span class="sourceLineNo">1233</span>    }<a name="line.1233"></a>
-<span class="sourceLineNo">1234</span><a name="line.1234"></a>
-<span class="sourceLineNo">1235</span>    public boolean hasError() {<a name="line.1235"></a>
-<span class="sourceLineNo">1236</span>      return errorCode != 0;<a name="line.1236"></a>
-<span class="sourceLineNo">1237</span>    }<a name="line.1237"></a>
-<span class="sourceLineNo">1238</span><a name="line.1238"></a>
-<span class="sourceLineNo">1239</span>    public boolean finalCheckForErrors() {<a name="line.1239"></a>
-<span class="sourceLineNo">1240</span>      if (errorCode != 0) {<a name="line.1240"></a>
-<span class="sourceLineNo">1241</span>        return true;<a name="line.1241"></a>
-<span class="sourceLineNo">1242</span>      }<a name="line.1242"></a>
-<span class="sourceLineNo">1243</span>      if (treatFailureAsError &amp;&amp;<a name="line.1243"></a>
-<span class="sourceLineNo">1244</span>          (sink.getReadFailureCount() &gt; allowedFailures || sink.getWriteFailureCount() &gt; allowedFailures)) {<a name="line.1244"></a>
-<span class="sourceLineNo">1245</span>        LOG.error("Too many failures detected, treating failure as error, failing the Canary.");<a name="line.1245"></a>
-<span class="sourceLineNo">1246</span>        errorCode = FAILURE_EXIT_CODE;<a name="line.1246"></a>
-<span class="sourceLineNo">1247</span>        return true;<a name="line.1247"></a>
-<span class="sourceLineNo">1248</span>      }<a name="line.1248"></a>
-<span class="sourceLineNo">1249</span>      return false;<a name="line.1249"></a>
-<span class="sourceLineNo">1250</span>    }<a name="line.1250"></a>
-<span class="sourceLineNo">1251</span><a name="line.1251"></a>
-<span class="sourceLineNo">1252</span>    @Override<a name="line.1252"></a>
-<span class="sourceLineNo">1253</span>    public void close() throws IOException {<a name="line.1253"></a>
-<span class="sourceLineNo">1254</span>      if (this.admin != null) this.admin.close();<a name="line.1254"></a>
-<span class="sourceLineNo">1255</span>    }<a name="line.1255"></a>
-<span class="sourceLineNo">1256</span><a name="line.1256"></a>
-<span class="sourceLineNo">1257</span>    protected Monitor(Connection connection, String[] monitorTargets, boolean useRegExp, Sink sink,<a name="line.1257"></a>
-<span class="sourceLineNo">1258</span>        ExecutorService executor, boolean treatFailureAsError, long allowedFailures) {<a name="line.1258"></a>
-<span class="sourceLineNo">1259</span>      if (null == connection) throw new IllegalArgumentException("connection shall not be null");<a name="line.1259"></a>
-<span class="sourceLineNo">1260</span><a name="line.1260"></a>
-<span class="sourceLineNo">1261</span>      this.connection = connection;<a name="line.1261"></a>
-<span class="sourceLineNo">1262</span>      this.targets = monitorTargets;<a name="line.1262"></a>
-<span class="sourceLineNo">1263</span>      this.useRegExp = useRegExp;<a name="line.1263"></a>
-<span class="sourceLineNo">1264</span>      this.treatFailureAsError = treatFailureAsError;<a name="line.1264"></a>
-<span class="sourceLineNo">1265</span>      this.sink = sink;<a name="line.1265"></a>
-<span class="sourceLineNo">1266</span>      this.executor = executor;<a name="line.1266"></a>
-<span class="sourceLineNo">1267</span>      this.allowedFailures = allowedFailures;<a name="line.1267"></a>
-<span class="sourceLineNo">1268</span>    }<a name="line.1268"></a>
-<span class="sourceLineNo">1269</span><a name="line.1269"></a>
-<span class="sourceLineNo">1270</span>    @Override<a name="line.1270"></a>
-<span class="sourceLineNo">1271</span>    public abstract void run();<a name="line.1271"></a>
-<span class="sourceLineNo">1272</span><a name="line.1272"></a>
-<span class="sourceLineNo">1273</span>    protected boolean initAdmin() {<a name="line.1273"></a>
-<span class="sourceLineNo">1274</span>      if (null == this.admin) {<a name="line.1274"></a>
-<span class="sourceLineNo">1275</span>        try {<a name="line.1275"></a>
-<span class="sourceLineNo">1276</span>          this.admin = this.connection.getAdmin();<a name="line.1276"></a>
-<span class="sourceLineNo">1277</span>        } catch (Exception e) {<a name="line.1277"></a>
-<span class="sourceLineNo">1278</span>          LOG.error("Initial HBaseAdmin failed...", e);<a name="line.1278"></a>
-<span class="sourceLineNo">1279</span>          this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1279"></a>
-<span class="sourceLineNo">1280</span>        }<a name="line.1280"></a>
-<span class="sourceLineNo">1281</span>      } else if (admin.isAborted()) {<a name="line.1281"></a>
-<span class="sourceLineNo">1282</span>        LOG.error("HBaseAdmin aborted");<a name="line.1282"></a>
-<span class="sourceLineNo">1283</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1283"></a>
-<span class="sourceLineNo">1284</span>      }<a name="line.1284"></a>
-<span class="sourceLineNo">1285</span>      return !this.hasError();<a name="line.1285"></a>
-<span class="sourceLineNo">1286</span>    }<a name="line.1286"></a>
-<span class="sourceLineNo">1287</span>  }<a name="line.1287"></a>
-<span class="sourceLineNo">1288</span><a name="line.1288"></a>
-<span class="sourceLineNo">1289</span>  /**<a name="line.1289"></a>
-<span class="sourceLineNo">1290</span>   * A monitor for region mode.<a name="line.1290"></a>
-<span class="sourceLineNo">1291</span>   */<a name="line.1291"></a>
-<span class="sourceLineNo">1292</span>  private static class RegionMonitor extends Monitor {<a name="line.1292"></a>
-<span class="sourceLineNo">1293</span>    // 10 minutes<a name="line.1293"></a>
-<span class="sourceLineNo">1294</span>    private static final int DEFAULT_WRITE_TABLE_CHECK_PERIOD = 10 * 60 * 1000;<a name="line.1294"></a>
-<span class="sourceLineNo">1295</span>    // 1 days<a name="line.1295"></a>
-<span class="sourceLineNo">1296</span>    private static final int DEFAULT_WRITE_DATA_TTL = 24 * 60 * 60;<a name="line.1296"></a>
-<span class="sourceLineNo">1297</span><a name="line.1297"></a>
-<span class="sourceLineNo">1298</span>    private long lastCheckTime = -1;<a name="line.1298"></a>
-<span class="sourceLineNo">1299</span>    private boolean writeSniffing;<a name="line.1299"></a>
-<span class="sourceLineNo">1300</span>    private TableName writeTableName;<a name="line.1300"></a>
-<span class="sourceLineNo">1301</span>    private int writeDataTTL;<a name="line.1301"></a>
-<span class="sourceLineNo">1302</span>    private float regionsLowerLimit;<a name="line.1302"></a>
-<span class="sourceLineNo">1303</span>    private float regionsUpperLimit;<a name="line.1303"></a>
-<span class="sourceLineNo">1304</span>    private int checkPeriod;<a name="line.1304"></a>
-<span class="sourceLineNo">1305</span>    private boolean rawScanEnabled;<a name="line.1305"></a>
-<span class="sourceLineNo">1306</span><a name="line.1306"></a>
-<span class="sourceLineNo">1307</span>    /**<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span>     * This is a timeout per table. If read of each region in the table aggregated takes longer<a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>     * than what is configured here, we log an ERROR rather than just an INFO.<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span>     */<a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>    private HashMap&lt;String, Long&gt; configuredReadTableTimeouts;<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span><a name="line.1312"></a>
-<span class="sourceLineNo">1313</span>    private long configuredWriteTableTimeout;<a name="line.1313"></a>
-<span class="sourceLineNo">1314</span><a name="line.1314"></a>
-<span class="sourceLineNo">1315</span>    public RegionMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>        Sink sink, ExecutorService executor, boolean writeSniffing, TableName writeTableName,<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span>        boolean treatFailureAsError, HashMap&lt;String, Long&gt; configuredReadTableTimeouts,<a name="line.1317"></a>
-<span class="sourceLineNo">1318</span>        long configuredWriteTableTimeout,<a name="line.1318"></a>
-<span class="sourceLineNo">1319</span>        long allowedFailures) {<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>      super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError,<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span>          allowedFailures);<a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>      Configuration conf = connection.getConfiguration();<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span>      this.writeSniffing = writeSniffing;<a name="line.1323"></a>
-<span class="sourceLineNo">1324</span>      this.writeTableName = writeTableName;<a name="line.1324"></a>
-<span class="sourceLineNo">1325</span>      this.writeDataTTL =<a name="line.1325"></a>
-<span class="sourceLineNo">1326</span>          conf.getInt(HConstants.HBASE_CANARY_WRITE_DATA_TTL_KEY, DEFAULT_WRITE_DATA_TTL);<a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>      this.regionsLowerLimit =<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span>          conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY, 1.0f);<a name="line.1328"></a>
-<span class="sourceLineNo">1329</span>      this.regionsUpperLimit =<a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>          conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_UPPERLIMIT_KEY, 1.5f);<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span>      this.checkPeriod =<a name="line.1331"></a>
-<span class="sourceLineNo">1332</span>          conf.getInt(HConstants.HBASE_CANARY_WRITE_TABLE_CHECK_PERIOD_KEY,<a name="line.1332"></a>
-<span class="sourceLineNo">1333</span>            DEFAULT_WRITE_TABLE_CHECK_PERIOD);<a name="line.1333"></a>
-<span class="sourceLineNo">1334</span>      this.rawScanEnabled = conf.getBoolean(HConstants.HBASE_CANARY_READ_RAW_SCAN_KEY, false);<a name="line.1334"></a>
-<span class="sourceLineNo">1335</span>      this.configuredReadTableTimeouts = new HashMap&lt;&gt;(configuredReadTableTimeouts);<a name="line.1335"></a>
-<span class="sourceLineNo">1336</span>      this.configuredWriteTableTimeout = configuredWriteTableTimeout;<a name="line.1336"></a>
-<span class="sourceLineNo">1337</span>    }<a name="line.1337"></a>
-<span class="sourceLineNo">1338</span><a name="line.1338"></a>
-<span class="sourceLineNo">1339</span>    private RegionStdOutSink getSink() {<a name="line.1339"></a>
-<span class="sourceLineNo">1340</span>      if (!(sink instanceof RegionStdOutSink)) {<a name="line.1340"></a>
-<span class="sourceLineNo">1341</span>        throw new RuntimeException("Can only write to Region sink");<a name="line.1341"></a>
-<span class="sourceLineNo">1342</span>      }<a name="line.1342"></a>
-<span class="sourceLineNo">1343</span>      return ((RegionStdOutSink) sink);<a name="line.1343"></a>
-<span class="sourceLineNo">1344</span>    }<a name="line.1344"></a>
-<span class="sourceLineNo">1345</span><a name="line.1345"></a>
-<span class="sourceLineNo">1346</span>    @Override<a name="line.1346"></a>
-<span class="sourceLineNo">1347</span>    public void run() {<a name="line.1347"></a>
-<span class="sourceLineNo">1348</span>      if (this.initAdmin()) {<a name="line.1348"></a>
-<span class="sourceLineNo">1349</span>        try {<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span>          List&lt;Future&lt;Void&gt;&gt; taskFutures = new LinkedList&lt;&gt;();<a name="line.1350"></a>
-<span class="sourceLineNo">1351</span>          RegionStdOutSink regionSink = this.getSink();<a name="line.1351"></a>
-<span class="sourceLineNo">1352</span>          if (this.targets != null &amp;&amp; this.targets.length &gt; 0) {<a name="line.1352"></a>
-<span class="sourceLineNo">1353</span>            String[] tables = generateMonitorTables(this.targets);<a name="line.1353"></a>
-<span class="sourceLineNo">1354</span>            // Check to see that each table name passed in the -readTableTimeouts argument is also<a name="line.1354"></a>
-<span class="sourceLineNo">1355</span>            // passed as a monitor target.<a name="line.1355"></a>
-<span class="sourceLineNo">1356</span>            if (!new HashSet&lt;&gt;(Arrays.asList(tables)).<a name="line.1356"></a>
-<span class="sourceLineNo">1357</span>                containsAll(this.configuredReadTableTimeouts.keySet())) {<a name="line.1357"></a>
-<span class="sourceLineNo">1358</span>              LOG.error("-readTableTimeouts can only specify read timeouts for monitor targets " +<a name="line.1358"></a>
-<span class="sourceLineNo">1359</span>                  "passed via command line.");<a name="line.1359"></a>
-<span class="sourceLineNo">1360</span>              this.errorCode = USAGE_EXIT_CODE;<a name="line.1360"></a>
-<span class="sourceLineNo">1361</span>              return;<a name="line.1361"></a>
-<span class="sourceLineNo">1362</span>            }<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>            this.initialized = true;<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span>            for (String table : tables) {<a name="line.1364"></a>
-<span class="sourceLineNo">1365</span>              LongAdder readLatency = regionSink.initializeAndGetReadLatencyForTable(table);<a name="line.1365"></a>
-<span class="sourceLineNo">1366</span>              taskFutures.addAll(CanaryTool.sniff(admin, regionSink, table, executor, TaskType.READ,<a name="line.1366"></a>
-<span class="sourceLineNo">1367</span>                this.rawScanEnabled, readLatency));<a name="line.1367"></a>
-<span class="sourceLineNo">1368</span>            }<a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>          } else {<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span>            taskFutures.addAll(sniff(TaskType.READ, regionSink));<a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>          }<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span><a name="line.1372"></a>
-<span class="sourceLineNo">1373</span>          if (writeSniffing) {<a name="line.1373"></a>
-<span class="sourceLineNo">1374</span>            if (EnvironmentEdgeManager.currentTime() - lastCheckTime &gt; checkPeriod) {<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>              try {<a name="line.1375"></a>
-<span class="sourceLineNo">1376</span>                checkWriteTableDistribution();<a name="line.1376"></a>
-<span class="sourceLineNo">1377</span>              } catch (IOException e) {<a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>                LOG.error("Check canary table distribution failed!", e);<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span>              }<a name="line.1379"></a>
-<span class="sourceLineNo">1380</span>              lastCheckTime = EnvironmentEdgeManager.currentTime();<a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>            }<a name="line.1381"></a>
-<span class="sourceLineNo">1382</span>            // sniff canary table with write operation<a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>            regionSink.initializeWriteLatency();<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span>            LongAdder writeTableLatency = regionSink.getWriteLatency();<a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>            taskFutures.addAll(CanaryTool.sniff(admin, regionSink, admin.getDescriptor(writeTableName),<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span>              executor, TaskType.WRITE, this.rawScanEnabled, writeTableLatency));<a name="line.1386"></a>
-<span class="sourceLineNo">1387</span>          }<a name="line.1387"></a>
-<span class="sourceLineNo">1388</span><a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>          for (Future&lt;Void&gt; future : taskFutures) {<a name="line.1389"></a>
-<span class="sourceLineNo">1390</span>            try {<a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>              future.get();<a name="line.1391"></a>
-<span class="sourceLineNo">1392</span>            } catch (ExecutionException e) {<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span>              LOG.error("Sniff region failed!", e);<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>            }<a name="line.1394"></a>
-<span class="sourceLineNo">1395</span>          }<a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>          Map&lt;String, LongAdder&gt; actualReadTableLatency = regionSink.getReadLatencyMap();<a name="line.1396"></a>
-<span class="sourceLineNo">1397</span>          for (Map.Entry&lt;String, Long&gt; entry : configuredReadTableTimeouts.entrySet()) {<a name="line.1397"></a>
-<span class="sourceLineNo">1398</span>            String tableName = entry.getKey();<a name="line.1398"></a>
-<span class="sourceLineNo">1399</span>            if (actualReadTableLatency.containsKey(tableName)) {<a name="line.1399"></a>
-<span class="sourceLineNo">1400</span>              Long actual = actualReadTableLatency.get(tableName).longValue();<a name="line.1400"></a>
-<span class="sourceLineNo">1401</span>              Long configured = entry.getValue();<a name="line.1401"></a>
-<span class="sourceLineNo">1402</span>              if (actual &gt; configured) {<a name="line.1402"></a>
-<span class="sourceLineNo">1403</span>                LOG.error("Read operation for {} took {}ms exceeded the configured read timeout." +<a name="line.1403"></a>
-<span class="sourceLineNo">1404</span>                    "(Configured read timeout {}ms.", tableName, actual, configured);<a name="line.1404"></a>
-<span class="sourceLineNo">1405</span>              } else {<a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>                LOG.info("Read operation for {} took {}ms (Configured read timeout {}ms.",<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>                    tableName, actual, configured);<a name="line.1407"></a>
-<span class="sourceLineNo">1408</span>              }<a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>            } else {<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span>              LOG.error("Read operation for {} failed!", tableName);<a name="line.1410"></a>
-<span class="sourceLineNo">1411</span>            }<a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>          }<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span>          if (this.writeSniffing) {<a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>            String writeTableStringName = this.writeTableName.getNameAsString();<a name="line.1414"></a>
-<span class="sourceLineNo">1415</span>            long actualWriteLatency = regionSink.getWriteLatency().longValue();<a name="line.1415"></a>
-<span class="sourceLineNo">1416</span>            LOG.info("Write operation for {} took {}ms. Configured write timeout {}ms.",<a name="line.1416"></a>
-<span class="sourceLineNo">1417</span>                writeTableStringName, actualWriteLatency, this.configuredWriteTableTimeout);<a name="line.1417"></a>
-<span class="sourceLineNo">1418</span>            // Check that the writeTable write operation latency does not exceed the configured timeout.<a name="line.1418"></a>
-<span class="sourceLineNo">1419</span>            if (actualWriteLatency &gt; this.configuredWriteTableTimeout) {<a name="line.1419"></a>
-<span class="sourceLineNo">1420</span>              LOG.error("Write operation for {} exceeded the configured write timeout.",<a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>                  writeTableStringName);<a name="line.1421"></a>
-<span class="sourceLineNo">1422</span>            }<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>          }<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>        } catch (Exception e) {<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>          LOG.error("Run regionMonitor failed", e);<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span>          this.errorCode = ERROR_EXIT_CODE;<a name="line.1426"></a>
-<span class="sourceLineNo">1427</span>        } finally {<a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>          this.done = true;<a name="line.1428"></a>
-<span class="sourceLineNo">1429</span>        }<a name="line.1429"></a>
-<span class="sourceLineNo">1430</span>      }<a name="line.1430"></a>
-<span class="sourceLineNo">1431</span>      this.done = true;<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span>    }<a name="line.1432"></a>
-<span class="sourceLineNo">1433</span><a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>    /**<a name="line.1434"></a>
-<span class="sourceLineNo">1435</span>     * @return List of tables to use in test.<a name="line.1435"></a>
-<span class="sourceLineNo">1436</span>     */<a name="line.1436"></a>
-<span class="sourceLineNo">1437</span>    private String[] generateMonitorTables(String[] monitorTargets) throws IOException {<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span>      String[] returnTables = null;<a name="line.1438"></a>
-<span class="sourceLineNo">1439</span><a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>      if (this.useRegExp) {<a name="line.1440"></a>
-<span class="sourceLineNo">1441</span>        Pattern pattern = null;<a name="line.1441"></a>
-<span class="sourceLineNo">1442</span>        List&lt;TableDescriptor&gt; tds = null;<a name="line.1442"></a>
-<span class="sourceLineNo">1443</span>        Set&lt;String&gt; tmpTables = new TreeSet&lt;&gt;();<a name="line.1443"></a>
-<span class="sourceLineNo">1444</span>        try {<a name="line.1444"></a>
-<span class="sourceLineNo">1445</span>          LOG.debug(String.format("reading list of tables"));<a name="line.1445"></a>
-<span class="sourceLineNo">1446</span>          tds = this.admin.listTableDescriptors(pattern);<a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>          if (tds == null) {<a name="line.1447"></a>
-<span class="sourceLineNo">1448</span>            tds = Collections.emptyList();<a name="line.1448"></a>
-<span class="sourceLineNo">1449</span>          }<a name="line.1449"></a>
-<span class="sourceLineNo">1450</span>          for (String monitorTarget : monitorTargets) {<a name="line.1450"></a>
-<span class="sourceLineNo">1451</span>            pattern = Pattern.compile(monitorTarget);<a name="line.1451"></a>
-<span class="sourceLineNo">1452</span>            for (TableDescriptor td : tds) {<a name="line.1452"></a>
-<span class="sourceLineNo">1453</span>              if (pattern.matcher(td.getTableName().getNameAsString()).matches()) {<a name="line.1453"></a>
-<span class="sourceLineNo">1454</span>                tmpTables.add(td.getTableName().getNameAsString());<a name="line.1454"></a>
-<span class="sourceLineNo">1455</span>              }<a name="line.1455"></a>
-<span class="sourceLineNo">1456</span>            }<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span>          }<a name="line.1457"></a>
-<span class="sourceLineNo">1458</span>        } catch (IOException e) {<a name="line.1458"></a>
-<span class="sourceLineNo">1459</span>          LOG.error("Communicate with admin failed", e);<a name="line.1459"></a>
-<span class="sourceLineNo">1460</span>          throw e;<a name="line.1460"></a>
-<span class="sourceLineNo">1461</span>        }<a name="line.1461"></a>
-<span class="sourceLineNo">1462</span><a name="line.1462"></a>
-<span class="sourceLineNo">1463</span>        if (tmpTables.size() &gt; 0) {<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span>          returnTables = tmpTables.toArray(new String[tmpTables.size()]);<a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>        } else {<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span>          String msg = "No HTable found, tablePattern:" + Arrays.toString(monitorTargets);<a name="line.1466"></a>
-<span class="sourceLineNo">1467</span>          LOG.error(msg);<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>          this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>          throw new TableNotFoundException(msg);<a name="line.1469"></a>
-<span class="sourceLineNo">1470</span>        }<a name="line.1470"></a>
-<span class="sourceLineNo">1471</span>      } else {<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>        returnTables = monitorTargets;<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>      }<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span><a name="line.1474"></a>
-<span class="sourceLineNo">1475</span>      return returnTables;<a name="line.1475"></a>
-<span class="sourceLineNo">1476</span>    }<a name="line.1476"></a>
-<span class="sourceLineNo">1477</span><a name="line.1477"></a>
-<span class="sourceLineNo">1478</span>    /*<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>     * Canary entry point to monitor all the tables.<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>     */<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>    private List&lt;Future&lt;Void&gt;&gt; sniff(TaskType taskType, RegionStdOutSink regionSink)<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span>        throws Exception {<a name="line.1482"></a>
-<span class="sourceLineNo">1483</span>      LOG.debug("Reading list of tables");<a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>      List&lt;Future&lt;Void&gt;&gt; taskFutures = new LinkedList&lt;&gt;();<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>      for (TableDescriptor td: admin.listTableDescriptors()) {<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>        if (admin.tableExists(td.getTableName()) &amp;&amp; admin.isTableEnabled(td.getTableName()) &amp;&amp;<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>            (!td.getTableName().equals(writeTableName))) {<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span>          LongAdder readLatency =<a name="line.1488"></a>
-<span class="sourceLineNo">1489</span>              regionSink.initializeAndGetReadLatencyForTable(td.getTableName().getNameAsString());<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>          taskFutures.addAll(CanaryTool.sniff(admin, sink, td, executor, taskType, this.rawScanEnabled,<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>              readLatency));<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>        }<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span>      }<a name="line.1493"></a>
-<span class="sourceLineNo">1494</span>      return taskFutures;<a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>    }<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span><a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>    private void checkWriteTableDistribution() throws IOException {<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>      if (!admin.tableExists(writeTableName)) {<a name="line.1498"></a>
-<span class="sourceLineNo">1499</span>        int numberOfServers = admin.getRegionServers().size();<a name="line.1499"></a>
-<span class="sourceLineNo">1500</span>        if (numberOfServers == 0) {<a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>          throw new IllegalStateException("No live regionservers");<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>        }<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>        createWriteTable(numberOfServers);<a name="line.1503"></a>
-<span class="sourceLineNo">1504</span>      }<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span><a name="line.1505"></a>
-<span class="sourceLineNo">1506</span>      if (!admin.isTableEnabled(writeTableName)) {<a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>        admin.enableTable(writeTableName);<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>      }<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span><a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>      ClusterMetrics status =<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>          admin.getClusterMetrics(EnumSet.of(Option.SERVERS_NAME, Option.MASTER));<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>      int numberOfServers = status.getServersName().size();<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>      if (status.getServersName().contains(status.getMasterName())) {<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>        numberOfServers -= 1;<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>      }<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span><a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>      List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; pairs =<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span>          MetaTableAccessor.getTableRegionsAndLocations(connection, writeTableName);<a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>      int numberOfRegions = pairs.size();<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span>      if (numberOfRegions &lt; numberOfServers * regionsLowerLimit<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>          || numberOfRegions &gt; numberOfServers * regionsUpperLimit) {<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>        admin.disableTable(writeTableName);<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>        admin.deleteTable(writeTableName);<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>        createWriteTable(numberOfServers);<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>      }<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>      HashSet&lt;ServerName&gt; serverSet = new HashSet&lt;&gt;();<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>      for (Pair&lt;RegionInfo, ServerName&gt; pair : pairs) {<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>        serverSet.add(pair.getSecond());<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>      }<a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>      int numberOfCoveredServers = serverSet.size();<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>      if (numberOfCoveredServers &lt; numberOfServers) {<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>        admin.balance();<a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>      }<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>    }<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span><a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>    private void createWriteTable(int numberOfServers) throws IOException {<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span>      int numberOfRegions = (int)(numberOfServers * regionsLowerLimit);<a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>      LOG.info("Number of live regionservers {}, pre-splitting the canary table into {} regions " +<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>        "(current lower limit of regions per server is {} and you can change it with config {}).",<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>          numberOfServers, numberOfRegions, regionsLowerLimit,<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>          HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY);<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>      HTableDescriptor desc = new HTableDescriptor(writeTableName);<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>      HColumnDescriptor family = new HColumnDescriptor(CANARY_TABLE_FAMILY_NAME);<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>      family.setMaxVersions(1);<a name="line.1544"></a>
-<span class="sourceLineNo">1545</span>      family.setTimeToLive(writeDataTTL);<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span><a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>      desc.addFamily(family);<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>      byte[][] splits = new RegionSplitter.HexStringSplit().split(numberOfRegions);<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>      admin.createTable(desc, splits);<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>    }<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>  }<a name="line.1551"></a>
-<span class="sourceLineNo">1552</span><a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>  /**<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>   * Canary entry point for specified table.<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span>   * @throws Exception<a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>   */<a name="line.1556"></a>
-<span class="sourceLineNo">1557</span>  private static List&lt;Future&lt;Void&gt;&gt; sniff(final Admin admin, final Sink sink, String tableName,<a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>      ExecutorService executor, TaskType taskType, boolean rawScanEnabled, LongAdder readLatency)<a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>      throws Exception {<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>    LOG.debug("Checking table is enabled and getting table descriptor for table {}", tableName);<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span>    if (admin.isTableEnabled(TableName.valueOf(tableName))) {<a name="line.1561"></a>
-<span class="sourceLineNo">1562</span>      return CanaryTool.sniff(admin, sink, admin.getDescriptor(TableName.valueOf(tableName)),<a name="line.1562"></a>
-<span class="sourceLineNo">1563</span>        executor, taskType, rawScanEnabled, readLatency);<a name="line.1563"></a>
-<span class="sourceLineNo">1564</span>    } else {<a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>      LOG.warn("Table {} is not enabled", tableName);<a name="line.1565"></a>
-<span class="sourceLineNo">1566</span>    }<a name="line.1566"></a>
-<span class="sourceLineNo">1567</span>    return new LinkedList&lt;&gt;();<a name="line.1567"></a>
-<span class="sourceLineNo">1568</span>  }<a name="line.1568"></a>
-<span class="sourceLineNo">1569</span><a name="line.1569"></a>
-<span class="sourceLineNo">1570</span>  /*<a name="line.1570"></a>
-<span class="sourceLineNo">1571</span>   * Loops over regions of this table, and outputs information about the state.<a name="line.1571"></a>
-<span class="sourceLineNo">1572</span>   */<a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>  private static List&lt;Future&lt;Void&gt;&gt; sniff(final Admin admin, final Sink sink,<a name="line.1573"></a>
-<span class="sourceLineNo">1574</span>      TableDescriptor tableDesc, ExecutorService executor, TaskType taskType,<a name="line.1574"></a>
-<span class="sourceLineNo">1575</span>      boolean rawScanEnabled, LongAdder rwLatency) throws Exception {<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>    LOG.debug("Reading list of regions for table {}", tableDesc.getTableName());<a name="line.1576"></a>
-<span class="sourceLineNo">1577</span>    try (Table table = admin.getConnection().getTable(tableDesc.getTableName())) {<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span>      List&lt;RegionTask&gt; tasks = new ArrayList&lt;&gt;();<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>      try (RegionLocator regionLocator =<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>               admin.getConnection().getRegionLocator(tableDesc.getTableName())) {<a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>        for (HRegionLocation location: regionLocator.getAllRegionLocations()) {<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span>          ServerName rs = location.getServerName();<a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>          RegionInfo region = location.getRegion();<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span>          tasks.add(new RegionTask(admin.getConnection(), region, rs, (RegionStdOutSink)sink,<a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>              taskType, rawScanEnabled, rwLatency));<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>          Map&lt;String, List&lt;RegionTaskResult&gt;&gt; regionMap = ((RegionStdOutSink) sink).getRegionMap();<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>          regionMap.put(region.getRegionNameAsString(), new ArrayList&lt;RegionTaskResult&gt;());<a name="line.1587"></a>
-<span class="sourceLineNo">1588</span>        }<a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>        return executor.invokeAll(tasks);<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span>      }<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>    } catch (TableNotFoundException e) {<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>      return Collections.EMPTY_LIST;<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>    }<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>  }<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span><a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>  //  monitor for zookeeper mode<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>  private static class ZookeeperMonitor extends Monitor {<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>    private List&lt;String&gt; hosts;<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span>    private final String znode;<a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>    private final int timeout;<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span><a name="line.1601"></a>
-<span class="sourceLineNo">1602</span>    protected ZookeeperMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1602"></a>
-<span class="sourceLineNo">1603</span>        Sink sink, ExecutorService executor, boolean treatFailureAsError, long allowedFailures)  {<a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>      super(connection, monitorTargets, useRegExp,<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span>          sink, executor, treatFailureAsError, allowedFailures);<a name="line.1605"></a>
-<span class="sourceLineNo">1606</span>      Configuration configuration = connection.getConfiguration();<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span>      znode =<a name="line.1607"></a>
-<span class="sourceLineNo">1608</span>          configuration.get(ZOOKEEPER_ZNODE_PARENT,<a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>              DEFAULT_ZOOKEEPER_ZNODE_PARENT);<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>      timeout = configuration<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span>          .getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);<a name="line.1611"></a>
-<span class="sourceLineNo">1612</span>      ConnectStringParser parser =<a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>          new ConnectStringParser(ZKConfig.getZKQuorumServersString(configuration));<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>      hosts = Lists.newArrayList();<a name="line.1614"></a>
-<span class="sourceLineNo">1615</span>      for (InetSocketAddress server : parser.getServerAddresses()) {<a name="line.1615"></a>
-<span class="sourceLineNo">1616</span>        hosts.add(server.toString());<a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>      }<a name="line.1617"></a>
-<span class="sourceLineNo">1618</span>      if (allowedFailures &gt; (hosts.size() - 1) / 2) {<a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>        LOG.warn("Confirm allowable number of failed ZooKeeper nodes, as quorum will " +<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span>                        "already be lost. Setting of {} failures is unexpected for {} ensemble size.",<a name="line.1620"></a>
-<span class="sourceLineNo">1621</span>                allowedFailures, hosts.size());<a name="line.1621"></a>
+<span class="sourceLineNo">703</span><a name="line.703"></a>
+<span class="sourceLineNo">704</span>  private ExecutorService executor; // threads to retrieve data from regionservers<a name="line.704"></a>
+<span class="sourceLineNo">705</span><a name="line.705"></a>
+<span class="sourceLineNo">706</span>  public CanaryTool() {<a name="line.706"></a>
+<span class="sourceLineNo">707</span>    this(new ScheduledThreadPoolExecutor(1));<a name="line.707"></a>
+<span class="sourceLineNo">708</span>  }<a name="line.708"></a>
+<span class="sourceLineNo">709</span><a name="line.709"></a>
+<span class="sourceLineNo">710</span>  public CanaryTool(ExecutorService executor) {<a name="line.710"></a>
+<span class="sourceLineNo">711</span>    this(executor, null);<a name="line.711"></a>
+<span class="sourceLineNo">712</span>  }<a name="line.712"></a>
+<span class="sourceLineNo">713</span><a name="line.713"></a>
+<span class="sourceLineNo">714</span>  @VisibleForTesting<a name="line.714"></a>
+<span class="sourceLineNo">715</span>  CanaryTool(ExecutorService executor, Sink sink) {<a name="line.715"></a>
+<span class="sourceLineNo">716</span>    this.executor = executor;<a name="line.716"></a>
+<span class="sourceLineNo">717</span>    this.sink = sink;<a name="line.717"></a>
+<span class="sourceLineNo">718</span>  }<a name="line.718"></a>
+<span class="sourceLineNo">719</span><a name="line.719"></a>
+<span class="sourceLineNo">720</span>  CanaryTool(Configuration conf, ExecutorService executor) {<a name="line.720"></a>
+<span class="sourceLineNo">721</span>    this(conf, executor, null);<a name="line.721"></a>
+<span class="sourceLineNo">722</span>  }<a name="line.722"></a>
+<span class="sourceLineNo">723</span><a name="line.723"></a>
+<span class="sourceLineNo">724</span>  CanaryTool(Configuration conf, ExecutorService executor, Sink sink) {<a name="line.724"></a>
+<span class="sourceLineNo">725</span>    this(executor, sink);<a name="line.725"></a>
+<span class="sourceLineNo">726</span>    setConf(conf);<a name="line.726"></a>
+<span class="sourceLineNo">727</span>  }<a name="line.727"></a>
+<span class="sourceLineNo">728</span><a name="line.728"></a>
+<span class="sourceLineNo">729</span>  @Override<a name="line.729"></a>
+<span class="sourceLineNo">730</span>  public Configuration getConf() {<a name="line.730"></a>
+<span class="sourceLineNo">731</span>    return conf;<a name="line.731"></a>
+<span class="sourceLineNo">732</span>  }<a name="line.732"></a>
+<span class="sourceLineNo">733</span><a name="line.733"></a>
+<span class="sourceLineNo">734</span>  @Override<a name="line.734"></a>
+<span class="sourceLineNo">735</span>  public void setConf(Configuration conf) {<a name="line.735"></a>
+<span class="sourceLineNo">736</span>    if (conf == null) {<a name="line.736"></a>
+<span class="sourceLineNo">737</span>      conf = HBaseConfiguration.create();<a name="line.737"></a>
+<span class="sourceLineNo">738</span>    }<a name="line.738"></a>
+<span class="sourceLineNo">739</span>    this.conf = conf;<a name="line.739"></a>
+<span class="sourceLineNo">740</span>  }<a name="line.740"></a>
+<span class="sourceLineNo">741</span><a name="line.741"></a>
+<span class="sourceLineNo">742</span>  private int parseArgs(String[] args) {<a name="line.742"></a>
+<span class="sourceLineNo">743</span>    int index = -1;<a name="line.743"></a>
+<span class="sourceLineNo">744</span>    long permittedFailures = 0;<a name="line.744"></a>
+<span class="sourceLineNo">745</span>    boolean regionServerAllRegions = false, writeSniffing = false;<a name="line.745"></a>
+<span class="sourceLineNo">746</span>    String readTableTimeoutsStr = null;<a name="line.746"></a>
+<span class="sourceLineNo">747</span><a name="line.747"></a>
+<span class="sourceLineNo">748</span>    // Process command line args<a name="line.748"></a>
+<span class="sourceLineNo">749</span>    for (int i = 0; i &lt; args.length; i++) {<a name="line.749"></a>
+<span class="sourceLineNo">750</span>      String cmd = args[i];<a name="line.750"></a>
+<span class="sourceLineNo">751</span><a name="line.751"></a>
+<span class="sourceLineNo">752</span>      if (cmd.startsWith("-")) {<a name="line.752"></a>
+<span class="sourceLineNo">753</span>        if (index &gt;= 0) {<a name="line.753"></a>
+<span class="sourceLineNo">754</span>          // command line args must be in the form: [opts] [table 1 [table 2 ...]]<a name="line.754"></a>
+<span class="sourceLineNo">755</span>          System.err.println("Invalid command line options");<a name="line.755"></a>
+<span class="sourceLineNo">756</span>          printUsageAndExit();<a name="line.756"></a>
+<span class="sourceLineNo">757</span>        }<a name="line.757"></a>
+<span class="sourceLineNo">758</span><a name="line.758"></a>
+<span class="sourceLineNo">759</span>        if (cmd.equals("-help") || cmd.equals("-h")) {<a name="line.759"></a>
+<span class="sourceLineNo">760</span>          // user asked for help, print the help and quit.<a name="line.760"></a>
+<span class="sourceLineNo">761</span>          printUsageAndExit();<a name="line.761"></a>
+<span class="sourceLineNo">762</span>        } else if (cmd.equals("-daemon") &amp;&amp; interval == 0) {<a name="line.762"></a>
+<span class="sourceLineNo">763</span>          // user asked for daemon mode, set a default interval between checks<a name="line.763"></a>
+<span class="sourceLineNo">764</span>          interval = DEFAULT_INTERVAL;<a name="line.764"></a>
+<span class="sourceLineNo">765</span>        } else if (cmd.equals("-interval")) {<a name="line.765"></a>
+<span class="sourceLineNo">766</span>          // user has specified an interval for canary breaths (-interval N)<a name="line.766"></a>
+<span class="sourceLineNo">767</span>          i++;<a name="line.767"></a>
+<span class="sourceLineNo">768</span><a name="line.768"></a>
+<span class="sourceLineNo">769</span>          if (i == args.length) {<a name="line.769"></a>
+<span class="sourceLineNo">770</span>            System.err.println("-interval takes a numeric seconds value argument.");<a name="line.770"></a>
+<span class="sourceLineNo">771</span>            printUsageAndExit();<a name="line.771"></a>
+<span class="sourceLineNo">772</span>          }<a name="line.772"></a>
+<span class="sourceLineNo">773</span><a name="line.773"></a>
+<span class="sourceLineNo">774</span>          try {<a name="line.774"></a>
+<span class="sourceLineNo">775</span>            interval = Long.parseLong(args[i]) * 1000;<a name="line.775"></a>
+<span class="sourceLineNo">776</span>          } catch (NumberFormatException e) {<a name="line.776"></a>
+<span class="sourceLineNo">777</span>            System.err.println("-interval needs a numeric value argument.");<a name="line.777"></a>
+<span class="sourceLineNo">778</span>            printUsageAndExit();<a name="line.778"></a>
+<span class="sourceLineNo">779</span>          }<a name="line.779"></a>
+<span class="sourceLineNo">780</span>        } else if (cmd.equals("-zookeeper")) {<a name="line.780"></a>
+<span class="sourceLineNo">781</span>          this.zookeeperMode = true;<a name="line.781"></a>
+<span class="sourceLineNo">782</span>        } else if(cmd.equals("-regionserver")) {<a name="line.782"></a>
+<span class="sourceLineNo">783</span>          this.regionServerMode = true;<a name="line.783"></a>
+<span class="sourceLineNo">784</span>        } else if(cmd.equals("-allRegions")) {<a name="line.784"></a>
+<span class="sourceLineNo">785</span>          conf.setBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, true);<a name="line.785"></a>
+<span class="sourceLineNo">786</span>          regionServerAllRegions = true;<a name="line.786"></a>
+<span class="sourceLineNo">787</span>        } else if(cmd.equals("-writeSniffing")) {<a name="line.787"></a>
+<span class="sourceLineNo">788</span>          writeSniffing = true;<a name="line.788"></a>
+<span class="sourceLineNo">789</span>          conf.setBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, true);<a name="line.789"></a>
+<span class="sourceLineNo">790</span>        } else if(cmd.equals("-treatFailureAsError") || cmd.equals("-failureAsError")) {<a name="line.790"></a>
+<span class="sourceLineNo">791</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.791"></a>
+<span class="sourceLineNo">792</span>        } else if (cmd.equals("-e")) {<a name="line.792"></a>
+<span class="sourceLineNo">793</span>          conf.setBoolean(HBASE_CANARY_USE_REGEX, true);<a name="line.793"></a>
+<span class="sourceLineNo">794</span>        } else if (cmd.equals("-t")) {<a name="line.794"></a>
+<span class="sourceLineNo">795</span>          i++;<a name="line.795"></a>
+<span class="sourceLineNo">796</span><a name="line.796"></a>
+<span class="sourceLineNo">797</span>          if (i == args.length) {<a name="line.797"></a>
+<span class="sourceLineNo">798</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.798"></a>
+<span class="sourceLineNo">799</span>            printUsageAndExit();<a name="line.799"></a>
+<span class="sourceLineNo">800</span>          }<a name="line.800"></a>
+<span class="sourceLineNo">801</span>          long timeout = 0;<a name="line.801"></a>
+<span class="sourceLineNo">802</span>          try {<a name="line.802"></a>
+<span class="sourceLineNo">803</span>            timeout = Long.parseLong(args[i]);<a name="line.803"></a>
+<span class="sourceLineNo">804</span>          } catch (NumberFormatException e) {<a name="line.804"></a>
+<span class="sourceLineNo">805</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.805"></a>
+<span class="sourceLineNo">806</span>            printUsageAndExit();<a name="line.806"></a>
+<span class="sourceLineNo">807</span>          }<a name="line.807"></a>
+<span class="sourceLineNo">808</span>          conf.setLong(HBASE_CANARY_TIMEOUT, timeout);<a name="line.808"></a>
+<span class="sourceLineNo">809</span>        } else if(cmd.equals("-writeTableTimeout")) {<a name="line.809"></a>
+<span class="sourceLineNo">810</span>          i++;<a name="line.810"></a>
+<span class="sourceLineNo">811</span><a name="line.811"></a>
+<span class="sourceLineNo">812</span>          if (i == args.length) {<a name="line.812"></a>
+<span class="sourceLineNo">813</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.813"></a>
+<span class="sourceLineNo">814</span>            printUsageAndExit();<a name="line.814"></a>
+<span class="sourceLineNo">815</span>          }<a name="line.815"></a>
+<span class="sourceLineNo">816</span>          long configuredWriteTableTimeout = 0;<a name="line.816"></a>
+<span class="sourceLineNo">817</span>          try {<a name="line.817"></a>
+<span class="sourceLineNo">818</span>            configuredWriteTableTimeout = Long.parseLong(args[i]);<a name="line.818"></a>
+<span class="sourceLineNo">819</span>          } catch (NumberFormatException e) {<a name="line.819"></a>
+<span class="sourceLineNo">820</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.820"></a>
+<span class="sourceLineNo">821</span>            printUsageAndExit();<a name="line.821"></a>
+<span class="sourceLineNo">822</span>          }<a name="line.822"></a>
+<span class="sourceLineNo">823</span>          conf.setLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, configuredWriteTableTimeout);<a name="line.823"></a>
+<span class="sourceLineNo">824</span>        } else if (cmd.equals("-writeTable")) {<a name="line.824"></a>
+<span class="sourceLineNo">825</span>          i++;<a name="line.825"></a>
+<span class="sourceLineNo">826</span><a name="line.826"></a>
+<span class="sourceLineNo">827</span>          if (i == args.length) {<a name="line.827"></a>
+<span class="sourceLineNo">828</span>            System.err.println("-writeTable takes a string tablename value argument.");<a name="line.828"></a>
+<span class="sourceLineNo">829</span>            printUsageAndExit();<a name="line.829"></a>
+<span class="sourceLineNo">830</span>          }<a name="line.830"></a>
+<span class="sourceLineNo">831</span>          conf.set(HBASE_CANARY_REGION_WRITE_TABLE_NAME, args[i]);<a name="line.831"></a>
+<span class="sourceLineNo">832</span>        } else if (cmd.equals("-f")) {<a name="line.832"></a>
+<span class="sourceLineNo">833</span>          i++;<a name="line.833"></a>
+<span class="sourceLineNo">834</span><a name="line.834"></a>
+<span class="sourceLineNo">835</span>          if (i == args.length) {<a name="line.835"></a>
+<span class="sourceLineNo">836</span>            System.err<a name="line.836"></a>
+<span class="sourceLineNo">837</span>                .println("-f needs a boolean value argument (true|false).");<a name="line.837"></a>
+<span class="sourceLineNo">838</span>            printUsageAndExit();<a name="line.838"></a>
+<span class="sourceLineNo">839</span>          }<a name="line.839"></a>
+<span class="sourceLineNo">840</span><a name="line.840"></a>
+<span class="sourceLineNo">841</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, Boolean.parseBoolean(args[i]));<a name="line.841"></a>
+<span class="sourceLineNo">842</span>        } else if (cmd.equals("-readTableTimeouts")) {<a name="line.842"></a>
+<span class="sourceLineNo">843</span>          i++;<a name="line.843"></a>
+<span class="sourceLineNo">844</span><a name="line.844"></a>
+<span class="sourceLineNo">845</span>          if (i == args.length) {<a name="line.845"></a>
+<span class="sourceLineNo">846</span>            System.err.println("-readTableTimeouts needs a comma-separated list of read " +<a name="line.846"></a>
+<span class="sourceLineNo">847</span>                "millisecond timeouts per table (without spaces).");<a name="line.847"></a>
+<span class="sourceLineNo">848</span>            printUsageAndExit();<a name="line.848"></a>
+<span class="sourceLineNo">849</span>          }<a name="line.849"></a>
+<span class="sourceLineNo">850</span>          readTableTimeoutsStr = args[i];<a name="line.850"></a>
+<span class="sourceLineNo">851</span>          conf.set(HBASE_CANARY_REGION_READ_TABLE_TIMEOUT, readTableTimeoutsStr);<a name="line.851"></a>
+<span class="sourceLineNo">852</span>        } else if (cmd.equals("-permittedZookeeperFailures")) {<a name="line.852"></a>
+<span class="sourceLineNo">853</span>          i++;<a name="line.853"></a>
+<span class="sourceLineNo">854</span><a name="line.854"></a>
+<span class="sourceLineNo">855</span>          if (i == args.length) {<a name="line.855"></a>
+<span class="sourceLineNo">856</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.856"></a>
+<span class="sourceLineNo">857</span>            printUsageAndExit();<a name="line.857"></a>
+<span class="sourceLineNo">858</span>          }<a name="line.858"></a>
+<span class="sourceLineNo">859</span>          try {<a name="line.859"></a>
+<span class="sourceLineNo">860</span>            permittedFailures = Long.parseLong(args[i]);<a name="line.860"></a>
+<span class="sourceLineNo">861</span>          } catch (NumberFormatException e) {<a name="line.861"></a>
+<span class="sourceLineNo">862</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.862"></a>
+<span class="sourceLineNo">863</span>            printUsageAndExit();<a name="line.863"></a>
+<span class="sourceLineNo">864</span>          }<a name="line.864"></a>
+<span class="sourceLineNo">865</span>          conf.setLong(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, permittedFailures);<a name="line.865"></a>
+<span class="sourceLineNo">866</span>        } else {<a name="line.866"></a>
+<span class="sourceLineNo">867</span>          // no options match<a name="line.867"></a>
+<span class="sourceLineNo">868</span>          System.err.println(cmd + " options is invalid.");<a name="line.868"></a>
+<span class="sourceLineNo">869</span>          printUsageAndExit();<a name="line.869"></a>
+<span class="sourceLineNo">870</span>        }<a name="line.870"></a>
+<span class="sourceLineNo">871</span>      } else if (index &lt; 0) {<a name="line.871"></a>
+<span class="sourceLineNo">872</span>        // keep track of first table name specified by the user<a name="line.872"></a>
+<span class="sourceLineNo">873</span>        index = i;<a name="line.873"></a>
+<span class="sourceLineNo">874</span>      }<a name="line.874"></a>
+<span class="sourceLineNo">875</span>    }<a name="line.875"></a>
+<span class="sourceLineNo">876</span>    if (regionServerAllRegions &amp;&amp; !this.regionServerMode) {<a name="line.876"></a>
+<span class="sourceLineNo">877</span>      System.err.println("-allRegions can only be specified in regionserver mode.");<a name="line.877"></a>
+<span class="sourceLineNo">878</span>      printUsageAndExit();<a name="line.878"></a>
+<span class="sourceLineNo">879</span>    }<a name="line.879"></a>
+<span class="sourceLineNo">880</span>    if (this.zookeeperMode) {<a name="line.880"></a>
+<span class="sourceLineNo">881</span>      if (this.regionServerMode || regionServerAllRegions || writeSniffing) {<a name="line.881"></a>
+<span class="sourceLineNo">882</span>        System.err.println("-zookeeper is exclusive and cannot be combined with "<a name="line.882"></a>
+<span class="sourceLineNo">883</span>            + "other modes.");<a name="line.883"></a>
+<span class="sourceLineNo">884</span>        printUsageAndExit();<a name="line.884"></a>
+<span class="sourceLineNo">885</span>      }<a name="line.885"></a>
+<span class="sourceLineNo">886</span>    }<a name="line.886"></a>
+<span class="sourceLineNo">887</span>    if (permittedFailures != 0 &amp;&amp; !this.zookeeperMode) {<a name="line.887"></a>
+<span class="sourceLineNo">888</span>      System.err.println("-permittedZookeeperFailures requires -zookeeper mode.");<a name="line.888"></a>
+<span class="sourceLineNo">889</span>      printUsageAndExit();<a name="line.889"></a>
+<span class="sourceLineNo">890</span>    }<a name="line.890"></a>
+<span class="sourceLineNo">891</span>    if (readTableTimeoutsStr != null &amp;&amp; (this.regionServerMode || this.zookeeperMode)) {<a name="line.891"></a>
+<span class="sourceLineNo">892</span>      System.err.println("-readTableTimeouts can only be configured in region mode.");<a name="line.892"></a>
+<span class="sourceLineNo">893</span>      printUsageAndExit();<a name="line.893"></a>
+<span class="sourceLineNo">894</span>    }<a name="line.894"></a>
+<span class="sourceLineNo">895</span>    return index;<a name="line.895"></a>
+<span class="sourceLineNo">896</span>  }<a name="line.896"></a>
+<span class="sourceLineNo">897</span><a name="line.897"></a>
+<span class="sourceLineNo">898</span>  @Override<a name="line.898"></a>
+<span class="sourceLineNo">899</span>  public int run(String[] args) throws Exception {<a name="line.899"></a>
+<span class="sourceLineNo">900</span>    int index = parseArgs(args);<a name="line.900"></a>
+<span class="sourceLineNo">901</span>    String[] monitorTargets = null;<a name="line.901"></a>
+<span class="sourceLineNo">902</span><a name="line.902"></a>
+<span class="sourceLineNo">903</span>    if (index &gt;= 0) {<a name="line.903"></a>
+<span class="sourceLineNo">904</span>      int length = args.length - index;<a name="line.904"></a>
+<span class="sourceLineNo">905</span>      monitorTargets = new String[length];<a name="line.905"></a>
+<span class="sourceLineNo">906</span>      System.arraycopy(args, index, monitorTargets, 0, length);<a name="line.906"></a>
+<span class="sourceLineNo">907</span>    }<a name="line.907"></a>
+<span class="sourceLineNo">908</span><a name="line.908"></a>
+<span class="sourceLineNo">909</span>    if (zookeeperMode) {<a name="line.909"></a>
+<span class="sourceLineNo">910</span>      return checkZooKeeper();<a name="line.910"></a>
+<span class="sourceLineNo">911</span>    } else if (regionServerMode) {<a name="line.911"></a>
+<span class="sourceLineNo">912</span>      return checkRegionServers(monitorTargets);<a name="line.912"></a>
+<span class="sourceLineNo">913</span>    } else {<a name="line.913"></a>
+<span class="sourceLineNo">914</span>      return checkRegions(monitorTargets);<a name="line.914"></a>
+<span class="sourceLineNo">915</span>    }<a name="line.915"></a>
+<span class="sourceLineNo">916</span>  }<a name="line.916"></a>
+<span class="sourceLineNo">917</span><a name="line.917"></a>
+<span class="sourceLineNo">918</span>  private int runMonitor(String[] monitorTargets) throws Exception {<a name="line.918"></a>
+<span class="sourceLineNo">919</span>    ChoreService choreService = null;<a name="line.919"></a>
+<span class="sourceLineNo">920</span><a name="line.920"></a>
+<span class="sourceLineNo">921</span>    // Launches chore for refreshing kerberos credentials if security is enabled.<a name="line.921"></a>
+<span class="sourceLineNo">922</span>    // Please see http://hbase.apache.org/book.html#_running_canary_in_a_kerberos_enabled_cluster<a name="line.922"></a>
+<span class="sourceLineNo">923</span>    // for more details.<a name="line.923"></a>
+<span class="sourceLineNo">924</span>    final ScheduledChore authChore = AuthUtil.getAuthChore(conf);<a name="line.924"></a>
+<span class="sourceLineNo">925</span>    if (authChore != null) {<a name="line.925"></a>
+<span class="sourceLineNo">926</span>      choreService = new ChoreService("CANARY_TOOL");<a name="line.926"></a>
+<span class="sourceLineNo">927</span>      choreService.scheduleChore(authChore);<a name="line.927"></a>
+<span class="sourceLineNo">928</span>    }<a name="line.928"></a>
+<span class="sourceLineNo">929</span><a name="line.929"></a>
+<span class="sourceLineNo">930</span>    // Start to prepare the stuffs<a name="line.930"></a>
+<span class="sourceLineNo">931</span>    Monitor monitor = null;<a name="line.931"></a>
+<span class="sourceLineNo">932</span>    Thread monitorThread;<a name="line.932"></a>
+<span class="sourceLineNo">933</span>    long startTime = 0;<a name="line.933"></a>
+<span class="sourceLineNo">934</span>    long currentTimeLength = 0;<a name="line.934"></a>
+<span class="sourceLineNo">935</span>    boolean failOnError = conf.getBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.935"></a>
+<span class="sourceLineNo">936</span>    long timeout = conf.getLong(HBASE_CANARY_TIMEOUT, DEFAULT_TIMEOUT);<a name="line.936"></a>
+<span class="sourceLineNo">937</span>    // Get a connection to use in below.<a name="line.937"></a>
+<span class="sourceLineNo">938</span>    try (Connection connection = ConnectionFactory.createConnection(this.conf)) {<a name="line.938"></a>
+<span class="sourceLineNo">939</span>      do {<a name="line.939"></a>
+<span class="sourceLineNo">940</span>        // Do monitor !!<a name="line.940"></a>
+<span class="sourceLineNo">941</span>        try {<a name="line.941"></a>
+<span class="sourceLineNo">942</span>          monitor = this.newMonitor(connection, monitorTargets);<a name="line.942"></a>
+<span class="sourceLineNo">943</span>          monitorThread = new Thread(monitor, "CanaryMonitor-" + System.currentTimeMillis());<a name="line.943"></a>
+<span class="sourceLineNo">944</span>          startTime = System.currentTimeMillis();<a name="line.944"></a>
+<span class="sourceLineNo">945</span>          monitorThread.start();<a name="line.945"></a>
+<span class="sourceLineNo">946</span>          while (!monitor.isDone()) {<a name="line.946"></a>
+<span class="sourceLineNo">947</span>            // wait for 1 sec<a name="line.947"></a>
+<span class="sourceLineNo">948</span>            Thread.sleep(1000);<a name="line.948"></a>
+<span class="sourceLineNo">949</span>            // exit if any error occurs<a name="line.949"></a>
+<span class="sourceLineNo">950</span>            if (failOnError &amp;&amp; monitor.hasError()) {<a name="line.950"></a>
+<span class="sourceLineNo">951</span>              monitorThread.interrupt();<a name="line.951"></a>
+<span class="sourceLineNo">952</span>              if (monitor.initialized) {<a name="line.952"></a>
+<span class="sourceLineNo">953</span>                return monitor.errorCode;<a name="line.953"></a>
+<span class="sourceLineNo">954</span>              } else {<a name="line.954"></a>
+<span class="sourceLineNo">955</span>                return INIT_ERROR_EXIT_CODE;<a name="line.955"></a>
+<span class="sourceLineNo">956</span>              }<a name="line.956"></a>
+<span class="sourceLineNo">957</span>            }<a name="line.957"></a>
+<span class="sourceLineNo">958</span>            currentTimeLength = System.currentTimeMillis() - startTime;<a name="line.958"></a>
+<span class="sourceLineNo">959</span>            if (currentTimeLength &gt; timeout) {<a name="line.959"></a>
+<span class="sourceLineNo">960</span>              LOG.error("The monitor is running too long (" + currentTimeLength<a name="line.960"></a>
+<span class="sourceLineNo">961</span>                  + ") after timeout limit:" + timeout<a name="line.961"></a>
+<span class="sourceLineNo">962</span>                  + " will be killed itself !!");<a name="line.962"></a>
+<span class="sourceLineNo">963</span>              if (monitor.initialized) {<a name="line.963"></a>
+<span class="sourceLineNo">964</span>                return TIMEOUT_ERROR_EXIT_CODE;<a name="line.964"></a>
+<span class="sourceLineNo">965</span>              } else {<a name="line.965"></a>
+<span class="sourceLineNo">966</span>                return INIT_ERROR_EXIT_CODE;<a name="line.966"></a>
+<span class="sourceLineNo">967</span>              }<a name="line.967"></a>
+<span class="sourceLineNo">968</span>            }<a name="line.968"></a>
+<span class="sourceLineNo">969</span>          }<a name="line.969"></a>
+<span class="sourceLineNo">970</span><a name="line.970"></a>
+<span class="sourceLineNo">971</span>          if (failOnError &amp;&amp; monitor.finalCheckForErrors()) {<a name="line.971"></a>
+<span class="sourceLineNo">972</span>            monitorThread.interrupt();<a name="line.972"></a>
+<span class="sourceLineNo">973</span>            return monitor.errorCode;<a name="line.973"></a>
+<span class="sourceLineNo">974</span>          }<a name="line.974"></a>
+<span class="sourceLineNo">975</span>        } finally {<a name="line.975"></a>
+<span class="sourceLineNo">976</span>          if (monitor != null) monitor.close();<a name="line.976"></a>
+<span class="sourceLineNo">977</span>        }<a name="line.977"></a>
+<span class="sourceLineNo">978</span><a name="line.978"></a>
+<span class="sourceLineNo">979</span>        Thread.sleep(interval);<a name="line.979"></a>
+<span class="sourceLineNo">980</span>      } while (interval &gt; 0);<a name="line.980"></a>
+<span class="sourceLineNo">981</span>    } // try-with-resources close<a name="line.981"></a>
+<span class="sourceLineNo">982</span><a name="line.982"></a>
+<span class="sourceLineNo">983</span>    if (choreService != null) {<a name="line.983"></a>
+<span class="sourceLineNo">984</span>      choreService.shutdown();<a name="line.984"></a>
+<span class="sourceLineNo">985</span>    }<a name="line.985"></a>
+<span class="sourceLineNo">986</span>    return monitor.errorCode;<a name="line.986"></a>
+<span class="sourceLineNo">987</span>  }<a name="line.987"></a>
+<span class="sourceLineNo">988</span><a name="line.988"></a>
+<span class="sourceLineNo">989</span>  @Override<a name="line.989"></a>
+<span class="sourceLineNo">990</span>  public Map&lt;String, String&gt; getReadFailures()  {<a name="line.990"></a>
+<span class="sourceLineNo">991</span>    return sink.getReadFailures();<a name="line.991"></a>
+<span class="sourceLineNo">992</span>  }<a name="line.992"></a>
+<span class="sourceLineNo">993</span><a name="line.993"></a>
+<span class="sourceLineNo">994</span>  @Override<a name="line.994"></a>
+<span class="sourceLineNo">995</span>  public Map&lt;String, String&gt; getWriteFailures()  {<a name="line.995"></a>
+<span class="sourceLineNo">996</span>    return sink.getWriteFailures();<a name="line.996"></a>
+<span class="sourceLineNo">997</span>  }<a name="line.997"></a>
+<span class="sourceLineNo">998</span><a name="line.998"></a>
+<span class="sourceLineNo">999</span>  private void printUsageAndExit() {<a name="line.999"></a>
+<span class="sourceLineNo">1000</span>    System.err.println(<a name="line.1000"></a>
+<span class="sourceLineNo">1001</span>      "Usage: canary [OPTIONS] [&lt;TABLE1&gt; [&lt;TABLE2]...] | [&lt;REGIONSERVER1&gt; [&lt;REGIONSERVER2]..]");<a name="line.1001"></a>
+<span class="sourceLineNo">1002</span>    System.err.println("Where [OPTIONS] are:");<a name="line.1002"></a>
+<span class="sourceLineNo">1003</span>    System.err.println(" -h,-help        show this help and exit.");<a name="line.1003"></a>
+<span class="sourceLineNo">1004</span>    System.err.println(" -regionserver   set 'regionserver mode'; gets row from random region on " +<a name="line.1004"></a>
+<span class="sourceLineNo">1005</span>        "server");<a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>    System.err.println(" -allRegions     get from ALL regions when 'regionserver mode', not just " +<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>        "random one.");<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span>    System.err.println(" -zookeeper      set 'zookeeper mode'; grab zookeeper.znode.parent on " +<a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>        "each ensemble member");<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span>    System.err.println(" -daemon         continuous check at defined intervals.");<a name="line.1010"></a>
+<span class="sourceLineNo">1011</span>    System.err.println(" -interval &lt;N&gt;   interval between checks in seconds");<a name="line.1011"></a>
+<span class="sourceLineNo">1012</span>    System.err.println(" -e              consider table/regionserver argument as regular " +<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>        "expression");<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>    System.err.println(" -f &lt;B&gt;          exit on first error; default=true");<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>    System.err.println(" -failureAsError treat read/write failure as error");<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span>    System.err.println(" -t &lt;N&gt;          timeout for canary-test run; default=600000ms");<a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>    System.err.println(" -writeSniffing  enable write sniffing");<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span>    System.err.println(" -writeTable     the table used for write sniffing; default=hbase:canary");<a name="line.1018"></a>
+<span class="sourceLineNo">1019</span>    System.err.println(" -writeTableTimeout &lt;N&gt;  timeout for writeTable; default=600000ms");<a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>    System.err.println(" -readTableTimeouts &lt;tableName&gt;=&lt;read timeout&gt;," +<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>        "&lt;tableName&gt;=&lt;read timeout&gt;,...");<a name="line.1021"></a>
+<span class="sourceLineNo">1022</span>    System.err.println("                comma-separated list of table read timeouts " +<a name="line.1022"></a>
+<span class="sourceLineNo">1023</span>        "(no spaces);");<a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>    System.err.println("                logs 'ERROR' if takes longer. default=600000ms");<a name="line.1024"></a>
+<span class="sourceLineNo">1025</span>    System.err.println(" -permittedZookeeperFailures &lt;N&gt;  Ignore first N failures attempting to ");<a name="line.1025"></a>
+<span class="sourceLineNo">1026</span>    System.err.println("                connect to individual zookeeper nodes in ensemble");<a name="line.1026"></a>
+<span class="sourceLineNo">1027</span>    System.err.println("");<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span>    System.err.println(" -D&lt;configProperty&gt;=&lt;value&gt; to assign or override configuration params");<a name="line.1028"></a>
+<span class="sourceLineNo">1029</span>    System.err.println(" -Dhbase.canary.read.raw.enabled=&lt;true/false&gt; Set to enable/disable " +<a name="line.1029"></a>
+<span class="sourceLineNo">1030</span>        "raw scan; default=false");<a name="line.1030"></a>
+<span class="sourceLineNo">1031</span>    System.err.println("");<a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>    System.err.println("Canary runs in one of three modes: region (default), regionserver, or " +<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span>        "zookeeper.");<a name="line.1033"></a>
+<span class="sourceLineNo">1034</span>    System.err.println("To sniff/probe all regions, pass no arguments.");<a name="line.1034"></a>
+<span class="sourceLineNo">1035</span>    System.err.println("To sniff/probe all regions of a table, pass tablename.");<a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>    System.err.println("To sniff/probe regionservers, pass -regionserver, etc.");<a name="line.1036"></a>
+<span class="sourceLineNo">1037</span>    System.err.println("See http://hbase.apache.org/book.html#_canary for Canary documentation.");<a name="line.1037"></a>
+<span class="sourceLineNo">1038</span>    System.exit(USAGE_EXIT_CODE);<a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>  }<a name="line.1039"></a>
+<span class="sourceLineNo">1040</span><a name="line.1040"></a>
+<span class="sourceLineNo">1041</span>  Sink getSink(Configuration configuration, Class clazz) {<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>    // In test context, this.sink might be set. Use it if non-null. For testing.<a name="line.1042"></a>
+<span class="sourceLineNo">1043</span>    return this.sink != null? this.sink:<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>        (Sink)ReflectionUtils.newInstance(configuration.getClass("hbase.canary.sink.class",<a name="line.1044"></a>
+<span class="sourceLineNo">1045</span>            clazz, Sink.class));<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span>  }<a name="line.1046"></a>
+<span class="sourceLineNo">1047</span><a name="line.1047"></a>
+<span class="sourceLineNo">1048</span>  /**<a name="line.1048"></a>
+<span class="sourceLineNo">1049</span>   * Canary region mode-specific data structure which stores information about each region<a name="line.1049"></a>
+<span class="sourceLineNo">1050</span>   * to be scanned<a name="line.1050"></a>
+<span class="sourceLineNo">1051</span>   */<a name="line.1051"></a>
+<span class="sourceLineNo">1052</span>  public static class RegionTaskResult {<a name="line.1052"></a>
+<span class="sourceLineNo">1053</span>    private RegionInfo region;<a name="line.1053"></a>
+<span class="sourceLineNo">1054</span>    private TableName tableName;<a name="line.1054"></a>
+<span class="sourceLineNo">1055</span>    private ServerName serverName;<a name="line.1055"></a>
+<span class="sourceLineNo">1056</span>    private ColumnFamilyDescriptor column;<a name="line.1056"></a>
+<span class="sourceLineNo">1057</span>    private AtomicLong readLatency = null;<a name="line.1057"></a>
+<span class="sourceLineNo">1058</span>    private AtomicLong writeLatency = null;<a name="line.1058"></a>
+<span class="sourceLineNo">1059</span>    private boolean readSuccess = false;<a name="line.1059"></a>
+<span class="sourceLineNo">1060</span>    private boolean writeSuccess = false;<a name="line.1060"></a>
+<span class="sourceLineNo">1061</span><a name="line.1061"></a>
+<span class="sourceLineNo">1062</span>    public RegionTaskResult(RegionInfo region, TableName tableName, ServerName serverName,<a name="line.1062"></a>
+<span class="sourceLineNo">1063</span>        ColumnFamilyDescriptor column) {<a name="line.1063"></a>
+<span class="sourceLineNo">1064</span>      this.region = region;<a name="line.1064"></a>
+<span class="sourceLineNo">1065</span>      this.tableName = tableName;<a name="line.1065"></a>
+<span class="sourceLineNo">1066</span>      this.serverName = serverName;<a name="line.1066"></a>
+<span class="sourceLineNo">1067</span>      this.column = column;<a name="line.1067"></a>
+<span class="sourceLineNo">1068</span>    }<a name="line.1068"></a>
+<span class="sourceLineNo">1069</span><a name="line.1069"></a>
+<span class="sourceLineNo">1070</span>    public RegionInfo getRegionInfo() {<a name="line.1070"></a>
+<span class="sourceLineNo">1071</span>      return this.region;<a name="line.1071"></a>
+<span class="sourceLineNo">1072</span>    }<a name="line.1072"></a>
+<span class="sourceLineNo">1073</span><a name="line.1073"></a>
+<span class="sourceLineNo">1074</span>    public String getRegionNameAsString() {<a name="line.1074"></a>
+<span class="sourceLineNo">1075</span>      return this.region.getRegionNameAsString();<a name="line.1075"></a>
+<span class="sourceLineNo">1076</span>    }<a name="line.1076"></a>
+<span class="sourceLineNo">1077</span><a name="line.1077"></a>
+<span class="sourceLineNo">1078</span>    public TableName getTableName() {<a name="line.1078"></a>
+<span class="sourceLineNo">1079</span>      return this.tableName;<a name="line.1079"></a>
+<span class="sourceLineNo">1080</span>    }<a name="line.1080"></a>
+<span class="sourceLineNo">1081</span><a name="line.1081"></a>
+<span class="sourceLineNo">1082</span>    public String getTableNameAsString() {<a name="line.1082"></a>
+<span class="sourceLineNo">1083</span>      return this.tableName.getNameAsString();<a name="line.1083"></a>
+<span class="sourceLineNo">1084</span>    }<a name="line.1084"></a>
+<span class="sourceLineNo">1085</span><a name="line.1085"></a>
+<span class="sourceLineNo">1086</span>    public ServerName getServerName() {<a name="line.1086"></a>
+<span class="sourceLineNo">1087</span>      return this.serverName;<a name="line.1087"></a>
+<span class="sourceLineNo">1088</span>    }<a name="line.1088"></a>
+<span class="sourceLineNo">1089</span><a name="line.1089"></a>
+<span class="sourceLineNo">1090</span>    public String getServerNameAsString() {<a name="line.1090"></a>
+<span class="sourceLineNo">1091</span>      return this.serverName.getServerName();<a name="line.1091"></a>
+<span class="sourceLineNo">1092</span>    }<a name="line.1092"></a>
+<span class="sourceLineNo">1093</span><a name="line.1093"></a>
+<span class="sourceLineNo">1094</span>    public ColumnFamilyDescriptor getColumnFamily() {<a name="line.1094"></a>
+<span class="sourceLineNo">1095</span>      return this.column;<a name="line.1095"></a>
+<span class="sourceLineNo">1096</span>    }<a name="line.1096"></a>
+<span class="sourceLineNo">1097</span><a name="line.1097"></a>
+<span class="sourceLineNo">1098</span>    public String getColumnFamilyNameAsString() {<a name="line.1098"></a>
+<span class="sourceLineNo">1099</span>      return this.column.getNameAsString();<a name="line.1099"></a>
+<span class="sourceLineNo">1100</span>    }<a name="line.1100"></a>
+<span class="sourceLineNo">1101</span><a name="line.1101"></a>
+<span class="sourceLineNo">1102</span>    public long getReadLatency() {<a name="line.1102"></a>
+<span class="sourceLineNo">1103</span>      if (this.readLatency == null) {<a name="line.1103"></a>
+<span class="sourceLineNo">1104</span>        return -1;<a name="line.1104"></a>
+<span class="sourceLineNo">1105</span>      }<a name="line.1105"></a>
+<span class="sourceLineNo">1106</span>      return this.readLatency.get();<a name="line.1106"></a>
+<span class="sourceLineNo">1107</span>    }<a name="line.1107"></a>
+<span class="sourceLineNo">1108</span><a name="line.1108"></a>
+<span class="sourceLineNo">1109</span>    public void setReadLatency(long readLatency) {<a name="line.1109"></a>
+<span class="sourceLineNo">1110</span>      if (this.readLatency != null) {<a name="line.1110"></a>
+<span class="sourceLineNo">1111</span>        this.readLatency.set(readLatency);<a name="line.1111"></a>
+<span class="sourceLineNo">1112</span>      } else {<a name="line.1112"></a>
+<span class="sourceLineNo">1113</span>        this.readLatency = new AtomicLong(readLatency);<a name="line.1113"></a>
+<span class="sourceLineNo">1114</span>      }<a name="line.1114"></a>
+<span class="sourceLineNo">1115</span>    }<a name="line.1115"></a>
+<span class="sourceLineNo">1116</span><a name="line.1116"></a>
+<span class="sourceLineNo">1117</span>    public long getWriteLatency() {<a name="line.1117"></a>
+<span class="sourceLineNo">1118</span>      if (this.writeLatency == null) {<a name="line.1118"></a>
+<span class="sourceLineNo">1119</span>        return -1;<a name="line.1119"></a>
+<span class="sourceLineNo">1120</span>      }<a name="line.1120"></a>
+<span class="sourceLineNo">1121</span>      return this.writeLatency.get();<a name="line.1121"></a>
+<span class="sourceLineNo">1122</span>    }<a name="line.1122"></a>
+<span class="sourceLineNo">1123</span><a name="line.1123"></a>
+<span class="sourceLineNo">1124</span>    public void setWriteLatency(long writeLatency) {<a name="line.1124"></a>
+<span class="sourceLineNo">1125</span>      if (this.writeLatency != null) {<a name="line.1125"></a>
+<span class="sourceLineNo">1126</span>        this.writeLatency.set(writeLatency);<a name="line.1126"></a>
+<span class="sourceLineNo">1127</span>      } else {<a name="line.1127"></a>
+<span class="sourceLineNo">1128</span>        this.writeLatency = new AtomicLong(writeLatency);<a name="line.1128"></a>
+<span class="sourceLineNo">1129</span>      }<a name="line.1129"></a>
+<span class="sourceLineNo">1130</span>    }<a name="line.1130"></a>
+<span class="sourceLineNo">1131</span><a name="line.1131"></a>
+<span class="sourceLineNo">1132</span>    public boolean isReadSuccess() {<a name="line.1132"></a>
+<span class="sourceLineNo">1133</span>      return this.readSuccess;<a name="line.1133"></a>
+<span class="sourceLineNo">1134</span>    }<a name="line.1134"></a>
+<span class="sourceLineNo">1135</span><a name="line.1135"></a>
+<span class="sourceLineNo">1136</span>    public void setReadSuccess() {<a name="line.1136"></a>
+<span class="sourceLineNo">1137</span>      this.readSuccess = true;<a name="line.1137"></a>
+<span class="sourceLineNo">1138</span>    }<a name="line.1138"></a>
+<span class="sourceLineNo">1139</span><a name="line.1139"></a>
+<span class="sourceLineNo">1140</span>    public boolean isWriteSuccess() {<a name="line.1140"></a>
+<span class="sourceLineNo">1141</span>      return this.writeSuccess;<a name="line.1141"></a>
+<span class="sourceLineNo">1142</span>    }<a name="line.1142"></a>
+<span class="sourceLineNo">1143</span><a name="line.1143"></a>
+<span class="sourceLineNo">1144</span>    public void setWriteSuccess() {<a name="line.1144"></a>
+<span class="sourceLineNo">1145</span>      this.writeSuccess = true;<a name="line.1145"></a>
+<span class="sourceLineNo">1146</span>    }<a name="line.1146"></a>
+<span class="sourceLineNo">1147</span>  }<a name="line.1147"></a>
+<span class="sourceLineNo">1148</span><a name="line.1148"></a>
+<span class="sourceLineNo">1149</span>  /**<a name="line.1149"></a>
+<span class="sourceLineNo">1150</span>   * A Factory method for {@link Monitor}.<a name="line.1150"></a>
+<span class="sourceLineNo">1151</span>   * Makes a RegionServerMonitor, or a ZooKeeperMonitor, or a RegionMonitor.<a name="line.1151"></a>
+<span class="sourceLineNo">1152</span>   * @return a Monitor instance<a name="line.1152"></a>
+<span class="sourceLineNo">1153</span>   */<a name="line.1153"></a>
+<span class="sourceLineNo">1154</span>  private Monitor newMonitor(final Connection connection, String[] monitorTargets) {<a name="line.1154"></a>
+<span class="sourceLineNo">1155</span>    Monitor monitor;<a name="line.1155"></a>
+<span class="sourceLineNo">1156</span>    boolean useRegExp = conf.getBoolean(HBASE_CANARY_USE_REGEX, false);<a name="line.1156"></a>
+<span class="sourceLineNo">1157</span>    boolean regionServerAllRegions<a name="line.1157"></a>
+<span class="sourceLineNo">1158</span>            = conf.getBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, false);<a name="line.1158"></a>
+<span class="sourceLineNo">1159</span>    boolean failOnError<a name="line.1159"></a>
+<span class="sourceLineNo">1160</span>            = conf.getBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.1160"></a>
+<span class="sourceLineNo">1161</span>    int permittedFailures<a name="line.1161"></a>
+<span class="sourceLineNo">1162</span>            = conf.getInt(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, 0);<a name="line.1162"></a>
+<span class="sourceLineNo">1163</span>    boolean writeSniffing<a name="line.1163"></a>
+<span class="sourceLineNo">1164</span>            = conf.getBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, false);<a name="line.1164"></a>
+<span class="sourceLineNo">1165</span>    String writeTableName = conf.get(HBASE_CANARY_REGION_WRITE_TABLE_NAME,<a name="line.1165"></a>
+<span class="sourceLineNo">1166</span>            DEFAULT_WRITE_TABLE_NAME.getNameAsString());<a name="line.1166"></a>
+<span class="sourceLineNo">1167</span>    long configuredWriteTableTimeout<a name="line.1167"></a>
+<span class="sourceLineNo">1168</span>            = conf.getLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, DEFAULT_TIMEOUT);<a name="line.1168"></a>
+<span class="sourceLineNo">1169</span><a name="line.1169"></a>
+<span class="sourceLineNo">1170</span>    if (this.regionServerMode) {<a name="line.1170"></a>
+<span class="sourceLineNo">1171</span>      monitor =<a name="line.1171"></a>
+<span class="sourceLineNo">1172</span>          new RegionServerMonitor(connection, monitorTargets, useRegExp,<a name="line.1172"></a>
+<span class="sourceLineNo">1173</span>              getSink(connection.getConfiguration(), RegionServerStdOutSink.class),<a name="line.1173"></a>
+<span class="sourceLineNo">1174</span>              this.executor, regionServerAllRegions,<a name="line.1174"></a>
+<span class="sourceLineNo">1175</span>              failOnError, permittedFailures);<a name="line.1175"></a>
+<span class="sourceLineNo">1176</span><a name="line.1176"></a>
+<span class="sourceLineNo">1177</span>    } else if (this.zookeeperMode) {<a name="line.1177"></a>
+<span class="sourceLineNo">1178</span>      monitor =<a name="line.1178"></a>
+<span class="sourceLineNo">1179</span>          new ZookeeperMonitor(connection, monitorTargets, useRegExp,<a name="line.1179"></a>
+<span class="sourceLineNo">1180</span>              getSink(connection.getConfiguration(), ZookeeperStdOutSink.class),<a name="line.1180"></a>
+<span class="sourceLineNo">1181</span>              this.executor, failOnError, permittedFailures);<a name="line.1181"></a>
+<span class="sourceLineNo">1182</span>    } else {<a name="line.1182"></a>
+<span class="sourceLineNo">1183</span>      monitor =<a name="line.1183"></a>
+<span class="sourceLineNo">1184</span>          new RegionMonitor(connection, monitorTargets, useRegExp,<a name="line.1184"></a>
+<span class="sourceLineNo">1185</span>              getSink(connection.getConfiguration(), RegionStdOutSink.class),<a name="line.1185"></a>
+<span class="sourceLineNo">1186</span>              this.executor, writeSniffing,<a name="line.1186"></a>
+<span class="sourceLineNo">1187</span>              TableName.valueOf(writeTableName), failOnError, configuredReadTableTimeouts,<a name="line.1187"></a>
+<span class="sourceLineNo">1188</span>              configuredWriteTableTimeout, permittedFailures);<a name="line.1188"></a>
+<span class="sourceLineNo">1189</span>    }<a name="line.1189"></a>
+<span class="sourceLineNo">1190</span>    return monitor;<a name="line.1190"></a>
+<span class="sourceLineNo">1191</span>  }<a name="line.1191"></a>
+<span class="sourceLineNo">1192</span><a name="line.1192"></a>
+<span class="sourceLineNo">1193</span>  private void populateReadTableTimeoutsMap(String configuredReadTableTimeoutsStr) {<a name="line.1193"></a>
+<span class="sourceLineNo">1194</span>    String[] tableTimeouts = configuredReadTableTimeoutsStr.split(",");<a name="line.1194"></a>
+<span class="sourceLineNo">1195</span>    for (String tT : tableTimeouts) {<a name="line.1195"></a>
+<span class="sourceLineNo">1196</span>      String[] nameTimeout = tT.split("=");<a name="line.1196"></a>
+<span class="sourceLineNo">1197</span>      if (nameTimeout.length &lt; 2) {<a name="line.1197"></a>
+<span class="sourceLineNo">1198</span>        throw new IllegalArgumentException("Each -readTableTimeouts argument must be of the form " +<a name="line.1198"></a>
+<span class="sourceLineNo">1199</span>            "&lt;tableName&gt;=&lt;read timeout&gt; (without spaces).");<a name="line.1199"></a>
+<span class="sourceLineNo">1200</span>      }<a name="line.1200"></a>
+<span class="sourceLineNo">1201</span>      long timeoutVal;<a name="line.1201"></a>
+<span class="sourceLineNo">1202</span>      try {<a name="line.1202"></a>
+<span class="sourceLineNo">1203</span>        timeoutVal = Long.parseLong(nameTimeout[1]);<a name="line.1203"></a>
+<span class="sourceLineNo">1204</span>      } catch (NumberFormatException e) {<a name="line.1204"></a>
+<span class="sourceLineNo">1205</span>        throw new IllegalArgumentException("-readTableTimeouts read timeout for each table" +<a name="line.1205"></a>
+<span class="sourceLineNo">1206</span>            " must be a numeric value argument.");<a name="line.1206"></a>
+<span class="sourceLineNo">1207</span>      }<a name="line.1207"></a>
+<span class="sourceLineNo">1208</span>      configuredReadTableTimeouts.put(nameTimeout[0], timeoutVal);<a name="line.1208"></a>
+<span class="sourceLineNo">1209</span>    }<a name="line.1209"></a>
+<span class="sourceLineNo">1210</span>  }<a name="line.1210"></a>
+<span class="sourceLineNo">1211</span>  /**<a name="line.1211"></a>
+<span class="sourceLineNo">1212</span>   * A Monitor super-class can be extended by users<a name="line.1212"></a>
+<span class="sourceLineNo">1213</span>   */<a name="line.1213"></a>
+<span class="sourceLineNo">1214</span>  public static abstract class Monitor implements Runnable, Closeable {<a name="line.1214"></a>
+<span class="sourceLineNo">1215</span>    protected Connection connection;<a name="line.1215"></a>
+<span class="sourceLineNo">1216</span>    protected Admin admin;<a name="line.1216"></a>
+<span class="sourceLineNo">1217</span>    /**<a name="line.1217"></a>
+<span class="sourceLineNo">1218</span>     * 'Target' dependent on 'mode'. Could be Tables or RegionServers or ZNodes.<a name="line.1218"></a>
+<span class="sourceLineNo">1219</span>     * Passed on the command-line as arguments.<a name="line.1219"></a>
+<span class="sourceLineNo">1220</span>     */<a name="line.1220"></a>
+<span class="sourceLineNo">1221</span>    protected String[] targets;<a name="line.1221"></a>
+<span class="sourceLineNo">1222</span>    protected boolean useRegExp;<a name="line.1222"></a>
+<span class="sourceLineNo">1223</span>    protected boolean treatFailureAsError;<a name="line.1223"></a>
+<span class="sourceLineNo">1224</span>    protected boolean initialized = false;<a name="line.1224"></a>
+<span class="sourceLineNo">1225</span><a name="line.1225"></a>
+<span class="sourceLineNo">1226</span>    protected boolean done = false;<a name="line.1226"></a>
+<span class="sourceLineNo">1227</span>    protected int errorCode = 0;<a name="line.1227"></a>
+<span class="sourceLineNo">1228</span>    protected long allowedFailures = 0;<a name="line.1228"></a>
+<span class="sourceLineNo">1229</span>    protected Sink sink;<a name="line.1229"></a>
+<span class="sourceLineNo">1230</span>    protected ExecutorService executor;<a name="line.1230"></a>
+<span class="sourceLineNo">1231</span><a name="line.1231"></a>
+<span class="sourceLineNo">1232</span>    public boolean isDone() {<a name="line.1232"></a>
+<span class="sourceLineNo">1233</span>      return done;<a name="line.1233"></a>
+<span class="sourceLineNo">1234</span>    }<a name="line.1234"></a>
+<span class="sourceLineNo">1235</span><a name="line.1235"></a>
+<span class="sourceLineNo">1236</span>    public boolean hasError() {<a name="line.1236"></a>
+<span class="sourceLineNo">1237</span>      return errorCode != 0;<a name="line.1237"></a>
+<span class="sourceLineNo">1238</span>    }<a name="line.1238"></a>
+<span class="sourceLineNo">1239</span><a name="line.1239"></a>
+<span class="sourceLineNo">1240</span>    public boolean finalCheckForErrors() {<a name="line.1240"></a>
+<span class="sourceLineNo">1241</span>      if (errorCode != 0) {<a name="line.1241"></a>
+<span class="sourceLineNo">1242</span>        return true;<a name="line.1242"></a>
+<span class="sourceLineNo">1243</span>      }<a name="line.1243"></a>
+<span class="sourceLineNo">1244</span>      if (treatFailureAsError &amp;&amp;<a name="line.1244"></a>
+<span class="sourceLineNo">1245</span>          (sink.getReadFailureCount() &gt; allowedFailures || sink.getWriteFailureCount() &gt; allowedFailures)) {<a name="line.1245"></a>
+<span class="sourceLineNo">1246</span>        LOG.error("Too many failures detected, treating failure as error, failing the Canary.");<a name="line.1246"></a>
+<span class="sourceLineNo">1247</span>        errorCode = FAILURE_EXIT_CODE;<a name="line.1247"></a>
+<span class="sourceLineNo">1248</span>        return true;<a name="line.1248"></a>
+<span class="sourceLineNo">1249</span>      }<a name="line.1249"></a>
+<span class="sourceLineNo">1250</span>      return false;<a name="line.1250"></a>
+<span class="sourceLineNo">1251</span>    }<a name="line.1251"></a>
+<span class="sourceLineNo">1252</span><a name="line.1252"></a>
+<span class="sourceLineNo">1253</span>    @Override<a name="line.1253"></a>
+<span class="sourceLineNo">1254</span>    public void close() throws IOException {<a name="line.1254"></a>
+<span class="sourceLineNo">1255</span>      if (this.admin != null) this.admin.close();<a name="line.1255"></a>
+<span class="sourceLineNo">1256</span>    }<a name="line.1256"></a>
+<span class="sourceLineNo">1257</span><a name="line.1257"></a>
+<span class="sourceLineNo">1258</span>    protected Monitor(Connection connection, String[] monitorTargets, boolean useRegExp, Sink sink,<a name="line.1258"></a>
+<span class="sourceLineNo">1259</span>        ExecutorService executor, boolean treatFailureAsError, long allowedFailures) {<a name="line.1259"></a>
+<span class="sourceLineNo">1260</span>      if (null == connection) throw new IllegalArgumentException("connection shall not be null");<a name="line.1260"></a>
+<span class="sourceLineNo">1261</span><a name="line.1261"></a>
+<span class="sourceLineNo">1262</span>      this.connection = connection;<a name="line.1262"></a>
+<span class="sourceLineNo">1263</span>      this.targets = monitorTargets;<a name="line.1263"></a>
+<span class="sourceLineNo">1264</span>      this.useRegExp = useRegExp;<a name="line.1264"></a>
+<span class="sourceLineNo">1265</span>      this.treatFailureAsError = treatFailureAsError;<a name="line.1265"></a>
+<span class="sourceLineNo">1266</span>      this.sink = sink;<a name="line.1266"></a>
+<span class="sourceLineNo">1267</span>      this.executor = executor;<a name="line.1267"></a>
+<span class="sourceLineNo">1268</span>      this.allowedFailures = allowedFailures;<a name="line.1268"></a>
+<span class="sourceLineNo">1269</span>    }<a name="line.1269"></a>
+<span class="sourceLineNo">1270</span><a name="line.1270"></a>
+<span class="sourceLineNo">1271</span>    @Override<a name="line.1271"></a>
+<span class="sourceLineNo">1272</span>    public abstract void run();<a name="line.1272"></a>
+<span class="sourceLineNo">1273</span><a name="line.1273"></a>
+<span class="sourceLineNo">1274</span>    protected boolean initAdmin() {<a name="line.1274"></a>
+<span class="sourceLineNo">1275</span>      if (null == this.admin) {<a name="line.1275"></a>
+<span class="sourceLineNo">1276</span>        try {<a name="line.1276"></a>
+<span class="sourceLineNo">1277</span>          this.admin = this.connection.getAdmin();<a name="line.1277"></a>
+<span class="sourceLineNo">1278</span>        } catch (Exception e) {<a name="line.1278"></a>
+<span class="sourceLineNo">1279</span>          LOG.error("Initial HBaseAdmin failed...", e);<a name="line.1279"></a>
+<span class="sourceLineNo">1280</span>          this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1280"></a>
+<span class="sourceLineNo">1281</span>        }<a name="line.1281"></a>
+<span class="sourceLineNo">1282</span>      } else if (admin.isAborted()) {<a name="line.1282"></a>
+<span class="sourceLineNo">1283</span>        LOG.error("HBaseAdmin aborted");<a name="line.1283"></a>
+<span class="sourceLineNo">1284</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1284"></a>
+<span class="sourceLineNo">1285</span>      }<a name="line.1285"></a>
+<span class="sourceLineNo">1286</span>      return !this.hasError();<a name="line.1286"></a>
+<span class="sourceLineNo">1287</span>    }<a name="line.1287"></a>
+<span class="sourceLineNo">1288</span>  }<a name="line.1288"></a>
+<span class="sourceLineNo">1289</span><a name="line.1289"></a>
+<span class="sourceLineNo">1290</span>  /**<a name="line.1290"></a>
+<span class="sourceLineNo">1291</span>   * A monitor for region mode.<a name="line.1291"></a>
+<span class="sourceLineNo">1292</span>   */<a name="line.1292"></a>
+<span class="sourceLineNo">1293</span>  private static class RegionMonitor extends Monitor {<a name="line.1293"></a>
+<span class="sourceLineNo">1294</span>    // 10 minutes<a name="line.1294"></a>
+<span class="sourceLineNo">1295</span>    private static final int DEFAULT_WRITE_TABLE_CHECK_PERIOD = 10 * 60 * 1000;<a name="line.1295"></a>
+<span class="sourceLineNo">1296</span>    // 1 days<a name="line.1296"></a>
+<span class="sourceLineNo">1297</span>    private static final int DEFAULT_WRITE_DATA_TTL = 24 * 60 * 60;<a name="line.1297"></a>
+<span class="sourceLineNo">1298</span><a name="line.1298"></a>
+<span class="sourceLineNo">1299</span>    private long lastCheckTime = -1;<a name="line.1299"></a>
+<span class="sourceLineNo">1300</span>    private boolean writeSniffing;<a name="line.1300"></a>
+<span class="sourceLineNo">1301</span>    private TableName writeTableName;<a name="line.1301"></a>
+<span class="sourceLineNo">1302</span>    private int writeDataTTL;<a name="line.1302"></a>
+<span class="sourceLineNo">1303</span>    private float regionsLowerLimit;<a name="line.1303"></a>
+<span class="sourceLineNo">1304</span>    private float regionsUpperLimit;<a name="line.1304"></a>
+<span class="sourceLineNo">1305</span>    private int checkPeriod;<a name="line.1305"></a>
+<span class="sourceLineNo">1306</span>    private boolean rawScanEnabled;<a name="line.1306"></a>
+<span class="sourceLineNo">1307</span><a name="line.1307"></a>
+<span class="sourceLineNo">1308</span>    /**<a name="line.1308"></a>
+<span class="sourceLineNo">1309</span>     * This is a timeout per table. If read of each region in the table aggregated takes longer<a name="line.1309"></a>
+<span class="sourceLineNo">1310</span>     * than what is configured here, we log an ERROR rather than just an INFO.<a name="line.1310"></a>
+<span class="sourceLineNo">1311</span>     */<a name="line.1311"></a>
+<span class="sourceLineNo">1312</span>    private HashMap&lt;String, Long&gt; configuredReadTableTimeouts;<a name="line.1312"></a>
+<span class="sourceLineNo">1313</span><a name="line.1313"></a>
+<span class="sourceLineNo">1314</span>    private long configuredWriteTableTimeout;<a name="line.1314"></a>
+<span class="sourceLineNo">1315</span><a name="line.1315"></a>
+<span class="sourceLineNo">1316</span>    public RegionMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1316"></a>
+<span class="sourceLineNo">1317</span>        Sink sink, ExecutorService executor, boolean writeSniffing, TableName writeTableName,<a name="line.1317"></a>
+<span class="sourceLineNo">1318</span>        boolean treatFailureAsError, HashMap&lt;String, Long&gt; configuredReadTableTimeouts,<a name="line.1318"></a>
+<span class="sourceLineNo">1319</span>        long configuredWriteTableTimeout,<a name="line.1319"></a>
+<span class="sourceLineNo">1320</span>        long allowedFailures) {<a name="line.1320"></a>
+<span class="sourceLineNo">1321</span>      super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError,<a name="line.1321"></a>
+<span class="sourceLineNo">1322</span>          allowedFailures);<a name="line.1322"></a>
+<span class="sourceLineNo">1323</span>      Configuration conf = connection.getConfiguration();<a name="line.1323"></a>
+<span class="sourceLineNo">1324</span>      this.writeSniffing = writeSniffing;<a name="line.1324"></a>
+<span class="sourceLineNo">1325</span>      this.writeTableName = writeTableName;<a name="line.1325"></a>
+<span class="sourceLineNo">1326</span>      this.writeDataTTL =<a name="line.1326"></a>
+<span class="sourceLineNo">1327</span>          conf.getInt(HConstants.HBASE_CANARY_WRITE_DATA_TTL_KEY, DEFAULT_WRITE_DATA_TTL);<a name="line.1327"></a>
+<span class="sourceLineNo">1328</span>      this.regionsLowerLimit =<a name="line.1328"></a>
+<span class="sourceLineNo">1329</span>          conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY, 1.0f);<a name="line.1329"></a>
+<span class="sourceLineNo">1330</span>      this.regionsUpperLimit =<a name="line.1330"></a>
+<span class="sourceLineNo">1331</span>          conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_UPPERLIMIT_KEY, 1.5f);<a name="line.1331"></a>
+<span class="sourceLineNo">1332</span>      this.checkPeriod =<a name="line.1332"></a>
+<span class="sourceLineNo">1333</span>          conf.getInt(HConstants.HBASE_CANARY_WRITE_TABLE_CHECK_PERIOD_KEY,<a name="line.1333"></a>
+<span class="sourceLineNo">1334</span>            DEFAULT_WRITE_TABLE_CHECK_PERIOD);<a name="line.1334"></a>
+<span class="sourceLineNo">1335</span>      this.rawScanEnabled = conf.getBoolean(HConstants.HBASE_CANARY_READ_RAW_SCAN_KEY, false);<a name="line.1335"></a>
+<span class="sourceLineNo">1336</span>      this.configuredReadTableTimeouts = new HashMap&lt;&gt;(configuredReadTableTimeouts);<a name="line.1336"></a>
+<span class="sourceLineNo">1337</span>      this.configuredWriteTableTimeout = configuredWriteTableTimeout;<a name="line.1337"></a>
+<span class="sourceLineNo">1338</span>    }<a name="line.1338"></a>
+<span class="sourceLineNo">1339</span><a name="line.1339"></a>
+<span class="sourceLineNo">1340</span>    private RegionStdOutSink getSink() {<a name="line.1340"></a>
+<span class="sourceLineNo">1341</span>      if (!(sink instanceof RegionStdOutSink)) {<a name="line.1341"></a>
+<span class="sourceLineNo">1342</span>        throw new RuntimeException("Can only write to Region sink");<a name="line.1342"></a>
+<span class="sourceLineNo">1343</span>      }<a name="line.1343"></a>
+<span class="sourceLineNo">1344</span>      return ((RegionStdOutSink) sink);<a name="line.1344"></a>
+<span class="sourceLineNo">1345</span>    }<a name="line.1345"></a>
+<span class="sourceLineNo">1346</span><a name="line.1346"></a>
+<span class="sourceLineNo">1347</span>    @Override<a name="line.1347"></a>
+<span class="sourceLineNo">1348</span>    public void run() {<a name="line.1348"></a>
+<span class="sourceLineNo">1349</span>      if (this.initAdmin()) {<a name="line.1349"></a>
+<span class="sourceLineNo">1350</span>        try {<a name="line.1350"></a>
+<span class="sourceLineNo">1351</span>          List&lt;Future&lt;Void&gt;&gt; taskFutures = new LinkedList&lt;&gt;();<a name="line.1351"></a>
+<span class="sourceLineNo">1352</span>          RegionStdOutSink regionSink = this.getSink();<a name="line.1352"></a>
+<span class="sourceLineNo">1353</span>          if (this.targets != null &amp;&amp; this.targets.length &gt; 0) {<a name="line.1353"></a>
+<span class="sourceLineNo">1354</span>            String[] tables = generateMonitorTables(this.targets);<a name="line.1354"></a>
+<span class="sourceLineNo">1355</span>            // Check to see that each table name passed in the -readTableTimeouts argument is also<a name="line.1355"></a>
+<span class="sourceLineNo">1356</span>            // passed as a monitor target.<a name="line.1356"></a>
+<span class="sourceLineNo">1357</span>            if (!new HashSet&lt;&gt;(Arrays.asList(tables)).<a name="line.1357"></a>
+<span class="sourceLineNo">1358</span>                containsAll(this.configuredReadTableTimeouts.keySet())) {<a name="line.1358"></a>
+<span class="sourceLineNo">1359</span>              LOG.error("-readTableTimeouts can only specify read timeouts for monitor targets " +<a name="line.1359"></a>
+<span class="sourceLineNo">1360</span>                  "passed via command line.");<a name="line.1360"></a>
+<span class="sourceLineNo">1361</span>              this.errorCode = USAGE_EXIT_CODE;<a name="line.1361"></a>
+<span class="sourceLineNo">1362</span>              return;<a name="line.1362"></a>
+<span class="sourceLineNo">1363</span>            }<a name="line.1363"></a>
+<span class="sourceLineNo">1364</span>            this.initialized = true;<a name="line.1364"></a>
+<span class="sourceLineNo">1365</span>            for (String table : tables) {<a name="line.1365"></a>
+<span class="sourceLineNo">1366</span>              LongAdder readLatency = regionSink.initializeAndGetReadLatencyForTable(table);<a name="line.1366"></a>
+<span class="sourceLineNo">1367</span>              taskFutures.addAll(CanaryTool.sniff(admin, regionSink, table, executor, TaskType.READ,<a name="line.1367"></a>
+<span class="sourceLineNo">1368</span>                this.rawScanEnabled, readLatency));<a name="line.1368"></a>
+<span class="sourceLineNo">1369</span>            }<a name="line.1369"></a>
+<span class="sourceLineNo">1370</span>          } else {<a name="line.1370"></a>
+<span class="sourceLineNo">1371</span>            taskFutures.addAll(sniff(TaskType.READ, regionSink));<a name="line.1371"></a>
+<span class="sourceLineNo">1372</span>          }<a name="line.1372"></a>
+<span class="sourceLineNo">1373</span><a name="line.1373"></a>
+<span class="sourceLineNo">1374</span>          if (writeSniffing) {<a name="line.1374"></a>
+<span class="sourceLineNo">1375</span>            if (EnvironmentEdgeManager.currentTime() - lastCheckTime &gt; checkPeriod) {<a name="line.1375"></a>
+<span class="sourceLineNo">1376</span>              try {<a name="line.1376"></a>
+<span class="sourceLineNo">1377</span>                checkWriteTableDistribution();<a name="line.1377"></a>
+<span class="sourceLineNo">1378</span>              } catch (IOException e) {<a name="line.1378"></a>
+<span class="sourceLineNo">1379</span>                LOG.error("Check canary table distribution failed!", e);<a name="line.1379"></a>
+<span class="sourceLineNo">1380</span>              }<a name="line.1380"></a>
+<span class="sourceLineNo">1381</span>              lastCheckTime = EnvironmentEdgeManager.currentTime();<a name="line.1381"></a>
+<span class="sourceLineNo">1382</span>            }<a name="line.1382"></a>
+<span class="sourceLineNo">1383</span>            // sniff canary table with write operation<a name="line.1383"></a>
+<span class="sourceLineNo">1384</span>            regionSink.initializeWriteLatency();<a name="line.1384"></a>
+<span class="sourceLineNo">1385</span>            LongAdder writeTableLatency = regionSink.getWriteLatency();<a name="line.1385"></a>
+<span class="sourceLineNo">1386</span>            taskFutures.addAll(CanaryTool.sniff(admin, regionSink, admin.getDescriptor(writeTableName),<a name="line.1386"></a>
+<span class="sourceLineNo">1387</span>              executor, TaskType.WRITE, this.rawScanEnabled, writeTableLatency));<a name="line.1387"></a>
+<span class="sourceLineNo">1388</span>          }<a name="line.1388"></a>
+<span class="sourceLineNo">1389</span><a name="line.1389"></a>
+<span class="sourceLineNo">1390</span>          for (Future&lt;Void&gt; future : taskFutures) {<a name="line.1390"></a>
+<span class="sourceLineNo">1391</span>            try {<a name="line.1391"></a>
+<span class="sourceLineNo">1392</span>              future.get();<a name="line.1392"></a>
+<span class="sourceLineNo">1393</span>            } catch (ExecutionException e) {<a name="line.1393"></a>
+<span class="sourceLineNo">1394</span>              LOG.error("Sniff region failed!", e);<a name="line.1394"></a>
+<span class="sourceLineNo">1395</span>            }<a name="line.1395"></a>
+<span class="sourceLineNo">1396</span>          }<a name="line.1396"></a>
+<span class="sourceLineNo">1397</span>          Map&lt;String, LongAdder&gt; actualReadTableLatency = regionSink.getReadLatencyMap();<a name="line.1397"></a>
+<span class="sourceLineNo">1398</span>          for (Map.Entry&lt;String, Long&gt; entry : configuredReadTableTimeouts.entrySet()) {<a name="line.1398"></a>
+<span class="sourceLineNo">1399</span>            String tableName = entry.getKey();<a name="line.1399"></a>
+<span class="sourceLineNo">1400</span>            if (actualReadTableLatency.containsKey(tableName)) {<a name="line.1400"></a>
+<span class="sourceLineNo">1401</span>              Long actual = actualReadTableLatency.get(tableName).longValue();<a name="line.1401"></a>
+<span class="sourceLineNo">1402</span>              Long configured = entry.getValue();<a name="line.1402"></a>
+<span class="sourceLineNo">1403</span>              if (actual &gt; configured) {<a name="line.1403"></a>
+<span class="sourceLineNo">1404</span>                LOG.error("Read operation for {} took {}ms exceeded the configured read timeout." +<a name="line.1404"></a>
+<span class="sourceLineNo">1405</span>                    "(Configured read timeout {}ms.", tableName, actual, configured);<a name="line.1405"></a>
+<span class="sourceLineNo">1406</span>              } else {<a name="line.1406"></a>
+<span class="sourceLineNo">1407</span>                LOG.info("Read operation for {} took {}ms (Configured read timeout {}ms.",<a name="line.1407"></a>
+<span class="sourceLineNo">1408</span>                    tableName, actual, configured);<a name="line.1408"></a>
+<span class="sourceLineNo">1409</span>              }<a name="line.1409"></a>
+<span class="sourceLineNo">1410</span>            } else {<a name="line.1410"></a>
+<span class="sourceLineNo">1411</span>              LOG.error("Read operation for {} failed!", tableName);<a name="line.1411"></a>
+<span class="sourceLineNo">1412</span>            }<a name="line.1412"></a>
+<span class="sourceLineNo">1413</span>          }<a name="line.1413"></a>
+<span class="sourceLineNo">1414</span>          if (this.writeSniffing) {<a name="line.1414"></a>
+<span class="sourceLineNo">1415</span>            String writeTableStringName = this.writeTableName.getNameAsString();<a name="line.1415"></a>
+<span class="sourceLineNo">1416</span>            long actualWriteLatency = regionSink.getWriteLatency().longValue();<a name="line.1416"></a>
+<span class="sourceLineNo">1417</span>            LOG.info("Write operation for {} took {}ms. Configured write timeout {}ms.",<a name="line.1417"></a>
+<span class="sourceLineNo">1418</span>                writeTableStringName, actualWriteLatency, this.configuredWriteTableTimeout);<a name="line.1418"></a>
+<span class="sourceLineNo">1419</span>            // Check that the writeTable write operation latency does not exceed the configured timeout.<a name="line.1419"></a>
+<span class="sourceLineNo">1420</span>            if (actualWriteLatency &gt; this.configuredWriteTableTimeout) {<a name="line.1420"></a>
+<span class="sourceLineNo">1421</span>              LOG.error("Write operation for {} exceeded the configured write timeout.",<a name="line.1421"></a>
+<span class="sourceLineNo">1422</span>                  writeTableStringName);<a name="line.1422"></a>
+<span class="sourceLineNo">1423</span>            }<a name="line.1423"></a>
+<span class="sourceLineNo">1424</span>          }<a name="line.1424"></a>
+<span class="sourceLineNo">1425</span>        } catch (Exception e) {<a name="line.1425"></a>
+<span class="sourceLineNo">1426</span>          LOG.error("Run regionMonitor failed", e);<a name="line.1426"></a>
+<span class="sourceLineNo">1427</span>          this.errorCode = ERROR_EXIT_CODE;<a name="line.1427"></a>
+<span class="sourceLineNo">1428</span>        } finally {<a name="line.1428"></a>
+<span class="sourceLineNo">1429</span>          this.done = true;<a name="line.1429"></a>
+<span class="sourceLineNo">1430</span>        }<a name="line.1430"></a>
+<span class="sourceLineNo">1431</span>      }<a name="line.1431"></a>
+<span class="sourceLineNo">1432</span>      this.done = true;<a name="line.1432"></a>
+<span class="sourceLineNo">1433</span>    }<a name="line.1433"></a>
+<span class="sourceLineNo">1434</span><a name="line.1434"></a>
+<span class="sourceLineNo">1435</span>    /**<a name="line.1435"></a>
+<span class="sourceLineNo">1436</span>     * @return List of tables to use in test.<a name="line.1436"></a>
+<span class="sourceLineNo">1437</span>     */<a name="line.1437"></a>
+<span class="sourceLineNo">1438</span>    private String[] generateMonitorTables(String[] monitorTargets) throws IOException {<a name="line.1438"></a>
+<span class="sourceLineNo">1439</span>      String[] returnTables = null;<a name="line.1439"></a>
+<span class="sourceLineNo">1440</span><a name="line.1440"></a>
+<span class="sourceLineNo">1441</span>      if (this.useRegExp) {<a name="line.1441"></a>
+<span class="sourceLineNo">1442</span>        Pattern pattern = null;<a name="line.1442"></a>
+<span class="sourceLineNo">1443</span>        List&lt;TableDescriptor&gt; tds = null;<a name="line.1443"></a>
+<span class="sourceLineNo">1444</span>        Set&lt;String&gt; tmpTables = new TreeSet&lt;&gt;();<a name="line.1444"></a>
+<span class="sourceLineNo">1445</span>        try {<a name="line.1445"></a>
+<span class="sourceLineNo">1446</span>          LOG.debug(String.format("reading list of tables"));<a name="line.1446"></a>
+<span class="sourceLineNo">1447</span>          tds = this.admin.listTableDescriptors(pattern);<a name="line.1447"></a>
+<span class="sourceLineNo">1448</span>          if (tds == null) {<a name="line.1448"></a>
+<span class="sourceLineNo">1449</span>            tds = Collections.emptyList();<a name="line.1449"></a>
+<span class="sourceLineNo">1450</span>          }<a name="line.1450"></a>
+<span class="sourceLineNo">1451</span>          for (String monitorTarget : monitorTargets) {<a name="line.1451"></a>
+<span class="sourceLineNo">1452</span>            pattern = Pattern.compile(monitorTarget);<a name="line.1452"></a>
+<span class="sourceLineNo">1453</span>            for (TableDescriptor td : tds) {<a name="line.1453"></a>
+<span class="sourceLineNo">1454</span>              if (pattern.matcher(td.getTableName().getNameAsString()).matches()) {<a name="line.1454"></a>
+<span class="sourceLineNo">1455</span>                tmpTables.add(td.getTableName().getNameAsString());<a name="line.1455"></a>
+<span class="sourceLineNo">1456</span>              }<a name="line.1456"></a>
+<span class="sourceLineNo">1457</span>            }<a name="line.1457"></a>
+<span class="sourceLineNo">1458</span>          }<a name="line.1458"></a>
+<span class="sourceLineNo">1459</span>        } catch (IOException e) {<a name="line.1459"></a>
+<span class="sourceLineNo">1460</span>          LOG.error("Communicate with admin failed", e);<a name="line.1460"></a>
+<span class="sourceLineNo">1461</span>          throw e;<a name="line.1461"></a>
+<span class="sourceLineNo">1462</span>        }<a name="line.1462"></a>
+<span class="sourceLineNo">1463</span><a name="line.1463"></a>
+<span class="sourceLineNo">1464</span>        if (tmpTables.size() &gt; 0) {<a name="line.1464"></a>
+<span class="sourceLineNo">1465</span>          returnTables = tmpTables.toArray(new String[tmpTables.size()]);<a name="line.1465"></a>
+<span class="sourceLineNo">1466</span>        } else {<a name="line.1466"></a>
+<span class="sourceLineNo">1467</span>          String msg = "No HTable found, tablePattern:" + Arrays.toString(monitorTargets);<a name="line.1467"></a>
+<span class="sourceLineNo">1468</span>          LOG.error(msg);<a name="line.1468"></a>
+<span class="sourceLineNo">1469</span>          this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1469"></a>
+<span class="sourceLineNo">1470</span>          throw new TableNotFoundException(msg);<a name="line.1470"></a>
+<span class="sourceLineNo">1471</span>        }<a name="line.1471"></a>
+<span class="sourceLineNo">1472</span>      } else {<a name="line.1472"></a>
+<span class="sourceLineNo">1473</span>        returnTables = monitorTargets;<a name="line.1473"></a>
+<span class="sourceLineNo">1474</span>      }<a name="line.1474"></a>
+<span class="sourceLineNo">1475</span><a name="line.1475"></a>
+<span class="sourceLineNo">1476</span>      return returnTables;<a name="line.1476"></a>
+<span class="sourceLineNo">1477</span>    }<a name="line.1477"></a>
+<span class="sourceLineNo">1478</span><a name="line.1478"></a>
+<span class="sourceLineNo">1479</span>    /*<a name="line.1479"></a>
+<span class="sourceLineNo">1480</span>     * Canary entry point to monitor all the tables.<a name="line.1480"></a>
+<span class="sourceLineNo">1481</span>     */<a name="line.1481"></a>
+<span class="sourceLineNo">1482</span>    private List&lt;Future&lt;Void&gt;&gt; sniff(TaskType taskType, RegionStdOutSink regionSink)<a name="line.1482"></a>
+<span class="sourceLineNo">1483</span>        throws Exception {<a name="line.1483"></a>
+<span class="sourceLineNo">1484</span>      LOG.debug("Reading list of tables");<a name="line.1484"></a>
+<span class="sourceLineNo">1485</span>      List&lt;Future&lt;Void&gt;&gt; taskFutures = new LinkedList&lt;&gt;();<a name="line.1485"></a>
+<span class="sourceLineNo">1486</span>      for (TableDescriptor td: admin.listTableDescriptors()) {<a name="line.1486"></a>
+<span class="sourceLineNo">1487</span>        if (admin.tableExists(td.getTableName()) &amp;&amp; admin.isTableEnabled(td.getTableName()) &amp;&amp;<a name="line.1487"></a>
+<span class="sourceLineNo">1488</span>            (!td.getTableName().equals(writeTableName))) {<a name="line.1488"></a>
+<span class="sourceLineNo">1489</span>          LongAdder readLatency =<a name="line.1489"></a>
+<span class="sourceLineNo">1490</span>              regionSink.initializeAndGetReadLatencyForTable(td.getTableName().getNameAsString());<a name="line.1490"></a>
+<span class="sourceLineNo">1491</span>          taskFutures.addAll(CanaryTool.sniff(admin, sink, td, executor, taskType, this.rawScanEnabled,<a name="line.1491"></a>
+<span class="sourceLineNo">1492</span>              readLatency));<a name="line.1492"></a>
+<span class="sourceLineNo">1493</span>        }<a name="line.1493"></a>
+<span class="sourceLineNo">1494</span>      }<a name="line.1494"></a>
+<span class="sourceLineNo">1495</span>      return taskFutures;<a name="line.1495"></a>
+<span class="sourceLineNo">1496</span>    }<a name="line.1496"></a>
+<span class="sourceLineNo">1497</span><a name="line.1497"></a>
+<span class="sourceLineNo">1498</span>    private void checkWriteTableDistribution() throws IOException {<a name="line.1498"></a>
+<span class="sourceLineNo">1499</span>      if (!admin.tableExists(writeTableName)) {<a name="line.1499"></a>
+<span class="sourceLineNo">1500</span>        int numberOfServers = admin.getRegionServers().size();<a name="line.1500"></a>
+<span class="sourceLineNo">1501</span>        if (numberOfServers == 0) {<a name="line.1501"></a>
+<span class="sourceLineNo">1502</span>          throw new IllegalStateException("No live regionservers");<a name="line.1502"></a>
+<span class="sourceLineNo">1503</span>        }<a name="line.1503"></a>
+<span class="sourceLineNo">1504</span>        createWriteTable(numberOfServers);<a name="line.1504"></a>
+<span class="sourceLineNo">1505</span>      }<a name="line.1505"></a>
+<span class="sourceLineNo">1506</span><a name="line.1506"></a>
+<span class="sourceLineNo">1507</span>      if (!admin.isTableEnabled(writeTableName)) {<a name="line.1507"></a>
+<span class="sourceLineNo">1508</span>        admin.enableTable(writeTableName);<a name="line.1508"></a>
+<span class="sourceLineNo">1509</span>      }<a name="line.1509"></a>
+<span class="sourceLineNo">1510</span><a name="line.1510"></a>
+<span class="sourceLineNo">1511</span>      ClusterMetrics status =<a name="line.1511"></a>
+<span class="sourceLineNo">1512</span>          admin.getClusterMetrics(EnumSet.of(Option.SERVERS_NAME, Option.MASTER));<a name="line.1512"></a>
+<span class="sourceLineNo">1513</span>      int numberOfServers = status.getServersName().size();<a name="line.1513"></a>
+<span class="sourceLineNo">1514</span>      if (status.getServersName().contains(status.getMasterName())) {<a name="line.1514"></a>
+<span class="sourceLineNo">1515</span>        numberOfServers -= 1;<a name="line.1515"></a>
+<span class="sourceLineNo">1516</span>      }<a name="line.1516"></a>
+<span class="sourceLineNo">1517</span><a name="line.1517"></a>
+<span class="sourceLineNo">1518</span>      List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; pairs =<a name="line.1518"></a>
+<span class="sourceLineNo">1519</span>          MetaTableAccessor.getTableRegionsAndLocations(connection, writeTableName);<a name="line.1519"></a>
+<span class="sourceLineNo">1520</span>      int numberOfRegions = pairs.size();<a name="line.1520"></a>
+<span class="sourceLineNo">1521</span>      if (numberOfRegions &lt; numberOfServers * regionsLowerLimit<a name="line.1521"></a>
+<span class="sourceLineNo">1522</span>          || numberOfRegions &gt; numberOfServers * regionsUpperLimit) {<a name="line.1522"></a>
+<span class="sourceLineNo">1523</span>        admin.disableTable(writeTableName);<a name="line.1523"></a>
+<span class="sourceLineNo">1524</span>        admin.deleteTable(writeTableName);<a name="line.1524"></a>
+<span class="sourceLineNo">1525</span>        createWriteTable(numberOfServers);<a name="line.1525"></a>
+<span class="sourceLineNo">1526</span>      }<a name="line.1526"></a>
+<span class="sourceLineNo">1527</span>      HashSet&lt;ServerName&gt; serverSet = new HashSet&lt;&gt;();<a name="line.1527"></a>
+<span class="sourceLineNo">1528</span>      for (Pair&lt;RegionInfo, ServerName&gt; pair : pairs) {<a name="line.1528"></a>
+<span class="sourceLineNo">1529</span>        serverSet.add(pair.getSecond());<a name="line.1529"></a>
+<span class="sourceLineNo">1530</span>      }<a name="line.1530"></a>
+<span class="sourceLineNo">1531</span>      int numberOfCoveredServers = serverSet.size();<a name="line.1531"></a>
+<span class="sourceLineNo">1532</span>      if (numberOfCoveredServers &lt; numberOfServers) {<a name="line.1532"></a>
+<span class="sourceLineNo">1533</span>        admin.balance();<a name="line.1533"></a>
+<span class="sourceLineNo">1534</span>      }<a name="line.1534"></a>
+<span class="sourceLineNo">1535</span>    }<a name="line.1535"></a>
+<span class="sourceLineNo">1536</span><a name="line.1536"></a>
+<span class="sourceLineNo">1537</span>    private void createWriteTable(int numberOfServers) throws IOException {<a name="line.1537"></a>
+<span class="sourceLineNo">1538</span>      int numberOfRegions = (int)(numberOfServers * regionsLowerLimit);<a name="line.1538"></a>
+<span class="sourceLineNo">1539</span>      LOG.info("Number of live regionservers {}, pre-splitting the canary table into {} regions " +<a name="line.1539"></a>
+<span class="sourceLineNo">1540</span>        "(current lower limit of regions per server is {} and you can change it with config {}).",<a name="line.1540"></a>
+<span class="sourceLineNo">1541</span>          numberOfServers, numberOfRegions, regionsLowerLimit,<a name="line.1541"></a>
+<span class="sourceLineNo">1542</span>          HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY);<a name="line.1542"></a>
+<span class="sourceLineNo">1543</span>      HTableDescriptor desc = new HTableDescriptor(writeTableName);<a name="line.1543"></a>
+<span class="sourceLineNo">1544</span>      HColumnDescriptor family = new HColumnDescriptor(CANARY_TABLE_FAMILY_NAME);<a name="line.1544"></a>
+<span class="sourceLineNo">1545</span>      family.setMaxVersions(1);<a name="line.1545"></a>
+<span class="sourceLineNo">1546</span>      family.setTimeToLive(writeDataTTL);<a name="line.1546"></a>
+<span class="sourceLineNo">1547</span><a name="line.1547"></a>
+<span class="sourceLineNo">1548</span>      desc.addFamily(family);<a name="line.1548"></a>
+<span class="sourceLineNo">1549</span>      byte[][] splits = new RegionSplitter.HexStringSplit().split(numberOfRegions);<a name="line.1549"></a>
+<span class="sourceLineNo">1550</span>      admin.createTable(desc, splits);<a name="line.1550"></a>
+<span class="sourceLineNo">1551</span>    }<a name="line.1551"></a>
+<span class="sourceLineNo">1552</span>  }<a name="line.1552"></a>
+<span class="sourceLineNo">1553</span><a name="line.1553"></a>
+<span class="sourceLineNo">1554</span>  /**<a name="line.1554"></a>
+<span class="sourceLineNo">1555</span>   * Canary entry point for specified table.<a name="line.1555"></a>
+<span class="sourceLineNo">1556</span>   * @throws Exception<a name="line.1556"></a>
+<span class="sourceLineNo">1557</span>   */<a name="line.1557"></a>
+<span class="sourceLineNo">1558</span>  private static List&lt;Future&lt;Void&gt;&gt; sniff(final Admin admin, final Sink sink, String tableName,<a name="line.1558"></a>
+<span class="sourceLineNo">1559</span>      ExecutorService executor, TaskType taskType, boolean rawScanEnabled, LongAdder readLatency)<a name="line.1559"></a>
+<span class="sourceLineNo">1560</span>      throws Exception {<a name="line.1560"></a>
+<span class="sourceLineNo">1561</span>    LOG.debug("Checking table is enabled and getting table descriptor for table {}", tableName);<a name="line.1561"></a>
+<span class="sourceLineNo">1562</span>    if (admin.isTableEnabled(TableName.valueOf(tableName))) {<a name="line.1562"></a>
+<span class="sourceLineNo">1563</span>      return CanaryTool.sniff(admin, sink, admin.getDescriptor(TableName.valueOf(tableName)),<a name="line.1563"></a>
+<span class="sourceLineNo">1564</span>        executor, taskType, rawScanEnabled, readLatency);<a name="line.1564"></a>
+<span class="sourceLineNo">1565</span>    } else {<a name="line.1565"></a>
+<span class="sourceLineNo">1566</span>      LOG.warn("Table {} is not enabled", tableName);<a name="line.1566"></a>
+<span class="sourceLineNo">1567</span>    }<a name="line.1567"></a>
+<span class="sourceLineNo">1568</span>    return new LinkedList&lt;&gt;();<a name="line.1568"></a>
+<span class="sourceLineNo">1569</span>  }<a name="line.1569"></a>
+<span class="sourceLineNo">1570</span><a name="line.1570"></a>
+<span class="sourceLineNo">1571</span>  /*<a name="line.1571"></a>
+<span class="sourceLineNo">1572</span>   * Loops over regions of this table, and outputs information about the state.<a name="line.1572"></a>
+<span class="sourceLineNo">1573</span>   */<a name="line.1573"></a>
+<span class="sourceLineNo">1574</span>  private static List&lt;Future&lt;Void&gt;&gt; sniff(final Admin admin, final Sink sink,<a name="line.1574"></a>
+<span class="sourceLineNo">1575</span>      TableDescriptor tableDesc, ExecutorService executor, TaskType taskType,<a name="line.1575"></a>
+<span class="sourceLineNo">1576</span>      boolean rawScanEnabled, LongAdder rwLatency) throws Exception {<a name="line.1576"></a>
+<span class="sourceLineNo">1577</span>    LOG.debug("Reading list of regions for table {}", tableDesc.getTableName());<a name="line.1577"></a>
+<span class="sourceLineNo">1578</span>    try (Table table = admin.getConnection().getTable(tableDesc.getTableName())) {<a name="line.1578"></a>
+<span class="sourceLineNo">1579</span>      List&lt;RegionTask&gt; tasks = new ArrayList&lt;&gt;();<a name="line.1579"></a>
+<span class="sourceLineNo">1580</span>      try (RegionLocator regionLocator =<a name="line.1580"></a>
+<span class="sourceLineNo">1581</span>               admin.getConnection().getRegionLocator(tableDesc.getTableName())) {<a name="line.1581"></a>
+<span class="sourceLineNo">1582</span>        for (HRegionLocation location: regionLocator.getAllRegionLocations()) {<a name="line.1582"></a>
+<span class="sourceLineNo">1583</span>          if (location == null) {<a name="line.1583"></a>
+<span class="sourceLineNo">1584</span>            LOG.warn("Null location");<a name="line.1584"></a>
+<span class="sourceLineNo">1585</span>            continue;<a name="line.1585"></a>
+<span class="sourceLineNo">1586</span>          }<a name="line.1586"></a>
+<span class="sourceLineNo">1587</span>          ServerName rs = location.getServerName();<a name="line.1587"></a>
+<span class="sourceLineNo">1588</span>          RegionInfo region = location.getRegion();<a name="line.1588"></a>
+<span class="sourceLineNo">1589</span>          tasks.add(new RegionTask(admin.getConnection(), region, rs, (RegionStdOutSink)sink,<a name="line.1589"></a>
+<span class="sourceLineNo">1590</span>              taskType, rawScanEnabled, rwLatency));<a name="line.1590"></a>
+<span class="sourceLineNo">1591</span>          Map&lt;String, List&lt;RegionTaskResult&gt;&gt; regionMap = ((RegionStdOutSink) sink).getRegionMap();<a name="line.1591"></a>
+<span class="sourceLineNo">1592</span>          regionMap.put(region.getRegionNameAsString(), new ArrayList&lt;RegionTaskResult&gt;());<a name="line.1592"></a>
+<span class="sourceLineNo">1593</span>        }<a name="line.1593"></a>
+<span class="sourceLineNo">1594</span>        return executor.invokeAll(tasks);<a name="line.1594"></a>
+<span class="sourceLineNo">1595</span>      }<a name="line.1595"></a>
+<span class="sourceLineNo">1596</span>    } catch (TableNotFoundException e) {<a name="line.1596"></a>
+<span class="sourceLineNo">1597</span>      return Collections.EMPTY_LIST;<a name="line.1597"></a>
+<span class="sourceLineNo">1598</span>    }<a name="line.1598"></a>
+<span class="sourceLineNo">1599</span>  }<a name="line.1599"></a>
+<span class="sourceLineNo">1600</span><a name="line.1600"></a>
+<span class="sourceLineNo">1601</span>  //  monitor for zookeeper mode<a name="line.1601"></a>
+<span class="sourceLineNo">1602</span>  private static class ZookeeperMonitor extends Monitor {<a name="line.1602"></a>
+<span class="sourceLineNo">1603</span>    private List&lt;String&gt; hosts;<a name="line.1603"></a>
+<span class="sourceLineNo">1604</span>    private final String znode;<a name="line.1604"></a>
+<span class="sourceLineNo">1605</span>    private final int timeout;<a name="line.1605"></a>
+<span class="sourceLineNo">1606</span><a name="line.1606"></a>
+<span class="sourceLineNo">1607</span>    protected ZookeeperMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1607"></a>
+<span class="sourceLineNo">1608</span>        Sink sink, ExecutorService executor, boolean treatFailureAsError, long allowedFailures)  {<a name="line.1608"></a>
+<span class="sourceLineNo">1609</span>      super(connection, monitorTargets, useRegExp,<a name="line.1609"></a>
+<span class="sourceLineNo">1610</span>          sink, executor, treatFailureAsError, allowedFailures);<a name="line.1610"></a>
+<span class="sourceLineNo">1611</span>      Configuration configuration = connection.getConfiguration();<a name="line.1611"></a>
+<span class="sourceLineNo">1612</span>      znode =<a name="line.1612"></a>
+<span class="sourceLineNo">1613</span>          configuration.get(ZOOKEEPER_ZNODE_PARENT,<a name="line.1613"></a>
+<span class="sourceLineNo">1614</span>              DEFAULT_ZOOKEEPER_ZNODE_PARENT);<a name="line.1614"></a>
+<span class="sourceLineNo">1615</span>      timeout = configuration<a name="line.1615"></a>
+<span class="sourceLineNo">1616</span>          .getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);<a name="line.1616"></a>
+<span class="sourceLineNo">1617</span>      ConnectStringParser parser =<a name="line.1617"></a>
+<span class="sourceLineNo">1618</span>          new ConnectStringParser(ZKConfig.getZKQuorumServersString(configuration));<a name="line.1618"></a>
+<span class="sourceLineNo">1619</span>      hosts = Lists.newArrayList();<a name="line.1619"></a>
+<span class="sourceLineNo">1620</span>      for (InetSocketAddress server : parser.getServerAddresses()) {<a name="line.1620"></a>
+<span class="sourceLineNo">1621</span>        hosts.add(server.toString());<a name="line.1621"></a>
 <span class="sourceLineNo">1622</span>      }<a name="line.1622"></a>
-<span class="sourceLineNo">1623</span>    }<a name="line.1623"></a>
-<span class="sourceLineNo">1624</span><a name="line.1624"></a>
-<span class="sourceLineNo">1625</span>    @Override public void run() {<a name="line.1625"></a>
-<span class="sourceLineNo">1626</span>      List&lt;ZookeeperTask&gt; tasks = Lists.newArrayList();<a name="line.1626"></a>
-<span class="sourceLineNo">1627</span>      ZookeeperStdOutSink zkSink = null;<a name="line.1627"></a>
-<span class="sourceLineNo">1628</span>      try {<a name="line.1628"></a>
-<span class="sourceLineNo">1629</span>        zkSink = this.getSink();<a name="line.1629"></a>
-<span class="sourceLineNo">1630</span>      } catch (RuntimeException e) {<a name="line.1630"></a>
-<span class="sourceLineNo">1631</span>        LOG.error("Run ZooKeeperMonitor failed!", e);<a name="line.1631"></a>
-<span class="sourceLineNo">1632</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1632"></a>
-<span class="sourceLineNo">1633</span>      }<a name="line.1633"></a>
-<span class="sourceLineNo">1634</span>      this.initialized = true;<a name="line.1634"></a>
-<span class="sourceLineNo">1635</span>      for (final String host : hosts) {<a name="line.1635"></a>
-<span class="sourceLineNo">1636</span>        tasks.add(new ZookeeperTask(connection, host, znode, timeout, zkSink));<a name="line.1636"></a>
-<span class="sourceLineNo">1637</span>      }<a name="line.1637"></a>
-<span class="sourceLineNo">1638</span>      try {<a name="line.1638"></a>
-<span class="sourceLineNo">1639</span>        for (Future&lt;Void&gt; future : this.executor.invokeAll(tasks)) {<a name="line.1639"></a>
-<span class="sourceLineNo">1640</span>          try {<a name="line.1640"></a>
-<span class="sourceLineNo">1641</span>            future.get();<a name="line.1641"></a>
-<span class="sourceLineNo">1642</span>          } catch (ExecutionException e) {<a name="line.1642"></a>
-<span class="sourceLineNo">1643</span>            LOG.error("Sniff zookeeper failed!", e);<a name="line.1643"></a>
-<span class="sourceLineNo">1644</span>            this.errorCode = ERROR_EXIT_CODE;<a name="line.1644"></a>
-<span class="sourceLineNo">1645</span>          }<a name="line.1645"></a>
-<span class="sourceLineNo">1646</span>        }<a name="line.1646"></a>
-<span class="sourceLineNo">1647</span>      } catch (InterruptedException e) {<a name="line.1647"></a>
-<span class="sourceLineNo">1648</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1648"></a>
-<span class="sourceLineNo">1649</span>        Thread.currentThread().interrupt();<a name="line.1649"></a>
-<span class="sourceLineNo">1650</span>        LOG.error("Sniff zookeeper interrupted!", e);<a name="line.1650"></a>
-<span class="sourceLineNo">1651</span>      }<a name="line.1651"></a>
-<span class="sourceLineNo">1652</span>      this.done = true;<a name="line.1652"></a>
-<span class="sourceLineNo">1653</span>    }<a name="line.1653"></a>
-<span class="sourceLineNo">1654</span><a name="line.1654"></a>
-<span class="sourceLineNo">1655</span>    private ZookeeperStdOutSink getSink() {<a name="line.1655"></a>
-<span class="sourceLineNo">1656</span>      if (!(sink instanceof ZookeeperStdOutSink)) {<a name="line.1656"></a>
-<span class="sourceLineNo">1657</span>        throw new RuntimeException("Can only write to zookeeper sink");<a name="line.1657"></a>
-<span class="sourceLineNo">1658</span>      }<a name="line.1658"></a>
-<span class="sourceLineNo">1659</span>      return ((ZookeeperStdOutSink) sink);<a name="line.1659"></a>
-<span class="sourceLineNo">1660</span>    }<a name="line.1660"></a>
-<span class="sourceLineNo">1661</span>  }<a name="line.1661"></a>
-<span class="sourceLineNo">1662</span><a name="line.1662"></a>
-<span class="sourceLineNo">1663</span><a name="line.1663"></a>
-<span class="sourceLineNo">1664</span>  /**<a name="line.1664"></a>
-<span class="sourceLineNo">1665</span>   * A monitor for regionserver mode<a name="line.1665"></a>
-<span class="sourceLineNo">1666</span>   */<a name="line.1666"></a>
-<span class="sourceLineNo">1667</span>  private static class RegionServerMonitor extends Monitor {<a name="line.1667"></a>
-<span class="sourceLineNo">1668</span>    private boolean allRegions;<a name="line.1668"></a>
-<span class="sourceLineNo">1669</span><a name="line.1669"></a>
-<span class="sourceLineNo">1670</span>    public RegionServerMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1670"></a>
-<span class="sourceLineNo">1671</span>        Sink sink, ExecutorService executor, boolean allRegions,<a name="line.1671"></a>
-<span class="sourceLineNo">1672</span>        boolean treatFailureAsError, long allowedFailures) {<a name="line.1672"></a>
-<span class="sourceLineNo">1673</span>      super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError,<a name="line.1673"></a>
-<span class="sourceLineNo">1674</span>          allowedFailures);<a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>      this.allRegions = allRegions;<a name="line.1675"></a>
-<span class="sourceLineNo">1676</span>    }<a name="line.1676"></a>
-<span class="sourceLineNo">1677</span><a name="line.1677"></a>
-<span class="sourceLineNo">1678</span>    private RegionServerStdOutSink getSink() {<a name="line.1678"></a>
-<span class="sourceLineNo">1679</span>      if (!(sink instanceof RegionServerStdOutSink)) {<a name="line.1679"></a>
-<span class="sourceLineNo">1680</span>        throw new RuntimeException("Can only write to regionserver sink");<a name="line.1680"></a>
-<span class="sourceLineNo">1681</span>      }<a name="line.1681"></a>
-<span class="sourceLineNo">1682</span>      return ((RegionServerStdOutSink) sink);<a name="line.1682"></a>
-<span class="sourceLineNo">1683</span>    }<a name="line.1683"></a>
-<span class="sourceLineNo">1684</span><a name="line.1684"></a>
-<span class="sourceLineNo">1685</span>    @Override<a name="line.1685"></a>
-<span class="sourceLineNo">1686</span>    public void run() {<a name="line.1686"></a>
-<span class="sourceLineNo">1687</span>      if (this.initAdmin() &amp;&amp; this.checkNoTableNames()) {<a name="line.1687"></a>
-<span class="sourceLineNo">1688</span>        RegionServerStdOutSink regionServerSink = null;<a name="line.1688"></a>
-<span class="sourceLineNo">1689</span>        try {<a name="line.1689"></a>
-<span class="sourceLineNo">1690</span>          regionServerSink = this.getSink();<a name="line.1690"></a>
-<span class="sourceLineNo">1691</span>        } catch (RuntimeException e) {<a name="line.1691"></a>
-<span class="sourceLineNo">1692</span>          LOG.error("Run RegionServerMonitor failed!", e);<a name="line.1692"></a>
-<span class="sourceLineNo">1693</span>          this.errorCode = ERROR_EXIT_CODE;<a name="line.1693"></a>
-<span class="sourceLineNo">1694</span>        }<a name="line.1694"></a>
-<span class="sourceLineNo">1695</span>        Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap = this.filterRegionServerByName();<a name="line.1695"></a>
-<span class="sourceLineNo">1696</span>        this.initialized = true;<a name="line.1696"></a>
-<span class="sourceLineNo">1697</span>        this.monitorRegionServers(rsAndRMap, regionServerSink);<a name="line.1697"></a>
-<span class="sourceLineNo">1698</span>      }<a name="line.1698"></a>
-<span class="sourceLineNo">1699</span>      this.done = true;<a name="line.1699"></a>
-<span class="sourceLineNo">1700</span>    }<a name="line.1700"></a>
-<span class="sourceLineNo">1701</span><a name="line.1701"></a>
-<span class="sourceLineNo">1702</span>    private boolean checkNoTableNames() {<a name="line.1702"></a>
-<span class="sourceLineNo">1703</span>      List&lt;String&gt; foundTableNames = new ArrayList&lt;&gt;();<a name="line.1703"></a>
-<span class="sourceLineNo">1704</span>      TableName[] tableNames = null;<a name="line.1704"></a>
-<span class="sourceLineNo">1705</span>      LOG.debug("Reading list of tables");<a name="line.1705"></a>
-<span class="sourceLineNo">1706</span>      try {<a name="line.1706"></a>
-<span class="sourceLineNo">1707</span>        tableNames = this.admin.listTableNames();<a name="line.1707"></a>
-<span class="sourceLineNo">1708</span>      } catch (IOException e) {<a name="line.1708"></a>
-<span class="sourceLineNo">1709</span>        LOG.error("Get listTableNames failed", e);<a name="line.1709"></a>
-<span class="sourceLineNo">1710</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1710"></a>
-<span class="sourceLineNo">1711</span>        return false;<a name="line.1711"></a>
-<span class="sourceLineNo">1712</span>      }<a name="line.1712"></a>
-<span class="sourceLineNo">1713</span><a name="line.1713"></a>
-<span class="sourceLineNo">1714</span>      if (this.targets == null || this.targets.length == 0) return true;<a name="line.1714"></a>
-<span class="sourceLineNo">1715</span><a name="line.1715"></a>
-<span class="sourceLineNo">1716</span>      for (String target : this.targets) {<a name="line.1716"></a>
-<span class="sourceLineNo">1717</span>        for (TableName tableName : tableNames) {<a name="line.1717"></a>
-<span class="sourceLineNo">1718</span>          if (target.equals(tableName.getNameAsString())) {<a name="line.1718"></a>
-<span class="sourceLineNo">1719</span>            foundTableNames.add(target);<a name="line.1719"></a>
-<span class="sourceLineNo">1720</span>          }<a name="line.1720"></a>
-<span class="sourceLineNo">1721</span>        }<a name="line.1721"></a>
-<span class="sourceLineNo">1722</span>      }<a name="line.1722"></a>
-<span class="sourceLineNo">1723</span><a name="line.1723"></a>
-<span class="sourceLineNo">1724</span>      if (foundTableNames.size() &gt; 0) {<a name="line.1724"></a>
-<span class="sourceLineNo">1725</span>        System.err.println("Cannot pass a tablename when using the -regionserver " +<a name="line.1725"></a>
-<span class="sourceLineNo">1726</span>            "option, tablenames:" + foundTableNames.toString());<a name="line.1726"></a>
-<span class="sourceLineNo">1727</span>        this.errorCode = USAGE_EXIT_CODE;<a name="line.1727"></a>
-<span class="sourceLineNo">1728</span>      }<a name="line.1728"></a>
-<span class="sourceLineNo">1729</span>      return foundTableNames.isEmpty();<a name="line.1729"></a>
-<span class="sourceLineNo">1730</span>    }<a name="line.1730"></a>
-<span class="sourceLineNo">1731</span><a name="line.1731"></a>
-<span class="sourceLineNo">1732</span>    private void monitorRegionServers(Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap, RegionServerStdOutSink regionServerSink) {<a name="line.1732"></a>
-<span class="sourceLineNo">1733</span>      List&lt;RegionServerTask&gt; tasks = new ArrayList&lt;&gt;();<a name="line.1733"></a>
-<span class="sourceLineNo">1734</span>      Map&lt;String, AtomicLong&gt; successMap = new HashMap&lt;&gt;();<a name="line.1734"></a>
-<span class="sourceLineNo">1735</span>      Random rand = new Random();<a name="line.1735"></a>
-<span class="sourceLineNo">1736</span>      for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : rsAndRMap.entrySet()) {<a name="line.1736"></a>
-<span class="sourceLineNo">1737</span>        String serverName = entry.getKey();<a name="line.1737"></a>
-<span class="sourceLineNo">1738</span>        AtomicLong successes = new AtomicLong(0);<a name="line.1738"></a>
-<span class="sourceLineNo">1739</span>        successMap.put(serverName, successes);<a name="line.1739"></a>
-<span class="sourceLineNo">1740</span>        if (entry.getValue().isEmpty()) {<a name="line.1740"></a>
-<span class="sourceLineNo">1741</span>          LOG.error("Regionserver not serving any regions - {}", serverName);<a name="line.1741"></a>
-<span class="sourceLineNo">1742</span>        } else if (this.allRegions) {<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span>          for (RegionInfo region : entry.getValue()) {<a name="line.1743"></a>
-<span class="sourceLineNo">1744</span>            tasks.add(new RegionServerTask(this.connection,<a name="line.1744"></a>
-<span class="sourceLineNo">1745</span>                serverName,<a name="line.1745"></a>
-<span class="sourceLineNo">1746</span>                region,<a name="line.1746"></a>
-<span class="sourceLineNo">1747</span>                regionServerSink,<a name="line.1747"></a>
-<span class="sourceLineNo">1748</span>                successes));<a name="line.1748"></a>
-<span class="sourceLineNo">1749</span>          }<a name="line.1749"></a>
-<span class="sourceLineNo">1750</span>        } else {<a name="line.1750"></a>
-<span class="sourceLineNo">1751</span>          // random select a region if flag not set<a name="line.1751"></a>
-<span class="sourceLineNo">1752</span>          RegionInfo region = entry.getValue().get(rand.nextInt(entry.getValue().size()));<a name="line.1752"></a>
-<span class="sourceLineNo">1753</span>          tasks.add(new RegionServerTask(this.connection,<a name="line.1753"></a>
-<span class="sourceLineNo">1754</span>              serverName,<a name="line.1754"></a>
-<span class="sourceLineNo">1755</span>              region,<a name="line.1755"></a>
-<span class="sourceLineNo">1756</span>              regionServerSink,<a name="line.1756"></a>
-<span class="sourceLineNo">1757</span>              successes));<a name="line.1757"></a>
-<span class="sourceLineNo">1758</span>        }<a name="line.1758"></a>
-<span class="sourceLineNo">1759</span>      }<a name="line.1759"></a>
-<span class="sourceLineNo">1760</span>      try {<a name="line.1760"></a>
-<span class="sourceLineNo">1761</span>        for (Future&lt;Void&gt; future : this.executor.invokeAll(tasks)) {<a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>          try {<a name="line.1762"></a>
-<span class="sourceLineNo">1763</span>            future.get();<a name="line.1763"></a>
-<span class="sourceLineNo">1764</span>          } catch (ExecutionException e) {<a name="line.1764"></a>
-<span class="sourceLineNo">1765</span>            LOG.error("Sniff regionserver failed!", e);<a name="line.1765"></a>
-<span class="sourceLineNo">1766</span>            this.errorCode = ERROR_EXIT_CODE;<a name="line.1766"></a>
-<span class="sourceLineNo">1767</span>          }<a name="line.1767"></a>
-<span class="sourceLineNo">1768</span>        }<a name="line.1768"></a>
-<span class="sourceLineNo">1769</span>        if (this.allRegions) {<a name="line.1769"></a>
-<span class="sourceLineNo">1770</span>          for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : rsAndRMap.entrySet()) {<a name="line.1770"></a>
-<span class="sourceLineNo">1771</span>            String serverName = entry.getKey();<a name="line.1771"></a>
-<span class="sourceLineNo">1772</span>            LOG.info("Successfully read {} regions out of {} on regionserver {}",<a name="line.1772"></a>
-<span class="sourceLineNo">1773</span>                successMap.get(serverName), entry.getValue().size(), serverName);<a name="line.1773"></a>
-<span class="sourceLineNo">1774</span>          }<a name="line.1774"></a>
-<span class="sourceLineNo">1775</span>        }<a name="line.1775"></a>
-<span class="sourceLineNo">1776</span>      } catch (InterruptedException e) {<a name="line.1776"></a>
-<span class="sourceLineNo">1777</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1777"></a>
-<span class="sourceLineNo">1778</span>        LOG.error("Sniff regionserver interrupted!", e);<a name="line.1778"></a>
-<span class="sourceLineNo">1779</span>      }<a name="line.1779"></a>
-<span class="sourceLineNo">1780</span>    }<a name="line.1780"></a>
-<span class="sourceLineNo">1781</span><a name="line.1781"></a>
-<span class="sourceLineNo">1782</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; filterRegionServerByName() {<a name="line.1782"></a>
-<span class="sourceLineNo">1783</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; regionServerAndRegionsMap = this.getAllRegionServerByName();<a name="line.1783"></a>
-<span class="sourceLineNo">1784</span>      regionServerAndRegionsMap = this.doFilterRegionServerByName(regionServerAndRegionsMap);<a name="line.1784"></a>
-<span class="sourceLineNo">1785</span>      return regionServerAndRegionsMap;<a name="line.1785"></a>
-<span class="sourceLineNo">1786</span>    }<a name="line.1786"></a>
-<span class="sourceLineNo">1787</span><a name="line.1787"></a>
-<span class="sourceLineNo">1788</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; getAllRegionServerByName() {<a name="line.1788"></a>
-<span class="sourceLineNo">1789</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap = new HashMap&lt;&gt;();<a name="line.1789"></a>
-<span class="sourceLineNo">1790</span>      try {<a name="line.1790"></a>
-<span class="sourceLineNo">1791</span>        LOG.debug("Reading list of tables and locations");<a name="line.1791"></a>
-<span class="sourceLineNo">1792</span>        List&lt;TableDescriptor&gt; tableDescs = this.admin.listTableDescriptors();<a name="line.1792"></a>
-<span class="sourceLineNo">1793</span>        List&lt;RegionInfo&gt; regions = null;<a name="line.1793"></a>
-<span class="sourceLineNo">1794</span>        for (TableDescriptor tableDesc: tableDescs) {<a name="line.1794"></a>
-<span class="sourceLineNo">1795</span>          try (RegionLocator regionLocator =<a name="line.1795"></a>
-<span class="sourceLineNo">1796</span>                   this.admin.getConnection().getRegionLocator(tableDesc.getTableName())) {<a name="line.1796"></a>
-<span class="sourceLineNo">1797</span>            for (HRegionLocation location : regionLocator.getAllRegionLocations()) {<a name="line.1797"></a>
-<span class="sourceLineNo">1798</span>              ServerName rs = location.getServerName();<a name="line.1798"></a>
-<span class="sourceLineNo">1799</span>              String rsName = rs.getHostname();<a name="line.1799"></a>
-<span class="sourceLineNo">1800</span>              RegionInfo r = location.getRegion();<a name="line.1800"></a>
-<span class="sourceLineNo">1801</span>              if (rsAndRMap.containsKey(rsName)) {<a name="line.1801"></a>
-<span class="sourceLineNo">1802</span>                regions = rsAndRMap.get(rsName);<a name="line.1802"></a>
-<span class="sourceLineNo">1803</span>              } else {<a name="line.1803"></a>
-<span class="sourceLineNo">1804</span>                regions = new ArrayList&lt;&gt;();<a name="line.1804"></a>
-<span class="sourceLineNo">1805</span>                rsAndRMap.put(rsName, regions);<a name="line.1805"></a>
+<span class="sourceLineNo">1623</span>      if (allowedFailures &gt; (hosts.size() - 1) / 2) {<a name="line.1623"></a>
+<span class="sourceLineNo">1624</span>        LOG.warn("Confirm allowable number of failed ZooKeeper nodes, as quorum will " +<a name="line.1624"></a>
+<span class="sourceLineNo">1625</span>                        "already be lost. Setting of {} failures is unexpected for {} ensemble size.",<a name="line.1625"></a>
+<span class="sourceLineNo">1626</span>                allowedFailures, hosts.size());<a name="line.1626"></a>
+<span class="sourceLineNo">1627</span>      }<a name="line.1627"></a>
+<span class="sourceLineNo">1628</span>    }<a name="line.1628"></a>
+<span class="sourceLineNo">1629</span><a name="line.1629"></a>
+<span class="sourceLineNo">1630</span>    @Override public void run() {<a name="line.1630"></a>
+<span class="sourceLineNo">1631</span>      List&lt;ZookeeperTask&gt; tasks = Lists.newArrayList();<a name="line.1631"></a>
+<span class="sourceLineNo">1632</span>      ZookeeperStdOutSink zkSink = null;<a name="line.1632"></a>
+<span class="sourceLineNo">1633</span>      try {<a name="line.1633"></a>
+<span class="sourceLineNo">1634</span>        zkSink = this.getSink();<a name="line.1634"></a>
+<span class="sourceLineNo">1635</span>      } catch (RuntimeException e) {<a name="line.1635"></a>
+<span class="sourceLineNo">1636</span>        LOG.error("Run ZooKeeperMonitor failed!", e);<a name="line.1636"></a>
+<span class="sourceLineNo">1637</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1637"></a>
+<span class="sourceLineNo">1638</span>      }<a name="line.1638"></a>
+<span class="sourceLineNo">1639</span>      this.initialized = true;<a name="line.1639"></a>
+<span class="sourceLineNo">1640</span>      for (final String host : hosts) {<a name="line.1640"></a>
+<span class="sourceLineNo">1641</span>        tasks.add(new ZookeeperTask(connection, host, znode, timeout, zkSink));<a name="line.1641"></a>
+<span class="sourceLineNo">1642</span>      }<a name="line.1642"></a>
+<span class="sourceLineNo">1643</span>      try {<a name="line.1643"></a>
+<span class="sourceLineNo">1644</span>        for (Future&lt;Void&gt; future : this.executor.invokeAll(tasks)) {<a name="line.1644"></a>
+<span class="sourceLineNo">1645</span>          try {<a name="line.1645"></a>
+<span class="sourceLineNo">1646</span>            future.get();<a name="line.1646"></a>
+<span class="sourceLineNo">1647</span>          } catch (ExecutionException e) {<a name="line.1647"></a>
+<span class="sourceLineNo">1648</span>            LOG.error("Sniff zookeeper failed!", e);<a name="line.1648"></a>
+<span class="sourceLineNo">1649</span>            this.errorCode = ERROR_EXIT_CODE;<a name="line.1649"></a>
+<span class="sourceLineNo">1650</span>          }<a name="line.1650"></a>
+<span class="sourceLineNo">1651</span>        }<a name="line.1651"></a>
+<span class="sourceLineNo">1652</span>      } catch (InterruptedException e) {<a name="line.1652"></a>
+<span class="sourceLineNo">1653</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1653"></a>
+<span class="sourceLineNo">1654</span>        Thread.currentThread().interrupt();<a name="line.1654"></a>
+<span class="sourceLineNo">1655</span>        LOG.error("Sniff zookeeper interrupted!", e);<a name="line.1655"></a>
+<span class="sourceLineNo">1656</span>      }<a name="line.1656"></a>
+<span class="sourceLineNo">1657</span>      this.done = true;<a name="line.1657"></a>
+<span class="sourceLineNo">1658</span>    }<a name="line.1658"></a>
+<span class="sourceLineNo">1659</span><a name="line.1659"></a>
+<span class="sourceLineNo">1660</span>    private ZookeeperStdOutSink getSink() {<a name="line.1660"></a>
+<span class="sourceLineNo">1661</span>      if (!(sink instanceof ZookeeperStdOutSink)) {<a name="line.1661"></a>
+<span class="sourceLineNo">1662</span>        throw new RuntimeException("Can only write to zookeeper sink");<a name="line.1662"></a>
+<span class="sourceLineNo">1663</span>      }<a name="line.1663"></a>
+<span class="sourceLineNo">1664</span>      return ((ZookeeperStdOutSink) sink);<a name="line.1664"></a>
+<span class="sourceLineNo">1665</span>    }<a name="line.1665"></a>
+<span class="sourceLineNo">1666</span>  }<a name="line.1666"></a>
+<span class="sourceLineNo">1667</span><a name="line.1667"></a>
+<span class="sourceLineNo">1668</span><a name="line.1668"></a>
+<span class="sourceLineNo">1669</span>  /**<a name="line.1669"></a>
+<span class="sourceLineNo">1670</span>   * A monitor for regionserver mode<a name="line.1670"></a>
+<span class="sourceLineNo">1671</span>   */<a name="line.1671"></a>
+<span class="sourceLineNo">1672</span>  private static class RegionServerMonitor extends Monitor {<a name="line.1672"></a>
+<span class="sourceLineNo">1673</span>    private boolean allRegions;<a name="line.1673"></a>
+<span class="sourceLineNo">1674</span><a name="line.1674"></a>
+<span class="sourceLineNo">1675</span>    public RegionServerMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1675"></a>
+<span class="sourceLineNo">1676</span>        Sink sink, ExecutorService executor, boolean allRegions,<a name="line.1676"></a>
+<span class="sourceLineNo">1677</span>        boolean treatFailureAsError, long allowedFailures) {<a name="line.1677"></a>
+<span class="sourceLineNo">1678</span>      super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError,<a name="line.1678"></a>
+<span class="sourceLineNo">1679</span>          allowedFailures);<a name="line.1679"></a>
+<span class="sourceLineNo">1680</span>      this.allRegions = allRegions;<a name="line.1680"></a>
+<span class="sourceLineNo">1681</span>    }<a name="line.1681"></a>
+<span class="sourceLineNo">1682</span><a name="line.1682"></a>
+<span class="sourceLineNo">1683</span>    private RegionServerStdOutSink getSink() {<a name="line.1683"></a>
+<span class="sourceLineNo">1684</span>      if (!(sink instanceof RegionServerStdOutSink)) {<a name="line.1684"></a>
+<span class="sourceLineNo">1685</span>        throw new RuntimeException("Can only write to regionserver sink");<a name="line.1685"></a>
+<span class="sourceLineNo">1686</span>      }<a name="line.1686"></a>
+<span class="sourceLineNo">1687</span>      return ((RegionServerStdOutSink) sink);<a name="line.1687"></a>
+<span class="sourceLineNo">1688</span>    }<a name="line.1688"></a>
+<span class="sourceLineNo">1689</span><a name="line.1689"></a>
+<span class="sourceLineNo">1690</span>    @Override<a name="line.1690"></a>
+<span class="sourceLineNo">1691</span>    public void run() {<a name="line.1691"></a>
+<span class="sourceLineNo">1692</span>      if (this.initAdmin() &amp;&amp; this.checkNoTableNames()) {<a name="line.1692"></a>
+<span class="sourceLineNo">1693</span>        RegionServerStdOutSink regionServerSink = null;<a name="line.1693"></a>
+<span class="sourceLineNo">1694</span>        try {<a name="line.1694"></a>
+<span class="sourceLineNo">1695</span>          regionServerSink = this.getSink();<a name="line.1695"></a>
+<span class="sourceLineNo">1696</span>        } catch (RuntimeException e) {<a name="line.1696"></a>
+<span class="sourceLineNo">1697</span>          LOG.error("Run RegionServerMonitor failed!", e);<a name="line.1697"></a>
+<span class="sourceLineNo">1698</span>          this.errorCode = ERROR_EXIT_CODE;<a name="line.1698"></a>
+<span class="sourceLineNo">1699</span>        }<a name="line.1699"></a>
+<span class="sourceLineNo">1700</span>        Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap = this.filterRegionServerByName();<a name="line.1700"></a>
+<span class="sourceLineNo">1701</span>        this.initialized = true;<a name="line.1701"></a>
+<span class="sourceLineNo">1702</span>        this.monitorRegionServers(rsAndRMap, regionServerSink);<a name="line.1702"></a>
+<span class="sourceLineNo">1703</span>      }<a name="line.1703"></a>
+<span class="sourceLineNo">1704</span>      this.done = true;<a name="line.1704"></a>
+<span class="sourceLineNo">1705</span>    }<a name="line.1705"></a>
+<span class="sourceLineNo">1706</span><a name="line.1706"></a>
+<span class="sourceLineNo">1707</span>    private boolean checkNoTableNames() {<a name="line.1707"></a>
+<span class="sourceLineNo">1708</span>      List&lt;String&gt; foundTableNames = new ArrayList&lt;&gt;();<a name="line.1708"></a>
+<span class="sourceLineNo">1709</span>      TableName[] tableNames = null;<a name="line.1709"></a>
+<span class="sourceLineNo">1710</span>      LOG.debug("Reading list of tables");<a name="line.1710"></a>
+<span class="sourceLineNo">1711</span>      try {<a name="line.1711"></a>
+<span class="sourceLineNo">1712</span>        tableNames = this.admin.listTableNames();<a name="line.1712"></a>
+<span class="sourceLineNo">1713</span>      } catch (IOException e) {<a name="line.1713"></a>
+<span class="sourceLineNo">1714</span>        LOG.error("Get listTableNames failed", e);<a name="line.1714"></a>
+<span class="sourceLineNo">1715</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1715"></a>
+<span class="sourceLineNo">1716</span>        return false;<a name="line.1716"></a>
+<span class="sourceLineNo">1717</span>      }<a name="line.1717"></a>
+<span class="sourceLineNo">1718</span><a name="line.1718"></a>
+<span class="sourceLineNo">1719</span>      if (this.targets == null || this.targets.length == 0) return true;<a name="line.1719"></a>
+<span class="sourceLineNo">1720</span><a name="line.1720"></a>
+<span class="sourceLineNo">1721</span>      for (String target : this.targets) {<a name="line.1721"></a>
+<span class="sourceLineNo">1722</span>        for (TableName tableName : tableNames) {<a name="line.1722"></a>
+<span class="sourceLineNo">1723</span>          if (target.equals(tableName.getNameAsString())) {<a name="line.1723"></a>
+<span class="sourceLineNo">1724</span>            foundTableNames.add(target);<a name="line.1724"></a>
+<span class="sourceLineNo">1725</span>          }<a name="line.1725"></a>
+<span class="sourceLineNo">1726</span>        }<a name="line.1726"></a>
+<span class="sourceLineNo">1727</span>      }<a name="line.1727"></a>
+<span class="sourceLineNo">1728</span><a name="line.1728"></a>
+<span class="sourceLineNo">1729</span>      if (foundTableNames.size() &gt; 0) {<a name="line.1729"></a>
+<span class="sourceLineNo">1730</span>        System.err.println("Cannot pass a tablename when using the -regionserver " +<a name="line.1730"></a>
+<span class="sourceLineNo">1731</span>            "option, tablenames:" + foundTableNames.toString());<a name="line.1731"></a>
+<span class="sourceLineNo">1732</span>        this.errorCode = USAGE_EXIT_CODE;<a name="line.1732"></a>
+<span class="sourceLineNo">1733</span>      }<a name="line.1733"></a>
+<span class="sourceLineNo">1734</span>      return foundTableNames.isEmpty();<a name="line.1734"></a>
+<span class="sourceLineNo">1735</span>    }<a name="line.1735"></a>
+<span class="sourceLineNo">1736</span><a name="line.1736"></a>
+<span class="sourceLineNo">1737</span>    private void monitorRegionServers(Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap, RegionServerStdOutSink regionServerSink) {<a name="line.1737"></a>
+<span class="sourceLineNo">1738</span>      List&lt;RegionServerTask&gt; tasks = new ArrayList&lt;&gt;();<a name="line.1738"></a>
+<span class="sourceLineNo">1739</span>      Map&lt;String, AtomicLong&gt; successMap = new HashMap&lt;&gt;();<a name="line.1739"></a>
+<span class="sourceLineNo">1740</span>      Random rand = new Random();<a name="line.1740"></a>
+<span class="sourceLineNo">1741</span>      for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : rsAndRMap.entrySet()) {<a name="line.1741"></a>
+<span class="sourceLineNo">1742</span>        String serverName = entry.getKey();<a name="line.1742"></a>
+<span class="sourceLineNo">1743</span>        AtomicLong successes = new AtomicLong(0);<a name="line.1743"></a>
+<span class="sourceLineNo">1744</span>        successMap.put(serverName, successes);<a name="line.1744"></a>
+<span class="sourceLineNo">1745</span>        if (entry.getValue().isEmpty()) {<a name="line.1745"></a>
+<span class="sourceLineNo">1746</span>          LOG.error("Regionserver not serving any regions - {}", serverName);<a name="line.1746"></a>
+<span class="sourceLineNo">1747</span>        } else if (this.allRegions) {<a name="line.1747"></a>
+<span class="sourceLineNo">1748</span>          for (RegionInfo region : entry.getValue()) {<a name="line.1748"></a>
+<span class="sourceLineNo">1749</span>            tasks.add(new RegionServerTask(this.connection,<a name="line.1749"></a>
+<span class="sourceLineNo">1750</span>                serverName,<a name="line.1750"></a>
+<span class="sourceLineNo">1751</span>                region,<a name="line.1751"></a>
+<span class="sourceLineNo">1752</span>                regionServerSink,<a name="line.1752"></a>
+<span class="sourceLineNo">1753</span>                successes));<a name="line.1753"></a>
+<span class="sourceLineNo">1754</span>          }<a name="line.1754"></a>
+<span class="sourceLineNo">1755</span>        } else {<a name="line.1755"></a>
+<span class="sourceLineNo">1756</span>          // random select a region if flag not set<a name="line.1756"></a>
+<span class="sourceLineNo">1757</span>          RegionInfo region = entry.getValue().get(rand.nextInt(entry.getValue().size()));<a name="line.1757"></a>
+<span class="sourceLineNo">1758</span>          tasks.add(new RegionServerTask(this.connection,<a name="line.1758"></a>
+<span class="sourceLineNo">1759</span>              serverName,<a name="line.1759"></a>
+<span class="sourceLineNo">1760</span>              region,<a name="line.1760"></a>
+<span class="sourceLineNo">1761</span>              regionServerSink,<a name="line.1761"></a>
+<span class="sourceLineNo">1762</span>              successes));<a name="line.1762"></a>
+<span class="sourceLineNo">1763</span>        }<a name="line.1763"></a>
+<span class="sourceLineNo">1764</span>      }<a name="line.1764"></a>
+<span class="sourceLineNo">1765</span>      try {<a name="line.1765"></a>
+<span class="sourceLineNo">1766</span>        for (Future&lt;Void&gt; future : this.executor.invokeAll(tasks)) {<a name="line.1766"></a>
+<span class="sourceLineNo">1767</span>          try {<a name="line.1767"></a>
+<span class="sourceLineNo">1768</span>            future.get();<a name="line.1768"></a>
+<span class="sourceLineNo">1769</span>          } catch (ExecutionException e) {<a name="line.1769"></a>
+<span class="sourceLineNo">1770</span>            LOG.error("Sniff regionserver failed!", e);<a name="line.1770"></a>
+<span class="sourceLineNo">1771</span>            this.errorCode = ERROR_EXIT_CODE;<a name="line.1771"></a>
+<span class="sourceLineNo">1772</span>          }<a name="line.1772"></a>
+<span class="sourceLineNo">1773</span>        }<a name="line.1773"></a>
+<span class="sourceLineNo">1774</span>        if (this.allRegions) {<a name="line.1774"></a>
+<span class="sourceLineNo">1775</span>          for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : rsAndRMap.entrySet()) {<a name="line.1775"></a>
+<span class="sourceLineNo">1776</span>            String serverName = entry.getKey();<a name="line.1776"></a>
+<span class="sourceLineNo">1777</span>            LOG.info("Successfully read {} regions out of {} on regionserver {}",<a name="line.1777"></a>
+<span class="sourceLineNo">1778</span>                successMap.get(serverName), entry.getValue().size(), serverName);<a name="line.1778"></a>
+<span class="sourceLineNo">1779</span>          }<a name="line.1779"></a>
+<span class="sourceLineNo">1780</span>        }<a name="line.1780"></a>
+<span class="sourceLineNo">1781</span>      } catch (InterruptedException e) {<a name="line.1781"></a>
+<span class="sourceLineNo">1782</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1782"></a>
+<span class="sourceLineNo">1783</span>        LOG.error("Sniff regionserver interrupted!", e);<a name="line.1783"></a>
+<span class="sourceLineNo">1784</span>      }<a name="line.1784"></a>
+<span class="sourceLineNo">1785</span>    }<a name="line.1785"></a>
+<span class="sourceLineNo">1786</span><a name="line.1786"></a>
+<span class="sourceLineNo">1787</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; filterRegionServerByName() {<a name="line.1787"></a>
+<span class="sourceLineNo">1788</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; regionServerAndRegionsMap = this.getAllRegionServerByName();<a name="line.1788"></a>
+<span class="sourceLineNo">1789</span>      regionServerAndRegionsMap = this.doFilterRegionServerByName(regionServerAndRegionsMap);<a name="line.1789"></a>
+<span class="sourceLineNo">1790</span>      return regionServerAndRegionsMap;<a name="line.1790"></a>
+<span class="sourceLineNo">1791</span>    }<a name="line.1791"></a>
+<span class="sourceLineNo">1792</span><a name="line.1792"></a>
+<span class="sourceLineNo">1793</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; getAllRegionServerByName() {<a name="line.1793"></a>
+<span class="sourceLineNo">1794</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap = new HashMap&lt;&gt;();<a name="line.1794"></a>
+<span class="sourceLineNo">1795</span>      try {<a name="line.1795"></a>
+<span class="sourceLineNo">1796</span>        LOG.debug("Reading list of tables and locations");<a name="line.1796"></a>
+<span class="sourceLineNo">1797</span>        List&lt;TableDescriptor&gt; tableDescs = this.admin.listTableDescriptors();<a name="line.1797"></a>
+<span class="sourceLineNo">1798</span>        List&lt;RegionInfo&gt; regions = null;<a name="line.1798"></a>
+<span class="sourceLineNo">1799</span>        for (TableDescriptor tableDesc: tableDescs) {<a name="line.1799"></a>
+<span class="sourceLineNo">1800</span>          try (RegionLocator regionLocator =<a name="line.1800"></a>
+<span class="sourceLineNo">1801</span>                   this.admin.getConnection().getRegionLocator(tableDesc.getTableName())) {<a name="line.1801"></a>
+<span class="sourceLineNo">1802</span>            for (HRegionLocation location : regionLocator.getAllRegionLocations()) {<a name="line.1802"></a>
+<span class="sourceLineNo">1803</span>              if (location == null) {<a name="line.1803"></a>
+<span class="sourceLineNo">1804</span>                LOG.warn("Null location");<a name="line.1804"></a>
+<span class="sourceLineNo">1805</span>                continue;<a name="line.1805"></a>
 <span class="sourceLineNo">1806</span>              }<a name="line.1806"></a>
-<span class="sourceLineNo">1807</span>              regions.add(r);<a name="line.1807"></a>
-<span class="sourceLineNo">1808</span>            }<a name="line.1808"></a>
-<span class="sourceLineNo">1809</span>          }<a name="line.1809"></a>
-<span class="sourceLineNo">1810</span>        }<a name="line.1810"></a>
-<span class="sourceLineNo">1811</span><a name="line.1811"></a>
-<span class="sourceLineNo">1812</span>        // get any live regionservers not serving any regions<a name="line.1812"></a>
-<span class="sourceLineNo">1813</span>        for (ServerName rs: this.admin.getRegionServers()) {<a name="line.1813"></a>
-<span class="sourceLineNo">1814</span>          String rsName = rs.getHostname();<a name="line.1814"></a>
-<span class="sourceLineNo">1815</span>          if (!rsAndRMap.containsKey(rsName)) {<a name="line.1815"></a>
-<span class="sourceLineNo">1816</span>            rsAndRMap.put(rsName, Collections.&lt;RegionInfo&gt; emptyList());<a name="line.1816"></a>
-<span class="sourceLineNo">1817</span>          }<a name="line.1817"></a>
-<span class="sourceLineNo">1818</span>        }<a name="line.1818"></a>
-<span class="sourceLineNo">1819</span>      } catch (IOException e) {<a name="line.1819"></a>
-<span class="sourceLineNo">1820</span>        LOG.error("Get HTables info failed", e);<a name="line.1820"></a>
-<span class="sourceLineNo">1821</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1821"></a>
-<span class="sourceLineNo">1822</span>      }<a name="line.1822"></a>
-<span class="sourceLineNo">1823</span>      return rsAndRMap;<a name="line.1823"></a>
-<span class="sourceLineNo">1824</span>    }<a name="line.1824"></a>
-<span class="sourceLineNo">1825</span><a name="line.1825"></a>
-<span class="sourceLineNo">1826</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; doFilterRegionServerByName(<a name="line.1826"></a>
-<span class="sourceLineNo">1827</span>        Map&lt;String, List&lt;RegionInfo&gt;&gt; fullRsAndRMap) {<a name="line.1827"></a>
-<span class="sourceLineNo">1828</span><a name="line.1828"></a>
-<span class="sourceLineNo">1829</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; filteredRsAndRMap = null;<a name="line.1829"></a>
-<span class="sourceLineNo">1830</span><a name="line.1830"></a>
-<span class="sourceLineNo">1831</span>      if (this.targets != null &amp;&amp; this.targets.length &gt; 0) {<a name="line.1831"></a>
-<span class="sourceLineNo">1832</span>        filteredRsAndRMap = new HashMap&lt;&gt;();<a name="line.1832"></a>
-<span class="sourceLineNo">1833</span>        Pattern pattern = null;<a name="line.1833"></a>
-<span class="sourceLineNo">1834</span>        Matcher matcher = null;<a name="line.1834"></a>
-<span class="sourceLineNo">1835</span>        boolean regExpFound = false;<a name="line.1835"></a>
-<span class="sourceLineNo">1836</span>        for (String rsName : this.targets) {<a name="line.1836"></a>
-<span class="sourceLineNo">1837</span>          if (this.useRegExp) {<a name="line.1837"></a>
-<span class="sourceLineNo">1838</span>            regExpFound = false;<a name="line.1838"></a>
-<span class="sourceLineNo">1839</span>            pattern = Pattern.compile(rsName);<a name="line.1839"></a>
-<span class="sourceLineNo">1840</span>            for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : fullRsAndRMap.entrySet()) {<a name="line.1840"></a>
-<span class="sourceLineNo">1841</span>              matcher = pattern.matcher(entry.getKey());<a name="line.1841"></a>
-<span class="sourceLineNo">1842</span>              if (matcher.matches()) {<a name="line.1842"></a>
-<span class="sourceLineNo">1843</span>                filteredRsAndRMap.put(entry.getKey(), entry.getValue());<a name="line.1843"></a>
-<span class="sourceLineNo">1844</span>                regExpFound = true;<a name="line.1844"></a>
-<span class="sourceLineNo">1845</span>              }<a name="line.1845"></a>
-<span class="sourceLineNo">1846</span>            }<a name="line.1846"></a>
-<span class="sourceLineNo">1847</span>            if (!regExpFound) {<a name="line.1847"></a>
-<span class="sourceLineNo">1848</span>              LOG.info("No RegionServerInfo found, regionServerPattern {}", rsName);<a name="line.1848"></a>
-<span class="sourceLineNo">1849</span>            }<a name="line.1849"></a>
-<span class="sourceLineNo">1850</span>          } else {<a name="line.1850"></a>
-<span class="sourceLineNo">1851</span>            if (fullRsAndRMap.containsKey(rsName)) {<a name="line.1851"></a>
-<span class="sourceLineNo">1852</span>              filteredRsAndRMap.put(rsName, fullRsAndRMap.get(rsName));<a name="line.1852"></a>
-<span class="sourceLineNo">1853</span>            } else {<a name="line.1853"></a>
-<span class="sourceLineNo">1854</span>              LOG.info("No RegionServerInfo found, regionServerName {}", rsName);<a name="line.1854"></a>
+<span class="sourceLineNo">1807</span>              ServerName rs = location.getServerName();<a name="line.1807"></a>
+<span class="sourceLineNo">1808</span>              String rsName = rs.getHostname();<a name="line.1808"></a>
+<span class="sourceLineNo">1809</span>              RegionInfo r = location.getRegion();<a name="line.1809"></a>
+<span class="sourceLineNo">1810</span>              if (rsAndRMap.containsKey(rsName)) {<a name="line.1810"></a>
+<span class="sourceLineNo">1811</span>                regions = rsAndRMap.get(rsName);<a name="line.1811"></a>
+<span class="sourceLineNo">1812</span>              } else {<a name="line.1812"></a>
+<span class="sourceLineNo">1813</span>                regions = new ArrayList&lt;&gt;();<a name="line.1813"></a>
+<span class="sourceLineNo">1814</span>                rsAndRMap.put(rsName, regions);<a name="line.1814"></a>
+<span class="sourceLineNo">1815</span>              }<a name="line.1815"></a>
+<span class="sourceLineNo">1816</span>              regions.add(r);<a name="line.1816"></a>
+<span class="sourceLineNo">1817</span>            }<a name="line.1817"></a>
+<span class="sourceLineNo">1818</span>          }<a name="line.1818"></a>
+<span class="sourceLineNo">1819</span>        }<a name="line.1819"></a>
+<span class="sourceLineNo">1820</span><a name="line.1820"></a>
+<span class="sourceLineNo">1821</span>        // get any live regionservers not serving any regions<a name="line.1821"></a>
+<span class="sourceLineNo">1822</span>        for (ServerName rs: this.admin.getRegionServers()) {<a name="line.1822"></a>
+<span class="sourceLineNo">1823</span>          String rsName = rs.getHostname();<a name="line.1823"></a>
+<span class="sourceLineNo">1824</span>          if (!rsAndRMap.containsKey(rsName)) {<a name="line.1824"></a>
+<span class="sourceLineNo">1825</span>            rsAndRMap.put(rsName, Collections.&lt;RegionInfo&gt; emptyList());<a name="line.1825"></a>
+<span class="sourceLineNo">1826</span>          }<a name="line.1826"></a>
+<span class="sourceLineNo">1827</span>        }<a name="line.1827"></a>
+<span class="sourceLineNo">1828</span>      } catch (IOException e) {<a name="line.1828"></a>
+<span class="sourceLineNo">1829</span>        LOG.error("Get HTables info failed", e);<a name="line.1829"></a>
+<span class="sourceLineNo">1830</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1830"></a>
+<span class="sourceLineNo">1831</span>      }<a name="line.1831"></a>
+<span class="sourceLineNo">1832</span>      return rsAndRMap;<a name="line.1832"></a>
+<span class="sourceLineNo">1833</span>    }<a name="line.1833"></a>
+<span class="sourceLineNo">1834</span><a name="line.1834"></a>
+<span class="sourceLineNo">1835</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; doFilterRegionServerByName(<a name="line.1835"></a>
+<span class="sourceLineNo">1836</span>        Map&lt;String, List&lt;RegionInfo&gt;&gt; fullRsAndRMap) {<a name="line.1836"></a>
+<span class="sourceLineNo">1837</span><a name="line.1837"></a>
+<span class="sourceLineNo">1838</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; filteredRsAndRMap = null;<a name="line.1838"></a>
+<span class="sourceLineNo">1839</span><a name="line.1839"></a>
+<span class="sourceLineNo">1840</span>      if (this.targets != null &amp;&amp; this.targets.length &gt; 0) {<a name="line.1840"></a>
+<span class="sourceLineNo">1841</span>        filteredRsAndRMap = new HashMap&lt;&gt;();<a name="line.1841"></a>
+<span class="sourceLineNo">1842</span>        Pattern pattern = null;<a name="line.1842"></a>
+<span class="sourceLineNo">1843</span>        Matcher matcher = null;<a name="line.1843"></a>
+<span class="sourceLineNo">1844</span>        boolean regExpFound = false;<a name="line.1844"></a>
+<span class="sourceLineNo">1845</span>        for (String rsName : this.targets) {<a name="line.1845"></a>
+<span class="sourceLineNo">1846</span>          if (this.useRegExp) {<a name="line.1846"></a>
+<span class="sourceLineNo">1847</span>            regExpFound = false;<a name="line.1847"></a>
+<span class="sourceLineNo">1848</span>            pattern = Pattern.compile(rsName);<a name="line.1848"></a>
+<span class="sourceLineNo">1849</span>            for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : fullRsAndRMap.entrySet()) {<a name="line.1849"></a>
+<span class="sourceLineNo">1850</span>              matcher = pattern.matcher(entry.getKey());<a name="line.1850"></a>
+<span class="sourceLineNo">1851</span>              if (matcher.matches()) {<a name="line.1851"></a>
+<span class="sourceLineNo">1852</span>                filteredRsAndRMap.put(entry.getKey(), entry.getValue());<a name="line.1852"></a>
+<span class="sourceLineNo">1853</span>                regExpFound = true;<a name="line.1853"></a>
+<span class="sourceLineNo">1854</span>              }<a name="line.1854"></a>
 <span class="sourceLineNo">1855</span>            }<a name="line.1855"></a>
-<span class="sourceLineNo">1856</span>          }<a name="line.1856"></a>
-<span class="sourceLineNo">1857</span>        }<a name="line.1857"></a>
-<span class="sourceLineNo">1858</span>      } else {<a name="line.1858"></a>
-<span class="sourceLineNo">1859</span>        filteredRsAndRMap = fullRsAndRMap;<a name="line.1859"></a>
-<span class="sourceLineNo">1860</span>      }<a name="line.1860"></a>
-<span class="sourceLineNo">1861</span>      return filteredRsAndRMap;<a name="line.1861"></a>
-<span class="sourceLineNo">1862</span>    }<a name="line.1862"></a>
-<span class="sourceLineNo">1863</span>  }<a name="line.1863"></a>
-<span class="sourceLineNo">1864</span><a name="line.1864"></a>
-<span class="sourceLineNo">1865</span>  public static void main(String[] args) throws Exception {<a name="line.1865"></a>
-<span class="sourceLineNo">1866</span>    final Configuration conf = HBaseConfiguration.create();<a name="line.1866"></a>
-<span class="sourceLineNo">1867</span><a name="line.1867"></a>
-<span class="sourceLineNo">1868</span>    int numThreads = conf.getInt("hbase.canary.threads.num", MAX_THREADS_NUM);<a name="line.1868"></a>
-<span class="sourceLineNo">1869</span>    LOG.info("Execution thread count={}", numThreads);<a name="line.1869"></a>
-<span class="sourceLineNo">1870</span><a name="line.1870"></a>
-<span class="sourceLineNo">1871</span>    int exitCode;<a name="line.1871"></a>
-<span class="sourceLineNo">1872</span>    ExecutorService executor = new ScheduledThreadPoolExecutor(numThreads);<a name="line.1872"></a>
-<span class="sourceLineNo">1873</span>    try {<a name="line.1873"></a>
-<span class="sourceLineNo">1874</span>      exitCode = ToolRunner.run(conf, new CanaryTool(executor), args);<a name="line.1874"></a>
-<span class="sourceLineNo">1875</span>    } finally {<a name="line.1875"></a>
-<span class="sourceLineNo">1876</span>      executor.shutdown();<a name="line.1876"></a>
-<span class="sourceLineNo">1877</span>    }<a name="line.1877"></a>
-<span class="sourceLineNo">1878</span>    System.exit(exitCode);<a name="line.1878"></a>
-<span class="sourceLineNo">1879</span>  }<a name="line.1879"></a>
-<span class="sourceLineNo">1880</span>}<a name="line.1880"></a>
+<span class="sourceLineNo">1856</span>            if (!regExpFound) {<a name="line.1856"></a>
+<span class="sourceLineNo">1857</span>              LOG.info("No RegionServerInfo found, regionServerPattern {}", rsName);<a name="line.1857"></a>
+<span class="sourceLineNo">1858</span>            }<a name="line.1858"></a>
+<span class="sourceLineNo">1859</span>          } else {<a name="line.1859"></a>
+<span class="sourceLineNo">1860</span>            if (fullRsAndRMap.containsKey(rsName)) {<a name="line.1860"></a>
+<span class="sourceLineNo">1861</span>              filteredRsAndRMap.put(rsName, fullRsAndRMap.get(rsName));<a name="line.1861"></a>
+<span class="sourceLineNo">1862</span>            } else {<a name="line.1862"></a>
+<span class="sourceLineNo">1863</span>              LOG.info("No RegionServerInfo found, regionServerName {}", rsName);<a name="line.1863"></a>
+<span class="sourceLineNo">1864</span>            }<a name="line.1864"></a>
+<span class="sourceLineNo">1865</span>          }<a name="line.1865"></a>
+<span class="sourceLineNo">1866</span>        }<a name="line.1866"></a>
+<span class="sourceLineNo">1867</span>      } else {<a name="line.1867"></a>
+<span class="sourceLineNo">1868</span>        filteredRsAndRMap = fullRsAndRMap;<a name="line.1868"></a>
+<span class="sourceLineNo">1869</span>      }<a name="line.1869"></a>
+<span class="sourceLineNo">1870</span>      return filteredRsAndRMap;<a name="line.1870"></a>
+<span class="sourceLineNo">1871</span>    }<a name="line.1871"></a>
+<span class="sourceLineNo">1872</span>  }<a name="line.1872"></a>
+<span class="sourceLineNo">1873</span><a name="line.1873"></a>
+<span class="sourceLineNo">1874</span>  public static void main(String[] args) throws Exception {<a name="line.1874"></a>
+<span class="sourceLineNo">1875</span>    final Configuration conf = HBaseConfiguration.create();<a name="line.1875"></a>
+<span class="sourceLineNo">1876</span><a name="line.1876"></a>
+<span class="sourceLineNo">1877</span>    int numThreads = conf.getInt("hbase.canary.threads.num", MAX_THREADS_NUM);<a name="line.1877"></a>
+<span class="sourceLineNo">1878</span>    LOG.info("Execution thread count={}", numThreads);<a name="line.1878"></a>
+<span class="sourceLineNo">1879</span><a name="line.1879"></a>
+<span class="sourceLineNo">1880</span>    int exitCode;<a name="line.1880"></a>
+<span class="sourceLineNo">1881</span>    ExecutorService executor = new ScheduledThreadPoolExecutor(numThreads);<a name="line.1881"></a>
+<span class="sourceLineNo">1882</span>    try {<a name="line.1882"></a>
+<span class="sourceLineNo">1883</span>      exitCode = ToolRunner.run(conf, new CanaryTool(executor), args);<a name="line.1883"></a>
+<span class="sourceLineNo">1884</span>    } finally {<a name="line.1884"></a>
+<span class="sourceLineNo">1885</span>      executor.shutdown();<a name="line.1885"></a>
+<span class="sourceLineNo">1886</span>    }<a name="line.1886"></a>
+<span class="sourceLineNo">1887</span>    System.exit(exitCode);<a name="line.1887"></a>
+<span class="sourceLineNo">1888</span>  }<a name="line.1888"></a>
+<span class="sourceLineNo">1889</span>}<a name="line.1889"></a>
 
 
 
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html b/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html
index 5e57151..4b34be0 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionMonitor.html
@@ -500,1392 +500,1401 @@
 <span class="sourceLineNo">492</span>          sink.publishReadTiming(serverName, region, column, stopWatch.getTime());<a name="line.492"></a>
 <span class="sourceLineNo">493</span>        } catch (Exception e) {<a name="line.493"></a>
 <span class="sourceLineNo">494</span>          sink.publishReadFailure(serverName, region, column, e);<a name="line.494"></a>
-<span class="sourceLineNo">495</span>          sink.updateReadFailures(region.getRegionNameAsString(), serverName.getHostname());<a name="line.495"></a>
-<span class="sourceLineNo">496</span>        } finally {<a name="line.496"></a>
-<span class="sourceLineNo">497</span>          if (rs != null) {<a name="line.497"></a>
-<span class="sourceLineNo">498</span>            rs.close();<a name="line.498"></a>
-<span class="sourceLineNo">499</span>          }<a name="line.499"></a>
-<span class="sourceLineNo">500</span>          scan = null;<a name="line.500"></a>
-<span class="sourceLineNo">501</span>          get = null;<a name="line.501"></a>
-<span class="sourceLineNo">502</span>        }<a name="line.502"></a>
-<span class="sourceLineNo">503</span>      }<a name="line.503"></a>
-<span class="sourceLineNo">504</span>      try {<a name="line.504"></a>
-<span class="sourceLineNo">505</span>        table.close();<a name="line.505"></a>
-<span class="sourceLineNo">506</span>      } catch (IOException e) {<a name="line.506"></a>
-<span class="sourceLineNo">507</span>        LOG.error("Close table failed", e);<a name="line.507"></a>
-<span class="sourceLineNo">508</span>      }<a name="line.508"></a>
-<span class="sourceLineNo">509</span>      return null;<a name="line.509"></a>
-<span class="sourceLineNo">510</span>    }<a name="line.510"></a>
-<span class="sourceLineNo">511</span><a name="line.511"></a>
-<span class="sourceLineNo">512</span>    /**<a name="line.512"></a>
-<span class="sourceLineNo">513</span>     * Check writes for the canary table<a name="line.513"></a>
-<span class="sourceLineNo">514</span>     */<a name="line.514"></a>
-<span class="sourceLineNo">515</span>    private Void write() {<a name="line.515"></a>
-<span class="sourceLineNo">516</span>      Table table = null;<a name="line.516"></a>
-<span class="sourceLineNo">517</span>      TableDescriptor tableDesc = null;<a name="line.517"></a>
-<span class="sourceLineNo">518</span>      try {<a name="line.518"></a>
-<span class="sourceLineNo">519</span>        table = connection.getTable(region.getTable());<a name="line.519"></a>
-<span class="sourceLineNo">520</span>        tableDesc = table.getDescriptor();<a name="line.520"></a>
-<span class="sourceLineNo">521</span>        byte[] rowToCheck = region.getStartKey();<a name="line.521"></a>
-<span class="sourceLineNo">522</span>        if (rowToCheck.length == 0) {<a name="line.522"></a>
-<span class="sourceLineNo">523</span>          rowToCheck = new byte[]{0x0};<a name="line.523"></a>
-<span class="sourceLineNo">524</span>        }<a name="line.524"></a>
-<span class="sourceLineNo">525</span>        int writeValueSize =<a name="line.525"></a>
-<span class="sourceLineNo">526</span>            connection.getConfiguration().getInt(HConstants.HBASE_CANARY_WRITE_VALUE_SIZE_KEY, 10);<a name="line.526"></a>
-<span class="sourceLineNo">527</span>        for (ColumnFamilyDescriptor column : tableDesc.getColumnFamilies()) {<a name="line.527"></a>
-<span class="sourceLineNo">528</span>          Put put = new Put(rowToCheck);<a name="line.528"></a>
-<span class="sourceLineNo">529</span>          byte[] value = new byte[writeValueSize];<a name="line.529"></a>
-<span class="sourceLineNo">530</span>          Bytes.random(value);<a name="line.530"></a>
-<span class="sourceLineNo">531</span>          put.addColumn(column.getName(), HConstants.EMPTY_BYTE_ARRAY, value);<a name="line.531"></a>
-<span class="sourceLineNo">532</span><a name="line.532"></a>
-<span class="sourceLineNo">533</span>          LOG.debug("Writing to {} {} {} {}",<a name="line.533"></a>
-<span class="sourceLineNo">534</span>            tableDesc.getTableName(), region.getRegionNameAsString(), column.getNameAsString(),<a name="line.534"></a>
-<span class="sourceLineNo">535</span>            Bytes.toStringBinary(rowToCheck));<a name="line.535"></a>
-<span class="sourceLineNo">536</span>          try {<a name="line.536"></a>
-<span class="sourceLineNo">537</span>            long startTime = System.currentTimeMillis();<a name="line.537"></a>
-<span class="sourceLineNo">538</span>            table.put(put);<a name="line.538"></a>
-<span class="sourceLineNo">539</span>            long time = System.currentTimeMillis() - startTime;<a name="line.539"></a>
-<span class="sourceLineNo">540</span>            this.readWriteLatency.add(time);<a name="line.540"></a>
-<span class="sourceLineNo">541</span>            sink.publishWriteTiming(serverName, region, column, time);<a name="line.541"></a>
-<span class="sourceLineNo">542</span>          } catch (Exception e) {<a name="line.542"></a>
-<span class="sourceLineNo">543</span>            sink.publishWriteFailure(serverName, region, column, e);<a name="line.543"></a>
-<span class="sourceLineNo">544</span>          }<a name="line.544"></a>
-<span class="sourceLineNo">545</span>        }<a name="line.545"></a>
-<span class="sourceLineNo">546</span>        table.close();<a name="line.546"></a>
-<span class="sourceLineNo">547</span>      } catch (IOException e) {<a name="line.547"></a>
-<span class="sourceLineNo">548</span>        sink.publishWriteFailure(serverName, region, e);<a name="line.548"></a>
-<span class="sourceLineNo">549</span>        sink.updateWriteFailures(region.getRegionNameAsString(), serverName.getHostname() );<a name="line.549"></a>
-<span class="sourceLineNo">550</span>      }<a name="line.550"></a>
-<span class="sourceLineNo">551</span>      return null;<a name="line.551"></a>
-<span class="sourceLineNo">552</span>    }<a name="line.552"></a>
-<span class="sourceLineNo">553</span>  }<a name="line.553"></a>
-<span class="sourceLineNo">554</span><a name="line.554"></a>
-<span class="sourceLineNo">555</span>  /**<a name="line.555"></a>
-<span class="sourceLineNo">556</span>   * Run a single RegionServer Task and then exit.<a name="line.556"></a>
-<span class="sourceLineNo">557</span>   * Get one row from a region on the regionserver and output latency or the failure.<a name="line.557"></a>
-<span class="sourceLineNo">558</span>   */<a name="line.558"></a>
-<span class="sourceLineNo">559</span>  static class RegionServerTask implements Callable&lt;Void&gt; {<a name="line.559"></a>
-<span class="sourceLineNo">560</span>    private Connection connection;<a name="line.560"></a>
-<span class="sourceLineNo">561</span>    private String serverName;<a name="line.561"></a>
-<span class="sourceLineNo">562</span>    private RegionInfo region;<a name="line.562"></a>
-<span class="sourceLineNo">563</span>    private RegionServerStdOutSink sink;<a name="line.563"></a>
-<span class="sourceLineNo">564</span>    private AtomicLong successes;<a name="line.564"></a>
-<span class="sourceLineNo">565</span><a name="line.565"></a>
-<span class="sourceLineNo">566</span>    RegionServerTask(Connection connection, String serverName, RegionInfo region,<a name="line.566"></a>
-<span class="sourceLineNo">567</span>        RegionServerStdOutSink sink, AtomicLong successes) {<a name="line.567"></a>
-<span class="sourceLineNo">568</span>      this.connection = connection;<a name="line.568"></a>
-<span class="sourceLineNo">569</span>      this.serverName = serverName;<a name="line.569"></a>
-<span class="sourceLineNo">570</span>      this.region = region;<a name="line.570"></a>
-<span class="sourceLineNo">571</span>      this.sink = sink;<a name="line.571"></a>
-<span class="sourceLineNo">572</span>      this.successes = successes;<a name="line.572"></a>
-<span class="sourceLineNo">573</span>    }<a name="line.573"></a>
-<span class="sourceLineNo">574</span><a name="line.574"></a>
-<span class="sourceLineNo">575</span>    @Override<a name="line.575"></a>
-<span class="sourceLineNo">576</span>    public Void call() {<a name="line.576"></a>
-<span class="sourceLineNo">577</span>      TableName tableName = null;<a name="line.577"></a>
-<span class="sourceLineNo">578</span>      Table table = null;<a name="line.578"></a>
-<span class="sourceLineNo">579</span>      Get get = null;<a name="line.579"></a>
-<span class="sourceLineNo">580</span>      byte[] startKey = null;<a name="line.580"></a>
-<span class="sourceLineNo">581</span>      Scan scan = null;<a name="line.581"></a>
-<span class="sourceLineNo">582</span>      StopWatch stopWatch = new StopWatch();<a name="line.582"></a>
-<span class="sourceLineNo">583</span>      // monitor one region on every region server<a name="line.583"></a>
-<span class="sourceLineNo">584</span>      stopWatch.reset();<a name="line.584"></a>
-<span class="sourceLineNo">585</span>      try {<a name="line.585"></a>
-<span class="sourceLineNo">586</span>        tableName = region.getTable();<a name="line.586"></a>
-<span class="sourceLineNo">587</span>        table = connection.getTable(tableName);<a name="line.587"></a>
-<span class="sourceLineNo">588</span>        startKey = region.getStartKey();<a name="line.588"></a>
-<span class="sourceLineNo">589</span>        // Can't do a get on empty start row so do a Scan of first element if any instead.<a name="line.589"></a>
-<span class="sourceLineNo">590</span>        LOG.debug("Reading from {} {} {} {}",<a name="line.590"></a>
-<span class="sourceLineNo">591</span>          serverName, region.getTable(), region.getRegionNameAsString(),<a name="line.591"></a>
-<span class="sourceLineNo">592</span>          Bytes.toStringBinary(startKey));<a name="line.592"></a>
-<span class="sourceLineNo">593</span>        if (startKey.length &gt; 0) {<a name="line.593"></a>
-<span class="sourceLineNo">594</span>          get = new Get(startKey);<a name="line.594"></a>
-<span class="sourceLineNo">595</span>          get.setCacheBlocks(false);<a name="line.595"></a>
-<span class="sourceLineNo">596</span>          get.setFilter(new FirstKeyOnlyFilter());<a name="line.596"></a>
-<span class="sourceLineNo">597</span>          stopWatch.start();<a name="line.597"></a>
-<span class="sourceLineNo">598</span>          table.get(get);<a name="line.598"></a>
-<span class="sourceLineNo">599</span>          stopWatch.stop();<a name="line.599"></a>
-<span class="sourceLineNo">600</span>        } else {<a name="line.600"></a>
-<span class="sourceLineNo">601</span>          scan = new Scan();<a name="line.601"></a>
-<span class="sourceLineNo">602</span>          scan.setCacheBlocks(false);<a name="line.602"></a>
-<span class="sourceLineNo">603</span>          scan.setFilter(new FirstKeyOnlyFilter());<a name="line.603"></a>
-<span class="sourceLineNo">604</span>          scan.setCaching(1);<a name="line.604"></a>
-<span class="sourceLineNo">605</span>          scan.setMaxResultSize(1L);<a name="line.605"></a>
-<span class="sourceLineNo">606</span>          scan.setOneRowLimit();<a name="line.606"></a>
-<span class="sourceLineNo">607</span>          stopWatch.start();<a name="line.607"></a>
-<span class="sourceLineNo">608</span>          ResultScanner s = table.getScanner(scan);<a name="line.608"></a>
-<span class="sourceLineNo">609</span>          s.next();<a name="line.609"></a>
-<span class="sourceLineNo">610</span>          s.close();<a name="line.610"></a>
-<span class="sourceLineNo">611</span>          stopWatch.stop();<a name="line.611"></a>
-<span class="sourceLineNo">612</span>        }<a name="line.612"></a>
-<span class="sourceLineNo">613</span>        successes.incrementAndGet();<a name="line.613"></a>
-<span class="sourceLineNo">614</span>        sink.publishReadTiming(tableName.getNameAsString(), serverName, stopWatch.getTime());<a name="line.614"></a>
-<span class="sourceLineNo">615</span>      } catch (TableNotFoundException tnfe) {<a name="line.615"></a>
-<span class="sourceLineNo">616</span>        LOG.error("Table may be deleted", tnfe);<a name="line.616"></a>
-<span class="sourceLineNo">617</span>        // This is ignored because it doesn't imply that the regionserver is dead<a name="line.617"></a>
-<span class="sourceLineNo">618</span>      } catch (TableNotEnabledException tnee) {<a name="line.618"></a>
-<span class="sourceLineNo">619</span>        // This is considered a success since we got a response.<a name="line.619"></a>
-<span class="sourceLineNo">620</span>        successes.incrementAndGet();<a name="line.620"></a>
-<span class="sourceLineNo">621</span>        LOG.debug("The targeted table was disabled.  Assuming success.");<a name="line.621"></a>
-<span class="sourceLineNo">622</span>      } catch (DoNotRetryIOException dnrioe) {<a name="line.622"></a>
-<span class="sourceLineNo">623</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.623"></a>
-<span class="sourceLineNo">624</span>        LOG.error(dnrioe.toString(), dnrioe);<a name="line.624"></a>
-<span class="sourceLineNo">625</span>      } catch (IOException e) {<a name="line.625"></a>
-<span class="sourceLineNo">626</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.626"></a>
-<span class="sourceLineNo">627</span>        LOG.error(e.toString(), e);<a name="line.627"></a>
-<span class="sourceLineNo">628</span>      } finally {<a name="line.628"></a>
-<span class="sourceLineNo">629</span>        if (table != null) {<a name="line.629"></a>
-<span class="sourceLineNo">630</span>          try {<a name="line.630"></a>
-<span class="sourceLineNo">631</span>            table.close();<a name="line.631"></a>
-<span class="sourceLineNo">632</span>          } catch (IOException e) {/* DO NOTHING */<a name="line.632"></a>
-<span class="sourceLineNo">633</span>            LOG.error("Close table failed", e);<a name="line.633"></a>
-<span class="sourceLineNo">634</span>          }<a name="line.634"></a>
-<span class="sourceLineNo">635</span>        }<a name="line.635"></a>
-<span class="sourceLineNo">636</span>        scan = null;<a name="line.636"></a>
-<span class="sourceLineNo">637</span>        get = null;<a name="line.637"></a>
-<span class="sourceLineNo">638</span>        startKey = null;<a name="line.638"></a>
-<span class="sourceLineNo">639</span>      }<a name="line.639"></a>
-<span class="sourceLineNo">640</span>      return null;<a name="line.640"></a>
-<span class="sourceLineNo">641</span>    }<a name="line.641"></a>
-<span class="sourceLineNo">642</span>  }<a name="line.642"></a>
-<span class="sourceLineNo">643</span><a name="line.643"></a>
-<span class="sourceLineNo">644</span>  private static final int USAGE_EXIT_CODE = 1;<a name="line.644"></a>
-<span class="sourceLineNo">645</span>  private static final int INIT_ERROR_EXIT_CODE = 2;<a name="line.645"></a>
-<span class="sourceLineNo">646</span>  private static final int TIMEOUT_ERROR_EXIT_CODE = 3;<a name="line.646"></a>
-<span class="sourceLineNo">647</span>  private static final int ERROR_EXIT_CODE = 4;<a name="line.647"></a>
-<span class="sourceLineNo">648</span>  private static final int FAILURE_EXIT_CODE = 5;<a name="line.648"></a>
-<span class="sourceLineNo">649</span><a name="line.649"></a>
-<span class="sourceLineNo">650</span>  private static final long DEFAULT_INTERVAL = 60000;<a name="line.650"></a>
-<span class="sourceLineNo">651</span><a name="line.651"></a>
-<span class="sourceLineNo">652</span>  private static final long DEFAULT_TIMEOUT = 600000; // 10 mins<a name="line.652"></a>
-<span class="sourceLineNo">653</span>  private static final int MAX_THREADS_NUM = 16; // #threads to contact regions<a name="line.653"></a>
-<span class="sourceLineNo">654</span><a name="line.654"></a>
-<span class="sourceLineNo">655</span>  private static final Logger LOG = LoggerFactory.getLogger(Canary.class);<a name="line.655"></a>
-<span class="sourceLineNo">656</span><a name="line.656"></a>
-<span class="sourceLineNo">657</span>  public static final TableName DEFAULT_WRITE_TABLE_NAME = TableName.valueOf(<a name="line.657"></a>
-<span class="sourceLineNo">658</span>    NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "canary");<a name="line.658"></a>
-<span class="sourceLineNo">659</span><a name="line.659"></a>
-<span class="sourceLineNo">660</span>  private static final String CANARY_TABLE_FAMILY_NAME = "Test";<a name="line.660"></a>
-<span class="sourceLineNo">661</span><a name="line.661"></a>
-<span class="sourceLineNo">662</span>  private Configuration conf = null;<a name="line.662"></a>
-<span class="sourceLineNo">663</span>  private long interval = 0;<a name="line.663"></a>
-<span class="sourceLineNo">664</span>  private Sink sink = null;<a name="line.664"></a>
-<span class="sourceLineNo">665</span><a name="line.665"></a>
-<span class="sourceLineNo">666</span>  /**<a name="line.666"></a>
-<span class="sourceLineNo">667</span>   * True if we are to run in 'regionServer' mode.<a name="line.667"></a>
-<span class="sourceLineNo">668</span>   */<a name="line.668"></a>
-<span class="sourceLineNo">669</span>  private boolean regionServerMode = false;<a name="line.669"></a>
-<span class="sourceLineNo">670</span><a name="line.670"></a>
-<span class="sourceLineNo">671</span>  /**<a name="line.671"></a>
-<span class="sourceLineNo">672</span>   * True if we are to run in zookeeper 'mode'.<a name="line.672"></a>
-<span class="sourceLineNo">673</span>   */<a name="line.673"></a>
-<span class="sourceLineNo">674</span>  private boolean zookeeperMode = false;<a name="line.674"></a>
-<span class="sourceLineNo">675</span><a name="line.675"></a>
-<span class="sourceLineNo">676</span>  /**<a name="line.676"></a>
-<span class="sourceLineNo">677</span>   * This is a Map of table to timeout. The timeout is for reading all regions in the table; i.e.<a name="line.677"></a>
-<span class="sourceLineNo">678</span>   * we aggregate time to fetch each region and it needs to be less than this value else we<a name="line.678"></a>
-<span class="sourceLineNo">679</span>   * log an ERROR.<a name="line.679"></a>
-<span class="sourceLineNo">680</span>   */<a name="line.680"></a>
-<span class="sourceLineNo">681</span>  private HashMap&lt;String, Long&gt; configuredReadTableTimeouts = new HashMap&lt;&gt;();<a name="line.681"></a>
-<span class="sourceLineNo">682</span><a name="line.682"></a>
-<span class="sourceLineNo">683</span>  public static final String HBASE_CANARY_REGIONSERVER_ALL_REGIONS<a name="line.683"></a>
-<span class="sourceLineNo">684</span>          = "hbase.canary.regionserver_all_regions";<a name="line.684"></a>
-<span class="sourceLineNo">685</span><a name="line.685"></a>
-<span class="sourceLineNo">686</span>  public static final String HBASE_CANARY_REGION_WRITE_SNIFFING<a name="line.686"></a>
-<span class="sourceLineNo">687</span>          = "hbase.canary.region.write.sniffing";<a name="line.687"></a>
-<span class="sourceLineNo">688</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT<a name="line.688"></a>
-<span class="sourceLineNo">689</span>          = "hbase.canary.region.write.table.timeout";<a name="line.689"></a>
-<span class="sourceLineNo">690</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_NAME<a name="line.690"></a>
-<span class="sourceLineNo">691</span>          = "hbase.canary.region.write.table.name";<a name="line.691"></a>
-<span class="sourceLineNo">692</span>  public static final String HBASE_CANARY_REGION_READ_TABLE_TIMEOUT<a name="line.692"></a>
-<span class="sourceLineNo">693</span>          = "hbase.canary.region.read.table.timeout";<a name="line.693"></a>
-<span class="sourceLineNo">694</span><a name="line.694"></a>
-<span class="sourceLineNo">695</span>  public static final String HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES<a name="line.695"></a>
-<span class="sourceLineNo">696</span>          = "hbase.canary.zookeeper.permitted.failures";<a name="line.696"></a>
-<span class="sourceLineNo">697</span><a name="line.697"></a>
-<span class="sourceLineNo">698</span>  public static final String HBASE_CANARY_USE_REGEX = "hbase.canary.use.regex";<a name="line.698"></a>
-<span class="sourceLineNo">699</span>  public static final String HBASE_CANARY_TIMEOUT = "hbase.canary.timeout";<a name="line.699"></a>
-<span class="sourceLineNo">700</span>  public static final String HBASE_CANARY_FAIL_ON_ERROR = "hbase.canary.fail.on.error";<a name="line.700"></a>
-<span class="sourceLineNo">701</span><a name="line.701"></a>
+<span class="sourceLineNo">495</span>          sink.updateReadFailures(region == null? "NULL": region.getRegionNameAsString(),<a name="line.495"></a>
+<span class="sourceLineNo">496</span>              serverName == null? "NULL": serverName.getHostname());<a name="line.496"></a>
+<span class="sourceLineNo">497</span>        } finally {<a name="line.497"></a>
+<span class="sourceLineNo">498</span>          if (rs != null) {<a name="line.498"></a>
+<span class="sourceLineNo">499</span>            rs.close();<a name="line.499"></a>
+<span class="sourceLineNo">500</span>          }<a name="line.500"></a>
+<span class="sourceLineNo">501</span>          scan = null;<a name="line.501"></a>
+<span class="sourceLineNo">502</span>          get = null;<a name="line.502"></a>
+<span class="sourceLineNo">503</span>        }<a name="line.503"></a>
+<span class="sourceLineNo">504</span>      }<a name="line.504"></a>
+<span class="sourceLineNo">505</span>      try {<a name="line.505"></a>
+<span class="sourceLineNo">506</span>        table.close();<a name="line.506"></a>
+<span class="sourceLineNo">507</span>      } catch (IOException e) {<a name="line.507"></a>
+<span class="sourceLineNo">508</span>        LOG.error("Close table failed", e);<a name="line.508"></a>
+<span class="sourceLineNo">509</span>      }<a name="line.509"></a>
+<span class="sourceLineNo">510</span>      return null;<a name="line.510"></a>
+<span class="sourceLineNo">511</span>    }<a name="line.511"></a>
+<span class="sourceLineNo">512</span><a name="line.512"></a>
+<span class="sourceLineNo">513</span>    /**<a name="line.513"></a>
+<span class="sourceLineNo">514</span>     * Check writes for the canary table<a name="line.514"></a>
+<span class="sourceLineNo">515</span>     */<a name="line.515"></a>
+<span class="sourceLineNo">516</span>    private Void write() {<a name="line.516"></a>
+<span class="sourceLineNo">517</span>      Table table = null;<a name="line.517"></a>
+<span class="sourceLineNo">518</span>      TableDescriptor tableDesc = null;<a name="line.518"></a>
+<span class="sourceLineNo">519</span>      try {<a name="line.519"></a>
+<span class="sourceLineNo">520</span>        table = connection.getTable(region.getTable());<a name="line.520"></a>
+<span class="sourceLineNo">521</span>        tableDesc = table.getDescriptor();<a name="line.521"></a>
+<span class="sourceLineNo">522</span>        byte[] rowToCheck = region.getStartKey();<a name="line.522"></a>
+<span class="sourceLineNo">523</span>        if (rowToCheck.length == 0) {<a name="line.523"></a>
+<span class="sourceLineNo">524</span>          rowToCheck = new byte[]{0x0};<a name="line.524"></a>
+<span class="sourceLineNo">525</span>        }<a name="line.525"></a>
+<span class="sourceLineNo">526</span>        int writeValueSize =<a name="line.526"></a>
+<span class="sourceLineNo">527</span>            connection.getConfiguration().getInt(HConstants.HBASE_CANARY_WRITE_VALUE_SIZE_KEY, 10);<a name="line.527"></a>
+<span class="sourceLineNo">528</span>        for (ColumnFamilyDescriptor column : tableDesc.getColumnFamilies()) {<a name="line.528"></a>
+<span class="sourceLineNo">529</span>          Put put = new Put(rowToCheck);<a name="line.529"></a>
+<span class="sourceLineNo">530</span>          byte[] value = new byte[writeValueSize];<a name="line.530"></a>
+<span class="sourceLineNo">531</span>          Bytes.random(value);<a name="line.531"></a>
+<span class="sourceLineNo">532</span>          put.addColumn(column.getName(), HConstants.EMPTY_BYTE_ARRAY, value);<a name="line.532"></a>
+<span class="sourceLineNo">533</span><a name="line.533"></a>
+<span class="sourceLineNo">534</span>          LOG.debug("Writing to {} {} {} {}",<a name="line.534"></a>
+<span class="sourceLineNo">535</span>            tableDesc.getTableName(), region.getRegionNameAsString(), column.getNameAsString(),<a name="line.535"></a>
+<span class="sourceLineNo">536</span>            Bytes.toStringBinary(rowToCheck));<a name="line.536"></a>
+<span class="sourceLineNo">537</span>          try {<a name="line.537"></a>
+<span class="sourceLineNo">538</span>            long startTime = System.currentTimeMillis();<a name="line.538"></a>
+<span class="sourceLineNo">539</span>            table.put(put);<a name="line.539"></a>
+<span class="sourceLineNo">540</span>            long time = System.currentTimeMillis() - startTime;<a name="line.540"></a>
+<span class="sourceLineNo">541</span>            this.readWriteLatency.add(time);<a name="line.541"></a>
+<span class="sourceLineNo">542</span>            sink.publishWriteTiming(serverName, region, column, time);<a name="line.542"></a>
+<span class="sourceLineNo">543</span>          } catch (Exception e) {<a name="line.543"></a>
+<span class="sourceLineNo">544</span>            sink.publishWriteFailure(serverName, region, column, e);<a name="line.544"></a>
+<span class="sourceLineNo">545</span>          }<a name="line.545"></a>
+<span class="sourceLineNo">546</span>        }<a name="line.546"></a>
+<span class="sourceLineNo">547</span>        table.close();<a name="line.547"></a>
+<span class="sourceLineNo">548</span>      } catch (IOException e) {<a name="line.548"></a>
+<span class="sourceLineNo">549</span>        sink.publishWriteFailure(serverName, region, e);<a name="line.549"></a>
+<span class="sourceLineNo">550</span>        sink.updateWriteFailures(region.getRegionNameAsString(), serverName.getHostname() );<a name="line.550"></a>
+<span class="sourceLineNo">551</span>      }<a name="line.551"></a>
+<span class="sourceLineNo">552</span>      return null;<a name="line.552"></a>
+<span class="sourceLineNo">553</span>    }<a name="line.553"></a>
+<span class="sourceLineNo">554</span>  }<a name="line.554"></a>
+<span class="sourceLineNo">555</span><a name="line.555"></a>
+<span class="sourceLineNo">556</span>  /**<a name="line.556"></a>
+<span class="sourceLineNo">557</span>   * Run a single RegionServer Task and then exit.<a name="line.557"></a>
+<span class="sourceLineNo">558</span>   * Get one row from a region on the regionserver and output latency or the failure.<a name="line.558"></a>
+<span class="sourceLineNo">559</span>   */<a name="line.559"></a>
+<span class="sourceLineNo">560</span>  static class RegionServerTask implements Callable&lt;Void&gt; {<a name="line.560"></a>
+<span class="sourceLineNo">561</span>    private Connection connection;<a name="line.561"></a>
+<span class="sourceLineNo">562</span>    private String serverName;<a name="line.562"></a>
+<span class="sourceLineNo">563</span>    private RegionInfo region;<a name="line.563"></a>
+<span class="sourceLineNo">564</span>    private RegionServerStdOutSink sink;<a name="line.564"></a>
+<span class="sourceLineNo">565</span>    private AtomicLong successes;<a name="line.565"></a>
+<span class="sourceLineNo">566</span><a name="line.566"></a>
+<span class="sourceLineNo">567</span>    RegionServerTask(Connection connection, String serverName, RegionInfo region,<a name="line.567"></a>
+<span class="sourceLineNo">568</span>        RegionServerStdOutSink sink, AtomicLong successes) {<a name="line.568"></a>
+<span class="sourceLineNo">569</span>      this.connection = connection;<a name="line.569"></a>
+<span class="sourceLineNo">570</span>      this.serverName = serverName;<a name="line.570"></a>
+<span class="sourceLineNo">571</span>      this.region = region;<a name="line.571"></a>
+<span class="sourceLineNo">572</span>      this.sink = sink;<a name="line.572"></a>
+<span class="sourceLineNo">573</span>      this.successes = successes;<a name="line.573"></a>
+<span class="sourceLineNo">574</span>    }<a name="line.574"></a>
+<span class="sourceLineNo">575</span><a name="line.575"></a>
+<span class="sourceLineNo">576</span>    @Override<a name="line.576"></a>
+<span class="sourceLineNo">577</span>    public Void call() {<a name="line.577"></a>
+<span class="sourceLineNo">578</span>      TableName tableName = null;<a name="line.578"></a>
+<span class="sourceLineNo">579</span>      Table table = null;<a name="line.579"></a>
+<span class="sourceLineNo">580</span>      Get get = null;<a name="line.580"></a>
+<span class="sourceLineNo">581</span>      byte[] startKey = null;<a name="line.581"></a>
+<span class="sourceLineNo">582</span>      Scan scan = null;<a name="line.582"></a>
+<span class="sourceLineNo">583</span>      StopWatch stopWatch = new StopWatch();<a name="line.583"></a>
+<span class="sourceLineNo">584</span>      // monitor one region on every region server<a name="line.584"></a>
+<span class="sourceLineNo">585</span>      stopWatch.reset();<a name="line.585"></a>
+<span class="sourceLineNo">586</span>      try {<a name="line.586"></a>
+<span class="sourceLineNo">587</span>        tableName = region.getTable();<a name="line.587"></a>
+<span class="sourceLineNo">588</span>        table = connection.getTable(tableName);<a name="line.588"></a>
+<span class="sourceLineNo">589</span>        startKey = region.getStartKey();<a name="line.589"></a>
+<span class="sourceLineNo">590</span>        // Can't do a get on empty start row so do a Scan of first element if any instead.<a name="line.590"></a>
+<span class="sourceLineNo">591</span>        LOG.debug("Reading from {} {} {} {}",<a name="line.591"></a>
+<span class="sourceLineNo">592</span>          serverName, region.getTable(), region.getRegionNameAsString(),<a name="line.592"></a>
+<span class="sourceLineNo">593</span>          Bytes.toStringBinary(startKey));<a name="line.593"></a>
+<span class="sourceLineNo">594</span>        if (startKey.length &gt; 0) {<a name="line.594"></a>
+<span class="sourceLineNo">595</span>          get = new Get(startKey);<a name="line.595"></a>
+<span class="sourceLineNo">596</span>          get.setCacheBlocks(false);<a name="line.596"></a>
+<span class="sourceLineNo">597</span>          get.setFilter(new FirstKeyOnlyFilter());<a name="line.597"></a>
+<span class="sourceLineNo">598</span>          stopWatch.start();<a name="line.598"></a>
+<span class="sourceLineNo">599</span>          table.get(get);<a name="line.599"></a>
+<span class="sourceLineNo">600</span>          stopWatch.stop();<a name="line.600"></a>
+<span class="sourceLineNo">601</span>        } else {<a name="line.601"></a>
+<span class="sourceLineNo">602</span>          scan = new Scan();<a name="line.602"></a>
+<span class="sourceLineNo">603</span>          scan.setCacheBlocks(false);<a name="line.603"></a>
+<span class="sourceLineNo">604</span>          scan.setFilter(new FirstKeyOnlyFilter());<a name="line.604"></a>
+<span class="sourceLineNo">605</span>          scan.setCaching(1);<a name="line.605"></a>
+<span class="sourceLineNo">606</span>          scan.setMaxResultSize(1L);<a name="line.606"></a>
+<span class="sourceLineNo">607</span>          scan.setOneRowLimit();<a name="line.607"></a>
+<span class="sourceLineNo">608</span>          stopWatch.start();<a name="line.608"></a>
+<span class="sourceLineNo">609</span>          ResultScanner s = table.getScanner(scan);<a name="line.609"></a>
+<span class="sourceLineNo">610</span>          s.next();<a name="line.610"></a>
+<span class="sourceLineNo">611</span>          s.close();<a name="line.611"></a>
+<span class="sourceLineNo">612</span>          stopWatch.stop();<a name="line.612"></a>
+<span class="sourceLineNo">613</span>        }<a name="line.613"></a>
+<span class="sourceLineNo">614</span>        successes.incrementAndGet();<a name="line.614"></a>
+<span class="sourceLineNo">615</span>        sink.publishReadTiming(tableName.getNameAsString(), serverName, stopWatch.getTime());<a name="line.615"></a>
+<span class="sourceLineNo">616</span>      } catch (TableNotFoundException tnfe) {<a name="line.616"></a>
+<span class="sourceLineNo">617</span>        LOG.error("Table may be deleted", tnfe);<a name="line.617"></a>
+<span class="sourceLineNo">618</span>        // This is ignored because it doesn't imply that the regionserver is dead<a name="line.618"></a>
+<span class="sourceLineNo">619</span>      } catch (TableNotEnabledException tnee) {<a name="line.619"></a>
+<span class="sourceLineNo">620</span>        // This is considered a success since we got a response.<a name="line.620"></a>
+<span class="sourceLineNo">621</span>        successes.incrementAndGet();<a name="line.621"></a>
+<span class="sourceLineNo">622</span>        LOG.debug("The targeted table was disabled.  Assuming success.");<a name="line.622"></a>
+<span class="sourceLineNo">623</span>      } catch (DoNotRetryIOException dnrioe) {<a name="line.623"></a>
+<span class="sourceLineNo">624</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.624"></a>
+<span class="sourceLineNo">625</span>        LOG.error(dnrioe.toString(), dnrioe);<a name="line.625"></a>
+<span class="sourceLineNo">626</span>      } catch (IOException e) {<a name="line.626"></a>
+<span class="sourceLineNo">627</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.627"></a>
+<span class="sourceLineNo">628</span>        LOG.error(e.toString(), e);<a name="line.628"></a>
+<span class="sourceLineNo">629</span>      } finally {<a name="line.629"></a>
+<span class="sourceLineNo">630</span>        if (table != null) {<a name="line.630"></a>
+<span class="sourceLineNo">631</span>          try {<a name="line.631"></a>
+<span class="sourceLineNo">632</span>            table.close();<a name="line.632"></a>
+<span class="sourceLineNo">633</span>          } catch (IOException e) {/* DO NOTHING */<a name="line.633"></a>
+<span class="sourceLineNo">634</span>            LOG.error("Close table failed", e);<a name="line.634"></a>
+<span class="sourceLineNo">635</span>          }<a name="line.635"></a>
+<span class="sourceLineNo">636</span>        }<a name="line.636"></a>
+<span class="sourceLineNo">637</span>        scan = null;<a name="line.637"></a>
+<span class="sourceLineNo">638</span>        get = null;<a name="line.638"></a>
+<span class="sourceLineNo">639</span>        startKey = null;<a name="line.639"></a>
+<span class="sourceLineNo">640</span>      }<a name="line.640"></a>
+<span class="sourceLineNo">641</span>      return null;<a name="line.641"></a>
+<span class="sourceLineNo">642</span>    }<a name="line.642"></a>
+<span class="sourceLineNo">643</span>  }<a name="line.643"></a>
+<span class="sourceLineNo">644</span><a name="line.644"></a>
+<span class="sourceLineNo">645</span>  private static final int USAGE_EXIT_CODE = 1;<a name="line.645"></a>
+<span class="sourceLineNo">646</span>  private static final int INIT_ERROR_EXIT_CODE = 2;<a name="line.646"></a>
+<span class="sourceLineNo">647</span>  private static final int TIMEOUT_ERROR_EXIT_CODE = 3;<a name="line.647"></a>
+<span class="sourceLineNo">648</span>  private static final int ERROR_EXIT_CODE = 4;<a name="line.648"></a>
+<span class="sourceLineNo">649</span>  private static final int FAILURE_EXIT_CODE = 5;<a name="line.649"></a>
+<span class="sourceLineNo">650</span><a name="line.650"></a>
+<span class="sourceLineNo">651</span>  private static final long DEFAULT_INTERVAL = 60000;<a name="line.651"></a>
+<span class="sourceLineNo">652</span><a name="line.652"></a>
+<span class="sourceLineNo">653</span>  private static final long DEFAULT_TIMEOUT = 600000; // 10 mins<a name="line.653"></a>
+<span class="sourceLineNo">654</span>  private static final int MAX_THREADS_NUM = 16; // #threads to contact regions<a name="line.654"></a>
+<span class="sourceLineNo">655</span><a name="line.655"></a>
+<span class="sourceLineNo">656</span>  private static final Logger LOG = LoggerFactory.getLogger(Canary.class);<a name="line.656"></a>
+<span class="sourceLineNo">657</span><a name="line.657"></a>
+<span class="sourceLineNo">658</span>  public static final TableName DEFAULT_WRITE_TABLE_NAME = TableName.valueOf(<a name="line.658"></a>
+<span class="sourceLineNo">659</span>    NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "canary");<a name="line.659"></a>
+<span class="sourceLineNo">660</span><a name="line.660"></a>
+<span class="sourceLineNo">661</span>  private static final String CANARY_TABLE_FAMILY_NAME = "Test";<a name="line.661"></a>
+<span class="sourceLineNo">662</span><a name="line.662"></a>
+<span class="sourceLineNo">663</span>  private Configuration conf = null;<a name="line.663"></a>
+<span class="sourceLineNo">664</span>  private long interval = 0;<a name="line.664"></a>
+<span class="sourceLineNo">665</span>  private Sink sink = null;<a name="line.665"></a>
+<span class="sourceLineNo">666</span><a name="line.666"></a>
+<span class="sourceLineNo">667</span>  /**<a name="line.667"></a>
+<span class="sourceLineNo">668</span>   * True if we are to run in 'regionServer' mode.<a name="line.668"></a>
+<span class="sourceLineNo">669</span>   */<a name="line.669"></a>
+<span class="sourceLineNo">670</span>  private boolean regionServerMode = false;<a name="line.670"></a>
+<span class="sourceLineNo">671</span><a name="line.671"></a>
+<span class="sourceLineNo">672</span>  /**<a name="line.672"></a>
+<span class="sourceLineNo">673</span>   * True if we are to run in zookeeper 'mode'.<a name="line.673"></a>
+<span class="sourceLineNo">674</span>   */<a name="line.674"></a>
+<span class="sourceLineNo">675</span>  private boolean zookeeperMode = false;<a name="line.675"></a>
+<span class="sourceLineNo">676</span><a name="line.676"></a>
+<span class="sourceLineNo">677</span>  /**<a name="line.677"></a>
+<span class="sourceLineNo">678</span>   * This is a Map of table to timeout. The timeout is for reading all regions in the table; i.e.<a name="line.678"></a>
+<span class="sourceLineNo">679</span>   * we aggregate time to fetch each region and it needs to be less than this value else we<a name="line.679"></a>
+<span class="sourceLineNo">680</span>   * log an ERROR.<a name="line.680"></a>
+<span class="sourceLineNo">681</span>   */<a name="line.681"></a>
+<span class="sourceLineNo">682</span>  private HashMap&lt;String, Long&gt; configuredReadTableTimeouts = new HashMap&lt;&gt;();<a name="line.682"></a>
+<span class="sourceLineNo">683</span><a name="line.683"></a>
+<span class="sourceLineNo">684</span>  public static final String HBASE_CANARY_REGIONSERVER_ALL_REGIONS<a name="line.684"></a>
+<span class="sourceLineNo">685</span>          = "hbase.canary.regionserver_all_regions";<a name="line.685"></a>
+<span class="sourceLineNo">686</span><a name="line.686"></a>
+<span class="sourceLineNo">687</span>  public static final String HBASE_CANARY_REGION_WRITE_SNIFFING<a name="line.687"></a>
+<span class="sourceLineNo">688</span>          = "hbase.canary.region.write.sniffing";<a name="line.688"></a>
+<span class="sourceLineNo">689</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT<a name="line.689"></a>
+<span class="sourceLineNo">690</span>          = "hbase.canary.region.write.table.timeout";<a name="line.690"></a>
+<span class="sourceLineNo">691</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_NAME<a name="line.691"></a>
+<span class="sourceLineNo">692</span>          = "hbase.canary.region.write.table.name";<a name="line.692"></a>
+<span class="sourceLineNo">693</span>  public static final String HBASE_CANARY_REGION_READ_TABLE_TIMEOUT<a name="line.693"></a>
+<span class="sourceLineNo">694</span>          = "hbase.canary.region.read.table.timeout";<a name="line.694"></a>
+<span class="sourceLineNo">695</span><a name="line.695"></a>
+<span class="sourceLineNo">696</span>  public static final String HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES<a name="line.696"></a>
+<span class="sourceLineNo">697</span>          = "hbase.canary.zookeeper.permitted.failures";<a name="line.697"></a>
+<span class="sourceLineNo">698</span><a name="line.698"></a>
+<span class="sourceLineNo">699</span>  public static final String HBASE_CANARY_USE_REGEX = "hbase.canary.use.regex";<a name="line.699"></a>
+<span class="sourceLineNo">700</span>  public static final String HBASE_CANARY_TIMEOUT = "hbase.canary.timeout";<a name="line.700"></a>
+<span class="sourceLineNo">701</span>  public static final String HBASE_CANARY_FAIL_ON_ERROR = "hbase.canary.fail.on.error";<a name="line.701"></a>
 <span class="sourceLineNo">702</span><a name="line.702"></a>
-<span class="sourceLineNo">703</span>  private ExecutorService executor; // threads to retrieve data from regionservers<a name="line.703"></a>
-<span class="sourceLineNo">704</span><a name="line.704"></a>
-<span class="sourceLineNo">705</span>  public CanaryTool() {<a name="line.705"></a>
-<span class="sourceLineNo">706</span>    this(new ScheduledThreadPoolExecutor(1));<a name="line.706"></a>
-<span class="sourceLineNo">707</span>  }<a name="line.707"></a>
-<span class="sourceLineNo">708</span><a name="line.708"></a>
-<span class="sourceLineNo">709</span>  public CanaryTool(ExecutorService executor) {<a name="line.709"></a>
-<span class="sourceLineNo">710</span>    this(executor, null);<a name="line.710"></a>
-<span class="sourceLineNo">711</span>  }<a name="line.711"></a>
-<span class="sourceLineNo">712</span><a name="line.712"></a>
-<span class="sourceLineNo">713</span>  @VisibleForTesting<a name="line.713"></a>
-<span class="sourceLineNo">714</span>  CanaryTool(ExecutorService executor, Sink sink) {<a name="line.714"></a>
-<span class="sourceLineNo">715</span>    this.executor = executor;<a name="line.715"></a>
-<span class="sourceLineNo">716</span>    this.sink = sink;<a name="line.716"></a>
-<span class="sourceLineNo">717</span>  }<a name="line.717"></a>
-<span class="sourceLineNo">718</span><a name="line.718"></a>
-<span class="sourceLineNo">719</span>  CanaryTool(Configuration conf, ExecutorService executor) {<a name="line.719"></a>
-<span class="sourceLineNo">720</span>    this(conf, executor, null);<a name="line.720"></a>
-<span class="sourceLineNo">721</span>  }<a name="line.721"></a>
-<span class="sourceLineNo">722</span><a name="line.722"></a>
-<span class="sourceLineNo">723</span>  CanaryTool(Configuration conf, ExecutorService executor, Sink sink) {<a name="line.723"></a>
-<span class="sourceLineNo">724</span>    this(executor, sink);<a name="line.724"></a>
-<span class="sourceLineNo">725</span>    setConf(conf);<a name="line.725"></a>
-<span class="sourceLineNo">726</span>  }<a name="line.726"></a>
-<span class="sourceLineNo">727</span><a name="line.727"></a>
-<span class="sourceLineNo">728</span>  @Override<a name="line.728"></a>
-<span class="sourceLineNo">729</span>  public Configuration getConf() {<a name="line.729"></a>
-<span class="sourceLineNo">730</span>    return conf;<a name="line.730"></a>
-<span class="sourceLineNo">731</span>  }<a name="line.731"></a>
-<span class="sourceLineNo">732</span><a name="line.732"></a>
-<span class="sourceLineNo">733</span>  @Override<a name="line.733"></a>
-<span class="sourceLineNo">734</span>  public void setConf(Configuration conf) {<a name="line.734"></a>
-<span class="sourceLineNo">735</span>    if (conf == null) {<a name="line.735"></a>
-<span class="sourceLineNo">736</span>      conf = HBaseConfiguration.create();<a name="line.736"></a>
-<span class="sourceLineNo">737</span>    }<a name="line.737"></a>
-<span class="sourceLineNo">738</span>    this.conf = conf;<a name="line.738"></a>
-<span class="sourceLineNo">739</span>  }<a name="line.739"></a>
-<span class="sourceLineNo">740</span><a name="line.740"></a>
-<span class="sourceLineNo">741</span>  private int parseArgs(String[] args) {<a name="line.741"></a>
-<span class="sourceLineNo">742</span>    int index = -1;<a name="line.742"></a>
-<span class="sourceLineNo">743</span>    long permittedFailures = 0;<a name="line.743"></a>
-<span class="sourceLineNo">744</span>    boolean regionServerAllRegions = false, writeSniffing = false;<a name="line.744"></a>
-<span class="sourceLineNo">745</span>    String readTableTimeoutsStr = null;<a name="line.745"></a>
-<span class="sourceLineNo">746</span><a name="line.746"></a>
-<span class="sourceLineNo">747</span>    // Process command line args<a name="line.747"></a>
-<span class="sourceLineNo">748</span>    for (int i = 0; i &lt; args.length; i++) {<a name="line.748"></a>
-<span class="sourceLineNo">749</span>      String cmd = args[i];<a name="line.749"></a>
-<span class="sourceLineNo">750</span><a name="line.750"></a>
-<span class="sourceLineNo">751</span>      if (cmd.startsWith("-")) {<a name="line.751"></a>
-<span class="sourceLineNo">752</span>        if (index &gt;= 0) {<a name="line.752"></a>
-<span class="sourceLineNo">753</span>          // command line args must be in the form: [opts] [table 1 [table 2 ...]]<a name="line.753"></a>
-<span class="sourceLineNo">754</span>          System.err.println("Invalid command line options");<a name="line.754"></a>
-<span class="sourceLineNo">755</span>          printUsageAndExit();<a name="line.755"></a>
-<span class="sourceLineNo">756</span>        }<a name="line.756"></a>
-<span class="sourceLineNo">757</span><a name="line.757"></a>
-<span class="sourceLineNo">758</span>        if (cmd.equals("-help") || cmd.equals("-h")) {<a name="line.758"></a>
-<span class="sourceLineNo">759</span>          // user asked for help, print the help and quit.<a name="line.759"></a>
-<span class="sourceLineNo">760</span>          printUsageAndExit();<a name="line.760"></a>
-<span class="sourceLineNo">761</span>        } else if (cmd.equals("-daemon") &amp;&amp; interval == 0) {<a name="line.761"></a>
-<span class="sourceLineNo">762</span>          // user asked for daemon mode, set a default interval between checks<a name="line.762"></a>
-<span class="sourceLineNo">763</span>          interval = DEFAULT_INTERVAL;<a name="line.763"></a>
-<span class="sourceLineNo">764</span>        } else if (cmd.equals("-interval")) {<a name="line.764"></a>
-<span class="sourceLineNo">765</span>          // user has specified an interval for canary breaths (-interval N)<a name="line.765"></a>
-<span class="sourceLineNo">766</span>          i++;<a name="line.766"></a>
-<span class="sourceLineNo">767</span><a name="line.767"></a>
-<span class="sourceLineNo">768</span>          if (i == args.length) {<a name="line.768"></a>
-<span class="sourceLineNo">769</span>            System.err.println("-interval takes a numeric seconds value argument.");<a name="line.769"></a>
-<span class="sourceLineNo">770</span>            printUsageAndExit();<a name="line.770"></a>
-<span class="sourceLineNo">771</span>          }<a name="line.771"></a>
-<span class="sourceLineNo">772</span><a name="line.772"></a>
-<span class="sourceLineNo">773</span>          try {<a name="line.773"></a>
-<span class="sourceLineNo">774</span>            interval = Long.parseLong(args[i]) * 1000;<a name="line.774"></a>
-<span class="sourceLineNo">775</span>          } catch (NumberFormatException e) {<a name="line.775"></a>
-<span class="sourceLineNo">776</span>            System.err.println("-interval needs a numeric value argument.");<a name="line.776"></a>
-<span class="sourceLineNo">777</span>            printUsageAndExit();<a name="line.777"></a>
-<span class="sourceLineNo">778</span>          }<a name="line.778"></a>
-<span class="sourceLineNo">779</span>        } else if (cmd.equals("-zookeeper")) {<a name="line.779"></a>
-<span class="sourceLineNo">780</span>          this.zookeeperMode = true;<a name="line.780"></a>
-<span class="sourceLineNo">781</span>        } else if(cmd.equals("-regionserver")) {<a name="line.781"></a>
-<span class="sourceLineNo">782</span>          this.regionServerMode = true;<a name="line.782"></a>
-<span class="sourceLineNo">783</span>        } else if(cmd.equals("-allRegions")) {<a name="line.783"></a>
-<span class="sourceLineNo">784</span>          conf.setBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, true);<a name="line.784"></a>
-<span class="sourceLineNo">785</span>          regionServerAllRegions = true;<a name="line.785"></a>
-<span class="sourceLineNo">786</span>        } else if(cmd.equals("-writeSniffing")) {<a name="line.786"></a>
-<span class="sourceLineNo">787</span>          writeSniffing = true;<a name="line.787"></a>
-<span class="sourceLineNo">788</span>          conf.setBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, true);<a name="line.788"></a>
-<span class="sourceLineNo">789</span>        } else if(cmd.equals("-treatFailureAsError") || cmd.equals("-failureAsError")) {<a name="line.789"></a>
-<span class="sourceLineNo">790</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.790"></a>
-<span class="sourceLineNo">791</span>        } else if (cmd.equals("-e")) {<a name="line.791"></a>
-<span class="sourceLineNo">792</span>          conf.setBoolean(HBASE_CANARY_USE_REGEX, true);<a name="line.792"></a>
-<span class="sourceLineNo">793</span>        } else if (cmd.equals("-t")) {<a name="line.793"></a>
-<span class="sourceLineNo">794</span>          i++;<a name="line.794"></a>
-<span class="sourceLineNo">795</span><a name="line.795"></a>
-<span class="sourceLineNo">796</span>          if (i == args.length) {<a name="line.796"></a>
-<span class="sourceLineNo">797</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.797"></a>
-<span class="sourceLineNo">798</span>            printUsageAndExit();<a name="line.798"></a>
-<span class="sourceLineNo">799</span>          }<a name="line.799"></a>
-<span class="sourceLineNo">800</span>          long timeout = 0;<a name="line.800"></a>
-<span class="sourceLineNo">801</span>          try {<a name="line.801"></a>
-<span class="sourceLineNo">802</span>            timeout = Long.parseLong(args[i]);<a name="line.802"></a>
-<span class="sourceLineNo">803</span>          } catch (NumberFormatException e) {<a name="line.803"></a>
-<span class="sourceLineNo">804</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.804"></a>
-<span class="sourceLineNo">805</span>            printUsageAndExit();<a name="line.805"></a>
-<span class="sourceLineNo">806</span>          }<a name="line.806"></a>
-<span class="sourceLineNo">807</span>          conf.setLong(HBASE_CANARY_TIMEOUT, timeout);<a name="line.807"></a>
-<span class="sourceLineNo">808</span>        } else if(cmd.equals("-writeTableTimeout")) {<a name="line.808"></a>
-<span class="sourceLineNo">809</span>          i++;<a name="line.809"></a>
-<span class="sourceLineNo">810</span><a name="line.810"></a>
-<span class="sourceLineNo">811</span>          if (i == args.length) {<a name="line.811"></a>
-<span class="sourceLineNo">812</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.812"></a>
-<span class="sourceLineNo">813</span>            printUsageAndExit();<a name="line.813"></a>
-<span class="sourceLineNo">814</span>          }<a name="line.814"></a>
-<span class="sourceLineNo">815</span>          long configuredWriteTableTimeout = 0;<a name="line.815"></a>
-<span class="sourceLineNo">816</span>          try {<a name="line.816"></a>
-<span class="sourceLineNo">817</span>            configuredWriteTableTimeout = Long.parseLong(args[i]);<a name="line.817"></a>
-<span class="sourceLineNo">818</span>          } catch (NumberFormatException e) {<a name="line.818"></a>
-<span class="sourceLineNo">819</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.819"></a>
-<span class="sourceLineNo">820</span>            printUsageAndExit();<a name="line.820"></a>
-<span class="sourceLineNo">821</span>          }<a name="line.821"></a>
-<span class="sourceLineNo">822</span>          conf.setLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, configuredWriteTableTimeout);<a name="line.822"></a>
-<span class="sourceLineNo">823</span>        } else if (cmd.equals("-writeTable")) {<a name="line.823"></a>
-<span class="sourceLineNo">824</span>          i++;<a name="line.824"></a>
-<span class="sourceLineNo">825</span><a name="line.825"></a>
-<span class="sourceLineNo">826</span>          if (i == args.length) {<a name="line.826"></a>
-<span class="sourceLineNo">827</span>            System.err.println("-writeTable takes a string tablename value argument.");<a name="line.827"></a>
-<span class="sourceLineNo">828</span>            printUsageAndExit();<a name="line.828"></a>
-<span class="sourceLineNo">829</span>          }<a name="line.829"></a>
-<span class="sourceLineNo">830</span>          conf.set(HBASE_CANARY_REGION_WRITE_TABLE_NAME, args[i]);<a name="line.830"></a>
-<span class="sourceLineNo">831</span>        } else if (cmd.equals("-f")) {<a name="line.831"></a>
-<span class="sourceLineNo">832</span>          i++;<a name="line.832"></a>
-<span class="sourceLineNo">833</span><a name="line.833"></a>
-<span class="sourceLineNo">834</span>          if (i == args.length) {<a name="line.834"></a>
-<span class="sourceLineNo">835</span>            System.err<a name="line.835"></a>
-<span class="sourceLineNo">836</span>                .println("-f needs a boolean value argument (true|false).");<a name="line.836"></a>
-<span class="sourceLineNo">837</span>            printUsageAndExit();<a name="line.837"></a>
-<span class="sourceLineNo">838</span>          }<a name="line.838"></a>
-<span class="sourceLineNo">839</span><a name="line.839"></a>
-<span class="sourceLineNo">840</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, Boolean.parseBoolean(args[i]));<a name="line.840"></a>
-<span class="sourceLineNo">841</span>        } else if (cmd.equals("-readTableTimeouts")) {<a name="line.841"></a>
-<span class="sourceLineNo">842</span>          i++;<a name="line.842"></a>
-<span class="sourceLineNo">843</span><a name="line.843"></a>
-<span class="sourceLineNo">844</span>          if (i == args.length) {<a name="line.844"></a>
-<span class="sourceLineNo">845</span>            System.err.println("-readTableTimeouts needs a comma-separated list of read " +<a name="line.845"></a>
-<span class="sourceLineNo">846</span>                "millisecond timeouts per table (without spaces).");<a name="line.846"></a>
-<span class="sourceLineNo">847</span>            printUsageAndExit();<a name="line.847"></a>
-<span class="sourceLineNo">848</span>          }<a name="line.848"></a>
-<span class="sourceLineNo">849</span>          readTableTimeoutsStr = args[i];<a name="line.849"></a>
-<span class="sourceLineNo">850</span>          conf.set(HBASE_CANARY_REGION_READ_TABLE_TIMEOUT, readTableTimeoutsStr);<a name="line.850"></a>
-<span class="sourceLineNo">851</span>        } else if (cmd.equals("-permittedZookeeperFailures")) {<a name="line.851"></a>
-<span class="sourceLineNo">852</span>          i++;<a name="line.852"></a>
-<span class="sourceLineNo">853</span><a name="line.853"></a>
-<span class="sourceLineNo">854</span>          if (i == args.length) {<a name="line.854"></a>
-<span class="sourceLineNo">855</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.855"></a>
-<span class="sourceLineNo">856</span>            printUsageAndExit();<a name="line.856"></a>
-<span class="sourceLineNo">857</span>          }<a name="line.857"></a>
-<span class="sourceLineNo">858</span>          try {<a name="line.858"></a>
-<span class="sourceLineNo">859</span>            permittedFailures = Long.parseLong(args[i]);<a name="line.859"></a>
-<span class="sourceLineNo">860</span>          } catch (NumberFormatException e) {<a name="line.860"></a>
-<span class="sourceLineNo">861</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.861"></a>
-<span class="sourceLineNo">862</span>            printUsageAndExit();<a name="line.862"></a>
-<span class="sourceLineNo">863</span>          }<a name="line.863"></a>
-<span class="sourceLineNo">864</span>          conf.setLong(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, permittedFailures);<a name="line.864"></a>
-<span class="sourceLineNo">865</span>        } else {<a name="line.865"></a>
-<span class="sourceLineNo">866</span>          // no options match<a name="line.866"></a>
-<span class="sourceLineNo">867</span>          System.err.println(cmd + " options is invalid.");<a name="line.867"></a>
-<span class="sourceLineNo">868</span>          printUsageAndExit();<a name="line.868"></a>
-<span class="sourceLineNo">869</span>        }<a name="line.869"></a>
-<span class="sourceLineNo">870</span>      } else if (index &lt; 0) {<a name="line.870"></a>
-<span class="sourceLineNo">871</span>        // keep track of first table name specified by the user<a name="line.871"></a>
-<span class="sourceLineNo">872</span>        index = i;<a name="line.872"></a>
-<span class="sourceLineNo">873</span>      }<a name="line.873"></a>
-<span class="sourceLineNo">874</span>    }<a name="line.874"></a>
-<span class="sourceLineNo">875</span>    if (regionServerAllRegions &amp;&amp; !this.regionServerMode) {<a name="line.875"></a>
-<span class="sourceLineNo">876</span>      System.err.println("-allRegions can only be specified in regionserver mode.");<a name="line.876"></a>
-<span class="sourceLineNo">877</span>      printUsageAndExit();<a name="line.877"></a>
-<span class="sourceLineNo">878</span>    }<a name="line.878"></a>
-<span class="sourceLineNo">879</span>    if (this.zookeeperMode) {<a name="line.879"></a>
-<span class="sourceLineNo">880</span>      if (this.regionServerMode || regionServerAllRegions || writeSniffing) {<a name="line.880"></a>
-<span class="sourceLineNo">881</span>        System.err.println("-zookeeper is exclusive and cannot be combined with "<a name="line.881"></a>
-<span class="sourceLineNo">882</span>            + "other modes.");<a name="line.882"></a>
-<span class="sourceLineNo">883</span>        printUsageAndExit();<a name="line.883"></a>
-<span class="sourceLineNo">884</span>      }<a name="line.884"></a>
-<span class="sourceLineNo">885</span>    }<a name="line.885"></a>
-<span class="sourceLineNo">886</span>    if (permittedFailures != 0 &amp;&amp; !this.zookeeperMode) {<a name="line.886"></a>
-<span class="sourceLineNo">887</span>      System.err.println("-permittedZookeeperFailures requires -zookeeper mode.");<a name="line.887"></a>
-<span class="sourceLineNo">888</span>      printUsageAndExit();<a name="line.888"></a>
-<span class="sourceLineNo">889</span>    }<a name="line.889"></a>
-<span class="sourceLineNo">890</span>    if (readTableTimeoutsStr != null &amp;&amp; (this.regionServerMode || this.zookeeperMode)) {<a name="line.890"></a>
-<span class="sourceLineNo">891</span>      System.err.println("-readTableTimeouts can only be configured in region mode.");<a name="line.891"></a>
-<span class="sourceLineNo">892</span>      printUsageAndExit();<a name="line.892"></a>
-<span class="sourceLineNo">893</span>    }<a name="line.893"></a>
-<span class="sourceLineNo">894</span>    return index;<a name="line.894"></a>
-<span class="sourceLineNo">895</span>  }<a name="line.895"></a>
-<span class="sourceLineNo">896</span><a name="line.896"></a>
-<span class="sourceLineNo">897</span>  @Override<a name="line.897"></a>
-<span class="sourceLineNo">898</span>  public int run(String[] args) throws Exception {<a name="line.898"></a>
-<span class="sourceLineNo">899</span>    int index = parseArgs(args);<a name="line.899"></a>
-<span class="sourceLineNo">900</span>    String[] monitorTargets = null;<a name="line.900"></a>
-<span class="sourceLineNo">901</span><a name="line.901"></a>
-<span class="sourceLineNo">902</span>    if (index &gt;= 0) {<a name="line.902"></a>
-<span class="sourceLineNo">903</span>      int length = args.length - index;<a name="line.903"></a>
-<span class="sourceLineNo">904</span>      monitorTargets = new String[length];<a name="line.904"></a>
-<span class="sourceLineNo">905</span>      System.arraycopy(args, index, monitorTargets, 0, length);<a name="line.905"></a>
-<span class="sourceLineNo">906</span>    }<a name="line.906"></a>
-<span class="sourceLineNo">907</span><a name="line.907"></a>
-<span class="sourceLineNo">908</span>    if (zookeeperMode) {<a name="line.908"></a>
-<span class="sourceLineNo">909</span>      return checkZooKeeper();<a name="line.909"></a>
-<span class="sourceLineNo">910</span>    } else if (regionServerMode) {<a name="line.910"></a>
-<span class="sourceLineNo">911</span>      return checkRegionServers(monitorTargets);<a name="line.911"></a>
-<span class="sourceLineNo">912</span>    } else {<a name="line.912"></a>
-<span class="sourceLineNo">913</span>      return checkRegions(monitorTargets);<a name="line.913"></a>
-<span class="sourceLineNo">914</span>    }<a name="line.914"></a>
-<span class="sourceLineNo">915</span>  }<a name="line.915"></a>
-<span class="sourceLineNo">916</span><a name="line.916"></a>
-<span class="sourceLineNo">917</span>  private int runMonitor(String[] monitorTargets) throws Exception {<a name="line.917"></a>
-<span class="sourceLineNo">918</span>    ChoreService choreService = null;<a name="line.918"></a>
-<span class="sourceLineNo">919</span><a name="line.919"></a>
-<span class="sourceLineNo">920</span>    // Launches chore for refreshing kerberos credentials if security is enabled.<a name="line.920"></a>
-<span class="sourceLineNo">921</span>    // Please see http://hbase.apache.org/book.html#_running_canary_in_a_kerberos_enabled_cluster<a name="line.921"></a>
-<span class="sourceLineNo">922</span>    // for more details.<a name="line.922"></a>
-<span class="sourceLineNo">923</span>    final ScheduledChore authChore = AuthUtil.getAuthChore(conf);<a name="line.923"></a>
-<span class="sourceLineNo">924</span>    if (authChore != null) {<a name="line.924"></a>
-<span class="sourceLineNo">925</span>      choreService = new ChoreService("CANARY_TOOL");<a name="line.925"></a>
-<span class="sourceLineNo">926</span>      choreService.scheduleChore(authChore);<a name="line.926"></a>
-<span class="sourceLineNo">927</span>    }<a name="line.927"></a>
-<span class="sourceLineNo">928</span><a name="line.928"></a>
-<span class="sourceLineNo">929</span>    // Start to prepare the stuffs<a name="line.929"></a>
-<span class="sourceLineNo">930</span>    Monitor monitor = null;<a name="line.930"></a>
-<span class="sourceLineNo">931</span>    Thread monitorThread;<a name="line.931"></a>
-<span class="sourceLineNo">932</span>    long startTime = 0;<a name="line.932"></a>
-<span class="sourceLineNo">933</span>    long currentTimeLength = 0;<a name="line.933"></a>
-<span class="sourceLineNo">934</span>    boolean failOnError = conf.getBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.934"></a>
-<span class="sourceLineNo">935</span>    long timeout = conf.getLong(HBASE_CANARY_TIMEOUT, DEFAULT_TIMEOUT);<a name="line.935"></a>
-<span class="sourceLineNo">936</span>    // Get a connection to use in below.<a name="line.936"></a>
-<span class="sourceLineNo">937</span>    try (Connection connection = ConnectionFactory.createConnection(this.conf)) {<a name="line.937"></a>
-<span class="sourceLineNo">938</span>      do {<a name="line.938"></a>
-<span class="sourceLineNo">939</span>        // Do monitor !!<a name="line.939"></a>
-<span class="sourceLineNo">940</span>        try {<a name="line.940"></a>
-<span class="sourceLineNo">941</span>          monitor = this.newMonitor(connection, monitorTargets);<a name="line.941"></a>
-<span class="sourceLineNo">942</span>          monitorThread = new Thread(monitor, "CanaryMonitor-" + System.currentTimeMillis());<a name="line.942"></a>
-<span class="sourceLineNo">943</span>          startTime = System.currentTimeMillis();<a name="line.943"></a>
-<span class="sourceLineNo">944</span>          monitorThread.start();<a name="line.944"></a>
-<span class="sourceLineNo">945</span>          while (!monitor.isDone()) {<a name="line.945"></a>
-<span class="sourceLineNo">946</span>            // wait for 1 sec<a name="line.946"></a>
-<span class="sourceLineNo">947</span>            Thread.sleep(1000);<a name="line.947"></a>
-<span class="sourceLineNo">948</span>            // exit if any error occurs<a name="line.948"></a>
-<span class="sourceLineNo">949</span>            if (failOnError &amp;&amp; monitor.hasError()) {<a name="line.949"></a>
-<span class="sourceLineNo">950</span>              monitorThread.interrupt();<a name="line.950"></a>
-<span class="sourceLineNo">951</span>              if (monitor.initialized) {<a name="line.951"></a>
-<span class="sourceLineNo">952</span>                return monitor.errorCode;<a name="line.952"></a>
-<span class="sourceLineNo">953</span>              } else {<a name="line.953"></a>
-<span class="sourceLineNo">954</span>                return INIT_ERROR_EXIT_CODE;<a name="line.954"></a>
-<span class="sourceLineNo">955</span>              }<a name="line.955"></a>
-<span class="sourceLineNo">956</span>            }<a name="line.956"></a>
-<span class="sourceLineNo">957</span>            currentTimeLength = System.currentTimeMillis() - startTime;<a name="line.957"></a>
-<span class="sourceLineNo">958</span>            if (currentTimeLength &gt; timeout) {<a name="line.958"></a>
-<span class="sourceLineNo">959</span>              LOG.error("The monitor is running too long (" + currentTimeLength<a name="line.959"></a>
-<span class="sourceLineNo">960</span>                  + ") after timeout limit:" + timeout<a name="line.960"></a>
-<span class="sourceLineNo">961</span>                  + " will be killed itself !!");<a name="line.961"></a>
-<span class="sourceLineNo">962</span>              if (monitor.initialized) {<a name="line.962"></a>
-<span class="sourceLineNo">963</span>                return TIMEOUT_ERROR_EXIT_CODE;<a name="line.963"></a>
-<span class="sourceLineNo">964</span>              } else {<a name="line.964"></a>
-<span class="sourceLineNo">965</span>                return INIT_ERROR_EXIT_CODE;<a name="line.965"></a>
-<span class="sourceLineNo">966</span>              }<a name="line.966"></a>
-<span class="sourceLineNo">967</span>            }<a name="line.967"></a>
-<span class="sourceLineNo">968</span>          }<a name="line.968"></a>
-<span class="sourceLineNo">969</span><a name="line.969"></a>
-<span class="sourceLineNo">970</span>          if (failOnError &amp;&amp; monitor.finalCheckForErrors()) {<a name="line.970"></a>
-<span class="sourceLineNo">971</span>            monitorThread.interrupt();<a name="line.971"></a>
-<span class="sourceLineNo">972</span>            return monitor.errorCode;<a name="line.972"></a>
-<span class="sourceLineNo">973</span>          }<a name="line.973"></a>
-<span class="sourceLineNo">974</span>        } finally {<a name="line.974"></a>
-<span class="sourceLineNo">975</span>          if (monitor != null) monitor.close();<a name="line.975"></a>
-<span class="sourceLineNo">976</span>        }<a name="line.976"></a>
-<span class="sourceLineNo">977</span><a name="line.977"></a>
-<span class="sourceLineNo">978</span>        Thread.sleep(interval);<a name="line.978"></a>
-<span class="sourceLineNo">979</span>      } while (interval &gt; 0);<a name="line.979"></a>
-<span class="sourceLineNo">980</span>    } // try-with-resources close<a name="line.980"></a>
-<span class="sourceLineNo">981</span><a name="line.981"></a>
-<span class="sourceLineNo">982</span>    if (choreService != null) {<a name="line.982"></a>
-<span class="sourceLineNo">983</span>      choreService.shutdown();<a name="line.983"></a>
-<span class="sourceLineNo">984</span>    }<a name="line.984"></a>
-<span class="sourceLineNo">985</span>    return monitor.errorCode;<a name="line.985"></a>
-<span class="sourceLineNo">986</span>  }<a name="line.986"></a>
-<span class="sourceLineNo">987</span><a name="line.987"></a>
-<span class="sourceLineNo">988</span>  @Override<a name="line.988"></a>
-<span class="sourceLineNo">989</span>  public Map&lt;String, String&gt; getReadFailures()  {<a name="line.989"></a>
-<span class="sourceLineNo">990</span>    return sink.getReadFailures();<a name="line.990"></a>
-<span class="sourceLineNo">991</span>  }<a name="line.991"></a>
-<span class="sourceLineNo">992</span><a name="line.992"></a>
-<span class="sourceLineNo">993</span>  @Override<a name="line.993"></a>
-<span class="sourceLineNo">994</span>  public Map&lt;String, String&gt; getWriteFailures()  {<a name="line.994"></a>
-<span class="sourceLineNo">995</span>    return sink.getWriteFailures();<a name="line.995"></a>
-<span class="sourceLineNo">996</span>  }<a name="line.996"></a>
-<span class="sourceLineNo">997</span><a name="line.997"></a>
-<span class="sourceLineNo">998</span>  private void printUsageAndExit() {<a name="line.998"></a>
-<span class="sourceLineNo">999</span>    System.err.println(<a name="line.999"></a>
-<span class="sourceLineNo">1000</span>      "Usage: canary [OPTIONS] [&lt;TABLE1&gt; [&lt;TABLE2]...] | [&lt;REGIONSERVER1&gt; [&lt;REGIONSERVER2]..]");<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>    System.err.println("Where [OPTIONS] are:");<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>    System.err.println(" -h,-help        show this help and exit.");<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>    System.err.println(" -regionserver   set 'regionserver mode'; gets row from random region on " +<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>        "server");<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>    System.err.println(" -allRegions     get from ALL regions when 'regionserver mode', not just " +<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>        "random one.");<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>    System.err.println(" -zookeeper      set 'zookeeper mode'; grab zookeeper.znode.parent on " +<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>        "each ensemble member");<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>    System.err.println(" -daemon         continuous check at defined intervals.");<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>    System.err.println(" -interval &lt;N&gt;   interval between checks in seconds");<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>    System.err.println(" -e              consider table/regionserver argument as regular " +<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>        "expression");<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>    System.err.println(" -f &lt;B&gt;          exit on first error; default=true");<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>    System.err.println(" -failureAsError treat read/write failure as error");<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>    System.err.println(" -t &lt;N&gt;          timeout for canary-test run; default=600000ms");<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>    System.err.println(" -writeSniffing  enable write sniffing");<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span>    System.err.println(" -writeTable     the table used for write sniffing; default=hbase:canary");<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>    System.err.println(" -writeTableTimeout &lt;N&gt;  timeout for writeTable; default=600000ms");<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>    System.err.println(" -readTableTimeouts &lt;tableName&gt;=&lt;read timeout&gt;," +<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span>        "&lt;tableName&gt;=&lt;read timeout&gt;,...");<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>    System.err.println("                comma-separated list of table read timeouts " +<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>        "(no spaces);");<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>    System.err.println("                logs 'ERROR' if takes longer. default=600000ms");<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>    System.err.println(" -permittedZookeeperFailures &lt;N&gt;  Ignore first N failures attempting to ");<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>    System.err.println("                connect to individual zookeeper nodes in ensemble");<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>    System.err.println("");<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>    System.err.println(" -D&lt;configProperty&gt;=&lt;value&gt; to assign or override configuration params");<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>    System.err.println(" -Dhbase.canary.read.raw.enabled=&lt;true/false&gt; Set to enable/disable " +<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>        "raw scan; default=false");<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span>    System.err.println("");<a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>    System.err.println("Canary runs in one of three modes: region (default), regionserver, or " +<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>        "zookeeper.");<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>    System.err.println("To sniff/probe all regions, pass no arguments.");<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>    System.err.println("To sniff/probe all regions of a table, pass tablename.");<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>    System.err.println("To sniff/probe regionservers, pass -regionserver, etc.");<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>    System.err.println("See http://hbase.apache.org/book.html#_canary for Canary documentation.");<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>    System.exit(USAGE_EXIT_CODE);<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>  }<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span><a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>  Sink getSink(Configuration configuration, Class clazz) {<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>    // In test context, this.sink might be set. Use it if non-null. For testing.<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>    return this.sink != null? this.sink:<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>        (Sink)ReflectionUtils.newInstance(configuration.getClass("hbase.canary.sink.class",<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>            clazz, Sink.class));<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>  }<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span><a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>  /**<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>   * Canary region mode-specific data structure which stores information about each region<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>   * to be scanned<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>   */<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>  public static class RegionTaskResult {<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>    private RegionInfo region;<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>    private TableName tableName;<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>    private ServerName serverName;<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>    private ColumnFamilyDescriptor column;<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>    private AtomicLong readLatency = null;<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>    private AtomicLong writeLatency = null;<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>    private boolean readSuccess = false;<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>    private boolean writeSuccess = false;<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span><a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>    public RegionTaskResult(RegionInfo region, TableName tableName, ServerName serverName,<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>        ColumnFamilyDescriptor column) {<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>      this.region = region;<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>      this.tableName = tableName;<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>      this.serverName = serverName;<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>      this.column = column;<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>    }<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span><a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>    public RegionInfo getRegionInfo() {<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>      return this.region;<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span>    }<a name="line.1071"></a>
-<span class="sourceLineNo">1072</span><a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>    public String getRegionNameAsString() {<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>      return this.region.getRegionNameAsString();<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span>    }<a name="line.1075"></a>
-<span class="sourceLineNo">1076</span><a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>    public TableName getTableName() {<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span>      return this.tableName;<a name="line.1078"></a>
-<span class="sourceLineNo">1079</span>    }<a name="line.1079"></a>
-<span class="sourceLineNo">1080</span><a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>    public String getTableNameAsString() {<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>      return this.tableName.getNameAsString();<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span>    }<a name="line.1083"></a>
-<span class="sourceLineNo">1084</span><a name="line.1084"></a>
-<span class="sourceLineNo">1085</span>    public ServerName getServerName() {<a name="line.1085"></a>
-<span class="sourceLineNo">1086</span>      return this.serverName;<a name="line.1086"></a>
-<span class="sourceLineNo">1087</span>    }<a name="line.1087"></a>
-<span class="sourceLineNo">1088</span><a name="line.1088"></a>
-<span class="sourceLineNo">1089</span>    public String getServerNameAsString() {<a name="line.1089"></a>
-<span class="sourceLineNo">1090</span>      return this.serverName.getServerName();<a name="line.1090"></a>
-<span class="sourceLineNo">1091</span>    }<a name="line.1091"></a>
-<span class="sourceLineNo">1092</span><a name="line.1092"></a>
-<span class="sourceLineNo">1093</span>    public ColumnFamilyDescriptor getColumnFamily() {<a name="line.1093"></a>
-<span class="sourceLineNo">1094</span>      return this.column;<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>    }<a name="line.1095"></a>
-<span class="sourceLineNo">1096</span><a name="line.1096"></a>
-<span class="sourceLineNo">1097</span>    public String getColumnFamilyNameAsString() {<a name="line.1097"></a>
-<span class="sourceLineNo">1098</span>      return this.column.getNameAsString();<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span>    }<a name="line.1099"></a>
-<span class="sourceLineNo">1100</span><a name="line.1100"></a>
-<span class="sourceLineNo">1101</span>    public long getReadLatency() {<a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>      if (this.readLatency == null) {<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>        return -1;<a name="line.1103"></a>
-<span class="sourceLineNo">1104</span>      }<a name="line.1104"></a>
-<span class="sourceLineNo">1105</span>      return this.readLatency.get();<a name="line.1105"></a>
-<span class="sourceLineNo">1106</span>    }<a name="line.1106"></a>
-<span class="sourceLineNo">1107</span><a name="line.1107"></a>
-<span class="sourceLineNo">1108</span>    public void setReadLatency(long readLatency) {<a name="line.1108"></a>
-<span class="sourceLineNo">1109</span>      if (this.readLatency != null) {<a name="line.1109"></a>
-<span class="sourceLineNo">1110</span>        this.readLatency.set(readLatency);<a name="line.1110"></a>
-<span class="sourceLineNo">1111</span>      } else {<a name="line.1111"></a>
-<span class="sourceLineNo">1112</span>        this.readLatency = new AtomicLong(readLatency);<a name="line.1112"></a>
-<span class="sourceLineNo">1113</span>      }<a name="line.1113"></a>
-<span class="sourceLineNo">1114</span>    }<a name="line.1114"></a>
-<span class="sourceLineNo">1115</span><a name="line.1115"></a>
-<span class="sourceLineNo">1116</span>    public long getWriteLatency() {<a name="line.1116"></a>
-<span class="sourceLineNo">1117</span>      if (this.writeLatency == null) {<a name="line.1117"></a>
-<span class="sourceLineNo">1118</span>        return -1;<a name="line.1118"></a>
-<span class="sourceLineNo">1119</span>      }<a name="line.1119"></a>
-<span class="sourceLineNo">1120</span>      return this.writeLatency.get();<a name="line.1120"></a>
-<span class="sourceLineNo">1121</span>    }<a name="line.1121"></a>
-<span class="sourceLineNo">1122</span><a name="line.1122"></a>
-<span class="sourceLineNo">1123</span>    public void setWriteLatency(long writeLatency) {<a name="line.1123"></a>
-<span class="sourceLineNo">1124</span>      if (this.writeLatency != null) {<a name="line.1124"></a>
-<span class="sourceLineNo">1125</span>        this.writeLatency.set(writeLatency);<a name="line.1125"></a>
-<span class="sourceLineNo">1126</span>      } else {<a name="line.1126"></a>
-<span class="sourceLineNo">1127</span>        this.writeLatency = new AtomicLong(writeLatency);<a name="line.1127"></a>
-<span class="sourceLineNo">1128</span>      }<a name="line.1128"></a>
-<span class="sourceLineNo">1129</span>    }<a name="line.1129"></a>
-<span class="sourceLineNo">1130</span><a name="line.1130"></a>
-<span class="sourceLineNo">1131</span>    public boolean isReadSuccess() {<a name="line.1131"></a>
-<span class="sourceLineNo">1132</span>      return this.readSuccess;<a name="line.1132"></a>
-<span class="sourceLineNo">1133</span>    }<a name="line.1133"></a>
-<span class="sourceLineNo">1134</span><a name="line.1134"></a>
-<span class="sourceLineNo">1135</span>    public void setReadSuccess() {<a name="line.1135"></a>
-<span class="sourceLineNo">1136</span>      this.readSuccess = true;<a name="line.1136"></a>
-<span class="sourceLineNo">1137</span>    }<a name="line.1137"></a>
-<span class="sourceLineNo">1138</span><a name="line.1138"></a>
-<span class="sourceLineNo">1139</span>    public boolean isWriteSuccess() {<a name="line.1139"></a>
-<span class="sourceLineNo">1140</span>      return this.writeSuccess;<a name="line.1140"></a>
-<span class="sourceLineNo">1141</span>    }<a name="line.1141"></a>
-<span class="sourceLineNo">1142</span><a name="line.1142"></a>
-<span class="sourceLineNo">1143</span>    public void setWriteSuccess() {<a name="line.1143"></a>
-<span class="sourceLineNo">1144</span>      this.writeSuccess = true;<a name="line.1144"></a>
-<span class="sourceLineNo">1145</span>    }<a name="line.1145"></a>
-<span class="sourceLineNo">1146</span>  }<a name="line.1146"></a>
-<span class="sourceLineNo">1147</span><a name="line.1147"></a>
-<span class="sourceLineNo">1148</span>  /**<a name="line.1148"></a>
-<span class="sourceLineNo">1149</span>   * A Factory method for {@link Monitor}.<a name="line.1149"></a>
-<span class="sourceLineNo">1150</span>   * Makes a RegionServerMonitor, or a ZooKeeperMonitor, or a RegionMonitor.<a name="line.1150"></a>
-<span class="sourceLineNo">1151</span>   * @return a Monitor instance<a name="line.1151"></a>
-<span class="sourceLineNo">1152</span>   */<a name="line.1152"></a>
-<span class="sourceLineNo">1153</span>  private Monitor newMonitor(final Connection connection, String[] monitorTargets) {<a name="line.1153"></a>
-<span class="sourceLineNo">1154</span>    Monitor monitor;<a name="line.1154"></a>
-<span class="sourceLineNo">1155</span>    boolean useRegExp = conf.getBoolean(HBASE_CANARY_USE_REGEX, false);<a name="line.1155"></a>
-<span class="sourceLineNo">1156</span>    boolean regionServerAllRegions<a name="line.1156"></a>
-<span class="sourceLineNo">1157</span>            = conf.getBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, false);<a name="line.1157"></a>
-<span class="sourceLineNo">1158</span>    boolean failOnError<a name="line.1158"></a>
-<span class="sourceLineNo">1159</span>            = conf.getBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.1159"></a>
-<span class="sourceLineNo">1160</span>    int permittedFailures<a name="line.1160"></a>
-<span class="sourceLineNo">1161</span>            = conf.getInt(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, 0);<a name="line.1161"></a>
-<span class="sourceLineNo">1162</span>    boolean writeSniffing<a name="line.1162"></a>
-<span class="sourceLineNo">1163</span>            = conf.getBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, false);<a name="line.1163"></a>
-<span class="sourceLineNo">1164</span>    String writeTableName = conf.get(HBASE_CANARY_REGION_WRITE_TABLE_NAME,<a name="line.1164"></a>
-<span class="sourceLineNo">1165</span>            DEFAULT_WRITE_TABLE_NAME.getNameAsString());<a name="line.1165"></a>
-<span class="sourceLineNo">1166</span>    long configuredWriteTableTimeout<a name="line.1166"></a>
-<span class="sourceLineNo">1167</span>            = conf.getLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, DEFAULT_TIMEOUT);<a name="line.1167"></a>
-<span class="sourceLineNo">1168</span><a name="line.1168"></a>
-<span class="sourceLineNo">1169</span>    if (this.regionServerMode) {<a name="line.1169"></a>
-<span class="sourceLineNo">1170</span>      monitor =<a name="line.1170"></a>
-<span class="sourceLineNo">1171</span>          new RegionServerMonitor(connection, monitorTargets, useRegExp,<a name="line.1171"></a>
-<span class="sourceLineNo">1172</span>              getSink(connection.getConfiguration(), RegionServerStdOutSink.class),<a name="line.1172"></a>
-<span class="sourceLineNo">1173</span>              this.executor, regionServerAllRegions,<a name="line.1173"></a>
-<span class="sourceLineNo">1174</span>              failOnError, permittedFailures);<a name="line.1174"></a>
-<span class="sourceLineNo">1175</span><a name="line.1175"></a>
-<span class="sourceLineNo">1176</span>    } else if (this.zookeeperMode) {<a name="line.1176"></a>
-<span class="sourceLineNo">1177</span>      monitor =<a name="line.1177"></a>
-<span class="sourceLineNo">1178</span>          new ZookeeperMonitor(connection, monitorTargets, useRegExp,<a name="line.1178"></a>
-<span class="sourceLineNo">1179</span>              getSink(connection.getConfiguration(), ZookeeperStdOutSink.class),<a name="line.1179"></a>
-<span class="sourceLineNo">1180</span>              this.executor, failOnError, permittedFailures);<a name="line.1180"></a>
-<span class="sourceLineNo">1181</span>    } else {<a name="line.1181"></a>
-<span class="sourceLineNo">1182</span>      monitor =<a name="line.1182"></a>
-<span class="sourceLineNo">1183</span>          new RegionMonitor(connection, monitorTargets, useRegExp,<a name="line.1183"></a>
-<span class="sourceLineNo">1184</span>              getSink(connection.getConfiguration(), RegionStdOutSink.class),<a name="line.1184"></a>
-<span class="sourceLineNo">1185</span>              this.executor, writeSniffing,<a name="line.1185"></a>
-<span class="sourceLineNo">1186</span>              TableName.valueOf(writeTableName), failOnError, configuredReadTableTimeouts,<a name="line.1186"></a>
-<span class="sourceLineNo">1187</span>              configuredWriteTableTimeout, permittedFailures);<a name="line.1187"></a>
-<span class="sourceLineNo">1188</span>    }<a name="line.1188"></a>
-<span class="sourceLineNo">1189</span>    return monitor;<a name="line.1189"></a>
-<span class="sourceLineNo">1190</span>  }<a name="line.1190"></a>
-<span class="sourceLineNo">1191</span><a name="line.1191"></a>
-<span class="sourceLineNo">1192</span>  private void populateReadTableTimeoutsMap(String configuredReadTableTimeoutsStr) {<a name="line.1192"></a>
-<span class="sourceLineNo">1193</span>    String[] tableTimeouts = configuredReadTableTimeoutsStr.split(",");<a name="line.1193"></a>
-<span class="sourceLineNo">1194</span>    for (String tT : tableTimeouts) {<a name="line.1194"></a>
-<span class="sourceLineNo">1195</span>      String[] nameTimeout = tT.split("=");<a name="line.1195"></a>
-<span class="sourceLineNo">1196</span>      if (nameTimeout.length &lt; 2) {<a name="line.1196"></a>
-<span class="sourceLineNo">1197</span>        throw new IllegalArgumentException("Each -readTableTimeouts argument must be of the form " +<a name="line.1197"></a>
-<span class="sourceLineNo">1198</span>            "&lt;tableName&gt;=&lt;read timeout&gt; (without spaces).");<a name="line.1198"></a>
-<span class="sourceLineNo">1199</span>      }<a name="line.1199"></a>
-<span class="sourceLineNo">1200</span>      long timeoutVal;<a name="line.1200"></a>
-<span class="sourceLineNo">1201</span>      try {<a name="line.1201"></a>
-<span class="sourceLineNo">1202</span>        timeoutVal = Long.parseLong(nameTimeout[1]);<a name="line.1202"></a>
-<span class="sourceLineNo">1203</span>      } catch (NumberFormatException e) {<a name="line.1203"></a>
-<span class="sourceLineNo">1204</span>        throw new IllegalArgumentException("-readTableTimeouts read timeout for each table" +<a name="line.1204"></a>
-<span class="sourceLineNo">1205</span>            " must be a numeric value argument.");<a name="line.1205"></a>
-<span class="sourceLineNo">1206</span>      }<a name="line.1206"></a>
-<span class="sourceLineNo">1207</span>      configuredReadTableTimeouts.put(nameTimeout[0], timeoutVal);<a name="line.1207"></a>
-<span class="sourceLineNo">1208</span>    }<a name="line.1208"></a>
-<span class="sourceLineNo">1209</span>  }<a name="line.1209"></a>
-<span class="sourceLineNo">1210</span>  /**<a name="line.1210"></a>
-<span class="sourceLineNo">1211</span>   * A Monitor super-class can be extended by users<a name="line.1211"></a>
-<span class="sourceLineNo">1212</span>   */<a name="line.1212"></a>
-<span class="sourceLineNo">1213</span>  public static abstract class Monitor implements Runnable, Closeable {<a name="line.1213"></a>
-<span class="sourceLineNo">1214</span>    protected Connection connection;<a name="line.1214"></a>
-<span class="sourceLineNo">1215</span>    protected Admin admin;<a name="line.1215"></a>
-<span class="sourceLineNo">1216</span>    /**<a name="line.1216"></a>
-<span class="sourceLineNo">1217</span>     * 'Target' dependent on 'mode'. Could be Tables or RegionServers or ZNodes.<a name="line.1217"></a>
-<span class="sourceLineNo">1218</span>     * Passed on the command-line as arguments.<a name="line.1218"></a>
-<span class="sourceLineNo">1219</span>     */<a name="line.1219"></a>
-<span class="sourceLineNo">1220</span>    protected String[] targets;<a name="line.1220"></a>
-<span class="sourceLineNo">1221</span>    protected boolean useRegExp;<a name="line.1221"></a>
-<span class="sourceLineNo">1222</span>    protected boolean treatFailureAsError;<a name="line.1222"></a>
-<span class="sourceLineNo">1223</span>    protected boolean initialized = false;<a name="line.1223"></a>
-<span class="sourceLineNo">1224</span><a name="line.1224"></a>
-<span class="sourceLineNo">1225</span>    protected boolean done = false;<a name="line.1225"></a>
-<span class="sourceLineNo">1226</span>    protected int errorCode = 0;<a name="line.1226"></a>
-<span class="sourceLineNo">1227</span>    protected long allowedFailures = 0;<a name="line.1227"></a>
-<span class="sourceLineNo">1228</span>    protected Sink sink;<a name="line.1228"></a>
-<span class="sourceLineNo">1229</span>    protected ExecutorService executor;<a name="line.1229"></a>
-<span class="sourceLineNo">1230</span><a name="line.1230"></a>
-<span class="sourceLineNo">1231</span>    public boolean isDone() {<a name="line.1231"></a>
-<span class="sourceLineNo">1232</span>      return done;<a name="line.1232"></a>
-<span class="sourceLineNo">1233</span>    }<a name="line.1233"></a>
-<span class="sourceLineNo">1234</span><a name="line.1234"></a>
-<span class="sourceLineNo">1235</span>    public boolean hasError() {<a name="line.1235"></a>
-<span class="sourceLineNo">1236</span>      return errorCode != 0;<a name="line.1236"></a>
-<span class="sourceLineNo">1237</span>    }<a name="line.1237"></a>
-<span class="sourceLineNo">1238</span><a name="line.1238"></a>
-<span class="sourceLineNo">1239</span>    public boolean finalCheckForErrors() {<a name="line.1239"></a>
-<span class="sourceLineNo">1240</span>      if (errorCode != 0) {<a name="line.1240"></a>
-<span class="sourceLineNo">1241</span>        return true;<a name="line.1241"></a>
-<span class="sourceLineNo">1242</span>      }<a name="line.1242"></a>
-<span class="sourceLineNo">1243</span>      if (treatFailureAsError &amp;&amp;<a name="line.1243"></a>
-<span class="sourceLineNo">1244</span>          (sink.getReadFailureCount() &gt; allowedFailures || sink.getWriteFailureCount() &gt; allowedFailures)) {<a name="line.1244"></a>
-<span class="sourceLineNo">1245</span>        LOG.error("Too many failures detected, treating failure as error, failing the Canary.");<a name="line.1245"></a>
-<span class="sourceLineNo">1246</span>        errorCode = FAILURE_EXIT_CODE;<a name="line.1246"></a>
-<span class="sourceLineNo">1247</span>        return true;<a name="line.1247"></a>
-<span class="sourceLineNo">1248</span>      }<a name="line.1248"></a>
-<span class="sourceLineNo">1249</span>      return false;<a name="line.1249"></a>
-<span class="sourceLineNo">1250</span>    }<a name="line.1250"></a>
-<span class="sourceLineNo">1251</span><a name="line.1251"></a>
-<span class="sourceLineNo">1252</span>    @Override<a name="line.1252"></a>
-<span class="sourceLineNo">1253</span>    public void close() throws IOException {<a name="line.1253"></a>
-<span class="sourceLineNo">1254</span>      if (this.admin != null) this.admin.close();<a name="line.1254"></a>
-<span class="sourceLineNo">1255</span>    }<a name="line.1255"></a>
-<span class="sourceLineNo">1256</span><a name="line.1256"></a>
-<span class="sourceLineNo">1257</span>    protected Monitor(Connection connection, String[] monitorTargets, boolean useRegExp, Sink sink,<a name="line.1257"></a>
-<span class="sourceLineNo">1258</span>        ExecutorService executor, boolean treatFailureAsError, long allowedFailures) {<a name="line.1258"></a>
-<span class="sourceLineNo">1259</span>      if (null == connection) throw new IllegalArgumentException("connection shall not be null");<a name="line.1259"></a>
-<span class="sourceLineNo">1260</span><a name="line.1260"></a>
-<span class="sourceLineNo">1261</span>      this.connection = connection;<a name="line.1261"></a>
-<span class="sourceLineNo">1262</span>      this.targets = monitorTargets;<a name="line.1262"></a>
-<span class="sourceLineNo">1263</span>      this.useRegExp = useRegExp;<a name="line.1263"></a>
-<span class="sourceLineNo">1264</span>      this.treatFailureAsError = treatFailureAsError;<a name="line.1264"></a>
-<span class="sourceLineNo">1265</span>      this.sink = sink;<a name="line.1265"></a>
-<span class="sourceLineNo">1266</span>      this.executor = executor;<a name="line.1266"></a>
-<span class="sourceLineNo">1267</span>      this.allowedFailures = allowedFailures;<a name="line.1267"></a>
-<span class="sourceLineNo">1268</span>    }<a name="line.1268"></a>
-<span class="sourceLineNo">1269</span><a name="line.1269"></a>
-<span class="sourceLineNo">1270</span>    @Override<a name="line.1270"></a>
-<span class="sourceLineNo">1271</span>    public abstract void run();<a name="line.1271"></a>
-<span class="sourceLineNo">1272</span><a name="line.1272"></a>
-<span class="sourceLineNo">1273</span>    protected boolean initAdmin() {<a name="line.1273"></a>
-<span class="sourceLineNo">1274</span>      if (null == this.admin) {<a name="line.1274"></a>
-<span class="sourceLineNo">1275</span>        try {<a name="line.1275"></a>
-<span class="sourceLineNo">1276</span>          this.admin = this.connection.getAdmin();<a name="line.1276"></a>
-<span class="sourceLineNo">1277</span>        } catch (Exception e) {<a name="line.1277"></a>
-<span class="sourceLineNo">1278</span>          LOG.error("Initial HBaseAdmin failed...", e);<a name="line.1278"></a>
-<span class="sourceLineNo">1279</span>          this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1279"></a>
-<span class="sourceLineNo">1280</span>        }<a name="line.1280"></a>
-<span class="sourceLineNo">1281</span>      } else if (admin.isAborted()) {<a name="line.1281"></a>
-<span class="sourceLineNo">1282</span>        LOG.error("HBaseAdmin aborted");<a name="line.1282"></a>
-<span class="sourceLineNo">1283</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1283"></a>
-<span class="sourceLineNo">1284</span>      }<a name="line.1284"></a>
-<span class="sourceLineNo">1285</span>      return !this.hasError();<a name="line.1285"></a>
-<span class="sourceLineNo">1286</span>    }<a name="line.1286"></a>
-<span class="sourceLineNo">1287</span>  }<a name="line.1287"></a>
-<span class="sourceLineNo">1288</span><a name="line.1288"></a>
-<span class="sourceLineNo">1289</span>  /**<a name="line.1289"></a>
-<span class="sourceLineNo">1290</span>   * A monitor for region mode.<a name="line.1290"></a>
-<span class="sourceLineNo">1291</span>   */<a name="line.1291"></a>
-<span class="sourceLineNo">1292</span>  private static class RegionMonitor extends Monitor {<a name="line.1292"></a>
-<span class="sourceLineNo">1293</span>    // 10 minutes<a name="line.1293"></a>
-<span class="sourceLineNo">1294</span>    private static final int DEFAULT_WRITE_TABLE_CHECK_PERIOD = 10 * 60 * 1000;<a name="line.1294"></a>
-<span class="sourceLineNo">1295</span>    // 1 days<a name="line.1295"></a>
-<span class="sourceLineNo">1296</span>    private static final int DEFAULT_WRITE_DATA_TTL = 24 * 60 * 60;<a name="line.1296"></a>
-<span class="sourceLineNo">1297</span><a name="line.1297"></a>
-<span class="sourceLineNo">1298</span>    private long lastCheckTime = -1;<a name="line.1298"></a>
-<span class="sourceLineNo">1299</span>    private boolean writeSniffing;<a name="line.1299"></a>
-<span class="sourceLineNo">1300</span>    private TableName writeTableName;<a name="line.1300"></a>
-<span class="sourceLineNo">1301</span>    private int writeDataTTL;<a name="line.1301"></a>
-<span class="sourceLineNo">1302</span>    private float regionsLowerLimit;<a name="line.1302"></a>
-<span class="sourceLineNo">1303</span>    private float regionsUpperLimit;<a name="line.1303"></a>
-<span class="sourceLineNo">1304</span>    private int checkPeriod;<a name="line.1304"></a>
-<span class="sourceLineNo">1305</span>    private boolean rawScanEnabled;<a name="line.1305"></a>
-<span class="sourceLineNo">1306</span><a name="line.1306"></a>
-<span class="sourceLineNo">1307</span>    /**<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span>     * This is a timeout per table. If read of each region in the table aggregated takes longer<a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>     * than what is configured here, we log an ERROR rather than just an INFO.<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span>     */<a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>    private HashMap&lt;String, Long&gt; configuredReadTableTimeouts;<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span><a name="line.1312"></a>
-<span class="sourceLineNo">1313</span>    private long configuredWriteTableTimeout;<a name="line.1313"></a>
-<span class="sourceLineNo">1314</span><a name="line.1314"></a>
-<span class="sourceLineNo">1315</span>    public RegionMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>        Sink sink, ExecutorService executor, boolean writeSniffing, TableName writeTableName,<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span>        boolean treatFailureAsError, HashMap&lt;String, Long&gt; configuredReadTableTimeouts,<a name="line.1317"></a>
-<span class="sourceLineNo">1318</span>        long configuredWriteTableTimeout,<a name="line.1318"></a>
-<span class="sourceLineNo">1319</span>        long allowedFailures) {<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>      super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError,<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span>          allowedFailures);<a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>      Configuration conf = connection.getConfiguration();<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span>      this.writeSniffing = writeSniffing;<a name="line.1323"></a>
-<span class="sourceLineNo">1324</span>      this.writeTableName = writeTableName;<a name="line.1324"></a>
-<span class="sourceLineNo">1325</span>      this.writeDataTTL =<a name="line.1325"></a>
-<span class="sourceLineNo">1326</span>          conf.getInt(HConstants.HBASE_CANARY_WRITE_DATA_TTL_KEY, DEFAULT_WRITE_DATA_TTL);<a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>      this.regionsLowerLimit =<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span>          conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY, 1.0f);<a name="line.1328"></a>
-<span class="sourceLineNo">1329</span>      this.regionsUpperLimit =<a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>          conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_UPPERLIMIT_KEY, 1.5f);<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span>      this.checkPeriod =<a name="line.1331"></a>
-<span class="sourceLineNo">1332</span>          conf.getInt(HConstants.HBASE_CANARY_WRITE_TABLE_CHECK_PERIOD_KEY,<a name="line.1332"></a>
-<span class="sourceLineNo">1333</span>            DEFAULT_WRITE_TABLE_CHECK_PERIOD);<a name="line.1333"></a>
-<span class="sourceLineNo">1334</span>      this.rawScanEnabled = conf.getBoolean(HConstants.HBASE_CANARY_READ_RAW_SCAN_KEY, false);<a name="line.1334"></a>
-<span class="sourceLineNo">1335</span>      this.configuredReadTableTimeouts = new HashMap&lt;&gt;(configuredReadTableTimeouts);<a name="line.1335"></a>
-<span class="sourceLineNo">1336</span>      this.configuredWriteTableTimeout = configuredWriteTableTimeout;<a name="line.1336"></a>
-<span class="sourceLineNo">1337</span>    }<a name="line.1337"></a>
-<span class="sourceLineNo">1338</span><a name="line.1338"></a>
-<span class="sourceLineNo">1339</span>    private RegionStdOutSink getSink() {<a name="line.1339"></a>
-<span class="sourceLineNo">1340</span>      if (!(sink instanceof RegionStdOutSink)) {<a name="line.1340"></a>
-<span class="sourceLineNo">1341</span>        throw new RuntimeException("Can only write to Region sink");<a name="line.1341"></a>
-<span class="sourceLineNo">1342</span>      }<a name="line.1342"></a>
-<span class="sourceLineNo">1343</span>      return ((RegionStdOutSink) sink);<a name="line.1343"></a>
-<span class="sourceLineNo">1344</span>    }<a name="line.1344"></a>
-<span class="sourceLineNo">1345</span><a name="line.1345"></a>
-<span class="sourceLineNo">1346</span>    @Override<a name="line.1346"></a>
-<span class="sourceLineNo">1347</span>    public void run() {<a name="line.1347"></a>
-<span class="sourceLineNo">1348</span>      if (this.initAdmin()) {<a name="line.1348"></a>
-<span class="sourceLineNo">1349</span>        try {<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span>          List&lt;Future&lt;Void&gt;&gt; taskFutures = new LinkedList&lt;&gt;();<a name="line.1350"></a>
-<span class="sourceLineNo">1351</span>          RegionStdOutSink regionSink = this.getSink();<a name="line.1351"></a>
-<span class="sourceLineNo">1352</span>          if (this.targets != null &amp;&amp; this.targets.length &gt; 0) {<a name="line.1352"></a>
-<span class="sourceLineNo">1353</span>            String[] tables = generateMonitorTables(this.targets);<a name="line.1353"></a>
-<span class="sourceLineNo">1354</span>            // Check to see that each table name passed in the -readTableTimeouts argument is also<a name="line.1354"></a>
-<span class="sourceLineNo">1355</span>            // passed as a monitor target.<a name="line.1355"></a>
-<span class="sourceLineNo">1356</span>            if (!new HashSet&lt;&gt;(Arrays.asList(tables)).<a name="line.1356"></a>
-<span class="sourceLineNo">1357</span>                containsAll(this.configuredReadTableTimeouts.keySet())) {<a name="line.1357"></a>
-<span class="sourceLineNo">1358</span>              LOG.error("-readTableTimeouts can only specify read timeouts for monitor targets " +<a name="line.1358"></a>
-<span class="sourceLineNo">1359</span>                  "passed via command line.");<a name="line.1359"></a>
-<span class="sourceLineNo">1360</span>              this.errorCode = USAGE_EXIT_CODE;<a name="line.1360"></a>
-<span class="sourceLineNo">1361</span>              return;<a name="line.1361"></a>
-<span class="sourceLineNo">1362</span>            }<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>            this.initialized = true;<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span>            for (String table : tables) {<a name="line.1364"></a>
-<span class="sourceLineNo">1365</span>              LongAdder readLatency = regionSink.initializeAndGetReadLatencyForTable(table);<a name="line.1365"></a>
-<span class="sourceLineNo">1366</span>              taskFutures.addAll(CanaryTool.sniff(admin, regionSink, table, executor, TaskType.READ,<a name="line.1366"></a>
-<span class="sourceLineNo">1367</span>                this.rawScanEnabled, readLatency));<a name="line.1367"></a>
-<span class="sourceLineNo">1368</span>            }<a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>          } else {<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span>            taskFutures.addAll(sniff(TaskType.READ, regionSink));<a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>          }<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span><a name="line.1372"></a>
-<span class="sourceLineNo">1373</span>          if (writeSniffing) {<a name="line.1373"></a>
-<span class="sourceLineNo">1374</span>            if (EnvironmentEdgeManager.currentTime() - lastCheckTime &gt; checkPeriod) {<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>              try {<a name="line.1375"></a>
-<span class="sourceLineNo">1376</span>                checkWriteTableDistribution();<a name="line.1376"></a>
-<span class="sourceLineNo">1377</span>              } catch (IOException e) {<a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>                LOG.error("Check canary table distribution failed!", e);<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span>              }<a name="line.1379"></a>
-<span class="sourceLineNo">1380</span>              lastCheckTime = EnvironmentEdgeManager.currentTime();<a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>            }<a name="line.1381"></a>
-<span class="sourceLineNo">1382</span>            // sniff canary table with write operation<a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>            regionSink.initializeWriteLatency();<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span>            LongAdder writeTableLatency = regionSink.getWriteLatency();<a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>            taskFutures.addAll(CanaryTool.sniff(admin, regionSink, admin.getDescriptor(writeTableName),<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span>              executor, TaskType.WRITE, this.rawScanEnabled, writeTableLatency));<a name="line.1386"></a>
-<span class="sourceLineNo">1387</span>          }<a name="line.1387"></a>
-<span class="sourceLineNo">1388</span><a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>          for (Future&lt;Void&gt; future : taskFutures) {<a name="line.1389"></a>
-<span class="sourceLineNo">1390</span>            try {<a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>              future.get();<a name="line.1391"></a>
-<span class="sourceLineNo">1392</span>            } catch (ExecutionException e) {<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span>              LOG.error("Sniff region failed!", e);<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>            }<a name="line.1394"></a>
-<span class="sourceLineNo">1395</span>          }<a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>          Map&lt;String, LongAdder&gt; actualReadTableLatency = regionSink.getReadLatencyMap();<a name="line.1396"></a>
-<span class="sourceLineNo">1397</span>          for (Map.Entry&lt;String, Long&gt; entry : configuredReadTableTimeouts.entrySet()) {<a name="line.1397"></a>
-<span class="sourceLineNo">1398</span>            String tableName = entry.getKey();<a name="line.1398"></a>
-<span class="sourceLineNo">1399</span>            if (actualReadTableLatency.containsKey(tableName)) {<a name="line.1399"></a>
-<span class="sourceLineNo">1400</span>              Long actual = actualReadTableLatency.get(tableName).longValue();<a name="line.1400"></a>
-<span class="sourceLineNo">1401</span>              Long configured = entry.getValue();<a name="line.1401"></a>
-<span class="sourceLineNo">1402</span>              if (actual &gt; configured) {<a name="line.1402"></a>
-<span class="sourceLineNo">1403</span>                LOG.error("Read operation for {} took {}ms exceeded the configured read timeout." +<a name="line.1403"></a>
-<span class="sourceLineNo">1404</span>                    "(Configured read timeout {}ms.", tableName, actual, configured);<a name="line.1404"></a>
-<span class="sourceLineNo">1405</span>              } else {<a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>                LOG.info("Read operation for {} took {}ms (Configured read timeout {}ms.",<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>                    tableName, actual, configured);<a name="line.1407"></a>
-<span class="sourceLineNo">1408</span>              }<a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>            } else {<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span>              LOG.error("Read operation for {} failed!", tableName);<a name="line.1410"></a>
-<span class="sourceLineNo">1411</span>            }<a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>          }<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span>          if (this.writeSniffing) {<a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>            String writeTableStringName = this.writeTableName.getNameAsString();<a name="line.1414"></a>
-<span class="sourceLineNo">1415</span>            long actualWriteLatency = regionSink.getWriteLatency().longValue();<a name="line.1415"></a>
-<span class="sourceLineNo">1416</span>            LOG.info("Write operation for {} took {}ms. Configured write timeout {}ms.",<a name="line.1416"></a>
-<span class="sourceLineNo">1417</span>                writeTableStringName, actualWriteLatency, this.configuredWriteTableTimeout);<a name="line.1417"></a>
-<span class="sourceLineNo">1418</span>            // Check that the writeTable write operation latency does not exceed the configured timeout.<a name="line.1418"></a>
-<span class="sourceLineNo">1419</span>            if (actualWriteLatency &gt; this.configuredWriteTableTimeout) {<a name="line.1419"></a>
-<span class="sourceLineNo">1420</span>              LOG.error("Write operation for {} exceeded the configured write timeout.",<a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>                  writeTableStringName);<a name="line.1421"></a>
-<span class="sourceLineNo">1422</span>            }<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>          }<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>        } catch (Exception e) {<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>          LOG.error("Run regionMonitor failed", e);<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span>          this.errorCode = ERROR_EXIT_CODE;<a name="line.1426"></a>
-<span class="sourceLineNo">1427</span>        } finally {<a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>          this.done = true;<a name="line.1428"></a>
-<span class="sourceLineNo">1429</span>        }<a name="line.1429"></a>
-<span class="sourceLineNo">1430</span>      }<a name="line.1430"></a>
-<span class="sourceLineNo">1431</span>      this.done = true;<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span>    }<a name="line.1432"></a>
-<span class="sourceLineNo">1433</span><a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>    /**<a name="line.1434"></a>
-<span class="sourceLineNo">1435</span>     * @return List of tables to use in test.<a name="line.1435"></a>
-<span class="sourceLineNo">1436</span>     */<a name="line.1436"></a>
-<span class="sourceLineNo">1437</span>    private String[] generateMonitorTables(String[] monitorTargets) throws IOException {<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span>      String[] returnTables = null;<a name="line.1438"></a>
-<span class="sourceLineNo">1439</span><a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>      if (this.useRegExp) {<a name="line.1440"></a>
-<span class="sourceLineNo">1441</span>        Pattern pattern = null;<a name="line.1441"></a>
-<span class="sourceLineNo">1442</span>        List&lt;TableDescriptor&gt; tds = null;<a name="line.1442"></a>
-<span class="sourceLineNo">1443</span>        Set&lt;String&gt; tmpTables = new TreeSet&lt;&gt;();<a name="line.1443"></a>
-<span class="sourceLineNo">1444</span>        try {<a name="line.1444"></a>
-<span class="sourceLineNo">1445</span>          LOG.debug(String.format("reading list of tables"));<a name="line.1445"></a>
-<span class="sourceLineNo">1446</span>          tds = this.admin.listTableDescriptors(pattern);<a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>          if (tds == null) {<a name="line.1447"></a>
-<span class="sourceLineNo">1448</span>            tds = Collections.emptyList();<a name="line.1448"></a>
-<span class="sourceLineNo">1449</span>          }<a name="line.1449"></a>
-<span class="sourceLineNo">1450</span>          for (String monitorTarget : monitorTargets) {<a name="line.1450"></a>
-<span class="sourceLineNo">1451</span>            pattern = Pattern.compile(monitorTarget);<a name="line.1451"></a>
-<span class="sourceLineNo">1452</span>            for (TableDescriptor td : tds) {<a name="line.1452"></a>
-<span class="sourceLineNo">1453</span>              if (pattern.matcher(td.getTableName().getNameAsString()).matches()) {<a name="line.1453"></a>
-<span class="sourceLineNo">1454</span>                tmpTables.add(td.getTableName().getNameAsString());<a name="line.1454"></a>
-<span class="sourceLineNo">1455</span>              }<a name="line.1455"></a>
-<span class="sourceLineNo">1456</span>            }<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span>          }<a name="line.1457"></a>
-<span class="sourceLineNo">1458</span>        } catch (IOException e) {<a name="line.1458"></a>
-<span class="sourceLineNo">1459</span>          LOG.error("Communicate with admin failed", e);<a name="line.1459"></a>
-<span class="sourceLineNo">1460</span>          throw e;<a name="line.1460"></a>
-<span class="sourceLineNo">1461</span>        }<a name="line.1461"></a>
-<span class="sourceLineNo">1462</span><a name="line.1462"></a>
-<span class="sourceLineNo">1463</span>        if (tmpTables.size() &gt; 0) {<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span>          returnTables = tmpTables.toArray(new String[tmpTables.size()]);<a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>        } else {<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span>          String msg = "No HTable found, tablePattern:" + Arrays.toString(monitorTargets);<a name="line.1466"></a>
-<span class="sourceLineNo">1467</span>          LOG.error(msg);<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>          this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>          throw new TableNotFoundException(msg);<a name="line.1469"></a>
-<span class="sourceLineNo">1470</span>        }<a name="line.1470"></a>
-<span class="sourceLineNo">1471</span>      } else {<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>        returnTables = monitorTargets;<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>      }<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span><a name="line.1474"></a>
-<span class="sourceLineNo">1475</span>      return returnTables;<a name="line.1475"></a>
-<span class="sourceLineNo">1476</span>    }<a name="line.1476"></a>
-<span class="sourceLineNo">1477</span><a name="line.1477"></a>
-<span class="sourceLineNo">1478</span>    /*<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>     * Canary entry point to monitor all the tables.<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>     */<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>    private List&lt;Future&lt;Void&gt;&gt; sniff(TaskType taskType, RegionStdOutSink regionSink)<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span>        throws Exception {<a name="line.1482"></a>
-<span class="sourceLineNo">1483</span>      LOG.debug("Reading list of tables");<a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>      List&lt;Future&lt;Void&gt;&gt; taskFutures = new LinkedList&lt;&gt;();<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>      for (TableDescriptor td: admin.listTableDescriptors()) {<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>        if (admin.tableExists(td.getTableName()) &amp;&amp; admin.isTableEnabled(td.getTableName()) &amp;&amp;<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>            (!td.getTableName().equals(writeTableName))) {<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span>          LongAdder readLatency =<a name="line.1488"></a>
-<span class="sourceLineNo">1489</span>              regionSink.initializeAndGetReadLatencyForTable(td.getTableName().getNameAsString());<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>          taskFutures.addAll(CanaryTool.sniff(admin, sink, td, executor, taskType, this.rawScanEnabled,<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>              readLatency));<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>        }<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span>      }<a name="line.1493"></a>
-<span class="sourceLineNo">1494</span>      return taskFutures;<a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>    }<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span><a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>    private void checkWriteTableDistribution() throws IOException {<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>      if (!admin.tableExists(writeTableName)) {<a name="line.1498"></a>
-<span class="sourceLineNo">1499</span>        int numberOfServers = admin.getRegionServers().size();<a name="line.1499"></a>
-<span class="sourceLineNo">1500</span>        if (numberOfServers == 0) {<a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>          throw new IllegalStateException("No live regionservers");<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>        }<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>        createWriteTable(numberOfServers);<a name="line.1503"></a>
-<span class="sourceLineNo">1504</span>      }<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span><a name="line.1505"></a>
-<span class="sourceLineNo">1506</span>      if (!admin.isTableEnabled(writeTableName)) {<a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>        admin.enableTable(writeTableName);<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>      }<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span><a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>      ClusterMetrics status =<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>          admin.getClusterMetrics(EnumSet.of(Option.SERVERS_NAME, Option.MASTER));<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>      int numberOfServers = status.getServersName().size();<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>      if (status.getServersName().contains(status.getMasterName())) {<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>        numberOfServers -= 1;<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>      }<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span><a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>      List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; pairs =<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span>          MetaTableAccessor.getTableRegionsAndLocations(connection, writeTableName);<a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>      int numberOfRegions = pairs.size();<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span>      if (numberOfRegions &lt; numberOfServers * regionsLowerLimit<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>          || numberOfRegions &gt; numberOfServers * regionsUpperLimit) {<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>        admin.disableTable(writeTableName);<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>        admin.deleteTable(writeTableName);<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>        createWriteTable(numberOfServers);<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>      }<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>      HashSet&lt;ServerName&gt; serverSet = new HashSet&lt;&gt;();<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>      for (Pair&lt;RegionInfo, ServerName&gt; pair : pairs) {<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>        serverSet.add(pair.getSecond());<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>      }<a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>      int numberOfCoveredServers = serverSet.size();<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>      if (numberOfCoveredServers &lt; numberOfServers) {<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>        admin.balance();<a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>      }<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>    }<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span><a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>    private void createWriteTable(int numberOfServers) throws IOException {<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span>      int numberOfRegions = (int)(numberOfServers * regionsLowerLimit);<a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>      LOG.info("Number of live regionservers {}, pre-splitting the canary table into {} regions " +<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>        "(current lower limit of regions per server is {} and you can change it with config {}).",<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>          numberOfServers, numberOfRegions, regionsLowerLimit,<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>          HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY);<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>      HTableDescriptor desc = new HTableDescriptor(writeTableName);<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>      HColumnDescriptor family = new HColumnDescriptor(CANARY_TABLE_FAMILY_NAME);<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>      family.setMaxVersions(1);<a name="line.1544"></a>
-<span class="sourceLineNo">1545</span>      family.setTimeToLive(writeDataTTL);<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span><a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>      desc.addFamily(family);<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>      byte[][] splits = new RegionSplitter.HexStringSplit().split(numberOfRegions);<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>      admin.createTable(desc, splits);<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>    }<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>  }<a name="line.1551"></a>
-<span class="sourceLineNo">1552</span><a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>  /**<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>   * Canary entry point for specified table.<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span>   * @throws Exception<a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>   */<a name="line.1556"></a>
-<span class="sourceLineNo">1557</span>  private static List&lt;Future&lt;Void&gt;&gt; sniff(final Admin admin, final Sink sink, String tableName,<a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>      ExecutorService executor, TaskType taskType, boolean rawScanEnabled, LongAdder readLatency)<a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>      throws Exception {<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>    LOG.debug("Checking table is enabled and getting table descriptor for table {}", tableName);<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span>    if (admin.isTableEnabled(TableName.valueOf(tableName))) {<a name="line.1561"></a>
-<span class="sourceLineNo">1562</span>      return CanaryTool.sniff(admin, sink, admin.getDescriptor(TableName.valueOf(tableName)),<a name="line.1562"></a>
-<span class="sourceLineNo">1563</span>        executor, taskType, rawScanEnabled, readLatency);<a name="line.1563"></a>
-<span class="sourceLineNo">1564</span>    } else {<a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>      LOG.warn("Table {} is not enabled", tableName);<a name="line.1565"></a>
-<span class="sourceLineNo">1566</span>    }<a name="line.1566"></a>
-<span class="sourceLineNo">1567</span>    return new LinkedList&lt;&gt;();<a name="line.1567"></a>
-<span class="sourceLineNo">1568</span>  }<a name="line.1568"></a>
-<span class="sourceLineNo">1569</span><a name="line.1569"></a>
-<span class="sourceLineNo">1570</span>  /*<a name="line.1570"></a>
-<span class="sourceLineNo">1571</span>   * Loops over regions of this table, and outputs information about the state.<a name="line.1571"></a>
-<span class="sourceLineNo">1572</span>   */<a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>  private static List&lt;Future&lt;Void&gt;&gt; sniff(final Admin admin, final Sink sink,<a name="line.1573"></a>
-<span class="sourceLineNo">1574</span>      TableDescriptor tableDesc, ExecutorService executor, TaskType taskType,<a name="line.1574"></a>
-<span class="sourceLineNo">1575</span>      boolean rawScanEnabled, LongAdder rwLatency) throws Exception {<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>    LOG.debug("Reading list of regions for table {}", tableDesc.getTableName());<a name="line.1576"></a>
-<span class="sourceLineNo">1577</span>    try (Table table = admin.getConnection().getTable(tableDesc.getTableName())) {<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span>      List&lt;RegionTask&gt; tasks = new ArrayList&lt;&gt;();<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>      try (RegionLocator regionLocator =<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>               admin.getConnection().getRegionLocator(tableDesc.getTableName())) {<a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>        for (HRegionLocation location: regionLocator.getAllRegionLocations()) {<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span>          ServerName rs = location.getServerName();<a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>          RegionInfo region = location.getRegion();<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span>          tasks.add(new RegionTask(admin.getConnection(), region, rs, (RegionStdOutSink)sink,<a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>              taskType, rawScanEnabled, rwLatency));<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>          Map&lt;String, List&lt;RegionTaskResult&gt;&gt; regionMap = ((RegionStdOutSink) sink).getRegionMap();<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>          regionMap.put(region.getRegionNameAsString(), new ArrayList&lt;RegionTaskResult&gt;());<a name="line.1587"></a>
-<span class="sourceLineNo">1588</span>        }<a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>        return executor.invokeAll(tasks);<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span>      }<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>    } catch (TableNotFoundException e) {<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>      return Collections.EMPTY_LIST;<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>    }<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>  }<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span><a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>  //  monitor for zookeeper mode<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>  private static class ZookeeperMonitor extends Monitor {<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>    private List&lt;String&gt; hosts;<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span>    private final String znode;<a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>    private final int timeout;<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span><a name="line.1601"></a>
-<span class="sourceLineNo">1602</span>    protected ZookeeperMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1602"></a>
-<span class="sourceLineNo">1603</span>        Sink sink, ExecutorService executor, boolean treatFailureAsError, long allowedFailures)  {<a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>      super(connection, monitorTargets, useRegExp,<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span>          sink, executor, treatFailureAsError, allowedFailures);<a name="line.1605"></a>
-<span class="sourceLineNo">1606</span>      Configuration configuration = connection.getConfiguration();<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span>      znode =<a name="line.1607"></a>
-<span class="sourceLineNo">1608</span>          configuration.get(ZOOKEEPER_ZNODE_PARENT,<a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>              DEFAULT_ZOOKEEPER_ZNODE_PARENT);<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>      timeout = configuration<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span>          .getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);<a name="line.1611"></a>
-<span class="sourceLineNo">1612</span>      ConnectStringParser parser =<a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>          new ConnectStringParser(ZKConfig.getZKQuorumServersString(configuration));<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>      hosts = Lists.newArrayList();<a name="line.1614"></a>
-<span class="sourceLineNo">1615</span>      for (InetSocketAddress server : parser.getServerAddresses()) {<a name="line.1615"></a>
-<span class="sourceLineNo">1616</span>        hosts.add(server.toString());<a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>      }<a name="line.1617"></a>
-<span class="sourceLineNo">1618</span>      if (allowedFailures &gt; (hosts.size() - 1) / 2) {<a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>        LOG.warn("Confirm allowable number of failed ZooKeeper nodes, as quorum will " +<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span>                        "already be lost. Setting of {} failures is unexpected for {} ensemble size.",<a name="line.1620"></a>
-<span class="sourceLineNo">1621</span>                allowedFailures, hosts.size());<a name="line.1621"></a>
+<span class="sourceLineNo">703</span><a name="line.703"></a>
+<span class="sourceLineNo">704</span>  private ExecutorService executor; // threads to retrieve data from regionservers<a name="line.704"></a>
+<span class="sourceLineNo">705</span><a name="line.705"></a>
+<span class="sourceLineNo">706</span>  public CanaryTool() {<a name="line.706"></a>
+<span class="sourceLineNo">707</span>    this(new ScheduledThreadPoolExecutor(1));<a name="line.707"></a>
+<span class="sourceLineNo">708</span>  }<a name="line.708"></a>
+<span class="sourceLineNo">709</span><a name="line.709"></a>
+<span class="sourceLineNo">710</span>  public CanaryTool(ExecutorService executor) {<a name="line.710"></a>
+<span class="sourceLineNo">711</span>    this(executor, null);<a name="line.711"></a>
+<span class="sourceLineNo">712</span>  }<a name="line.712"></a>
+<span class="sourceLineNo">713</span><a name="line.713"></a>
+<span class="sourceLineNo">714</span>  @VisibleForTesting<a name="line.714"></a>
+<span class="sourceLineNo">715</span>  CanaryTool(ExecutorService executor, Sink sink) {<a name="line.715"></a>
+<span class="sourceLineNo">716</span>    this.executor = executor;<a name="line.716"></a>
+<span class="sourceLineNo">717</span>    this.sink = sink;<a name="line.717"></a>
+<span class="sourceLineNo">718</span>  }<a name="line.718"></a>
+<span class="sourceLineNo">719</span><a name="line.719"></a>
+<span class="sourceLineNo">720</span>  CanaryTool(Configuration conf, ExecutorService executor) {<a name="line.720"></a>
+<span class="sourceLineNo">721</span>    this(conf, executor, null);<a name="line.721"></a>
+<span class="sourceLineNo">722</span>  }<a name="line.722"></a>
+<span class="sourceLineNo">723</span><a name="line.723"></a>
+<span class="sourceLineNo">724</span>  CanaryTool(Configuration conf, ExecutorService executor, Sink sink) {<a name="line.724"></a>
+<span class="sourceLineNo">725</span>    this(executor, sink);<a name="line.725"></a>
+<span class="sourceLineNo">726</span>    setConf(conf);<a name="line.726"></a>
+<span class="sourceLineNo">727</span>  }<a name="line.727"></a>
+<span class="sourceLineNo">728</span><a name="line.728"></a>
+<span class="sourceLineNo">729</span>  @Override<a name="line.729"></a>
+<span class="sourceLineNo">730</span>  public Configuration getConf() {<a name="line.730"></a>
+<span class="sourceLineNo">731</span>    return conf;<a name="line.731"></a>
+<span class="sourceLineNo">732</span>  }<a name="line.732"></a>
+<span class="sourceLineNo">733</span><a name="line.733"></a>
+<span class="sourceLineNo">734</span>  @Override<a name="line.734"></a>
+<span class="sourceLineNo">735</span>  public void setConf(Configuration conf) {<a name="line.735"></a>
+<span class="sourceLineNo">736</span>    if (conf == null) {<a name="line.736"></a>
+<span class="sourceLineNo">737</span>      conf = HBaseConfiguration.create();<a name="line.737"></a>
+<span class="sourceLineNo">738</span>    }<a name="line.738"></a>
+<span class="sourceLineNo">739</span>    this.conf = conf;<a name="line.739"></a>
+<span class="sourceLineNo">740</span>  }<a name="line.740"></a>
+<span class="sourceLineNo">741</span><a name="line.741"></a>
+<span class="sourceLineNo">742</span>  private int parseArgs(String[] args) {<a name="line.742"></a>
+<span class="sourceLineNo">743</span>    int index = -1;<a name="line.743"></a>
+<span class="sourceLineNo">744</span>    long permittedFailures = 0;<a name="line.744"></a>
+<span class="sourceLineNo">745</span>    boolean regionServerAllRegions = false, writeSniffing = false;<a name="line.745"></a>
+<span class="sourceLineNo">746</span>    String readTableTimeoutsStr = null;<a name="line.746"></a>
+<span class="sourceLineNo">747</span><a name="line.747"></a>
+<span class="sourceLineNo">748</span>    // Process command line args<a name="line.748"></a>
+<span class="sourceLineNo">749</span>    for (int i = 0; i &lt; args.length; i++) {<a name="line.749"></a>
+<span class="sourceLineNo">750</span>      String cmd = args[i];<a name="line.750"></a>
+<span class="sourceLineNo">751</span><a name="line.751"></a>
+<span class="sourceLineNo">752</span>      if (cmd.startsWith("-")) {<a name="line.752"></a>
+<span class="sourceLineNo">753</span>        if (index &gt;= 0) {<a name="line.753"></a>
+<span class="sourceLineNo">754</span>          // command line args must be in the form: [opts] [table 1 [table 2 ...]]<a name="line.754"></a>
+<span class="sourceLineNo">755</span>          System.err.println("Invalid command line options");<a name="line.755"></a>
+<span class="sourceLineNo">756</span>          printUsageAndExit();<a name="line.756"></a>
+<span class="sourceLineNo">757</span>        }<a name="line.757"></a>
+<span class="sourceLineNo">758</span><a name="line.758"></a>
+<span class="sourceLineNo">759</span>        if (cmd.equals("-help") || cmd.equals("-h")) {<a name="line.759"></a>
+<span class="sourceLineNo">760</span>          // user asked for help, print the help and quit.<a name="line.760"></a>
+<span class="sourceLineNo">761</span>          printUsageAndExit();<a name="line.761"></a>
+<span class="sourceLineNo">762</span>        } else if (cmd.equals("-daemon") &amp;&amp; interval == 0) {<a name="line.762"></a>
+<span class="sourceLineNo">763</span>          // user asked for daemon mode, set a default interval between checks<a name="line.763"></a>
+<span class="sourceLineNo">764</span>          interval = DEFAULT_INTERVAL;<a name="line.764"></a>
+<span class="sourceLineNo">765</span>        } else if (cmd.equals("-interval")) {<a name="line.765"></a>
+<span class="sourceLineNo">766</span>          // user has specified an interval for canary breaths (-interval N)<a name="line.766"></a>
+<span class="sourceLineNo">767</span>          i++;<a name="line.767"></a>
+<span class="sourceLineNo">768</span><a name="line.768"></a>
+<span class="sourceLineNo">769</span>          if (i == args.length) {<a name="line.769"></a>
+<span class="sourceLineNo">770</span>            System.err.println("-interval takes a numeric seconds value argument.");<a name="line.770"></a>
+<span class="sourceLineNo">771</span>            printUsageAndExit();<a name="line.771"></a>
+<span class="sourceLineNo">772</span>          }<a name="line.772"></a>
+<span class="sourceLineNo">773</span><a name="line.773"></a>
+<span class="sourceLineNo">774</span>          try {<a name="line.774"></a>
+<span class="sourceLineNo">775</span>            interval = Long.parseLong(args[i]) * 1000;<a name="line.775"></a>
+<span class="sourceLineNo">776</span>          } catch (NumberFormatException e) {<a name="line.776"></a>
+<span class="sourceLineNo">777</span>            System.err.println("-interval needs a numeric value argument.");<a name="line.777"></a>
+<span class="sourceLineNo">778</span>            printUsageAndExit();<a name="line.778"></a>
+<span class="sourceLineNo">779</span>          }<a name="line.779"></a>
+<span class="sourceLineNo">780</span>        } else if (cmd.equals("-zookeeper")) {<a name="line.780"></a>
+<span class="sourceLineNo">781</span>          this.zookeeperMode = true;<a name="line.781"></a>
+<span class="sourceLineNo">782</span>        } else if(cmd.equals("-regionserver")) {<a name="line.782"></a>
+<span class="sourceLineNo">783</span>          this.regionServerMode = true;<a name="line.783"></a>
+<span class="sourceLineNo">784</span>        } else if(cmd.equals("-allRegions")) {<a name="line.784"></a>
+<span class="sourceLineNo">785</span>          conf.setBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, true);<a name="line.785"></a>
+<span class="sourceLineNo">786</span>          regionServerAllRegions = true;<a name="line.786"></a>
+<span class="sourceLineNo">787</span>        } else if(cmd.equals("-writeSniffing")) {<a name="line.787"></a>
+<span class="sourceLineNo">788</span>          writeSniffing = true;<a name="line.788"></a>
+<span class="sourceLineNo">789</span>          conf.setBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, true);<a name="line.789"></a>
+<span class="sourceLineNo">790</span>        } else if(cmd.equals("-treatFailureAsError") || cmd.equals("-failureAsError")) {<a name="line.790"></a>
+<span class="sourceLineNo">791</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.791"></a>
+<span class="sourceLineNo">792</span>        } else if (cmd.equals("-e")) {<a name="line.792"></a>
+<span class="sourceLineNo">793</span>          conf.setBoolean(HBASE_CANARY_USE_REGEX, true);<a name="line.793"></a>
+<span class="sourceLineNo">794</span>        } else if (cmd.equals("-t")) {<a name="line.794"></a>
+<span class="sourceLineNo">795</span>          i++;<a name="line.795"></a>
+<span class="sourceLineNo">796</span><a name="line.796"></a>
+<span class="sourceLineNo">797</span>          if (i == args.length) {<a name="line.797"></a>
+<span class="sourceLineNo">798</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.798"></a>
+<span class="sourceLineNo">799</span>            printUsageAndExit();<a name="line.799"></a>
+<span class="sourceLineNo">800</span>          }<a name="line.800"></a>
+<span class="sourceLineNo">801</span>          long timeout = 0;<a name="line.801"></a>
+<span class="sourceLineNo">802</span>          try {<a name="line.802"></a>
+<span class="sourceLineNo">803</span>            timeout = Long.parseLong(args[i]);<a name="line.803"></a>
+<span class="sourceLineNo">804</span>          } catch (NumberFormatException e) {<a name="line.804"></a>
+<span class="sourceLineNo">805</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.805"></a>
+<span class="sourceLineNo">806</span>            printUsageAndExit();<a name="line.806"></a>
+<span class="sourceLineNo">807</span>          }<a name="line.807"></a>
+<span class="sourceLineNo">808</span>          conf.setLong(HBASE_CANARY_TIMEOUT, timeout);<a name="line.808"></a>
+<span class="sourceLineNo">809</span>        } else if(cmd.equals("-writeTableTimeout")) {<a name="line.809"></a>
+<span class="sourceLineNo">810</span>          i++;<a name="line.810"></a>
+<span class="sourceLineNo">811</span><a name="line.811"></a>
+<span class="sourceLineNo">812</span>          if (i == args.length) {<a name="line.812"></a>
+<span class="sourceLineNo">813</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.813"></a>
+<span class="sourceLineNo">814</span>            printUsageAndExit();<a name="line.814"></a>
+<span class="sourceLineNo">815</span>          }<a name="line.815"></a>
+<span class="sourceLineNo">816</span>          long configuredWriteTableTimeout = 0;<a name="line.816"></a>
+<span class="sourceLineNo">817</span>          try {<a name="line.817"></a>
+<span class="sourceLineNo">818</span>            configuredWriteTableTimeout = Long.parseLong(args[i]);<a name="line.818"></a>
+<span class="sourceLineNo">819</span>          } catch (NumberFormatException e) {<a name="line.819"></a>
+<span class="sourceLineNo">820</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.820"></a>
+<span class="sourceLineNo">821</span>            printUsageAndExit();<a name="line.821"></a>
+<span class="sourceLineNo">822</span>          }<a name="line.822"></a>
+<span class="sourceLineNo">823</span>          conf.setLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, configuredWriteTableTimeout);<a name="line.823"></a>
+<span class="sourceLineNo">824</span>        } else if (cmd.equals("-writeTable")) {<a name="line.824"></a>
+<span class="sourceLineNo">825</span>          i++;<a name="line.825"></a>
+<span class="sourceLineNo">826</span><a name="line.826"></a>
+<span class="sourceLineNo">827</span>          if (i == args.length) {<a name="line.827"></a>
+<span class="sourceLineNo">828</span>            System.err.println("-writeTable takes a string tablename value argument.");<a name="line.828"></a>
+<span class="sourceLineNo">829</span>            printUsageAndExit();<a name="line.829"></a>
+<span class="sourceLineNo">830</span>          }<a name="line.830"></a>
+<span class="sourceLineNo">831</span>          conf.set(HBASE_CANARY_REGION_WRITE_TABLE_NAME, args[i]);<a name="line.831"></a>
+<span class="sourceLineNo">832</span>        } else if (cmd.equals("-f")) {<a name="line.832"></a>
+<span class="sourceLineNo">833</span>          i++;<a name="line.833"></a>
+<span class="sourceLineNo">834</span><a name="line.834"></a>
+<span class="sourceLineNo">835</span>          if (i == args.length) {<a name="line.835"></a>
+<span class="sourceLineNo">836</span>            System.err<a name="line.836"></a>
+<span class="sourceLineNo">837</span>                .println("-f needs a boolean value argument (true|false).");<a name="line.837"></a>
+<span class="sourceLineNo">838</span>            printUsageAndExit();<a name="line.838"></a>
+<span class="sourceLineNo">839</span>          }<a name="line.839"></a>
+<span class="sourceLineNo">840</span><a name="line.840"></a>
+<span class="sourceLineNo">841</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, Boolean.parseBoolean(args[i]));<a name="line.841"></a>
+<span class="sourceLineNo">842</span>        } else if (cmd.equals("-readTableTimeouts")) {<a name="line.842"></a>
+<span class="sourceLineNo">843</span>          i++;<a name="line.843"></a>
+<span class="sourceLineNo">844</span><a name="line.844"></a>
+<span class="sourceLineNo">845</span>          if (i == args.length) {<a name="line.845"></a>
+<span class="sourceLineNo">846</span>            System.err.println("-readTableTimeouts needs a comma-separated list of read " +<a name="line.846"></a>
+<span class="sourceLineNo">847</span>                "millisecond timeouts per table (without spaces).");<a name="line.847"></a>
+<span class="sourceLineNo">848</span>            printUsageAndExit();<a name="line.848"></a>
+<span class="sourceLineNo">849</span>          }<a name="line.849"></a>
+<span class="sourceLineNo">850</span>          readTableTimeoutsStr = args[i];<a name="line.850"></a>
+<span class="sourceLineNo">851</span>          conf.set(HBASE_CANARY_REGION_READ_TABLE_TIMEOUT, readTableTimeoutsStr);<a name="line.851"></a>
+<span class="sourceLineNo">852</span>        } else if (cmd.equals("-permittedZookeeperFailures")) {<a name="line.852"></a>
+<span class="sourceLineNo">853</span>          i++;<a name="line.853"></a>
+<span class="sourceLineNo">854</span><a name="line.854"></a>
+<span class="sourceLineNo">855</span>          if (i == args.length) {<a name="line.855"></a>
+<span class="sourceLineNo">856</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.856"></a>
+<span class="sourceLineNo">857</span>            printUsageAndExit();<a name="line.857"></a>
+<span class="sourceLineNo">858</span>          }<a name="line.858"></a>
+<span class="sourceLineNo">859</span>          try {<a name="line.859"></a>
+<span class="sourceLineNo">860</span>            permittedFailures = Long.parseLong(args[i]);<a name="line.860"></a>
+<span class="sourceLineNo">861</span>          } catch (NumberFormatException e) {<a name="line.861"></a>
+<span class="sourceLineNo">862</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.862"></a>
+<span class="sourceLineNo">863</span>            printUsageAndExit();<a name="line.863"></a>
+<span class="sourceLineNo">864</span>          }<a name="line.864"></a>
+<span class="sourceLineNo">865</span>          conf.setLong(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, permittedFailures);<a name="line.865"></a>
+<span class="sourceLineNo">866</span>        } else {<a name="line.866"></a>
+<span class="sourceLineNo">867</span>          // no options match<a name="line.867"></a>
+<span class="sourceLineNo">868</span>          System.err.println(cmd + " options is invalid.");<a name="line.868"></a>
+<span class="sourceLineNo">869</span>          printUsageAndExit();<a name="line.869"></a>
+<span class="sourceLineNo">870</span>        }<a name="line.870"></a>
+<span class="sourceLineNo">871</span>      } else if (index &lt; 0) {<a name="line.871"></a>
+<span class="sourceLineNo">872</span>        // keep track of first table name specified by the user<a name="line.872"></a>
+<span class="sourceLineNo">873</span>        index = i;<a name="line.873"></a>
+<span class="sourceLineNo">874</span>      }<a name="line.874"></a>
+<span class="sourceLineNo">875</span>    }<a name="line.875"></a>
+<span class="sourceLineNo">876</span>    if (regionServerAllRegions &amp;&amp; !this.regionServerMode) {<a name="line.876"></a>
+<span class="sourceLineNo">877</span>      System.err.println("-allRegions can only be specified in regionserver mode.");<a name="line.877"></a>
+<span class="sourceLineNo">878</span>      printUsageAndExit();<a name="line.878"></a>
+<span class="sourceLineNo">879</span>    }<a name="line.879"></a>
+<span class="sourceLineNo">880</span>    if (this.zookeeperMode) {<a name="line.880"></a>
+<span class="sourceLineNo">881</span>      if (this.regionServerMode || regionServerAllRegions || writeSniffing) {<a name="line.881"></a>
+<span class="sourceLineNo">882</span>        System.err.println("-zookeeper is exclusive and cannot be combined with "<a name="line.882"></a>
+<span class="sourceLineNo">883</span>            + "other modes.");<a name="line.883"></a>
+<span class="sourceLineNo">884</span>        printUsageAndExit();<a name="line.884"></a>
+<span class="sourceLineNo">885</span>      }<a name="line.885"></a>
+<span class="sourceLineNo">886</span>    }<a name="line.886"></a>
+<span class="sourceLineNo">887</span>    if (permittedFailures != 0 &amp;&amp; !this.zookeeperMode) {<a name="line.887"></a>
+<span class="sourceLineNo">888</span>      System.err.println("-permittedZookeeperFailures requires -zookeeper mode.");<a name="line.888"></a>
+<span class="sourceLineNo">889</span>      printUsageAndExit();<a name="line.889"></a>
+<span class="sourceLineNo">890</span>    }<a name="line.890"></a>
+<span class="sourceLineNo">891</span>    if (readTableTimeoutsStr != null &amp;&amp; (this.regionServerMode || this.zookeeperMode)) {<a name="line.891"></a>
+<span class="sourceLineNo">892</span>      System.err.println("-readTableTimeouts can only be configured in region mode.");<a name="line.892"></a>
+<span class="sourceLineNo">893</span>      printUsageAndExit();<a name="line.893"></a>
+<span class="sourceLineNo">894</span>    }<a name="line.894"></a>
+<span class="sourceLineNo">895</span>    return index;<a name="line.895"></a>
+<span class="sourceLineNo">896</span>  }<a name="line.896"></a>
+<span class="sourceLineNo">897</span><a name="line.897"></a>
+<span class="sourceLineNo">898</span>  @Override<a name="line.898"></a>
+<span class="sourceLineNo">899</span>  public int run(String[] args) throws Exception {<a name="line.899"></a>
+<span class="sourceLineNo">900</span>    int index = parseArgs(args);<a name="line.900"></a>
+<span class="sourceLineNo">901</span>    String[] monitorTargets = null;<a name="line.901"></a>
+<span class="sourceLineNo">902</span><a name="line.902"></a>
+<span class="sourceLineNo">903</span>    if (index &gt;= 0) {<a name="line.903"></a>
+<span class="sourceLineNo">904</span>      int length = args.length - index;<a name="line.904"></a>
+<span class="sourceLineNo">905</span>      monitorTargets = new String[length];<a name="line.905"></a>
+<span class="sourceLineNo">906</span>      System.arraycopy(args, index, monitorTargets, 0, length);<a name="line.906"></a>
+<span class="sourceLineNo">907</span>    }<a name="line.907"></a>
+<span class="sourceLineNo">908</span><a name="line.908"></a>
+<span class="sourceLineNo">909</span>    if (zookeeperMode) {<a name="line.909"></a>
+<span class="sourceLineNo">910</span>      return checkZooKeeper();<a name="line.910"></a>
+<span class="sourceLineNo">911</span>    } else if (regionServerMode) {<a name="line.911"></a>
+<span class="sourceLineNo">912</span>      return checkRegionServers(monitorTargets);<a name="line.912"></a>
+<span class="sourceLineNo">913</span>    } else {<a name="line.913"></a>
+<span class="sourceLineNo">914</span>      return checkRegions(monitorTargets);<a name="line.914"></a>
+<span class="sourceLineNo">915</span>    }<a name="line.915"></a>
+<span class="sourceLineNo">916</span>  }<a name="line.916"></a>
+<span class="sourceLineNo">917</span><a name="line.917"></a>
+<span class="sourceLineNo">918</span>  private int runMonitor(String[] monitorTargets) throws Exception {<a name="line.918"></a>
+<span class="sourceLineNo">919</span>    ChoreService choreService = null;<a name="line.919"></a>
+<span class="sourceLineNo">920</span><a name="line.920"></a>
+<span class="sourceLineNo">921</span>    // Launches chore for refreshing kerberos credentials if security is enabled.<a name="line.921"></a>
+<span class="sourceLineNo">922</span>    // Please see http://hbase.apache.org/book.html#_running_canary_in_a_kerberos_enabled_cluster<a name="line.922"></a>
+<span class="sourceLineNo">923</span>    // for more details.<a name="line.923"></a>
+<span class="sourceLineNo">924</span>    final ScheduledChore authChore = AuthUtil.getAuthChore(conf);<a name="line.924"></a>
+<span class="sourceLineNo">925</span>    if (authChore != null) {<a name="line.925"></a>
+<span class="sourceLineNo">926</span>      choreService = new ChoreService("CANARY_TOOL");<a name="line.926"></a>
+<span class="sourceLineNo">927</span>      choreService.scheduleChore(authChore);<a name="line.927"></a>
+<span class="sourceLineNo">928</span>    }<a name="line.928"></a>
+<span class="sourceLineNo">929</span><a name="line.929"></a>
+<span class="sourceLineNo">930</span>    // Start to prepare the stuffs<a name="line.930"></a>
+<span class="sourceLineNo">931</span>    Monitor monitor = null;<a name="line.931"></a>
+<span class="sourceLineNo">932</span>    Thread monitorThread;<a name="line.932"></a>
+<span class="sourceLineNo">933</span>    long startTime = 0;<a name="line.933"></a>
+<span class="sourceLineNo">934</span>    long currentTimeLength = 0;<a name="line.934"></a>
+<span class="sourceLineNo">935</span>    boolean failOnError = conf.getBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.935"></a>
+<span class="sourceLineNo">936</span>    long timeout = conf.getLong(HBASE_CANARY_TIMEOUT, DEFAULT_TIMEOUT);<a name="line.936"></a>
+<span class="sourceLineNo">937</span>    // Get a connection to use in below.<a name="line.937"></a>
+<span class="sourceLineNo">938</span>    try (Connection connection = ConnectionFactory.createConnection(this.conf)) {<a name="line.938"></a>
+<span class="sourceLineNo">939</span>      do {<a name="line.939"></a>
+<span class="sourceLineNo">940</span>        // Do monitor !!<a name="line.940"></a>
+<span class="sourceLineNo">941</span>        try {<a name="line.941"></a>
+<span class="sourceLineNo">942</span>          monitor = this.newMonitor(connection, monitorTargets);<a name="line.942"></a>
+<span class="sourceLineNo">943</span>          monitorThread = new Thread(monitor, "CanaryMonitor-" + System.currentTimeMillis());<a name="line.943"></a>
+<span class="sourceLineNo">944</span>          startTime = System.currentTimeMillis();<a name="line.944"></a>
+<span class="sourceLineNo">945</span>          monitorThread.start();<a name="line.945"></a>
+<span class="sourceLineNo">946</span>          while (!monitor.isDone()) {<a name="line.946"></a>
+<span class="sourceLineNo">947</span>            // wait for 1 sec<a name="line.947"></a>
+<span class="sourceLineNo">948</span>            Thread.sleep(1000);<a name="line.948"></a>
+<span class="sourceLineNo">949</span>            // exit if any error occurs<a name="line.949"></a>
+<span class="sourceLineNo">950</span>            if (failOnError &amp;&amp; monitor.hasError()) {<a name="line.950"></a>
+<span class="sourceLineNo">951</span>              monitorThread.interrupt();<a name="line.951"></a>
+<span class="sourceLineNo">952</span>              if (monitor.initialized) {<a name="line.952"></a>
+<span class="sourceLineNo">953</span>                return monitor.errorCode;<a name="line.953"></a>
+<span class="sourceLineNo">954</span>              } else {<a name="line.954"></a>
+<span class="sourceLineNo">955</span>                return INIT_ERROR_EXIT_CODE;<a name="line.955"></a>
+<span class="sourceLineNo">956</span>              }<a name="line.956"></a>
+<span class="sourceLineNo">957</span>            }<a name="line.957"></a>
+<span class="sourceLineNo">958</span>            currentTimeLength = System.currentTimeMillis() - startTime;<a name="line.958"></a>
+<span class="sourceLineNo">959</span>            if (currentTimeLength &gt; timeout) {<a name="line.959"></a>
+<span class="sourceLineNo">960</span>              LOG.error("The monitor is running too long (" + currentTimeLength<a name="line.960"></a>
+<span class="sourceLineNo">961</span>                  + ") after timeout limit:" + timeout<a name="line.961"></a>
+<span class="sourceLineNo">962</span>                  + " will be killed itself !!");<a name="line.962"></a>
+<span class="sourceLineNo">963</span>              if (monitor.initialized) {<a name="line.963"></a>
+<span class="sourceLineNo">964</span>                return TIMEOUT_ERROR_EXIT_CODE;<a name="line.964"></a>
+<span class="sourceLineNo">965</span>              } else {<a name="line.965"></a>
+<span class="sourceLineNo">966</span>                return INIT_ERROR_EXIT_CODE;<a name="line.966"></a>
+<span class="sourceLineNo">967</span>              }<a name="line.967"></a>
+<span class="sourceLineNo">968</span>            }<a name="line.968"></a>
+<span class="sourceLineNo">969</span>          }<a name="line.969"></a>
+<span class="sourceLineNo">970</span><a name="line.970"></a>
+<span class="sourceLineNo">971</span>          if (failOnError &amp;&amp; monitor.finalCheckForErrors()) {<a name="line.971"></a>
+<span class="sourceLineNo">972</span>            monitorThread.interrupt();<a name="line.972"></a>
+<span class="sourceLineNo">973</span>            return monitor.errorCode;<a name="line.973"></a>
+<span class="sourceLineNo">974</span>          }<a name="line.974"></a>
+<span class="sourceLineNo">975</span>        } finally {<a name="line.975"></a>
+<span class="sourceLineNo">976</span>          if (monitor != null) monitor.close();<a name="line.976"></a>
+<span class="sourceLineNo">977</span>        }<a name="line.977"></a>
+<span class="sourceLineNo">978</span><a name="line.978"></a>
+<span class="sourceLineNo">979</span>        Thread.sleep(interval);<a name="line.979"></a>
+<span class="sourceLineNo">980</span>      } while (interval &gt; 0);<a name="line.980"></a>
+<span class="sourceLineNo">981</span>    } // try-with-resources close<a name="line.981"></a>
+<span class="sourceLineNo">982</span><a name="line.982"></a>
+<span class="sourceLineNo">983</span>    if (choreService != null) {<a name="line.983"></a>
+<span class="sourceLineNo">984</span>      choreService.shutdown();<a name="line.984"></a>
+<span class="sourceLineNo">985</span>    }<a name="line.985"></a>
+<span class="sourceLineNo">986</span>    return monitor.errorCode;<a name="line.986"></a>
+<span class="sourceLineNo">987</span>  }<a name="line.987"></a>
+<span class="sourceLineNo">988</span><a name="line.988"></a>
+<span class="sourceLineNo">989</span>  @Override<a name="line.989"></a>
+<span class="sourceLineNo">990</span>  public Map&lt;String, String&gt; getReadFailures()  {<a name="line.990"></a>
+<span class="sourceLineNo">991</span>    return sink.getReadFailures();<a name="line.991"></a>
+<span class="sourceLineNo">992</span>  }<a name="line.992"></a>
+<span class="sourceLineNo">993</span><a name="line.993"></a>
+<span class="sourceLineNo">994</span>  @Override<a name="line.994"></a>
+<span class="sourceLineNo">995</span>  public Map&lt;String, String&gt; getWriteFailures()  {<a name="line.995"></a>
+<span class="sourceLineNo">996</span>    return sink.getWriteFailures();<a name="line.996"></a>
+<span class="sourceLineNo">997</span>  }<a name="line.997"></a>
+<span class="sourceLineNo">998</span><a name="line.998"></a>
+<span class="sourceLineNo">999</span>  private void printUsageAndExit() {<a name="line.999"></a>
+<span class="sourceLineNo">1000</span>    System.err.println(<a name="line.1000"></a>
+<span class="sourceLineNo">1001</span>      "Usage: canary [OPTIONS] [&lt;TABLE1&gt; [&lt;TABLE2]...] | [&lt;REGIONSERVER1&gt; [&lt;REGIONSERVER2]..]");<a name="line.1001"></a>
+<span class="sourceLineNo">1002</span>    System.err.println("Where [OPTIONS] are:");<a name="line.1002"></a>
+<span class="sourceLineNo">1003</span>    System.err.println(" -h,-help        show this help and exit.");<a name="line.1003"></a>
+<span class="sourceLineNo">1004</span>    System.err.println(" -regionserver   set 'regionserver mode'; gets row from random region on " +<a name="line.1004"></a>
+<span class="sourceLineNo">1005</span>        "server");<a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>    System.err.println(" -allRegions     get from ALL regions when 'regionserver mode', not just " +<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>        "random one.");<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span>    System.err.println(" -zookeeper      set 'zookeeper mode'; grab zookeeper.znode.parent on " +<a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>        "each ensemble member");<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span>    System.err.println(" -daemon         continuous check at defined intervals.");<a name="line.1010"></a>
+<span class="sourceLineNo">1011</span>    System.err.println(" -interval &lt;N&gt;   interval between checks in seconds");<a name="line.1011"></a>
+<span class="sourceLineNo">1012</span>    System.err.println(" -e              consider table/regionserver argument as regular " +<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>        "expression");<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>    System.err.println(" -f &lt;B&gt;          exit on first error; default=true");<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>    System.err.println(" -failureAsError treat read/write failure as error");<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span>    System.err.println(" -t &lt;N&gt;          timeout for canary-test run; default=600000ms");<a name="line.1016"></a>
+<span class="sourceLineNo">1017</span>    System.err.println(" -writeSniffing  enable write sniffing");<a name="line.1017"></a>
+<span class="sourceLineNo">1018</span>    System.err.println(" -writeTable     the table used for write sniffing; default=hbase:canary");<a name="line.1018"></a>
+<span class="sourceLineNo">1019</span>    System.err.println(" -writeTableTimeout &lt;N&gt;  timeout for writeTable; default=600000ms");<a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>    System.err.println(" -readTableTimeouts &lt;tableName&gt;=&lt;read timeout&gt;," +<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>        "&lt;tableName&gt;=&lt;read timeout&gt;,...");<a name="line.1021"></a>
+<span class="sourceLineNo">1022</span>    System.err.println("                comma-separated list of table read timeouts " +<a name="line.1022"></a>
+<span class="sourceLineNo">1023</span>        "(no spaces);");<a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>    System.err.println("                logs 'ERROR' if takes longer. default=600000ms");<a name="line.1024"></a>
+<span class="sourceLineNo">1025</span>    System.err.println(" -permittedZookeeperFailures &lt;N&gt;  Ignore first N failures attempting to ");<a name="line.1025"></a>
+<span class="sourceLineNo">1026</span>    System.err.println("                connect to individual zookeeper nodes in ensemble");<a name="line.1026"></a>
+<span class="sourceLineNo">1027</span>    System.err.println("");<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span>    System.err.println(" -D&lt;configProperty&gt;=&lt;value&gt; to assign or override configuration params");<a name="line.1028"></a>
+<span class="sourceLineNo">1029</span>    System.err.println(" -Dhbase.canary.read.raw.enabled=&lt;true/false&gt; Set to enable/disable " +<a name="line.1029"></a>
+<span class="sourceLineNo">1030</span>        "raw scan; default=false");<a name="line.1030"></a>
+<span class="sourceLineNo">1031</span>    System.err.println("");<a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>    System.err.println("Canary runs in one of three modes: region (default), regionserver, or " +<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span>        "zookeeper.");<a name="line.1033"></a>
+<span class="sourceLineNo">1034</span>    System.err.println("To sniff/probe all regions, pass no arguments.");<a name="line.1034"></a>
+<span class="sourceLineNo">1035</span>    System.err.println("To sniff/probe all regions of a table, pass tablename.");<a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>    System.err.println("To sniff/probe regionservers, pass -regionserver, etc.");<a name="line.1036"></a>
+<span class="sourceLineNo">1037</span>    System.err.println("See http://hbase.apache.org/book.html#_canary for Canary documentation.");<a name="line.1037"></a>
+<span class="sourceLineNo">1038</span>    System.exit(USAGE_EXIT_CODE);<a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>  }<a name="line.1039"></a>
+<span class="sourceLineNo">1040</span><a name="line.1040"></a>
+<span class="sourceLineNo">1041</span>  Sink getSink(Configuration configuration, Class clazz) {<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>    // In test context, this.sink might be set. Use it if non-null. For testing.<a name="line.1042"></a>
+<span class="sourceLineNo">1043</span>    return this.sink != null? this.sink:<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>        (Sink)ReflectionUtils.newInstance(configuration.getClass("hbase.canary.sink.class",<a name="line.1044"></a>
+<span class="sourceLineNo">1045</span>            clazz, Sink.class));<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span>  }<a name="line.1046"></a>
+<span class="sourceLineNo">1047</span><a name="line.1047"></a>
+<span class="sourceLineNo">1048</span>  /**<a name="line.1048"></a>
+<span class="sourceLineNo">1049</span>   * Canary region mode-specific data structure which stores information about each region<a name="line.1049"></a>
+<span class="sourceLineNo">1050</span>   * to be scanned<a name="line.1050"></a>
+<span class="sourceLineNo">1051</span>   */<a name="line.1051"></a>
+<span class="sourceLineNo">1052</span>  public static class RegionTaskResult {<a name="line.1052"></a>
+<span class="sourceLineNo">1053</span>    private RegionInfo region;<a name="line.1053"></a>
+<span class="sourceLineNo">1054</span>    private TableName tableName;<a name="line.1054"></a>
+<span class="sourceLineNo">1055</span>    private ServerName serverName;<a name="line.1055"></a>
+<span class="sourceLineNo">1056</span>    private ColumnFamilyDescriptor column;<a name="line.1056"></a>
+<span class="sourceLineNo">1057</span>    private AtomicLong readLatency = null;<a name="line.1057"></a>
+<span class="sourceLineNo">1058</span>    private AtomicLong writeLatency = null;<a name="line.1058"></a>
+<span class="sourceLineNo">1059</span>    private boolean readSuccess = false;<a name="line.1059"></a>
+<span class="sourceLineNo">1060</span>    private boolean writeSuccess = false;<a name="line.1060"></a>
+<span class="sourceLineNo">1061</span><a name="line.1061"></a>
+<span class="sourceLineNo">1062</span>    public RegionTaskResult(RegionInfo region, TableName tableName, ServerName serverName,<a name="line.1062"></a>
+<span class="sourceLineNo">1063</span>        ColumnFamilyDescriptor column) {<a name="line.1063"></a>
+<span class="sourceLineNo">1064</span>      this.region = region;<a name="line.1064"></a>
+<span class="sourceLineNo">1065</span>      this.tableName = tableName;<a name="line.1065"></a>
+<span class="sourceLineNo">1066</span>      this.serverName = serverName;<a name="line.1066"></a>
+<span class="sourceLineNo">1067</span>      this.column = column;<a name="line.1067"></a>
+<span class="sourceLineNo">1068</span>    }<a name="line.1068"></a>
+<span class="sourceLineNo">1069</span><a name="line.1069"></a>
+<span class="sourceLineNo">1070</span>    public RegionInfo getRegionInfo() {<a name="line.1070"></a>
+<span class="sourceLineNo">1071</span>      return this.region;<a name="line.1071"></a>
+<span class="sourceLineNo">1072</span>    }<a name="line.1072"></a>
+<span class="sourceLineNo">1073</span><a name="line.1073"></a>
+<span class="sourceLineNo">1074</span>    public String getRegionNameAsString() {<a name="line.1074"></a>
+<span class="sourceLineNo">1075</span>      return this.region.getRegionNameAsString();<a name="line.1075"></a>
+<span class="sourceLineNo">1076</span>    }<a name="line.1076"></a>
+<span class="sourceLineNo">1077</span><a name="line.1077"></a>
+<span class="sourceLineNo">1078</span>    public TableName getTableName() {<a name="line.1078"></a>
+<span class="sourceLineNo">1079</span>      return this.tableName;<a name="line.1079"></a>
+<span class="sourceLineNo">1080</span>    }<a name="line.1080"></a>
+<span class="sourceLineNo">1081</span><a name="line.1081"></a>
+<span class="sourceLineNo">1082</span>    public String getTableNameAsString() {<a name="line.1082"></a>
+<span class="sourceLineNo">1083</span>      return this.tableName.getNameAsString();<a name="line.1083"></a>
+<span class="sourceLineNo">1084</span>    }<a name="line.1084"></a>
+<span class="sourceLineNo">1085</span><a name="line.1085"></a>
+<span class="sourceLineNo">1086</span>    public ServerName getServerName() {<a name="line.1086"></a>
+<span class="sourceLineNo">1087</span>      return this.serverName;<a name="line.1087"></a>
+<span class="sourceLineNo">1088</span>    }<a name="line.1088"></a>
+<span class="sourceLineNo">1089</span><a name="line.1089"></a>
+<span class="sourceLineNo">1090</span>    public String getServerNameAsString() {<a name="line.1090"></a>
+<span class="sourceLineNo">1091</span>      return this.serverName.getServerName();<a name="line.1091"></a>
+<span class="sourceLineNo">1092</span>    }<a name="line.1092"></a>
+<span class="sourceLineNo">1093</span><a name="line.1093"></a>
+<span class="sourceLineNo">1094</span>    public ColumnFamilyDescriptor getColumnFamily() {<a name="line.1094"></a>
+<span class="sourceLineNo">1095</span>      return this.column;<a name="line.1095"></a>
+<span class="sourceLineNo">1096</span>    }<a name="line.1096"></a>
+<span class="sourceLineNo">1097</span><a name="line.1097"></a>
+<span class="sourceLineNo">1098</span>    public String getColumnFamilyNameAsString() {<a name="line.1098"></a>
+<span class="sourceLineNo">1099</span>      return this.column.getNameAsString();<a name="line.1099"></a>
+<span class="sourceLineNo">1100</span>    }<a name="line.1100"></a>
+<span class="sourceLineNo">1101</span><a name="line.1101"></a>
+<span class="sourceLineNo">1102</span>    public long getReadLatency() {<a name="line.1102"></a>
+<span class="sourceLineNo">1103</span>      if (this.readLatency == null) {<a name="line.1103"></a>
+<span class="sourceLineNo">1104</span>        return -1;<a name="line.1104"></a>
+<span class="sourceLineNo">1105</span>      }<a name="line.1105"></a>
+<span class="sourceLineNo">1106</span>      return this.readLatency.get();<a name="line.1106"></a>
+<span class="sourceLineNo">1107</span>    }<a name="line.1107"></a>
+<span class="sourceLineNo">1108</span><a name="line.1108"></a>
+<span class="sourceLineNo">1109</span>    public void setReadLatency(long readLatency) {<a name="line.1109"></a>
+<span class="sourceLineNo">1110</span>      if (this.readLatency != null) {<a name="line.1110"></a>
+<span class="sourceLineNo">1111</span>        this.readLatency.set(readLatency);<a name="line.1111"></a>
+<span class="sourceLineNo">1112</span>      } else {<a name="line.1112"></a>
+<span class="sourceLineNo">1113</span>        this.readLatency = new AtomicLong(readLatency);<a name="line.1113"></a>
+<span class="sourceLineNo">1114</span>      }<a name="line.1114"></a>
+<span class="sourceLineNo">1115</span>    }<a name="line.1115"></a>
+<span class="sourceLineNo">1116</span><a name="line.1116"></a>
+<span class="sourceLineNo">1117</span>    public long getWriteLatency() {<a name="line.1117"></a>
+<span class="sourceLineNo">1118</span>      if (this.writeLatency == null) {<a name="line.1118"></a>
+<span class="sourceLineNo">1119</span>        return -1;<a name="line.1119"></a>
+<span class="sourceLineNo">1120</span>      }<a name="line.1120"></a>
+<span class="sourceLineNo">1121</span>      return this.writeLatency.get();<a name="line.1121"></a>
+<span class="sourceLineNo">1122</span>    }<a name="line.1122"></a>
+<span class="sourceLineNo">1123</span><a name="line.1123"></a>
+<span class="sourceLineNo">1124</span>    public void setWriteLatency(long writeLatency) {<a name="line.1124"></a>
+<span class="sourceLineNo">1125</span>      if (this.writeLatency != null) {<a name="line.1125"></a>
+<span class="sourceLineNo">1126</span>        this.writeLatency.set(writeLatency);<a name="line.1126"></a>
+<span class="sourceLineNo">1127</span>      } else {<a name="line.1127"></a>
+<span class="sourceLineNo">1128</span>        this.writeLatency = new AtomicLong(writeLatency);<a name="line.1128"></a>
+<span class="sourceLineNo">1129</span>      }<a name="line.1129"></a>
+<span class="sourceLineNo">1130</span>    }<a name="line.1130"></a>
+<span class="sourceLineNo">1131</span><a name="line.1131"></a>
+<span class="sourceLineNo">1132</span>    public boolean isReadSuccess() {<a name="line.1132"></a>
+<span class="sourceLineNo">1133</span>      return this.readSuccess;<a name="line.1133"></a>
+<span class="sourceLineNo">1134</span>    }<a name="line.1134"></a>
+<span class="sourceLineNo">1135</span><a name="line.1135"></a>
+<span class="sourceLineNo">1136</span>    public void setReadSuccess() {<a name="line.1136"></a>
+<span class="sourceLineNo">1137</span>      this.readSuccess = true;<a name="line.1137"></a>
+<span class="sourceLineNo">1138</span>    }<a name="line.1138"></a>
+<span class="sourceLineNo">1139</span><a name="line.1139"></a>
+<span class="sourceLineNo">1140</span>    public boolean isWriteSuccess() {<a name="line.1140"></a>
+<span class="sourceLineNo">1141</span>      return this.writeSuccess;<a name="line.1141"></a>
+<span class="sourceLineNo">1142</span>    }<a name="line.1142"></a>
+<span class="sourceLineNo">1143</span><a name="line.1143"></a>
+<span class="sourceLineNo">1144</span>    public void setWriteSuccess() {<a name="line.1144"></a>
+<span class="sourceLineNo">1145</span>      this.writeSuccess = true;<a name="line.1145"></a>
+<span class="sourceLineNo">1146</span>    }<a name="line.1146"></a>
+<span class="sourceLineNo">1147</span>  }<a name="line.1147"></a>
+<span class="sourceLineNo">1148</span><a name="line.1148"></a>
+<span class="sourceLineNo">1149</span>  /**<a name="line.1149"></a>
+<span class="sourceLineNo">1150</span>   * A Factory method for {@link Monitor}.<a name="line.1150"></a>
+<span class="sourceLineNo">1151</span>   * Makes a RegionServerMonitor, or a ZooKeeperMonitor, or a RegionMonitor.<a name="line.1151"></a>
+<span class="sourceLineNo">1152</span>   * @return a Monitor instance<a name="line.1152"></a>
+<span class="sourceLineNo">1153</span>   */<a name="line.1153"></a>
+<span class="sourceLineNo">1154</span>  private Monitor newMonitor(final Connection connection, String[] monitorTargets) {<a name="line.1154"></a>
+<span class="sourceLineNo">1155</span>    Monitor monitor;<a name="line.1155"></a>
+<span class="sourceLineNo">1156</span>    boolean useRegExp = conf.getBoolean(HBASE_CANARY_USE_REGEX, false);<a name="line.1156"></a>
+<span class="sourceLineNo">1157</span>    boolean regionServerAllRegions<a name="line.1157"></a>
+<span class="sourceLineNo">1158</span>            = conf.getBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, false);<a name="line.1158"></a>
+<span class="sourceLineNo">1159</span>    boolean failOnError<a name="line.1159"></a>
+<span class="sourceLineNo">1160</span>            = conf.getBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.1160"></a>
+<span class="sourceLineNo">1161</span>    int permittedFailures<a name="line.1161"></a>
+<span class="sourceLineNo">1162</span>            = conf.getInt(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, 0);<a name="line.1162"></a>
+<span class="sourceLineNo">1163</span>    boolean writeSniffing<a name="line.1163"></a>
+<span class="sourceLineNo">1164</span>            = conf.getBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, false);<a name="line.1164"></a>
+<span class="sourceLineNo">1165</span>    String writeTableName = conf.get(HBASE_CANARY_REGION_WRITE_TABLE_NAME,<a name="line.1165"></a>
+<span class="sourceLineNo">1166</span>            DEFAULT_WRITE_TABLE_NAME.getNameAsString());<a name="line.1166"></a>
+<span class="sourceLineNo">1167</span>    long configuredWriteTableTimeout<a name="line.1167"></a>
+<span class="sourceLineNo">1168</span>            = conf.getLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, DEFAULT_TIMEOUT);<a name="line.1168"></a>
+<span class="sourceLineNo">1169</span><a name="line.1169"></a>
+<span class="sourceLineNo">1170</span>    if (this.regionServerMode) {<a name="line.1170"></a>
+<span class="sourceLineNo">1171</span>      monitor =<a name="line.1171"></a>
+<span class="sourceLineNo">1172</span>          new RegionServerMonitor(connection, monitorTargets, useRegExp,<a name="line.1172"></a>
+<span class="sourceLineNo">1173</span>              getSink(connection.getConfiguration(), RegionServerStdOutSink.class),<a name="line.1173"></a>
+<span class="sourceLineNo">1174</span>              this.executor, regionServerAllRegions,<a name="line.1174"></a>
+<span class="sourceLineNo">1175</span>              failOnError, permittedFailures);<a name="line.1175"></a>
+<span class="sourceLineNo">1176</span><a name="line.1176"></a>
+<span class="sourceLineNo">1177</span>    } else if (this.zookeeperMode) {<a name="line.1177"></a>
+<span class="sourceLineNo">1178</span>      monitor =<a name="line.1178"></a>
+<span class="sourceLineNo">1179</span>          new ZookeeperMonitor(connection, monitorTargets, useRegExp,<a name="line.1179"></a>
+<span class="sourceLineNo">1180</span>              getSink(connection.getConfiguration(), ZookeeperStdOutSink.class),<a name="line.1180"></a>
+<span class="sourceLineNo">1181</span>              this.executor, failOnError, permittedFailures);<a name="line.1181"></a>
+<span class="sourceLineNo">1182</span>    } else {<a name="line.1182"></a>
+<span class="sourceLineNo">1183</span>      monitor =<a name="line.1183"></a>
+<span class="sourceLineNo">1184</span>          new RegionMonitor(connection, monitorTargets, useRegExp,<a name="line.1184"></a>
+<span class="sourceLineNo">1185</span>              getSink(connection.getConfiguration(), RegionStdOutSink.class),<a name="line.1185"></a>
+<span class="sourceLineNo">1186</span>              this.executor, writeSniffing,<a name="line.1186"></a>
+<span class="sourceLineNo">1187</span>              TableName.valueOf(writeTableName), failOnError, configuredReadTableTimeouts,<a name="line.1187"></a>
+<span class="sourceLineNo">1188</span>              configuredWriteTableTimeout, permittedFailures);<a name="line.1188"></a>
+<span class="sourceLineNo">1189</span>    }<a name="line.1189"></a>
+<span class="sourceLineNo">1190</span>    return monitor;<a name="line.1190"></a>
+<span class="sourceLineNo">1191</span>  }<a name="line.1191"></a>
+<span class="sourceLineNo">1192</span><a name="line.1192"></a>
+<span class="sourceLineNo">1193</span>  private void populateReadTableTimeoutsMap(String configuredReadTableTimeoutsStr) {<a name="line.1193"></a>
+<span class="sourceLineNo">1194</span>    String[] tableTimeouts = configuredReadTableTimeoutsStr.split(",");<a name="line.1194"></a>
+<span class="sourceLineNo">1195</span>    for (String tT : tableTimeouts) {<a name="line.1195"></a>
+<span class="sourceLineNo">1196</span>      String[] nameTimeout = tT.split("=");<a name="line.1196"></a>
+<span class="sourceLineNo">1197</span>      if (nameTimeout.length &lt; 2) {<a name="line.1197"></a>
+<span class="sourceLineNo">1198</span>        throw new IllegalArgumentException("Each -readTableTimeouts argument must be of the form " +<a name="line.1198"></a>
+<span class="sourceLineNo">1199</span>            "&lt;tableName&gt;=&lt;read timeout&gt; (without spaces).");<a name="line.1199"></a>
+<span class="sourceLineNo">1200</span>      }<a name="line.1200"></a>
+<span class="sourceLineNo">1201</span>      long timeoutVal;<a name="line.1201"></a>
+<span class="sourceLineNo">1202</span>      try {<a name="line.1202"></a>
+<span class="sourceLineNo">1203</span>        timeoutVal = Long.parseLong(nameTimeout[1]);<a name="line.1203"></a>
+<span class="sourceLineNo">1204</span>      } catch (NumberFormatException e) {<a name="line.1204"></a>
+<span class="sourceLineNo">1205</span>        throw new IllegalArgumentException("-readTableTimeouts read timeout for each table" +<a name="line.1205"></a>
+<span class="sourceLineNo">1206</span>            " must be a numeric value argument.");<a name="line.1206"></a>
+<span class="sourceLineNo">1207</span>      }<a name="line.1207"></a>
+<span class="sourceLineNo">1208</span>      configuredReadTableTimeouts.put(nameTimeout[0], timeoutVal);<a name="line.1208"></a>
+<span class="sourceLineNo">1209</span>    }<a name="line.1209"></a>
+<span class="sourceLineNo">1210</span>  }<a name="line.1210"></a>
+<span class="sourceLineNo">1211</span>  /**<a name="line.1211"></a>
+<span class="sourceLineNo">1212</span>   * A Monitor super-class can be extended by users<a name="line.1212"></a>
+<span class="sourceLineNo">1213</span>   */<a name="line.1213"></a>
+<span class="sourceLineNo">1214</span>  public static abstract class Monitor implements Runnable, Closeable {<a name="line.1214"></a>
+<span class="sourceLineNo">1215</span>    protected Connection connection;<a name="line.1215"></a>
+<span class="sourceLineNo">1216</span>    protected Admin admin;<a name="line.1216"></a>
+<span class="sourceLineNo">1217</span>    /**<a name="line.1217"></a>
+<span class="sourceLineNo">1218</span>     * 'Target' dependent on 'mode'. Could be Tables or RegionServers or ZNodes.<a name="line.1218"></a>
+<span class="sourceLineNo">1219</span>     * Passed on the command-line as arguments.<a name="line.1219"></a>
+<span class="sourceLineNo">1220</span>     */<a name="line.1220"></a>
+<span class="sourceLineNo">1221</span>    protected String[] targets;<a name="line.1221"></a>
+<span class="sourceLineNo">1222</span>    protected boolean useRegExp;<a name="line.1222"></a>
+<span class="sourceLineNo">1223</span>    protected boolean treatFailureAsError;<a name="line.1223"></a>
+<span class="sourceLineNo">1224</span>    protected boolean initialized = false;<a name="line.1224"></a>
+<span class="sourceLineNo">1225</span><a name="line.1225"></a>
+<span class="sourceLineNo">1226</span>    protected boolean done = false;<a name="line.1226"></a>
+<span class="sourceLineNo">1227</span>    protected int errorCode = 0;<a name="line.1227"></a>
+<span class="sourceLineNo">1228</span>    protected long allowedFailures = 0;<a name="line.1228"></a>
+<span class="sourceLineNo">1229</span>    protected Sink sink;<a name="line.1229"></a>
+<span class="sourceLineNo">1230</span>    protected ExecutorService executor;<a name="line.1230"></a>
+<span class="sourceLineNo">1231</span><a name="line.1231"></a>
+<span class="sourceLineNo">1232</span>    public boolean isDone() {<a name="line.1232"></a>
+<span class="sourceLineNo">1233</span>      return done;<a name="line.1233"></a>
+<span class="sourceLineNo">1234</span>    }<a name="line.1234"></a>
+<span class="sourceLineNo">1235</span><a name="line.1235"></a>
+<span class="sourceLineNo">1236</span>    public boolean hasError() {<a name="line.1236"></a>
+<span class="sourceLineNo">1237</span>      return errorCode != 0;<a name="line.1237"></a>
+<span class="sourceLineNo">1238</span>    }<a name="line.1238"></a>
+<span class="sourceLineNo">1239</span><a name="line.1239"></a>
+<span class="sourceLineNo">1240</span>    public boolean finalCheckForErrors() {<a name="line.1240"></a>
+<span class="sourceLineNo">1241</span>      if (errorCode != 0) {<a name="line.1241"></a>
+<span class="sourceLineNo">1242</span>        return true;<a name="line.1242"></a>
+<span class="sourceLineNo">1243</span>      }<a name="line.1243"></a>
+<span class="sourceLineNo">1244</span>      if (treatFailureAsError &amp;&amp;<a name="line.1244"></a>
+<span class="sourceLineNo">1245</span>          (sink.getReadFailureCount() &gt; allowedFailures || sink.getWriteFailureCount() &gt; allowedFailures)) {<a name="line.1245"></a>
+<span class="sourceLineNo">1246</span>        LOG.error("Too many failures detected, treating failure as error, failing the Canary.");<a name="line.1246"></a>
+<span class="sourceLineNo">1247</span>        errorCode = FAILURE_EXIT_CODE;<a name="line.1247"></a>
+<span class="sourceLineNo">1248</span>        return true;<a name="line.1248"></a>
+<span class="sourceLineNo">1249</span>      }<a name="line.1249"></a>
+<span class="sourceLineNo">1250</span>      return false;<a name="line.1250"></a>
+<span class="sourceLineNo">1251</span>    }<a name="line.1251"></a>
+<span class="sourceLineNo">1252</span><a name="line.1252"></a>
+<span class="sourceLineNo">1253</span>    @Override<a name="line.1253"></a>
+<span class="sourceLineNo">1254</span>    public void close() throws IOException {<a name="line.1254"></a>
+<span class="sourceLineNo">1255</span>      if (this.admin != null) this.admin.close();<a name="line.1255"></a>
+<span class="sourceLineNo">1256</span>    }<a name="line.1256"></a>
+<span class="sourceLineNo">1257</span><a name="line.1257"></a>
+<span class="sourceLineNo">1258</span>    protected Monitor(Connection connection, String[] monitorTargets, boolean useRegExp, Sink sink,<a name="line.1258"></a>
+<span class="sourceLineNo">1259</span>        ExecutorService executor, boolean treatFailureAsError, long allowedFailures) {<a name="line.1259"></a>
+<span class="sourceLineNo">1260</span>      if (null == connection) throw new IllegalArgumentException("connection shall not be null");<a name="line.1260"></a>
+<span class="sourceLineNo">1261</span><a name="line.1261"></a>
+<span class="sourceLineNo">1262</span>      this.connection = connection;<a name="line.1262"></a>
+<span class="sourceLineNo">1263</span>      this.targets = monitorTargets;<a name="line.1263"></a>
+<span class="sourceLineNo">1264</span>      this.useRegExp = useRegExp;<a name="line.1264"></a>
+<span class="sourceLineNo">1265</span>      this.treatFailureAsError = treatFailureAsError;<a name="line.1265"></a>
+<span class="sourceLineNo">1266</span>      this.sink = sink;<a name="line.1266"></a>
+<span class="sourceLineNo">1267</span>      this.executor = executor;<a name="line.1267"></a>
+<span class="sourceLineNo">1268</span>      this.allowedFailures = allowedFailures;<a name="line.1268"></a>
+<span class="sourceLineNo">1269</span>    }<a name="line.1269"></a>
+<span class="sourceLineNo">1270</span><a name="line.1270"></a>
+<span class="sourceLineNo">1271</span>    @Override<a name="line.1271"></a>
+<span class="sourceLineNo">1272</span>    public abstract void run();<a name="line.1272"></a>
+<span class="sourceLineNo">1273</span><a name="line.1273"></a>
+<span class="sourceLineNo">1274</span>    protected boolean initAdmin() {<a name="line.1274"></a>
+<span class="sourceLineNo">1275</span>      if (null == this.admin) {<a name="line.1275"></a>
+<span class="sourceLineNo">1276</span>        try {<a name="line.1276"></a>
+<span class="sourceLineNo">1277</span>          this.admin = this.connection.getAdmin();<a name="line.1277"></a>
+<span class="sourceLineNo">1278</span>        } catch (Exception e) {<a name="line.1278"></a>
+<span class="sourceLineNo">1279</span>          LOG.error("Initial HBaseAdmin failed...", e);<a name="line.1279"></a>
+<span class="sourceLineNo">1280</span>          this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1280"></a>
+<span class="sourceLineNo">1281</span>        }<a name="line.1281"></a>
+<span class="sourceLineNo">1282</span>      } else if (admin.isAborted()) {<a name="line.1282"></a>
+<span class="sourceLineNo">1283</span>        LOG.error("HBaseAdmin aborted");<a name="line.1283"></a>
+<span class="sourceLineNo">1284</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1284"></a>
+<span class="sourceLineNo">1285</span>      }<a name="line.1285"></a>
+<span class="sourceLineNo">1286</span>      return !this.hasError();<a name="line.1286"></a>
+<span class="sourceLineNo">1287</span>    }<a name="line.1287"></a>
+<span class="sourceLineNo">1288</span>  }<a name="line.1288"></a>
+<span class="sourceLineNo">1289</span><a name="line.1289"></a>
+<span class="sourceLineNo">1290</span>  /**<a name="line.1290"></a>
+<span class="sourceLineNo">1291</span>   * A monitor for region mode.<a name="line.1291"></a>
+<span class="sourceLineNo">1292</span>   */<a name="line.1292"></a>
+<span class="sourceLineNo">1293</span>  private static class RegionMonitor extends Monitor {<a name="line.1293"></a>
+<span class="sourceLineNo">1294</span>    // 10 minutes<a name="line.1294"></a>
+<span class="sourceLineNo">1295</span>    private static final int DEFAULT_WRITE_TABLE_CHECK_PERIOD = 10 * 60 * 1000;<a name="line.1295"></a>
+<span class="sourceLineNo">1296</span>    // 1 days<a name="line.1296"></a>
+<span class="sourceLineNo">1297</span>    private static final int DEFAULT_WRITE_DATA_TTL = 24 * 60 * 60;<a name="line.1297"></a>
+<span class="sourceLineNo">1298</span><a name="line.1298"></a>
+<span class="sourceLineNo">1299</span>    private long lastCheckTime = -1;<a name="line.1299"></a>
+<span class="sourceLineNo">1300</span>    private boolean writeSniffing;<a name="line.1300"></a>
+<span class="sourceLineNo">1301</span>    private TableName writeTableName;<a name="line.1301"></a>
+<span class="sourceLineNo">1302</span>    private int writeDataTTL;<a name="line.1302"></a>
+<span class="sourceLineNo">1303</span>    private float regionsLowerLimit;<a name="line.1303"></a>
+<span class="sourceLineNo">1304</span>    private float regionsUpperLimit;<a name="line.1304"></a>
+<span class="sourceLineNo">1305</span>    private int checkPeriod;<a name="line.1305"></a>
+<span class="sourceLineNo">1306</span>    private boolean rawScanEnabled;<a name="line.1306"></a>
+<span class="sourceLineNo">1307</span><a name="line.1307"></a>
+<span class="sourceLineNo">1308</span>    /**<a name="line.1308"></a>
+<span class="sourceLineNo">1309</span>     * This is a timeout per table. If read of each region in the table aggregated takes longer<a name="line.1309"></a>
+<span class="sourceLineNo">1310</span>     * than what is configured here, we log an ERROR rather than just an INFO.<a name="line.1310"></a>
+<span class="sourceLineNo">1311</span>     */<a name="line.1311"></a>
+<span class="sourceLineNo">1312</span>    private HashMap&lt;String, Long&gt; configuredReadTableTimeouts;<a name="line.1312"></a>
+<span class="sourceLineNo">1313</span><a name="line.1313"></a>
+<span class="sourceLineNo">1314</span>    private long configuredWriteTableTimeout;<a name="line.1314"></a>
+<span class="sourceLineNo">1315</span><a name="line.1315"></a>
+<span class="sourceLineNo">1316</span>    public RegionMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1316"></a>
+<span class="sourceLineNo">1317</span>        Sink sink, ExecutorService executor, boolean writeSniffing, TableName writeTableName,<a name="line.1317"></a>
+<span class="sourceLineNo">1318</span>        boolean treatFailureAsError, HashMap&lt;String, Long&gt; configuredReadTableTimeouts,<a name="line.1318"></a>
+<span class="sourceLineNo">1319</span>        long configuredWriteTableTimeout,<a name="line.1319"></a>
+<span class="sourceLineNo">1320</span>        long allowedFailures) {<a name="line.1320"></a>
+<span class="sourceLineNo">1321</span>      super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError,<a name="line.1321"></a>
+<span class="sourceLineNo">1322</span>          allowedFailures);<a name="line.1322"></a>
+<span class="sourceLineNo">1323</span>      Configuration conf = connection.getConfiguration();<a name="line.1323"></a>
+<span class="sourceLineNo">1324</span>      this.writeSniffing = writeSniffing;<a name="line.1324"></a>
+<span class="sourceLineNo">1325</span>      this.writeTableName = writeTableName;<a name="line.1325"></a>
+<span class="sourceLineNo">1326</span>      this.writeDataTTL =<a name="line.1326"></a>
+<span class="sourceLineNo">1327</span>          conf.getInt(HConstants.HBASE_CANARY_WRITE_DATA_TTL_KEY, DEFAULT_WRITE_DATA_TTL);<a name="line.1327"></a>
+<span class="sourceLineNo">1328</span>      this.regionsLowerLimit =<a name="line.1328"></a>
+<span class="sourceLineNo">1329</span>          conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY, 1.0f);<a name="line.1329"></a>
+<span class="sourceLineNo">1330</span>      this.regionsUpperLimit =<a name="line.1330"></a>
+<span class="sourceLineNo">1331</span>          conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_UPPERLIMIT_KEY, 1.5f);<a name="line.1331"></a>
+<span class="sourceLineNo">1332</span>      this.checkPeriod =<a name="line.1332"></a>
+<span class="sourceLineNo">1333</span>          conf.getInt(HConstants.HBASE_CANARY_WRITE_TABLE_CHECK_PERIOD_KEY,<a name="line.1333"></a>
+<span class="sourceLineNo">1334</span>            DEFAULT_WRITE_TABLE_CHECK_PERIOD);<a name="line.1334"></a>
+<span class="sourceLineNo">1335</span>      this.rawScanEnabled = conf.getBoolean(HConstants.HBASE_CANARY_READ_RAW_SCAN_KEY, false);<a name="line.1335"></a>
+<span class="sourceLineNo">1336</span>      this.configuredReadTableTimeouts = new HashMap&lt;&gt;(configuredReadTableTimeouts);<a name="line.1336"></a>
+<span class="sourceLineNo">1337</span>      this.configuredWriteTableTimeout = configuredWriteTableTimeout;<a name="line.1337"></a>
+<span class="sourceLineNo">1338</span>    }<a name="line.1338"></a>
+<span class="sourceLineNo">1339</span><a name="line.1339"></a>
+<span class="sourceLineNo">1340</span>    private RegionStdOutSink getSink() {<a name="line.1340"></a>
+<span class="sourceLineNo">1341</span>      if (!(sink instanceof RegionStdOutSink)) {<a name="line.1341"></a>
+<span class="sourceLineNo">1342</span>        throw new RuntimeException("Can only write to Region sink");<a name="line.1342"></a>
+<span class="sourceLineNo">1343</span>      }<a name="line.1343"></a>
+<span class="sourceLineNo">1344</span>      return ((RegionStdOutSink) sink);<a name="line.1344"></a>
+<span class="sourceLineNo">1345</span>    }<a name="line.1345"></a>
+<span class="sourceLineNo">1346</span><a name="line.1346"></a>
+<span class="sourceLineNo">1347</span>    @Override<a name="line.1347"></a>
+<span class="sourceLineNo">1348</span>    public void run() {<a name="line.1348"></a>
+<span class="sourceLineNo">1349</span>      if (this.initAdmin()) {<a name="line.1349"></a>
+<span class="sourceLineNo">1350</span>        try {<a name="line.1350"></a>
+<span class="sourceLineNo">1351</span>          List&lt;Future&lt;Void&gt;&gt; taskFutures = new LinkedList&lt;&gt;();<a name="line.1351"></a>
+<span class="sourceLineNo">1352</span>          RegionStdOutSink regionSink = this.getSink();<a name="line.1352"></a>
+<span class="sourceLineNo">1353</span>          if (this.targets != null &amp;&amp; this.targets.length &gt; 0) {<a name="line.1353"></a>
+<span class="sourceLineNo">1354</span>            String[] tables = generateMonitorTables(this.targets);<a name="line.1354"></a>
+<span class="sourceLineNo">1355</span>            // Check to see that each table name passed in the -readTableTimeouts argument is also<a name="line.1355"></a>
+<span class="sourceLineNo">1356</span>            // passed as a monitor target.<a name="line.1356"></a>
+<span class="sourceLineNo">1357</span>            if (!new HashSet&lt;&gt;(Arrays.asList(tables)).<a name="line.1357"></a>
+<span class="sourceLineNo">1358</span>                containsAll(this.configuredReadTableTimeouts.keySet())) {<a name="line.1358"></a>
+<span class="sourceLineNo">1359</span>              LOG.error("-readTableTimeouts can only specify read timeouts for monitor targets " +<a name="line.1359"></a>
+<span class="sourceLineNo">1360</span>                  "passed via command line.");<a name="line.1360"></a>
+<span class="sourceLineNo">1361</span>              this.errorCode = USAGE_EXIT_CODE;<a name="line.1361"></a>
+<span class="sourceLineNo">1362</span>              return;<a name="line.1362"></a>
+<span class="sourceLineNo">1363</span>            }<a name="line.1363"></a>
+<span class="sourceLineNo">1364</span>            this.initialized = true;<a name="line.1364"></a>
+<span class="sourceLineNo">1365</span>            for (String table : tables) {<a name="line.1365"></a>
+<span class="sourceLineNo">1366</span>              LongAdder readLatency = regionSink.initializeAndGetReadLatencyForTable(table);<a name="line.1366"></a>
+<span class="sourceLineNo">1367</span>              taskFutures.addAll(CanaryTool.sniff(admin, regionSink, table, executor, TaskType.READ,<a name="line.1367"></a>
+<span class="sourceLineNo">1368</span>                this.rawScanEnabled, readLatency));<a name="line.1368"></a>
+<span class="sourceLineNo">1369</span>            }<a name="line.1369"></a>
+<span class="sourceLineNo">1370</span>          } else {<a name="line.1370"></a>
+<span class="sourceLineNo">1371</span>            taskFutures.addAll(sniff(TaskType.READ, regionSink));<a name="line.1371"></a>
+<span class="sourceLineNo">1372</span>          }<a name="line.1372"></a>
+<span class="sourceLineNo">1373</span><a name="line.1373"></a>
+<span class="sourceLineNo">1374</span>          if (writeSniffing) {<a name="line.1374"></a>
+<span class="sourceLineNo">1375</span>            if (EnvironmentEdgeManager.currentTime() - lastCheckTime &gt; checkPeriod) {<a name="line.1375"></a>
+<span class="sourceLineNo">1376</span>              try {<a name="line.1376"></a>
+<span class="sourceLineNo">1377</span>                checkWriteTableDistribution();<a name="line.1377"></a>
+<span class="sourceLineNo">1378</span>              } catch (IOException e) {<a name="line.1378"></a>
+<span class="sourceLineNo">1379</span>                LOG.error("Check canary table distribution failed!", e);<a name="line.1379"></a>
+<span class="sourceLineNo">1380</span>              }<a name="line.1380"></a>
+<span class="sourceLineNo">1381</span>              lastCheckTime = EnvironmentEdgeManager.currentTime();<a name="line.1381"></a>
+<span class="sourceLineNo">1382</span>            }<a name="line.1382"></a>
+<span class="sourceLineNo">1383</span>            // sniff canary table with write operation<a name="line.1383"></a>
+<span class="sourceLineNo">1384</span>            regionSink.initializeWriteLatency();<a name="line.1384"></a>
+<span class="sourceLineNo">1385</span>            LongAdder writeTableLatency = regionSink.getWriteLatency();<a name="line.1385"></a>
+<span class="sourceLineNo">1386</span>            taskFutures.addAll(CanaryTool.sniff(admin, regionSink, admin.getDescriptor(writeTableName),<a name="line.1386"></a>
+<span class="sourceLineNo">1387</span>              executor, TaskType.WRITE, this.rawScanEnabled, writeTableLatency));<a name="line.1387"></a>
+<span class="sourceLineNo">1388</span>          }<a name="line.1388"></a>
+<span class="sourceLineNo">1389</span><a name="line.1389"></a>
+<span class="sourceLineNo">1390</span>          for (Future&lt;Void&gt; future : taskFutures) {<a name="line.1390"></a>
+<span class="sourceLineNo">1391</span>            try {<a name="line.1391"></a>
+<span class="sourceLineNo">1392</span>              future.get();<a name="line.1392"></a>
+<span class="sourceLineNo">1393</span>            } catch (ExecutionException e) {<a name="line.1393"></a>
+<span class="sourceLineNo">1394</span>              LOG.error("Sniff region failed!", e);<a name="line.1394"></a>
+<span class="sourceLineNo">1395</span>            }<a name="line.1395"></a>
+<span class="sourceLineNo">1396</span>          }<a name="line.1396"></a>
+<span class="sourceLineNo">1397</span>          Map&lt;String, LongAdder&gt; actualReadTableLatency = regionSink.getReadLatencyMap();<a name="line.1397"></a>
+<span class="sourceLineNo">1398</span>          for (Map.Entry&lt;String, Long&gt; entry : configuredReadTableTimeouts.entrySet()) {<a name="line.1398"></a>
+<span class="sourceLineNo">1399</span>            String tableName = entry.getKey();<a name="line.1399"></a>
+<span class="sourceLineNo">1400</span>            if (actualReadTableLatency.containsKey(tableName)) {<a name="line.1400"></a>
+<span class="sourceLineNo">1401</span>              Long actual = actualReadTableLatency.get(tableName).longValue();<a name="line.1401"></a>
+<span class="sourceLineNo">1402</span>              Long configured = entry.getValue();<a name="line.1402"></a>
+<span class="sourceLineNo">1403</span>              if (actual &gt; configured) {<a name="line.1403"></a>
+<span class="sourceLineNo">1404</span>                LOG.error("Read operation for {} took {}ms exceeded the configured read timeout." +<a name="line.1404"></a>
+<span class="sourceLineNo">1405</span>                    "(Configured read timeout {}ms.", tableName, actual, configured);<a name="line.1405"></a>
+<span class="sourceLineNo">1406</span>              } else {<a name="line.1406"></a>
+<span class="sourceLineNo">1407</span>                LOG.info("Read operation for {} took {}ms (Configured read timeout {}ms.",<a name="line.1407"></a>
+<span class="sourceLineNo">1408</span>                    tableName, actual, configured);<a name="line.1408"></a>
+<span class="sourceLineNo">1409</span>              }<a name="line.1409"></a>
+<span class="sourceLineNo">1410</span>            } else {<a name="line.1410"></a>
+<span class="sourceLineNo">1411</span>              LOG.error("Read operation for {} failed!", tableName);<a name="line.1411"></a>
+<span class="sourceLineNo">1412</span>            }<a name="line.1412"></a>
+<span class="sourceLineNo">1413</span>          }<a name="line.1413"></a>
+<span class="sourceLineNo">1414</span>          if (this.writeSniffing) {<a name="line.1414"></a>
+<span class="sourceLineNo">1415</span>            String writeTableStringName = this.writeTableName.getNameAsString();<a name="line.1415"></a>
+<span class="sourceLineNo">1416</span>            long actualWriteLatency = regionSink.getWriteLatency().longValue();<a name="line.1416"></a>
+<span class="sourceLineNo">1417</span>            LOG.info("Write operation for {} took {}ms. Configured write timeout {}ms.",<a name="line.1417"></a>
+<span class="sourceLineNo">1418</span>                writeTableStringName, actualWriteLatency, this.configuredWriteTableTimeout);<a name="line.1418"></a>
+<span class="sourceLineNo">1419</span>            // Check that the writeTable write operation latency does not exceed the configured timeout.<a name="line.1419"></a>
+<span class="sourceLineNo">1420</span>            if (actualWriteLatency &gt; this.configuredWriteTableTimeout) {<a name="line.1420"></a>
+<span class="sourceLineNo">1421</span>              LOG.error("Write operation for {} exceeded the configured write timeout.",<a name="line.1421"></a>
+<span class="sourceLineNo">1422</span>                  writeTableStringName);<a name="line.1422"></a>
+<span class="sourceLineNo">1423</span>            }<a name="line.1423"></a>
+<span class="sourceLineNo">1424</span>          }<a name="line.1424"></a>
+<span class="sourceLineNo">1425</span>        } catch (Exception e) {<a name="line.1425"></a>
+<span class="sourceLineNo">1426</span>          LOG.error("Run regionMonitor failed", e);<a name="line.1426"></a>
+<span class="sourceLineNo">1427</span>          this.errorCode = ERROR_EXIT_CODE;<a name="line.1427"></a>
+<span class="sourceLineNo">1428</span>        } finally {<a name="line.1428"></a>
+<span class="sourceLineNo">1429</span>          this.done = true;<a name="line.1429"></a>
+<span class="sourceLineNo">1430</span>        }<a name="line.1430"></a>
+<span class="sourceLineNo">1431</span>      }<a name="line.1431"></a>
+<span class="sourceLineNo">1432</span>      this.done = true;<a name="line.1432"></a>
+<span class="sourceLineNo">1433</span>    }<a name="line.1433"></a>
+<span class="sourceLineNo">1434</span><a name="line.1434"></a>
+<span class="sourceLineNo">1435</span>    /**<a name="line.1435"></a>
+<span class="sourceLineNo">1436</span>     * @return List of tables to use in test.<a name="line.1436"></a>
+<span class="sourceLineNo">1437</span>     */<a name="line.1437"></a>
+<span class="sourceLineNo">1438</span>    private String[] generateMonitorTables(String[] monitorTargets) throws IOException {<a name="line.1438"></a>
+<span class="sourceLineNo">1439</span>      String[] returnTables = null;<a name="line.1439"></a>
+<span class="sourceLineNo">1440</span><a name="line.1440"></a>
+<span class="sourceLineNo">1441</span>      if (this.useRegExp) {<a name="line.1441"></a>
+<span class="sourceLineNo">1442</span>        Pattern pattern = null;<a name="line.1442"></a>
+<span class="sourceLineNo">1443</span>        List&lt;TableDescriptor&gt; tds = null;<a name="line.1443"></a>
+<span class="sourceLineNo">1444</span>        Set&lt;String&gt; tmpTables = new TreeSet&lt;&gt;();<a name="line.1444"></a>
+<span class="sourceLineNo">1445</span>        try {<a name="line.1445"></a>
+<span class="sourceLineNo">1446</span>          LOG.debug(String.format("reading list of tables"));<a name="line.1446"></a>
+<span class="sourceLineNo">1447</span>          tds = this.admin.listTableDescriptors(pattern);<a name="line.1447"></a>
+<span class="sourceLineNo">1448</span>          if (tds == null) {<a name="line.1448"></a>
+<span class="sourceLineNo">1449</span>            tds = Collections.emptyList();<a name="line.1449"></a>
+<span class="sourceLineNo">1450</span>          }<a name="line.1450"></a>
+<span class="sourceLineNo">1451</span>          for (String monitorTarget : monitorTargets) {<a name="line.1451"></a>
+<span class="sourceLineNo">1452</span>            pattern = Pattern.compile(monitorTarget);<a name="line.1452"></a>
+<span class="sourceLineNo">1453</span>            for (TableDescriptor td : tds) {<a name="line.1453"></a>
+<span class="sourceLineNo">1454</span>              if (pattern.matcher(td.getTableName().getNameAsString()).matches()) {<a name="line.1454"></a>
+<span class="sourceLineNo">1455</span>                tmpTables.add(td.getTableName().getNameAsString());<a name="line.1455"></a>
+<span class="sourceLineNo">1456</span>              }<a name="line.1456"></a>
+<span class="sourceLineNo">1457</span>            }<a name="line.1457"></a>
+<span class="sourceLineNo">1458</span>          }<a name="line.1458"></a>
+<span class="sourceLineNo">1459</span>        } catch (IOException e) {<a name="line.1459"></a>
+<span class="sourceLineNo">1460</span>          LOG.error("Communicate with admin failed", e);<a name="line.1460"></a>
+<span class="sourceLineNo">1461</span>          throw e;<a name="line.1461"></a>
+<span class="sourceLineNo">1462</span>        }<a name="line.1462"></a>
+<span class="sourceLineNo">1463</span><a name="line.1463"></a>
+<span class="sourceLineNo">1464</span>        if (tmpTables.size() &gt; 0) {<a name="line.1464"></a>
+<span class="sourceLineNo">1465</span>          returnTables = tmpTables.toArray(new String[tmpTables.size()]);<a name="line.1465"></a>
+<span class="sourceLineNo">1466</span>        } else {<a name="line.1466"></a>
+<span class="sourceLineNo">1467</span>          String msg = "No HTable found, tablePattern:" + Arrays.toString(monitorTargets);<a name="line.1467"></a>
+<span class="sourceLineNo">1468</span>          LOG.error(msg);<a name="line.1468"></a>
+<span class="sourceLineNo">1469</span>          this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1469"></a>
+<span class="sourceLineNo">1470</span>          throw new TableNotFoundException(msg);<a name="line.1470"></a>
+<span class="sourceLineNo">1471</span>        }<a name="line.1471"></a>
+<span class="sourceLineNo">1472</span>      } else {<a name="line.1472"></a>
+<span class="sourceLineNo">1473</span>        returnTables = monitorTargets;<a name="line.1473"></a>
+<span class="sourceLineNo">1474</span>      }<a name="line.1474"></a>
+<span class="sourceLineNo">1475</span><a name="line.1475"></a>
+<span class="sourceLineNo">1476</span>      return returnTables;<a name="line.1476"></a>
+<span class="sourceLineNo">1477</span>    }<a name="line.1477"></a>
+<span class="sourceLineNo">1478</span><a name="line.1478"></a>
+<span class="sourceLineNo">1479</span>    /*<a name="line.1479"></a>
+<span class="sourceLineNo">1480</span>     * Canary entry point to monitor all the tables.<a name="line.1480"></a>
+<span class="sourceLineNo">1481</span>     */<a name="line.1481"></a>
+<span class="sourceLineNo">1482</span>    private List&lt;Future&lt;Void&gt;&gt; sniff(TaskType taskType, RegionStdOutSink regionSink)<a name="line.1482"></a>
+<span class="sourceLineNo">1483</span>        throws Exception {<a name="line.1483"></a>
+<span class="sourceLineNo">1484</span>      LOG.debug("Reading list of tables");<a name="line.1484"></a>
+<span class="sourceLineNo">1485</span>      List&lt;Future&lt;Void&gt;&gt; taskFutures = new LinkedList&lt;&gt;();<a name="line.1485"></a>
+<span class="sourceLineNo">1486</span>      for (TableDescriptor td: admin.listTableDescriptors()) {<a name="line.1486"></a>
+<span class="sourceLineNo">1487</span>        if (admin.tableExists(td.getTableName()) &amp;&amp; admin.isTableEnabled(td.getTableName()) &amp;&amp;<a name="line.1487"></a>
+<span class="sourceLineNo">1488</span>            (!td.getTableName().equals(writeTableName))) {<a name="line.1488"></a>
+<span class="sourceLineNo">1489</span>          LongAdder readLatency =<a name="line.1489"></a>
+<span class="sourceLineNo">1490</span>              regionSink.initializeAndGetReadLatencyForTable(td.getTableName().getNameAsString());<a name="line.1490"></a>
+<span class="sourceLineNo">1491</span>          taskFutures.addAll(CanaryTool.sniff(admin, sink, td, executor, taskType, this.rawScanEnabled,<a name="line.1491"></a>
+<span class="sourceLineNo">1492</span>              readLatency));<a name="line.1492"></a>
+<span class="sourceLineNo">1493</span>        }<a name="line.1493"></a>
+<span class="sourceLineNo">1494</span>      }<a name="line.1494"></a>
+<span class="sourceLineNo">1495</span>      return taskFutures;<a name="line.1495"></a>
+<span class="sourceLineNo">1496</span>    }<a name="line.1496"></a>
+<span class="sourceLineNo">1497</span><a name="line.1497"></a>
+<span class="sourceLineNo">1498</span>    private void checkWriteTableDistribution() throws IOException {<a name="line.1498"></a>
+<span class="sourceLineNo">1499</span>      if (!admin.tableExists(writeTableName)) {<a name="line.1499"></a>
+<span class="sourceLineNo">1500</span>        int numberOfServers = admin.getRegionServers().size();<a name="line.1500"></a>
+<span class="sourceLineNo">1501</span>        if (numberOfServers == 0) {<a name="line.1501"></a>
+<span class="sourceLineNo">1502</span>          throw new IllegalStateException("No live regionservers");<a name="line.1502"></a>
+<span class="sourceLineNo">1503</span>        }<a name="line.1503"></a>
+<span class="sourceLineNo">1504</span>        createWriteTable(numberOfServers);<a name="line.1504"></a>
+<span class="sourceLineNo">1505</span>      }<a name="line.1505"></a>
+<span class="sourceLineNo">1506</span><a name="line.1506"></a>
+<span class="sourceLineNo">1507</span>      if (!admin.isTableEnabled(writeTableName)) {<a name="line.1507"></a>
+<span class="sourceLineNo">1508</span>        admin.enableTable(writeTableName);<a name="line.1508"></a>
+<span class="sourceLineNo">1509</span>      }<a name="line.1509"></a>
+<span class="sourceLineNo">1510</span><a name="line.1510"></a>
+<span class="sourceLineNo">1511</span>      ClusterMetrics status =<a name="line.1511"></a>
+<span class="sourceLineNo">1512</span>          admin.getClusterMetrics(EnumSet.of(Option.SERVERS_NAME, Option.MASTER));<a name="line.1512"></a>
+<span class="sourceLineNo">1513</span>      int numberOfServers = status.getServersName().size();<a name="line.1513"></a>
+<span class="sourceLineNo">1514</span>      if (status.getServersName().contains(status.getMasterName())) {<a name="line.1514"></a>
+<span class="sourceLineNo">1515</span>        numberOfServers -= 1;<a name="line.1515"></a>
+<span class="sourceLineNo">1516</span>      }<a name="line.1516"></a>
+<span class="sourceLineNo">1517</span><a name="line.1517"></a>
+<span class="sourceLineNo">1518</span>      List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; pairs =<a name="line.1518"></a>
+<span class="sourceLineNo">1519</span>          MetaTableAccessor.getTableRegionsAndLocations(connection, writeTableName);<a name="line.1519"></a>
+<span class="sourceLineNo">1520</span>      int numberOfRegions = pairs.size();<a name="line.1520"></a>
+<span class="sourceLineNo">1521</span>      if (numberOfRegions &lt; numberOfServers * regionsLowerLimit<a name="line.1521"></a>
+<span class="sourceLineNo">1522</span>          || numberOfRegions &gt; numberOfServers * regionsUpperLimit) {<a name="line.1522"></a>
+<span class="sourceLineNo">1523</span>        admin.disableTable(writeTableName);<a name="line.1523"></a>
+<span class="sourceLineNo">1524</span>        admin.deleteTable(writeTableName);<a name="line.1524"></a>
+<span class="sourceLineNo">1525</span>        createWriteTable(numberOfServers);<a name="line.1525"></a>
+<span class="sourceLineNo">1526</span>      }<a name="line.1526"></a>
+<span class="sourceLineNo">1527</span>      HashSet&lt;ServerName&gt; serverSet = new HashSet&lt;&gt;();<a name="line.1527"></a>
+<span class="sourceLineNo">1528</span>      for (Pair&lt;RegionInfo, ServerName&gt; pair : pairs) {<a name="line.1528"></a>
+<span class="sourceLineNo">1529</span>        serverSet.add(pair.getSecond());<a name="line.1529"></a>
+<span class="sourceLineNo">1530</span>      }<a name="line.1530"></a>
+<span class="sourceLineNo">1531</span>      int numberOfCoveredServers = serverSet.size();<a name="line.1531"></a>
+<span class="sourceLineNo">1532</span>      if (numberOfCoveredServers &lt; numberOfServers) {<a name="line.1532"></a>
+<span class="sourceLineNo">1533</span>        admin.balance();<a name="line.1533"></a>
+<span class="sourceLineNo">1534</span>      }<a name="line.1534"></a>
+<span class="sourceLineNo">1535</span>    }<a name="line.1535"></a>
+<span class="sourceLineNo">1536</span><a name="line.1536"></a>
+<span class="sourceLineNo">1537</span>    private void createWriteTable(int numberOfServers) throws IOException {<a name="line.1537"></a>
+<span class="sourceLineNo">1538</span>      int numberOfRegions = (int)(numberOfServers * regionsLowerLimit);<a name="line.1538"></a>
+<span class="sourceLineNo">1539</span>      LOG.info("Number of live regionservers {}, pre-splitting the canary table into {} regions " +<a name="line.1539"></a>
+<span class="sourceLineNo">1540</span>        "(current lower limit of regions per server is {} and you can change it with config {}).",<a name="line.1540"></a>
+<span class="sourceLineNo">1541</span>          numberOfServers, numberOfRegions, regionsLowerLimit,<a name="line.1541"></a>
+<span class="sourceLineNo">1542</span>          HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY);<a name="line.1542"></a>
+<span class="sourceLineNo">1543</span>      HTableDescriptor desc = new HTableDescriptor(writeTableName);<a name="line.1543"></a>
+<span class="sourceLineNo">1544</span>      HColumnDescriptor family = new HColumnDescriptor(CANARY_TABLE_FAMILY_NAME);<a name="line.1544"></a>
+<span class="sourceLineNo">1545</span>      family.setMaxVersions(1);<a name="line.1545"></a>
+<span class="sourceLineNo">1546</span>      family.setTimeToLive(writeDataTTL);<a name="line.1546"></a>
+<span class="sourceLineNo">1547</span><a name="line.1547"></a>
+<span class="sourceLineNo">1548</span>      desc.addFamily(family);<a name="line.1548"></a>
+<span class="sourceLineNo">1549</span>      byte[][] splits = new RegionSplitter.HexStringSplit().split(numberOfRegions);<a name="line.1549"></a>
+<span class="sourceLineNo">1550</span>      admin.createTable(desc, splits);<a name="line.1550"></a>
+<span class="sourceLineNo">1551</span>    }<a name="line.1551"></a>
+<span class="sourceLineNo">1552</span>  }<a name="line.1552"></a>
+<span class="sourceLineNo">1553</span><a name="line.1553"></a>
+<span class="sourceLineNo">1554</span>  /**<a name="line.1554"></a>
+<span class="sourceLineNo">1555</span>   * Canary entry point for specified table.<a name="line.1555"></a>
+<span class="sourceLineNo">1556</span>   * @throws Exception<a name="line.1556"></a>
+<span class="sourceLineNo">1557</span>   */<a name="line.1557"></a>
+<span class="sourceLineNo">1558</span>  private static List&lt;Future&lt;Void&gt;&gt; sniff(final Admin admin, final Sink sink, String tableName,<a name="line.1558"></a>
+<span class="sourceLineNo">1559</span>      ExecutorService executor, TaskType taskType, boolean rawScanEnabled, LongAdder readLatency)<a name="line.1559"></a>
+<span class="sourceLineNo">1560</span>      throws Exception {<a name="line.1560"></a>
+<span class="sourceLineNo">1561</span>    LOG.debug("Checking table is enabled and getting table descriptor for table {}", tableName);<a name="line.1561"></a>
+<span class="sourceLineNo">1562</span>    if (admin.isTableEnabled(TableName.valueOf(tableName))) {<a name="line.1562"></a>
+<span class="sourceLineNo">1563</span>      return CanaryTool.sniff(admin, sink, admin.getDescriptor(TableName.valueOf(tableName)),<a name="line.1563"></a>
+<span class="sourceLineNo">1564</span>        executor, taskType, rawScanEnabled, readLatency);<a name="line.1564"></a>
+<span class="sourceLineNo">1565</span>    } else {<a name="line.1565"></a>
+<span class="sourceLineNo">1566</span>      LOG.warn("Table {} is not enabled", tableName);<a name="line.1566"></a>
+<span class="sourceLineNo">1567</span>    }<a name="line.1567"></a>
+<span class="sourceLineNo">1568</span>    return new LinkedList&lt;&gt;();<a name="line.1568"></a>
+<span class="sourceLineNo">1569</span>  }<a name="line.1569"></a>
+<span class="sourceLineNo">1570</span><a name="line.1570"></a>
+<span class="sourceLineNo">1571</span>  /*<a name="line.1571"></a>
+<span class="sourceLineNo">1572</span>   * Loops over regions of this table, and outputs information about the state.<a name="line.1572"></a>
+<span class="sourceLineNo">1573</span>   */<a name="line.1573"></a>
+<span class="sourceLineNo">1574</span>  private static List&lt;Future&lt;Void&gt;&gt; sniff(final Admin admin, final Sink sink,<a name="line.1574"></a>
+<span class="sourceLineNo">1575</span>      TableDescriptor tableDesc, ExecutorService executor, TaskType taskType,<a name="line.1575"></a>
+<span class="sourceLineNo">1576</span>      boolean rawScanEnabled, LongAdder rwLatency) throws Exception {<a name="line.1576"></a>
+<span class="sourceLineNo">1577</span>    LOG.debug("Reading list of regions for table {}", tableDesc.getTableName());<a name="line.1577"></a>
+<span class="sourceLineNo">1578</span>    try (Table table = admin.getConnection().getTable(tableDesc.getTableName())) {<a name="line.1578"></a>
+<span class="sourceLineNo">1579</span>      List&lt;RegionTask&gt; tasks = new ArrayList&lt;&gt;();<a name="line.1579"></a>
+<span class="sourceLineNo">1580</span>      try (RegionLocator regionLocator =<a name="line.1580"></a>
+<span class="sourceLineNo">1581</span>               admin.getConnection().getRegionLocator(tableDesc.getTableName())) {<a name="line.1581"></a>
+<span class="sourceLineNo">1582</span>        for (HRegionLocation location: regionLocator.getAllRegionLocations()) {<a name="line.1582"></a>
+<span class="sourceLineNo">1583</span>          if (location == null) {<a name="line.1583"></a>
+<span class="sourceLineNo">1584</span>            LOG.warn("Null location");<a name="line.1584"></a>
+<span class="sourceLineNo">1585</span>            continue;<a name="line.1585"></a>
+<span class="sourceLineNo">1586</span>          }<a name="line.1586"></a>
+<span class="sourceLineNo">1587</span>          ServerName rs = location.getServerName();<a name="line.1587"></a>
+<span class="sourceLineNo">1588</span>          RegionInfo region = location.getRegion();<a name="line.1588"></a>
+<span class="sourceLineNo">1589</span>          tasks.add(new RegionTask(admin.getConnection(), region, rs, (RegionStdOutSink)sink,<a name="line.1589"></a>
+<span class="sourceLineNo">1590</span>              taskType, rawScanEnabled, rwLatency));<a name="line.1590"></a>
+<span class="sourceLineNo">1591</span>          Map&lt;String, List&lt;RegionTaskResult&gt;&gt; regionMap = ((RegionStdOutSink) sink).getRegionMap();<a name="line.1591"></a>
+<span class="sourceLineNo">1592</span>          regionMap.put(region.getRegionNameAsString(), new ArrayList&lt;RegionTaskResult&gt;());<a name="line.1592"></a>
+<span class="sourceLineNo">1593</span>        }<a name="line.1593"></a>
+<span class="sourceLineNo">1594</span>        return executor.invokeAll(tasks);<a name="line.1594"></a>
+<span class="sourceLineNo">1595</span>      }<a name="line.1595"></a>
+<span class="sourceLineNo">1596</span>    } catch (TableNotFoundException e) {<a name="line.1596"></a>
+<span class="sourceLineNo">1597</span>      return Collections.EMPTY_LIST;<a name="line.1597"></a>
+<span class="sourceLineNo">1598</span>    }<a name="line.1598"></a>
+<span class="sourceLineNo">1599</span>  }<a name="line.1599"></a>
+<span class="sourceLineNo">1600</span><a name="line.1600"></a>
+<span class="sourceLineNo">1601</span>  //  monitor for zookeeper mode<a name="line.1601"></a>
+<span class="sourceLineNo">1602</span>  private static class ZookeeperMonitor extends Monitor {<a name="line.1602"></a>
+<span class="sourceLineNo">1603</span>    private List&lt;String&gt; hosts;<a name="line.1603"></a>
+<span class="sourceLineNo">1604</span>    private final String znode;<a name="line.1604"></a>
+<span class="sourceLineNo">1605</span>    private final int timeout;<a name="line.1605"></a>
+<span class="sourceLineNo">1606</span><a name="line.1606"></a>
+<span class="sourceLineNo">1607</span>    protected ZookeeperMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1607"></a>
+<span class="sourceLineNo">1608</span>        Sink sink, ExecutorService executor, boolean treatFailureAsError, long allowedFailures)  {<a name="line.1608"></a>
+<span class="sourceLineNo">1609</span>      super(connection, monitorTargets, useRegExp,<a name="line.1609"></a>
+<span class="sourceLineNo">1610</span>          sink, executor, treatFailureAsError, allowedFailures);<a name="line.1610"></a>
+<span class="sourceLineNo">1611</span>      Configuration configuration = connection.getConfiguration();<a name="line.1611"></a>
+<span class="sourceLineNo">1612</span>      znode =<a name="line.1612"></a>
+<span class="sourceLineNo">1613</span>          configuration.get(ZOOKEEPER_ZNODE_PARENT,<a name="line.1613"></a>
+<span class="sourceLineNo">1614</span>              DEFAULT_ZOOKEEPER_ZNODE_PARENT);<a name="line.1614"></a>
+<span class="sourceLineNo">1615</span>      timeout = configuration<a name="line.1615"></a>
+<span class="sourceLineNo">1616</span>          .getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);<a name="line.1616"></a>
+<span class="sourceLineNo">1617</span>      ConnectStringParser parser =<a name="line.1617"></a>
+<span class="sourceLineNo">1618</span>          new ConnectStringParser(ZKConfig.getZKQuorumServersString(configuration));<a name="line.1618"></a>
+<span class="sourceLineNo">1619</span>      hosts = Lists.newArrayList();<a name="line.1619"></a>
+<span class="sourceLineNo">1620</span>      for (InetSocketAddress server : parser.getServerAddresses()) {<a name="line.1620"></a>
+<span class="sourceLineNo">1621</span>        hosts.add(server.toString());<a name="line.1621"></a>
 <span class="sourceLineNo">1622</span>      }<a name="line.1622"></a>
-<span class="sourceLineNo">1623</span>    }<a name="line.1623"></a>
-<span class="sourceLineNo">1624</span><a name="line.1624"></a>
-<span class="sourceLineNo">1625</span>    @Override public void run() {<a name="line.1625"></a>
-<span class="sourceLineNo">1626</span>      List&lt;ZookeeperTask&gt; tasks = Lists.newArrayList();<a name="line.1626"></a>
-<span class="sourceLineNo">1627</span>      ZookeeperStdOutSink zkSink = null;<a name="line.1627"></a>
-<span class="sourceLineNo">1628</span>      try {<a name="line.1628"></a>
-<span class="sourceLineNo">1629</span>        zkSink = this.getSink();<a name="line.1629"></a>
-<span class="sourceLineNo">1630</span>      } catch (RuntimeException e) {<a name="line.1630"></a>
-<span class="sourceLineNo">1631</span>        LOG.error("Run ZooKeeperMonitor failed!", e);<a name="line.1631"></a>
-<span class="sourceLineNo">1632</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1632"></a>
-<span class="sourceLineNo">1633</span>      }<a name="line.1633"></a>
-<span class="sourceLineNo">1634</span>      this.initialized = true;<a name="line.1634"></a>
-<span class="sourceLineNo">1635</span>      for (final String host : hosts) {<a name="line.1635"></a>
-<span class="sourceLineNo">1636</span>        tasks.add(new ZookeeperTask(connection, host, znode, timeout, zkSink));<a name="line.1636"></a>
-<span class="sourceLineNo">1637</span>      }<a name="line.1637"></a>
-<span class="sourceLineNo">1638</span>      try {<a name="line.1638"></a>
-<span class="sourceLineNo">1639</span>        for (Future&lt;Void&gt; future : this.executor.invokeAll(tasks)) {<a name="line.1639"></a>
-<span class="sourceLineNo">1640</span>          try {<a name="line.1640"></a>
-<span class="sourceLineNo">1641</span>            future.get();<a name="line.1641"></a>
-<span class="sourceLineNo">1642</span>          } catch (ExecutionException e) {<a name="line.1642"></a>
-<span class="sourceLineNo">1643</span>            LOG.error("Sniff zookeeper failed!", e);<a name="line.1643"></a>
-<span class="sourceLineNo">1644</span>            this.errorCode = ERROR_EXIT_CODE;<a name="line.1644"></a>
-<span class="sourceLineNo">1645</span>          }<a name="line.1645"></a>
-<span class="sourceLineNo">1646</span>        }<a name="line.1646"></a>
-<span class="sourceLineNo">1647</span>      } catch (InterruptedException e) {<a name="line.1647"></a>
-<span class="sourceLineNo">1648</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1648"></a>
-<span class="sourceLineNo">1649</span>        Thread.currentThread().interrupt();<a name="line.1649"></a>
-<span class="sourceLineNo">1650</span>        LOG.error("Sniff zookeeper interrupted!", e);<a name="line.1650"></a>
-<span class="sourceLineNo">1651</span>      }<a name="line.1651"></a>
-<span class="sourceLineNo">1652</span>      this.done = true;<a name="line.1652"></a>
-<span class="sourceLineNo">1653</span>    }<a name="line.1653"></a>
-<span class="sourceLineNo">1654</span><a name="line.1654"></a>
-<span class="sourceLineNo">1655</span>    private ZookeeperStdOutSink getSink() {<a name="line.1655"></a>
-<span class="sourceLineNo">1656</span>      if (!(sink instanceof ZookeeperStdOutSink)) {<a name="line.1656"></a>
-<span class="sourceLineNo">1657</span>        throw new RuntimeException("Can only write to zookeeper sink");<a name="line.1657"></a>
-<span class="sourceLineNo">1658</span>      }<a name="line.1658"></a>
-<span class="sourceLineNo">1659</span>      return ((ZookeeperStdOutSink) sink);<a name="line.1659"></a>
-<span class="sourceLineNo">1660</span>    }<a name="line.1660"></a>
-<span class="sourceLineNo">1661</span>  }<a name="line.1661"></a>
-<span class="sourceLineNo">1662</span><a name="line.1662"></a>
-<span class="sourceLineNo">1663</span><a name="line.1663"></a>
-<span class="sourceLineNo">1664</span>  /**<a name="line.1664"></a>
-<span class="sourceLineNo">1665</span>   * A monitor for regionserver mode<a name="line.1665"></a>
-<span class="sourceLineNo">1666</span>   */<a name="line.1666"></a>
-<span class="sourceLineNo">1667</span>  private static class RegionServerMonitor extends Monitor {<a name="line.1667"></a>
-<span class="sourceLineNo">1668</span>    private boolean allRegions;<a name="line.1668"></a>
-<span class="sourceLineNo">1669</span><a name="line.1669"></a>
-<span class="sourceLineNo">1670</span>    public RegionServerMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1670"></a>
-<span class="sourceLineNo">1671</span>        Sink sink, ExecutorService executor, boolean allRegions,<a name="line.1671"></a>
-<span class="sourceLineNo">1672</span>        boolean treatFailureAsError, long allowedFailures) {<a name="line.1672"></a>
-<span class="sourceLineNo">1673</span>      super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError,<a name="line.1673"></a>
-<span class="sourceLineNo">1674</span>          allowedFailures);<a name="line.1674"></a>
-<span class="sourceLineNo">1675</span>      this.allRegions = allRegions;<a name="line.1675"></a>
-<span class="sourceLineNo">1676</span>    }<a name="line.1676"></a>
-<span class="sourceLineNo">1677</span><a name="line.1677"></a>
-<span class="sourceLineNo">1678</span>    private RegionServerStdOutSink getSink() {<a name="line.1678"></a>
-<span class="sourceLineNo">1679</span>      if (!(sink instanceof RegionServerStdOutSink)) {<a name="line.1679"></a>
-<span class="sourceLineNo">1680</span>        throw new RuntimeException("Can only write to regionserver sink");<a name="line.1680"></a>
-<span class="sourceLineNo">1681</span>      }<a name="line.1681"></a>
-<span class="sourceLineNo">1682</span>      return ((RegionServerStdOutSink) sink);<a name="line.1682"></a>
-<span class="sourceLineNo">1683</span>    }<a name="line.1683"></a>
-<span class="sourceLineNo">1684</span><a name="line.1684"></a>
-<span class="sourceLineNo">1685</span>    @Override<a name="line.1685"></a>
-<span class="sourceLineNo">1686</span>    public void run() {<a name="line.1686"></a>
-<span class="sourceLineNo">1687</span>      if (this.initAdmin() &amp;&amp; this.checkNoTableNames()) {<a name="line.1687"></a>
-<span class="sourceLineNo">1688</span>        RegionServerStdOutSink regionServerSink = null;<a name="line.1688"></a>
-<span class="sourceLineNo">1689</span>        try {<a name="line.1689"></a>
-<span class="sourceLineNo">1690</span>          regionServerSink = this.getSink();<a name="line.1690"></a>
-<span class="sourceLineNo">1691</span>        } catch (RuntimeException e) {<a name="line.1691"></a>
-<span class="sourceLineNo">1692</span>          LOG.error("Run RegionServerMonitor failed!", e);<a name="line.1692"></a>
-<span class="sourceLineNo">1693</span>          this.errorCode = ERROR_EXIT_CODE;<a name="line.1693"></a>
-<span class="sourceLineNo">1694</span>        }<a name="line.1694"></a>
-<span class="sourceLineNo">1695</span>        Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap = this.filterRegionServerByName();<a name="line.1695"></a>
-<span class="sourceLineNo">1696</span>        this.initialized = true;<a name="line.1696"></a>
-<span class="sourceLineNo">1697</span>        this.monitorRegionServers(rsAndRMap, regionServerSink);<a name="line.1697"></a>
-<span class="sourceLineNo">1698</span>      }<a name="line.1698"></a>
-<span class="sourceLineNo">1699</span>      this.done = true;<a name="line.1699"></a>
-<span class="sourceLineNo">1700</span>    }<a name="line.1700"></a>
-<span class="sourceLineNo">1701</span><a name="line.1701"></a>
-<span class="sourceLineNo">1702</span>    private boolean checkNoTableNames() {<a name="line.1702"></a>
-<span class="sourceLineNo">1703</span>      List&lt;String&gt; foundTableNames = new ArrayList&lt;&gt;();<a name="line.1703"></a>
-<span class="sourceLineNo">1704</span>      TableName[] tableNames = null;<a name="line.1704"></a>
-<span class="sourceLineNo">1705</span>      LOG.debug("Reading list of tables");<a name="line.1705"></a>
-<span class="sourceLineNo">1706</span>      try {<a name="line.1706"></a>
-<span class="sourceLineNo">1707</span>        tableNames = this.admin.listTableNames();<a name="line.1707"></a>
-<span class="sourceLineNo">1708</span>      } catch (IOException e) {<a name="line.1708"></a>
-<span class="sourceLineNo">1709</span>        LOG.error("Get listTableNames failed", e);<a name="line.1709"></a>
-<span class="sourceLineNo">1710</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1710"></a>
-<span class="sourceLineNo">1711</span>        return false;<a name="line.1711"></a>
-<span class="sourceLineNo">1712</span>      }<a name="line.1712"></a>
-<span class="sourceLineNo">1713</span><a name="line.1713"></a>
-<span class="sourceLineNo">1714</span>      if (this.targets == null || this.targets.length == 0) return true;<a name="line.1714"></a>
-<span class="sourceLineNo">1715</span><a name="line.1715"></a>
-<span class="sourceLineNo">1716</span>      for (String target : this.targets) {<a name="line.1716"></a>
-<span class="sourceLineNo">1717</span>        for (TableName tableName : tableNames) {<a name="line.1717"></a>
-<span class="sourceLineNo">1718</span>          if (target.equals(tableName.getNameAsString())) {<a name="line.1718"></a>
-<span class="sourceLineNo">1719</span>            foundTableNames.add(target);<a name="line.1719"></a>
-<span class="sourceLineNo">1720</span>          }<a name="line.1720"></a>
-<span class="sourceLineNo">1721</span>        }<a name="line.1721"></a>
-<span class="sourceLineNo">1722</span>      }<a name="line.1722"></a>
-<span class="sourceLineNo">1723</span><a name="line.1723"></a>
-<span class="sourceLineNo">1724</span>      if (foundTableNames.size() &gt; 0) {<a name="line.1724"></a>
-<span class="sourceLineNo">1725</span>        System.err.println("Cannot pass a tablename when using the -regionserver " +<a name="line.1725"></a>
-<span class="sourceLineNo">1726</span>            "option, tablenames:" + foundTableNames.toString());<a name="line.1726"></a>
-<span class="sourceLineNo">1727</span>        this.errorCode = USAGE_EXIT_CODE;<a name="line.1727"></a>
-<span class="sourceLineNo">1728</span>      }<a name="line.1728"></a>
-<span class="sourceLineNo">1729</span>      return foundTableNames.isEmpty();<a name="line.1729"></a>
-<span class="sourceLineNo">1730</span>    }<a name="line.1730"></a>
-<span class="sourceLineNo">1731</span><a name="line.1731"></a>
-<span class="sourceLineNo">1732</span>    private void monitorRegionServers(Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap, RegionServerStdOutSink regionServerSink) {<a name="line.1732"></a>
-<span class="sourceLineNo">1733</span>      List&lt;RegionServerTask&gt; tasks = new ArrayList&lt;&gt;();<a name="line.1733"></a>
-<span class="sourceLineNo">1734</span>      Map&lt;String, AtomicLong&gt; successMap = new HashMap&lt;&gt;();<a name="line.1734"></a>
-<span class="sourceLineNo">1735</span>      Random rand = new Random();<a name="line.1735"></a>
-<span class="sourceLineNo">1736</span>      for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : rsAndRMap.entrySet()) {<a name="line.1736"></a>
-<span class="sourceLineNo">1737</span>        String serverName = entry.getKey();<a name="line.1737"></a>
-<span class="sourceLineNo">1738</span>        AtomicLong successes = new AtomicLong(0);<a name="line.1738"></a>
-<span class="sourceLineNo">1739</span>        successMap.put(serverName, successes);<a name="line.1739"></a>
-<span class="sourceLineNo">1740</span>        if (entry.getValue().isEmpty()) {<a name="line.1740"></a>
-<span class="sourceLineNo">1741</span>          LOG.error("Regionserver not serving any regions - {}", serverName);<a name="line.1741"></a>
-<span class="sourceLineNo">1742</span>        } else if (this.allRegions) {<a name="line.1742"></a>
-<span class="sourceLineNo">1743</span>          for (RegionInfo region : entry.getValue()) {<a name="line.1743"></a>
-<span class="sourceLineNo">1744</span>            tasks.add(new RegionServerTask(this.connection,<a name="line.1744"></a>
-<span class="sourceLineNo">1745</span>                serverName,<a name="line.1745"></a>
-<span class="sourceLineNo">1746</span>                region,<a name="line.1746"></a>
-<span class="sourceLineNo">1747</span>                regionServerSink,<a name="line.1747"></a>
-<span class="sourceLineNo">1748</span>                successes));<a name="line.1748"></a>
-<span class="sourceLineNo">1749</span>          }<a name="line.1749"></a>
-<span class="sourceLineNo">1750</span>        } else {<a name="line.1750"></a>
-<span class="sourceLineNo">1751</span>          // random select a region if flag not set<a name="line.1751"></a>
-<span class="sourceLineNo">1752</span>          RegionInfo region = entry.getValue().get(rand.nextInt(entry.getValue().size()));<a name="line.1752"></a>
-<span class="sourceLineNo">1753</span>          tasks.add(new RegionServerTask(this.connection,<a name="line.1753"></a>
-<span class="sourceLineNo">1754</span>              serverName,<a name="line.1754"></a>
-<span class="sourceLineNo">1755</span>              region,<a name="line.1755"></a>
-<span class="sourceLineNo">1756</span>              regionServerSink,<a name="line.1756"></a>
-<span class="sourceLineNo">1757</span>              successes));<a name="line.1757"></a>
-<span class="sourceLineNo">1758</span>        }<a name="line.1758"></a>
-<span class="sourceLineNo">1759</span>      }<a name="line.1759"></a>
-<span class="sourceLineNo">1760</span>      try {<a name="line.1760"></a>
-<span class="sourceLineNo">1761</span>        for (Future&lt;Void&gt; future : this.executor.invokeAll(tasks)) {<a name="line.1761"></a>
-<span class="sourceLineNo">1762</span>          try {<a name="line.1762"></a>
-<span class="sourceLineNo">1763</span>            future.get();<a name="line.1763"></a>
-<span class="sourceLineNo">1764</span>          } catch (ExecutionException e) {<a name="line.1764"></a>
-<span class="sourceLineNo">1765</span>            LOG.error("Sniff regionserver failed!", e);<a name="line.1765"></a>
-<span class="sourceLineNo">1766</span>            this.errorCode = ERROR_EXIT_CODE;<a name="line.1766"></a>
-<span class="sourceLineNo">1767</span>          }<a name="line.1767"></a>
-<span class="sourceLineNo">1768</span>        }<a name="line.1768"></a>
-<span class="sourceLineNo">1769</span>        if (this.allRegions) {<a name="line.1769"></a>
-<span class="sourceLineNo">1770</span>          for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : rsAndRMap.entrySet()) {<a name="line.1770"></a>
-<span class="sourceLineNo">1771</span>            String serverName = entry.getKey();<a name="line.1771"></a>
-<span class="sourceLineNo">1772</span>            LOG.info("Successfully read {} regions out of {} on regionserver {}",<a name="line.1772"></a>
-<span class="sourceLineNo">1773</span>                successMap.get(serverName), entry.getValue().size(), serverName);<a name="line.1773"></a>
-<span class="sourceLineNo">1774</span>          }<a name="line.1774"></a>
-<span class="sourceLineNo">1775</span>        }<a name="line.1775"></a>
-<span class="sourceLineNo">1776</span>      } catch (InterruptedException e) {<a name="line.1776"></a>
-<span class="sourceLineNo">1777</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1777"></a>
-<span class="sourceLineNo">1778</span>        LOG.error("Sniff regionserver interrupted!", e);<a name="line.1778"></a>
-<span class="sourceLineNo">1779</span>      }<a name="line.1779"></a>
-<span class="sourceLineNo">1780</span>    }<a name="line.1780"></a>
-<span class="sourceLineNo">1781</span><a name="line.1781"></a>
-<span class="sourceLineNo">1782</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; filterRegionServerByName() {<a name="line.1782"></a>
-<span class="sourceLineNo">1783</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; regionServerAndRegionsMap = this.getAllRegionServerByName();<a name="line.1783"></a>
-<span class="sourceLineNo">1784</span>      regionServerAndRegionsMap = this.doFilterRegionServerByName(regionServerAndRegionsMap);<a name="line.1784"></a>
-<span class="sourceLineNo">1785</span>      return regionServerAndRegionsMap;<a name="line.1785"></a>
-<span class="sourceLineNo">1786</span>    }<a name="line.1786"></a>
-<span class="sourceLineNo">1787</span><a name="line.1787"></a>
-<span class="sourceLineNo">1788</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; getAllRegionServerByName() {<a name="line.1788"></a>
-<span class="sourceLineNo">1789</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap = new HashMap&lt;&gt;();<a name="line.1789"></a>
-<span class="sourceLineNo">1790</span>      try {<a name="line.1790"></a>
-<span class="sourceLineNo">1791</span>        LOG.debug("Reading list of tables and locations");<a name="line.1791"></a>
-<span class="sourceLineNo">1792</span>        List&lt;TableDescriptor&gt; tableDescs = this.admin.listTableDescriptors();<a name="line.1792"></a>
-<span class="sourceLineNo">1793</span>        List&lt;RegionInfo&gt; regions = null;<a name="line.1793"></a>
-<span class="sourceLineNo">1794</span>        for (TableDescriptor tableDesc: tableDescs) {<a name="line.1794"></a>
-<span class="sourceLineNo">1795</span>          try (RegionLocator regionLocator =<a name="line.1795"></a>
-<span class="sourceLineNo">1796</span>                   this.admin.getConnection().getRegionLocator(tableDesc.getTableName())) {<a name="line.1796"></a>
-<span class="sourceLineNo">1797</span>            for (HRegionLocation location : regionLocator.getAllRegionLocations()) {<a name="line.1797"></a>
-<span class="sourceLineNo">1798</span>              ServerName rs = location.getServerName();<a name="line.1798"></a>
-<span class="sourceLineNo">1799</span>              String rsName = rs.getHostname();<a name="line.1799"></a>
-<span class="sourceLineNo">1800</span>              RegionInfo r = location.getRegion();<a name="line.1800"></a>
-<span class="sourceLineNo">1801</span>              if (rsAndRMap.containsKey(rsName)) {<a name="line.1801"></a>
-<span class="sourceLineNo">1802</span>                regions = rsAndRMap.get(rsName);<a name="line.1802"></a>
-<span class="sourceLineNo">1803</span>              } else {<a name="line.1803"></a>
-<span class="sourceLineNo">1804</span>                regions = new ArrayList&lt;&gt;();<a name="line.1804"></a>
-<span class="sourceLineNo">1805</span>                rsAndRMap.put(rsName, regions);<a name="line.1805"></a>
+<span class="sourceLineNo">1623</span>      if (allowedFailures &gt; (hosts.size() - 1) / 2) {<a name="line.1623"></a>
+<span class="sourceLineNo">1624</span>        LOG.warn("Confirm allowable number of failed ZooKeeper nodes, as quorum will " +<a name="line.1624"></a>
+<span class="sourceLineNo">1625</span>                        "already be lost. Setting of {} failures is unexpected for {} ensemble size.",<a name="line.1625"></a>
+<span class="sourceLineNo">1626</span>                allowedFailures, hosts.size());<a name="line.1626"></a>
+<span class="sourceLineNo">1627</span>      }<a name="line.1627"></a>
+<span class="sourceLineNo">1628</span>    }<a name="line.1628"></a>
+<span class="sourceLineNo">1629</span><a name="line.1629"></a>
+<span class="sourceLineNo">1630</span>    @Override public void run() {<a name="line.1630"></a>
+<span class="sourceLineNo">1631</span>      List&lt;ZookeeperTask&gt; tasks = Lists.newArrayList();<a name="line.1631"></a>
+<span class="sourceLineNo">1632</span>      ZookeeperStdOutSink zkSink = null;<a name="line.1632"></a>
+<span class="sourceLineNo">1633</span>      try {<a name="line.1633"></a>
+<span class="sourceLineNo">1634</span>        zkSink = this.getSink();<a name="line.1634"></a>
+<span class="sourceLineNo">1635</span>      } catch (RuntimeException e) {<a name="line.1635"></a>
+<span class="sourceLineNo">1636</span>        LOG.error("Run ZooKeeperMonitor failed!", e);<a name="line.1636"></a>
+<span class="sourceLineNo">1637</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1637"></a>
+<span class="sourceLineNo">1638</span>      }<a name="line.1638"></a>
+<span class="sourceLineNo">1639</span>      this.initialized = true;<a name="line.1639"></a>
+<span class="sourceLineNo">1640</span>      for (final String host : hosts) {<a name="line.1640"></a>
+<span class="sourceLineNo">1641</span>        tasks.add(new ZookeeperTask(connection, host, znode, timeout, zkSink));<a name="line.1641"></a>
+<span class="sourceLineNo">1642</span>      }<a name="line.1642"></a>
+<span class="sourceLineNo">1643</span>      try {<a name="line.1643"></a>
+<span class="sourceLineNo">1644</span>        for (Future&lt;Void&gt; future : this.executor.invokeAll(tasks)) {<a name="line.1644"></a>
+<span class="sourceLineNo">1645</span>          try {<a name="line.1645"></a>
+<span class="sourceLineNo">1646</span>            future.get();<a name="line.1646"></a>
+<span class="sourceLineNo">1647</span>          } catch (ExecutionException e) {<a name="line.1647"></a>
+<span class="sourceLineNo">1648</span>            LOG.error("Sniff zookeeper failed!", e);<a name="line.1648"></a>
+<span class="sourceLineNo">1649</span>            this.errorCode = ERROR_EXIT_CODE;<a name="line.1649"></a>
+<span class="sourceLineNo">1650</span>          }<a name="line.1650"></a>
+<span class="sourceLineNo">1651</span>        }<a name="line.1651"></a>
+<span class="sourceLineNo">1652</span>      } catch (InterruptedException e) {<a name="line.1652"></a>
+<span class="sourceLineNo">1653</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1653"></a>
+<span class="sourceLineNo">1654</span>        Thread.currentThread().interrupt();<a name="line.1654"></a>
+<span class="sourceLineNo">1655</span>        LOG.error("Sniff zookeeper interrupted!", e);<a name="line.1655"></a>
+<span class="sourceLineNo">1656</span>      }<a name="line.1656"></a>
+<span class="sourceLineNo">1657</span>      this.done = true;<a name="line.1657"></a>
+<span class="sourceLineNo">1658</span>    }<a name="line.1658"></a>
+<span class="sourceLineNo">1659</span><a name="line.1659"></a>
+<span class="sourceLineNo">1660</span>    private ZookeeperStdOutSink getSink() {<a name="line.1660"></a>
+<span class="sourceLineNo">1661</span>      if (!(sink instanceof ZookeeperStdOutSink)) {<a name="line.1661"></a>
+<span class="sourceLineNo">1662</span>        throw new RuntimeException("Can only write to zookeeper sink");<a name="line.1662"></a>
+<span class="sourceLineNo">1663</span>      }<a name="line.1663"></a>
+<span class="sourceLineNo">1664</span>      return ((ZookeeperStdOutSink) sink);<a name="line.1664"></a>
+<span class="sourceLineNo">1665</span>    }<a name="line.1665"></a>
+<span class="sourceLineNo">1666</span>  }<a name="line.1666"></a>
+<span class="sourceLineNo">1667</span><a name="line.1667"></a>
+<span class="sourceLineNo">1668</span><a name="line.1668"></a>
+<span class="sourceLineNo">1669</span>  /**<a name="line.1669"></a>
+<span class="sourceLineNo">1670</span>   * A monitor for regionserver mode<a name="line.1670"></a>
+<span class="sourceLineNo">1671</span>   */<a name="line.1671"></a>
+<span class="sourceLineNo">1672</span>  private static class RegionServerMonitor extends Monitor {<a name="line.1672"></a>
+<span class="sourceLineNo">1673</span>    private boolean allRegions;<a name="line.1673"></a>
+<span class="sourceLineNo">1674</span><a name="line.1674"></a>
+<span class="sourceLineNo">1675</span>    public RegionServerMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1675"></a>
+<span class="sourceLineNo">1676</span>        Sink sink, ExecutorService executor, boolean allRegions,<a name="line.1676"></a>
+<span class="sourceLineNo">1677</span>        boolean treatFailureAsError, long allowedFailures) {<a name="line.1677"></a>
+<span class="sourceLineNo">1678</span>      super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError,<a name="line.1678"></a>
+<span class="sourceLineNo">1679</span>          allowedFailures);<a name="line.1679"></a>
+<span class="sourceLineNo">1680</span>      this.allRegions = allRegions;<a name="line.1680"></a>
+<span class="sourceLineNo">1681</span>    }<a name="line.1681"></a>
+<span class="sourceLineNo">1682</span><a name="line.1682"></a>
+<span class="sourceLineNo">1683</span>    private RegionServerStdOutSink getSink() {<a name="line.1683"></a>
+<span class="sourceLineNo">1684</span>      if (!(sink instanceof RegionServerStdOutSink)) {<a name="line.1684"></a>
+<span class="sourceLineNo">1685</span>        throw new RuntimeException("Can only write to regionserver sink");<a name="line.1685"></a>
+<span class="sourceLineNo">1686</span>      }<a name="line.1686"></a>
+<span class="sourceLineNo">1687</span>      return ((RegionServerStdOutSink) sink);<a name="line.1687"></a>
+<span class="sourceLineNo">1688</span>    }<a name="line.1688"></a>
+<span class="sourceLineNo">1689</span><a name="line.1689"></a>
+<span class="sourceLineNo">1690</span>    @Override<a name="line.1690"></a>
+<span class="sourceLineNo">1691</span>    public void run() {<a name="line.1691"></a>
+<span class="sourceLineNo">1692</span>      if (this.initAdmin() &amp;&amp; this.checkNoTableNames()) {<a name="line.1692"></a>
+<span class="sourceLineNo">1693</span>        RegionServerStdOutSink regionServerSink = null;<a name="line.1693"></a>
+<span class="sourceLineNo">1694</span>        try {<a name="line.1694"></a>
+<span class="sourceLineNo">1695</span>          regionServerSink = this.getSink();<a name="line.1695"></a>
+<span class="sourceLineNo">1696</span>        } catch (RuntimeException e) {<a name="line.1696"></a>
+<span class="sourceLineNo">1697</span>          LOG.error("Run RegionServerMonitor failed!", e);<a name="line.1697"></a>
+<span class="sourceLineNo">1698</span>          this.errorCode = ERROR_EXIT_CODE;<a name="line.1698"></a>
+<span class="sourceLineNo">1699</span>        }<a name="line.1699"></a>
+<span class="sourceLineNo">1700</span>        Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap = this.filterRegionServerByName();<a name="line.1700"></a>
+<span class="sourceLineNo">1701</span>        this.initialized = true;<a name="line.1701"></a>
+<span class="sourceLineNo">1702</span>        this.monitorRegionServers(rsAndRMap, regionServerSink);<a name="line.1702"></a>
+<span class="sourceLineNo">1703</span>      }<a name="line.1703"></a>
+<span class="sourceLineNo">1704</span>      this.done = true;<a name="line.1704"></a>
+<span class="sourceLineNo">1705</span>    }<a name="line.1705"></a>
+<span class="sourceLineNo">1706</span><a name="line.1706"></a>
+<span class="sourceLineNo">1707</span>    private boolean checkNoTableNames() {<a name="line.1707"></a>
+<span class="sourceLineNo">1708</span>      List&lt;String&gt; foundTableNames = new ArrayList&lt;&gt;();<a name="line.1708"></a>
+<span class="sourceLineNo">1709</span>      TableName[] tableNames = null;<a name="line.1709"></a>
+<span class="sourceLineNo">1710</span>      LOG.debug("Reading list of tables");<a name="line.1710"></a>
+<span class="sourceLineNo">1711</span>      try {<a name="line.1711"></a>
+<span class="sourceLineNo">1712</span>        tableNames = this.admin.listTableNames();<a name="line.1712"></a>
+<span class="sourceLineNo">1713</span>      } catch (IOException e) {<a name="line.1713"></a>
+<span class="sourceLineNo">1714</span>        LOG.error("Get listTableNames failed", e);<a name="line.1714"></a>
+<span class="sourceLineNo">1715</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1715"></a>
+<span class="sourceLineNo">1716</span>        return false;<a name="line.1716"></a>
+<span class="sourceLineNo">1717</span>      }<a name="line.1717"></a>
+<span class="sourceLineNo">1718</span><a name="line.1718"></a>
+<span class="sourceLineNo">1719</span>      if (this.targets == null || this.targets.length == 0) return true;<a name="line.1719"></a>
+<span class="sourceLineNo">1720</span><a name="line.1720"></a>
+<span class="sourceLineNo">1721</span>      for (String target : this.targets) {<a name="line.1721"></a>
+<span class="sourceLineNo">1722</span>        for (TableName tableName : tableNames) {<a name="line.1722"></a>
+<span class="sourceLineNo">1723</span>          if (target.equals(tableName.getNameAsString())) {<a name="line.1723"></a>
+<span class="sourceLineNo">1724</span>            foundTableNames.add(target);<a name="line.1724"></a>
+<span class="sourceLineNo">1725</span>          }<a name="line.1725"></a>
+<span class="sourceLineNo">1726</span>        }<a name="line.1726"></a>
+<span class="sourceLineNo">1727</span>      }<a name="line.1727"></a>
+<span class="sourceLineNo">1728</span><a name="line.1728"></a>
+<span class="sourceLineNo">1729</span>      if (foundTableNames.size() &gt; 0) {<a name="line.1729"></a>
+<span class="sourceLineNo">1730</span>        System.err.println("Cannot pass a tablename when using the -regionserver " +<a name="line.1730"></a>
+<span class="sourceLineNo">1731</span>            "option, tablenames:" + foundTableNames.toString());<a name="line.1731"></a>
+<span class="sourceLineNo">1732</span>        this.errorCode = USAGE_EXIT_CODE;<a name="line.1732"></a>
+<span class="sourceLineNo">1733</span>      }<a name="line.1733"></a>
+<span class="sourceLineNo">1734</span>      return foundTableNames.isEmpty();<a name="line.1734"></a>
+<span class="sourceLineNo">1735</span>    }<a name="line.1735"></a>
+<span class="sourceLineNo">1736</span><a name="line.1736"></a>
+<span class="sourceLineNo">1737</span>    private void monitorRegionServers(Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap, RegionServerStdOutSink regionServerSink) {<a name="line.1737"></a>
+<span class="sourceLineNo">1738</span>      List&lt;RegionServerTask&gt; tasks = new ArrayList&lt;&gt;();<a name="line.1738"></a>
+<span class="sourceLineNo">1739</span>      Map&lt;String, AtomicLong&gt; successMap = new HashMap&lt;&gt;();<a name="line.1739"></a>
+<span class="sourceLineNo">1740</span>      Random rand = new Random();<a name="line.1740"></a>
+<span class="sourceLineNo">1741</span>      for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : rsAndRMap.entrySet()) {<a name="line.1741"></a>
+<span class="sourceLineNo">1742</span>        String serverName = entry.getKey();<a name="line.1742"></a>
+<span class="sourceLineNo">1743</span>        AtomicLong successes = new AtomicLong(0);<a name="line.1743"></a>
+<span class="sourceLineNo">1744</span>        successMap.put(serverName, successes);<a name="line.1744"></a>
+<span class="sourceLineNo">1745</span>        if (entry.getValue().isEmpty()) {<a name="line.1745"></a>
+<span class="sourceLineNo">1746</span>          LOG.error("Regionserver not serving any regions - {}", serverName);<a name="line.1746"></a>
+<span class="sourceLineNo">1747</span>        } else if (this.allRegions) {<a name="line.1747"></a>
+<span class="sourceLineNo">1748</span>          for (RegionInfo region : entry.getValue()) {<a name="line.1748"></a>
+<span class="sourceLineNo">1749</span>            tasks.add(new RegionServerTask(this.connection,<a name="line.1749"></a>
+<span class="sourceLineNo">1750</span>                serverName,<a name="line.1750"></a>
+<span class="sourceLineNo">1751</span>                region,<a name="line.1751"></a>
+<span class="sourceLineNo">1752</span>                regionServerSink,<a name="line.1752"></a>
+<span class="sourceLineNo">1753</span>                successes));<a name="line.1753"></a>
+<span class="sourceLineNo">1754</span>          }<a name="line.1754"></a>
+<span class="sourceLineNo">1755</span>        } else {<a name="line.1755"></a>
+<span class="sourceLineNo">1756</span>          // random select a region if flag not set<a name="line.1756"></a>
+<span class="sourceLineNo">1757</span>          RegionInfo region = entry.getValue().get(rand.nextInt(entry.getValue().size()));<a name="line.1757"></a>
+<span class="sourceLineNo">1758</span>          tasks.add(new RegionServerTask(this.connection,<a name="line.1758"></a>
+<span class="sourceLineNo">1759</span>              serverName,<a name="line.1759"></a>
+<span class="sourceLineNo">1760</span>              region,<a name="line.1760"></a>
+<span class="sourceLineNo">1761</span>              regionServerSink,<a name="line.1761"></a>
+<span class="sourceLineNo">1762</span>              successes));<a name="line.1762"></a>
+<span class="sourceLineNo">1763</span>        }<a name="line.1763"></a>
+<span class="sourceLineNo">1764</span>      }<a name="line.1764"></a>
+<span class="sourceLineNo">1765</span>      try {<a name="line.1765"></a>
+<span class="sourceLineNo">1766</span>        for (Future&lt;Void&gt; future : this.executor.invokeAll(tasks)) {<a name="line.1766"></a>
+<span class="sourceLineNo">1767</span>          try {<a name="line.1767"></a>
+<span class="sourceLineNo">1768</span>            future.get();<a name="line.1768"></a>
+<span class="sourceLineNo">1769</span>          } catch (ExecutionException e) {<a name="line.1769"></a>
+<span class="sourceLineNo">1770</span>            LOG.error("Sniff regionserver failed!", e);<a name="line.1770"></a>
+<span class="sourceLineNo">1771</span>            this.errorCode = ERROR_EXIT_CODE;<a name="line.1771"></a>
+<span class="sourceLineNo">1772</span>          }<a name="line.1772"></a>
+<span class="sourceLineNo">1773</span>        }<a name="line.1773"></a>
+<span class="sourceLineNo">1774</span>        if (this.allRegions) {<a name="line.1774"></a>
+<span class="sourceLineNo">1775</span>          for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : rsAndRMap.entrySet()) {<a name="line.1775"></a>
+<span class="sourceLineNo">1776</span>            String serverName = entry.getKey();<a name="line.1776"></a>
+<span class="sourceLineNo">1777</span>            LOG.info("Successfully read {} regions out of {} on regionserver {}",<a name="line.1777"></a>
+<span class="sourceLineNo">1778</span>                successMap.get(serverName), entry.getValue().size(), serverName);<a name="line.1778"></a>
+<span class="sourceLineNo">1779</span>          }<a name="line.1779"></a>
+<span class="sourceLineNo">1780</span>        }<a name="line.1780"></a>
+<span class="sourceLineNo">1781</span>      } catch (InterruptedException e) {<a name="line.1781"></a>
+<span class="sourceLineNo">1782</span>        this.errorCode = ERROR_EXIT_CODE;<a name="line.1782"></a>
+<span class="sourceLineNo">1783</span>        LOG.error("Sniff regionserver interrupted!", e);<a name="line.1783"></a>
+<span class="sourceLineNo">1784</span>      }<a name="line.1784"></a>
+<span class="sourceLineNo">1785</span>    }<a name="line.1785"></a>
+<span class="sourceLineNo">1786</span><a name="line.1786"></a>
+<span class="sourceLineNo">1787</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; filterRegionServerByName() {<a name="line.1787"></a>
+<span class="sourceLineNo">1788</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; regionServerAndRegionsMap = this.getAllRegionServerByName();<a name="line.1788"></a>
+<span class="sourceLineNo">1789</span>      regionServerAndRegionsMap = this.doFilterRegionServerByName(regionServerAndRegionsMap);<a name="line.1789"></a>
+<span class="sourceLineNo">1790</span>      return regionServerAndRegionsMap;<a name="line.1790"></a>
+<span class="sourceLineNo">1791</span>    }<a name="line.1791"></a>
+<span class="sourceLineNo">1792</span><a name="line.1792"></a>
+<span class="sourceLineNo">1793</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; getAllRegionServerByName() {<a name="line.1793"></a>
+<span class="sourceLineNo">1794</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; rsAndRMap = new HashMap&lt;&gt;();<a name="line.1794"></a>
+<span class="sourceLineNo">1795</span>      try {<a name="line.1795"></a>
+<span class="sourceLineNo">1796</span>        LOG.debug("Reading list of tables and locations");<a name="line.1796"></a>
+<span class="sourceLineNo">1797</span>        List&lt;TableDescriptor&gt; tableDescs = this.admin.listTableDescriptors();<a name="line.1797"></a>
+<span class="sourceLineNo">1798</span>        List&lt;RegionInfo&gt; regions = null;<a name="line.1798"></a>
+<span class="sourceLineNo">1799</span>        for (TableDescriptor tableDesc: tableDescs) {<a name="line.1799"></a>
+<span class="sourceLineNo">1800</span>          try (RegionLocator regionLocator =<a name="line.1800"></a>
+<span class="sourceLineNo">1801</span>                   this.admin.getConnection().getRegionLocator(tableDesc.getTableName())) {<a name="line.1801"></a>
+<span class="sourceLineNo">1802</span>            for (HRegionLocation location : regionLocator.getAllRegionLocations()) {<a name="line.1802"></a>
+<span class="sourceLineNo">1803</span>              if (location == null) {<a name="line.1803"></a>
+<span class="sourceLineNo">1804</span>                LOG.warn("Null location");<a name="line.1804"></a>
+<span class="sourceLineNo">1805</span>                continue;<a name="line.1805"></a>
 <span class="sourceLineNo">1806</span>              }<a name="line.1806"></a>
-<span class="sourceLineNo">1807</span>              regions.add(r);<a name="line.1807"></a>
-<span class="sourceLineNo">1808</span>            }<a name="line.1808"></a>
-<span class="sourceLineNo">1809</span>          }<a name="line.1809"></a>
-<span class="sourceLineNo">1810</span>        }<a name="line.1810"></a>
-<span class="sourceLineNo">1811</span><a name="line.1811"></a>
-<span class="sourceLineNo">1812</span>        // get any live regionservers not serving any regions<a name="line.1812"></a>
-<span class="sourceLineNo">1813</span>        for (ServerName rs: this.admin.getRegionServers()) {<a name="line.1813"></a>
-<span class="sourceLineNo">1814</span>          String rsName = rs.getHostname();<a name="line.1814"></a>
-<span class="sourceLineNo">1815</span>          if (!rsAndRMap.containsKey(rsName)) {<a name="line.1815"></a>
-<span class="sourceLineNo">1816</span>            rsAndRMap.put(rsName, Collections.&lt;RegionInfo&gt; emptyList());<a name="line.1816"></a>
-<span class="sourceLineNo">1817</span>          }<a name="line.1817"></a>
-<span class="sourceLineNo">1818</span>        }<a name="line.1818"></a>
-<span class="sourceLineNo">1819</span>      } catch (IOException e) {<a name="line.1819"></a>
-<span class="sourceLineNo">1820</span>        LOG.error("Get HTables info failed", e);<a name="line.1820"></a>
-<span class="sourceLineNo">1821</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1821"></a>
-<span class="sourceLineNo">1822</span>      }<a name="line.1822"></a>
-<span class="sourceLineNo">1823</span>      return rsAndRMap;<a name="line.1823"></a>
-<span class="sourceLineNo">1824</span>    }<a name="line.1824"></a>
-<span class="sourceLineNo">1825</span><a name="line.1825"></a>
-<span class="sourceLineNo">1826</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; doFilterRegionServerByName(<a name="line.1826"></a>
-<span class="sourceLineNo">1827</span>        Map&lt;String, List&lt;RegionInfo&gt;&gt; fullRsAndRMap) {<a name="line.1827"></a>
-<span class="sourceLineNo">1828</span><a name="line.1828"></a>
-<span class="sourceLineNo">1829</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; filteredRsAndRMap = null;<a name="line.1829"></a>
-<span class="sourceLineNo">1830</span><a name="line.1830"></a>
-<span class="sourceLineNo">1831</span>      if (this.targets != null &amp;&amp; this.targets.length &gt; 0) {<a name="line.1831"></a>
-<span class="sourceLineNo">1832</span>        filteredRsAndRMap = new HashMap&lt;&gt;();<a name="line.1832"></a>
-<span class="sourceLineNo">1833</span>        Pattern pattern = null;<a name="line.1833"></a>
-<span class="sourceLineNo">1834</span>        Matcher matcher = null;<a name="line.1834"></a>
-<span class="sourceLineNo">1835</span>        boolean regExpFound = false;<a name="line.1835"></a>
-<span class="sourceLineNo">1836</span>        for (String rsName : this.targets) {<a name="line.1836"></a>
-<span class="sourceLineNo">1837</span>          if (this.useRegExp) {<a name="line.1837"></a>
-<span class="sourceLineNo">1838</span>            regExpFound = false;<a name="line.1838"></a>
-<span class="sourceLineNo">1839</span>            pattern = Pattern.compile(rsName);<a name="line.1839"></a>
-<span class="sourceLineNo">1840</span>            for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : fullRsAndRMap.entrySet()) {<a name="line.1840"></a>
-<span class="sourceLineNo">1841</span>              matcher = pattern.matcher(entry.getKey());<a name="line.1841"></a>
-<span class="sourceLineNo">1842</span>              if (matcher.matches()) {<a name="line.1842"></a>
-<span class="sourceLineNo">1843</span>                filteredRsAndRMap.put(entry.getKey(), entry.getValue());<a name="line.1843"></a>
-<span class="sourceLineNo">1844</span>                regExpFound = true;<a name="line.1844"></a>
-<span class="sourceLineNo">1845</span>              }<a name="line.1845"></a>
-<span class="sourceLineNo">1846</span>            }<a name="line.1846"></a>
-<span class="sourceLineNo">1847</span>            if (!regExpFound) {<a name="line.1847"></a>
-<span class="sourceLineNo">1848</span>              LOG.info("No RegionServerInfo found, regionServerPattern {}", rsName);<a name="line.1848"></a>
-<span class="sourceLineNo">1849</span>            }<a name="line.1849"></a>
-<span class="sourceLineNo">1850</span>          } else {<a name="line.1850"></a>
-<span class="sourceLineNo">1851</span>            if (fullRsAndRMap.containsKey(rsName)) {<a name="line.1851"></a>
-<span class="sourceLineNo">1852</span>              filteredRsAndRMap.put(rsName, fullRsAndRMap.get(rsName));<a name="line.1852"></a>
-<span class="sourceLineNo">1853</span>            } else {<a name="line.1853"></a>
-<span class="sourceLineNo">1854</span>              LOG.info("No RegionServerInfo found, regionServerName {}", rsName);<a name="line.1854"></a>
+<span class="sourceLineNo">1807</span>              ServerName rs = location.getServerName();<a name="line.1807"></a>
+<span class="sourceLineNo">1808</span>              String rsName = rs.getHostname();<a name="line.1808"></a>
+<span class="sourceLineNo">1809</span>              RegionInfo r = location.getRegion();<a name="line.1809"></a>
+<span class="sourceLineNo">1810</span>              if (rsAndRMap.containsKey(rsName)) {<a name="line.1810"></a>
+<span class="sourceLineNo">1811</span>                regions = rsAndRMap.get(rsName);<a name="line.1811"></a>
+<span class="sourceLineNo">1812</span>              } else {<a name="line.1812"></a>
+<span class="sourceLineNo">1813</span>                regions = new ArrayList&lt;&gt;();<a name="line.1813"></a>
+<span class="sourceLineNo">1814</span>                rsAndRMap.put(rsName, regions);<a name="line.1814"></a>
+<span class="sourceLineNo">1815</span>              }<a name="line.1815"></a>
+<span class="sourceLineNo">1816</span>              regions.add(r);<a name="line.1816"></a>
+<span class="sourceLineNo">1817</span>            }<a name="line.1817"></a>
+<span class="sourceLineNo">1818</span>          }<a name="line.1818"></a>
+<span class="sourceLineNo">1819</span>        }<a name="line.1819"></a>
+<span class="sourceLineNo">1820</span><a name="line.1820"></a>
+<span class="sourceLineNo">1821</span>        // get any live regionservers not serving any regions<a name="line.1821"></a>
+<span class="sourceLineNo">1822</span>        for (ServerName rs: this.admin.getRegionServers()) {<a name="line.1822"></a>
+<span class="sourceLineNo">1823</span>          String rsName = rs.getHostname();<a name="line.1823"></a>
+<span class="sourceLineNo">1824</span>          if (!rsAndRMap.containsKey(rsName)) {<a name="line.1824"></a>
+<span class="sourceLineNo">1825</span>            rsAndRMap.put(rsName, Collections.&lt;RegionInfo&gt; emptyList());<a name="line.1825"></a>
+<span class="sourceLineNo">1826</span>          }<a name="line.1826"></a>
+<span class="sourceLineNo">1827</span>        }<a name="line.1827"></a>
+<span class="sourceLineNo">1828</span>      } catch (IOException e) {<a name="line.1828"></a>
+<span class="sourceLineNo">1829</span>        LOG.error("Get HTables info failed", e);<a name="line.1829"></a>
+<span class="sourceLineNo">1830</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1830"></a>
+<span class="sourceLineNo">1831</span>      }<a name="line.1831"></a>
+<span class="sourceLineNo">1832</span>      return rsAndRMap;<a name="line.1832"></a>
+<span class="sourceLineNo">1833</span>    }<a name="line.1833"></a>
+<span class="sourceLineNo">1834</span><a name="line.1834"></a>
+<span class="sourceLineNo">1835</span>    private Map&lt;String, List&lt;RegionInfo&gt;&gt; doFilterRegionServerByName(<a name="line.1835"></a>
+<span class="sourceLineNo">1836</span>        Map&lt;String, List&lt;RegionInfo&gt;&gt; fullRsAndRMap) {<a name="line.1836"></a>
+<span class="sourceLineNo">1837</span><a name="line.1837"></a>
+<span class="sourceLineNo">1838</span>      Map&lt;String, List&lt;RegionInfo&gt;&gt; filteredRsAndRMap = null;<a name="line.1838"></a>
+<span class="sourceLineNo">1839</span><a name="line.1839"></a>
+<span class="sourceLineNo">1840</span>      if (this.targets != null &amp;&amp; this.targets.length &gt; 0) {<a name="line.1840"></a>
+<span class="sourceLineNo">1841</span>        filteredRsAndRMap = new HashMap&lt;&gt;();<a name="line.1841"></a>
+<span class="sourceLineNo">1842</span>        Pattern pattern = null;<a name="line.1842"></a>
+<span class="sourceLineNo">1843</span>        Matcher matcher = null;<a name="line.1843"></a>
+<span class="sourceLineNo">1844</span>        boolean regExpFound = false;<a name="line.1844"></a>
+<span class="sourceLineNo">1845</span>        for (String rsName : this.targets) {<a name="line.1845"></a>
+<span class="sourceLineNo">1846</span>          if (this.useRegExp) {<a name="line.1846"></a>
+<span class="sourceLineNo">1847</span>            regExpFound = false;<a name="line.1847"></a>
+<span class="sourceLineNo">1848</span>            pattern = Pattern.compile(rsName);<a name="line.1848"></a>
+<span class="sourceLineNo">1849</span>            for (Map.Entry&lt;String, List&lt;RegionInfo&gt;&gt; entry : fullRsAndRMap.entrySet()) {<a name="line.1849"></a>
+<span class="sourceLineNo">1850</span>              matcher = pattern.matcher(entry.getKey());<a name="line.1850"></a>
+<span class="sourceLineNo">1851</span>              if (matcher.matches()) {<a name="line.1851"></a>
+<span class="sourceLineNo">1852</span>                filteredRsAndRMap.put(entry.getKey(), entry.getValue());<a name="line.1852"></a>
+<span class="sourceLineNo">1853</span>                regExpFound = true;<a name="line.1853"></a>
+<span class="sourceLineNo">1854</span>              }<a name="line.1854"></a>
 <span class="sourceLineNo">1855</span>            }<a name="line.1855"></a>
-<span class="sourceLineNo">1856</span>          }<a name="line.1856"></a>
-<span class="sourceLineNo">1857</span>        }<a name="line.1857"></a>
-<span class="sourceLineNo">1858</span>      } else {<a name="line.1858"></a>
-<span class="sourceLineNo">1859</span>        filteredRsAndRMap = fullRsAndRMap;<a name="line.1859"></a>
-<span class="sourceLineNo">1860</span>      }<a name="line.1860"></a>
-<span class="sourceLineNo">1861</span>      return filteredRsAndRMap;<a name="line.1861"></a>
-<span class="sourceLineNo">1862</span>    }<a name="line.1862"></a>
-<span class="sourceLineNo">1863</span>  }<a name="line.1863"></a>
-<span class="sourceLineNo">1864</span><a name="line.1864"></a>
-<span class="sourceLineNo">1865</span>  public static void main(String[] args) throws Exception {<a name="line.1865"></a>
-<span class="sourceLineNo">1866</span>    final Configuration conf = HBaseConfiguration.create();<a name="line.1866"></a>
-<span class="sourceLineNo">1867</span><a name="line.1867"></a>
-<span class="sourceLineNo">1868</span>    int numThreads = conf.getInt("hbase.canary.threads.num", MAX_THREADS_NUM);<a name="line.1868"></a>
-<span class="sourceLineNo">1869</span>    LOG.info("Execution thread count={}", numThreads);<a name="line.1869"></a>
-<span class="sourceLineNo">1870</span><a name="line.1870"></a>
-<span class="sourceLineNo">1871</span>    int exitCode;<a name="line.1871"></a>
-<span class="sourceLineNo">1872</span>    ExecutorService executor = new ScheduledThreadPoolExecutor(numThreads);<a name="line.1872"></a>
-<span class="sourceLineNo">1873</span>    try {<a name="line.1873"></a>
-<span class="sourceLineNo">1874</span>      exitCode = ToolRunner.run(conf, new CanaryTool(executor), args);<a name="line.1874"></a>
-<span class="sourceLineNo">1875</span>    } finally {<a name="line.1875"></a>
-<span class="sourceLineNo">1876</span>      executor.shutdown();<a name="line.1876"></a>
-<span class="sourceLineNo">1877</span>    }<a name="line.1877"></a>
-<span class="sourceLineNo">1878</span>    System.exit(exitCode);<a name="line.1878"></a>
-<span class="sourceLineNo">1879</span>  }<a name="line.1879"></a>
-<span class="sourceLineNo">1880</span>}<a name="line.1880"></a>
+<span class="sourceLineNo">1856</span>            if (!regExpFound) {<a name="line.1856"></a>
+<span class="sourceLineNo">1857</span>              LOG.info("No RegionServerInfo found, regionServerPattern {}", rsName);<a name="line.1857"></a>
+<span class="sourceLineNo">1858</span>            }<a name="line.1858"></a>
+<span class="sourceLineNo">1859</span>          } else {<a name="line.1859"></a>
+<span class="sourceLineNo">1860</span>            if (fullRsAndRMap.containsKey(rsName)) {<a name="line.1860"></a>
+<span class="sourceLineNo">1861</span>              filteredRsAndRMap.put(rsName, fullRsAndRMap.get(rsName));<a name="line.1861"></a>
+<span class="sourceLineNo">1862</span>            } else {<a name="line.1862"></a>
+<span class="sourceLineNo">1863</span>              LOG.info("No RegionServerInfo found, regionServerName {}", rsName);<a name="line.1863"></a>
+<span class="sourceLineNo">1864</span>            }<a name="line.1864"></a>
+<span class="sourceLineNo">1865</span>          }<a name="line.1865"></a>
+<span class="sourceLineNo">1866</span>        }<a name="line.1866"></a>
+<span class="sourceLineNo">1867</span>      } else {<a name="line.1867"></a>
+<span class="sourceLineNo">1868</span>        filteredRsAndRMap = fullRsAndRMap;<a name="line.1868"></a>
+<span class="sourceLineNo">1869</span>      }<a name="line.1869"></a>
+<span class="sourceLineNo">1870</span>      return filteredRsAndRMap;<a name="line.1870"></a>
+<span class="sourceLineNo">1871</span>    }<a name="line.1871"></a>
+<span class="sourceLineNo">1872</span>  }<a name="line.1872"></a>
+<span class="sourceLineNo">1873</span><a name="line.1873"></a>
+<span class="sourceLineNo">1874</span>  public static void main(String[] args) throws Exception {<a name="line.1874"></a>
+<span class="sourceLineNo">1875</span>    final Configuration conf = HBaseConfiguration.create();<a name="line.1875"></a>
+<span class="sourceLineNo">1876</span><a name="line.1876"></a>
+<span class="sourceLineNo">1877</span>    int numThreads = conf.getInt("hbase.canary.threads.num", MAX_THREADS_NUM);<a name="line.1877"></a>
+<span class="sourceLineNo">1878</span>    LOG.info("Execution thread count={}", numThreads);<a name="line.1878"></a>
+<span class="sourceLineNo">1879</span><a name="line.1879"></a>
+<span class="sourceLineNo">1880</span>    int exitCode;<a name="line.1880"></a>
+<span class="sourceLineNo">1881</span>    ExecutorService executor = new ScheduledThreadPoolExecutor(numThreads);<a name="line.1881"></a>
+<span class="sourceLineNo">1882</span>    try {<a name="line.1882"></a>
+<span class="sourceLineNo">1883</span>      exitCode = ToolRunner.run(conf, new CanaryTool(executor), args);<a name="line.1883"></a>
+<span class="sourceLineNo">1884</span>    } finally {<a name="line.1884"></a>
+<span class="sourceLineNo">1885</span>      executor.shutdown();<a name="line.1885"></a>
+<span class="sourceLineNo">1886</span>    }<a name="line.1886"></a>
+<span class="sourceLineNo">1887</span>    System.exit(exitCode);<a name="line.1887"></a>
+<span class="sourceLineNo">1888</span>  }<a name="line.1888"></a>
+<span class="sourceLineNo">1889</span>}<a name="line.1889"></a>
 
 
 
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html b/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html
index 5e57151..4b34be0 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/tool/CanaryTool.RegionServerMonitor.html
@@ -500,1392 +500,1401 @@
 <span class="sourceLineNo">492</span>          sink.publishReadTiming(serverName, region, column, stopWatch.getTime());<a name="line.492"></a>
 <span class="sourceLineNo">493</span>        } catch (Exception e) {<a name="line.493"></a>
 <span class="sourceLineNo">494</span>          sink.publishReadFailure(serverName, region, column, e);<a name="line.494"></a>
-<span class="sourceLineNo">495</span>          sink.updateReadFailures(region.getRegionNameAsString(), serverName.getHostname());<a name="line.495"></a>
-<span class="sourceLineNo">496</span>        } finally {<a name="line.496"></a>
-<span class="sourceLineNo">497</span>          if (rs != null) {<a name="line.497"></a>
-<span class="sourceLineNo">498</span>            rs.close();<a name="line.498"></a>
-<span class="sourceLineNo">499</span>          }<a name="line.499"></a>
-<span class="sourceLineNo">500</span>          scan = null;<a name="line.500"></a>
-<span class="sourceLineNo">501</span>          get = null;<a name="line.501"></a>
-<span class="sourceLineNo">502</span>        }<a name="line.502"></a>
-<span class="sourceLineNo">503</span>      }<a name="line.503"></a>
-<span class="sourceLineNo">504</span>      try {<a name="line.504"></a>
-<span class="sourceLineNo">505</span>        table.close();<a name="line.505"></a>
-<span class="sourceLineNo">506</span>      } catch (IOException e) {<a name="line.506"></a>
-<span class="sourceLineNo">507</span>        LOG.error("Close table failed", e);<a name="line.507"></a>
-<span class="sourceLineNo">508</span>      }<a name="line.508"></a>
-<span class="sourceLineNo">509</span>      return null;<a name="line.509"></a>
-<span class="sourceLineNo">510</span>    }<a name="line.510"></a>
-<span class="sourceLineNo">511</span><a name="line.511"></a>
-<span class="sourceLineNo">512</span>    /**<a name="line.512"></a>
-<span class="sourceLineNo">513</span>     * Check writes for the canary table<a name="line.513"></a>
-<span class="sourceLineNo">514</span>     */<a name="line.514"></a>
-<span class="sourceLineNo">515</span>    private Void write() {<a name="line.515"></a>
-<span class="sourceLineNo">516</span>      Table table = null;<a name="line.516"></a>
-<span class="sourceLineNo">517</span>      TableDescriptor tableDesc = null;<a name="line.517"></a>
-<span class="sourceLineNo">518</span>      try {<a name="line.518"></a>
-<span class="sourceLineNo">519</span>        table = connection.getTable(region.getTable());<a name="line.519"></a>
-<span class="sourceLineNo">520</span>        tableDesc = table.getDescriptor();<a name="line.520"></a>
-<span class="sourceLineNo">521</span>        byte[] rowToCheck = region.getStartKey();<a name="line.521"></a>
-<span class="sourceLineNo">522</span>        if (rowToCheck.length == 0) {<a name="line.522"></a>
-<span class="sourceLineNo">523</span>          rowToCheck = new byte[]{0x0};<a name="line.523"></a>
-<span class="sourceLineNo">524</span>        }<a name="line.524"></a>
-<span class="sourceLineNo">525</span>        int writeValueSize =<a name="line.525"></a>
-<span class="sourceLineNo">526</span>            connection.getConfiguration().getInt(HConstants.HBASE_CANARY_WRITE_VALUE_SIZE_KEY, 10);<a name="line.526"></a>
-<span class="sourceLineNo">527</span>        for (ColumnFamilyDescriptor column : tableDesc.getColumnFamilies()) {<a name="line.527"></a>
-<span class="sourceLineNo">528</span>          Put put = new Put(rowToCheck);<a name="line.528"></a>
-<span class="sourceLineNo">529</span>          byte[] value = new byte[writeValueSize];<a name="line.529"></a>
-<span class="sourceLineNo">530</span>          Bytes.random(value);<a name="line.530"></a>
-<span class="sourceLineNo">531</span>          put.addColumn(column.getName(), HConstants.EMPTY_BYTE_ARRAY, value);<a name="line.531"></a>
-<span class="sourceLineNo">532</span><a name="line.532"></a>
-<span class="sourceLineNo">533</span>          LOG.debug("Writing to {} {} {} {}",<a name="line.533"></a>
-<span class="sourceLineNo">534</span>            tableDesc.getTableName(), region.getRegionNameAsString(), column.getNameAsString(),<a name="line.534"></a>
-<span class="sourceLineNo">535</span>            Bytes.toStringBinary(rowToCheck));<a name="line.535"></a>
-<span class="sourceLineNo">536</span>          try {<a name="line.536"></a>
-<span class="sourceLineNo">537</span>            long startTime = System.currentTimeMillis();<a name="line.537"></a>
-<span class="sourceLineNo">538</span>            table.put(put);<a name="line.538"></a>
-<span class="sourceLineNo">539</span>            long time = System.currentTimeMillis() - startTime;<a name="line.539"></a>
-<span class="sourceLineNo">540</span>            this.readWriteLatency.add(time);<a name="line.540"></a>
-<span class="sourceLineNo">541</span>            sink.publishWriteTiming(serverName, region, column, time);<a name="line.541"></a>
-<span class="sourceLineNo">542</span>          } catch (Exception e) {<a name="line.542"></a>
-<span class="sourceLineNo">543</span>            sink.publishWriteFailure(serverName, region, column, e);<a name="line.543"></a>
-<span class="sourceLineNo">544</span>          }<a name="line.544"></a>
-<span class="sourceLineNo">545</span>        }<a name="line.545"></a>
-<span class="sourceLineNo">546</span>        table.close();<a name="line.546"></a>
-<span class="sourceLineNo">547</span>      } catch (IOException e) {<a name="line.547"></a>
-<span class="sourceLineNo">548</span>        sink.publishWriteFailure(serverName, region, e);<a name="line.548"></a>
-<span class="sourceLineNo">549</span>        sink.updateWriteFailures(region.getRegionNameAsString(), serverName.getHostname() );<a name="line.549"></a>
-<span class="sourceLineNo">550</span>      }<a name="line.550"></a>
-<span class="sourceLineNo">551</span>      return null;<a name="line.551"></a>
-<span class="sourceLineNo">552</span>    }<a name="line.552"></a>
-<span class="sourceLineNo">553</span>  }<a name="line.553"></a>
-<span class="sourceLineNo">554</span><a name="line.554"></a>
-<span class="sourceLineNo">555</span>  /**<a name="line.555"></a>
-<span class="sourceLineNo">556</span>   * Run a single RegionServer Task and then exit.<a name="line.556"></a>
-<span class="sourceLineNo">557</span>   * Get one row from a region on the regionserver and output latency or the failure.<a name="line.557"></a>
-<span class="sourceLineNo">558</span>   */<a name="line.558"></a>
-<span class="sourceLineNo">559</span>  static class RegionServerTask implements Callable&lt;Void&gt; {<a name="line.559"></a>
-<span class="sourceLineNo">560</span>    private Connection connection;<a name="line.560"></a>
-<span class="sourceLineNo">561</span>    private String serverName;<a name="line.561"></a>
-<span class="sourceLineNo">562</span>    private RegionInfo region;<a name="line.562"></a>
-<span class="sourceLineNo">563</span>    private RegionServerStdOutSink sink;<a name="line.563"></a>
-<span class="sourceLineNo">564</span>    private AtomicLong successes;<a name="line.564"></a>
-<span class="sourceLineNo">565</span><a name="line.565"></a>
-<span class="sourceLineNo">566</span>    RegionServerTask(Connection connection, String serverName, RegionInfo region,<a name="line.566"></a>
-<span class="sourceLineNo">567</span>        RegionServerStdOutSink sink, AtomicLong successes) {<a name="line.567"></a>
-<span class="sourceLineNo">568</span>      this.connection = connection;<a name="line.568"></a>
-<span class="sourceLineNo">569</span>      this.serverName = serverName;<a name="line.569"></a>
-<span class="sourceLineNo">570</span>      this.region = region;<a name="line.570"></a>
-<span class="sourceLineNo">571</span>      this.sink = sink;<a name="line.571"></a>
-<span class="sourceLineNo">572</span>      this.successes = successes;<a name="line.572"></a>
-<span class="sourceLineNo">573</span>    }<a name="line.573"></a>
-<span class="sourceLineNo">574</span><a name="line.574"></a>
-<span class="sourceLineNo">575</span>    @Override<a name="line.575"></a>
-<span class="sourceLineNo">576</span>    public Void call() {<a name="line.576"></a>
-<span class="sourceLineNo">577</span>      TableName tableName = null;<a name="line.577"></a>
-<span class="sourceLineNo">578</span>      Table table = null;<a name="line.578"></a>
-<span class="sourceLineNo">579</span>      Get get = null;<a name="line.579"></a>
-<span class="sourceLineNo">580</span>      byte[] startKey = null;<a name="line.580"></a>
-<span class="sourceLineNo">581</span>      Scan scan = null;<a name="line.581"></a>
-<span class="sourceLineNo">582</span>      StopWatch stopWatch = new StopWatch();<a name="line.582"></a>
-<span class="sourceLineNo">583</span>      // monitor one region on every region server<a name="line.583"></a>
-<span class="sourceLineNo">584</span>      stopWatch.reset();<a name="line.584"></a>
-<span class="sourceLineNo">585</span>      try {<a name="line.585"></a>
-<span class="sourceLineNo">586</span>        tableName = region.getTable();<a name="line.586"></a>
-<span class="sourceLineNo">587</span>        table = connection.getTable(tableName);<a name="line.587"></a>
-<span class="sourceLineNo">588</span>        startKey = region.getStartKey();<a name="line.588"></a>
-<span class="sourceLineNo">589</span>        // Can't do a get on empty start row so do a Scan of first element if any instead.<a name="line.589"></a>
-<span class="sourceLineNo">590</span>        LOG.debug("Reading from {} {} {} {}",<a name="line.590"></a>
-<span class="sourceLineNo">591</span>          serverName, region.getTable(), region.getRegionNameAsString(),<a name="line.591"></a>
-<span class="sourceLineNo">592</span>          Bytes.toStringBinary(startKey));<a name="line.592"></a>
-<span class="sourceLineNo">593</span>        if (startKey.length &gt; 0) {<a name="line.593"></a>
-<span class="sourceLineNo">594</span>          get = new Get(startKey);<a name="line.594"></a>
-<span class="sourceLineNo">595</span>          get.setCacheBlocks(false);<a name="line.595"></a>
-<span class="sourceLineNo">596</span>          get.setFilter(new FirstKeyOnlyFilter());<a name="line.596"></a>
-<span class="sourceLineNo">597</span>          stopWatch.start();<a name="line.597"></a>
-<span class="sourceLineNo">598</span>          table.get(get);<a name="line.598"></a>
-<span class="sourceLineNo">599</span>          stopWatch.stop();<a name="line.599"></a>
-<span class="sourceLineNo">600</span>        } else {<a name="line.600"></a>
-<span class="sourceLineNo">601</span>          scan = new Scan();<a name="line.601"></a>
-<span class="sourceLineNo">602</span>          scan.setCacheBlocks(false);<a name="line.602"></a>
-<span class="sourceLineNo">603</span>          scan.setFilter(new FirstKeyOnlyFilter());<a name="line.603"></a>
-<span class="sourceLineNo">604</span>          scan.setCaching(1);<a name="line.604"></a>
-<span class="sourceLineNo">605</span>          scan.setMaxResultSize(1L);<a name="line.605"></a>
-<span class="sourceLineNo">606</span>          scan.setOneRowLimit();<a name="line.606"></a>
-<span class="sourceLineNo">607</span>          stopWatch.start();<a name="line.607"></a>
-<span class="sourceLineNo">608</span>          ResultScanner s = table.getScanner(scan);<a name="line.608"></a>
-<span class="sourceLineNo">609</span>          s.next();<a name="line.609"></a>
-<span class="sourceLineNo">610</span>          s.close();<a name="line.610"></a>
-<span class="sourceLineNo">611</span>          stopWatch.stop();<a name="line.611"></a>
-<span class="sourceLineNo">612</span>        }<a name="line.612"></a>
-<span class="sourceLineNo">613</span>        successes.incrementAndGet();<a name="line.613"></a>
-<span class="sourceLineNo">614</span>        sink.publishReadTiming(tableName.getNameAsString(), serverName, stopWatch.getTime());<a name="line.614"></a>
-<span class="sourceLineNo">615</span>      } catch (TableNotFoundException tnfe) {<a name="line.615"></a>
-<span class="sourceLineNo">616</span>        LOG.error("Table may be deleted", tnfe);<a name="line.616"></a>
-<span class="sourceLineNo">617</span>        // This is ignored because it doesn't imply that the regionserver is dead<a name="line.617"></a>
-<span class="sourceLineNo">618</span>      } catch (TableNotEnabledException tnee) {<a name="line.618"></a>
-<span class="sourceLineNo">619</span>        // This is considered a success since we got a response.<a name="line.619"></a>
-<span class="sourceLineNo">620</span>        successes.incrementAndGet();<a name="line.620"></a>
-<span class="sourceLineNo">621</span>        LOG.debug("The targeted table was disabled.  Assuming success.");<a name="line.621"></a>
-<span class="sourceLineNo">622</span>      } catch (DoNotRetryIOException dnrioe) {<a name="line.622"></a>
-<span class="sourceLineNo">623</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.623"></a>
-<span class="sourceLineNo">624</span>        LOG.error(dnrioe.toString(), dnrioe);<a name="line.624"></a>
-<span class="sourceLineNo">625</span>      } catch (IOException e) {<a name="line.625"></a>
-<span class="sourceLineNo">626</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.626"></a>
-<span class="sourceLineNo">627</span>        LOG.error(e.toString(), e);<a name="line.627"></a>
-<span class="sourceLineNo">628</span>      } finally {<a name="line.628"></a>
-<span class="sourceLineNo">629</span>        if (table != null) {<a name="line.629"></a>
-<span class="sourceLineNo">630</span>          try {<a name="line.630"></a>
-<span class="sourceLineNo">631</span>            table.close();<a name="line.631"></a>
-<span class="sourceLineNo">632</span>          } catch (IOException e) {/* DO NOTHING */<a name="line.632"></a>
-<span class="sourceLineNo">633</span>            LOG.error("Close table failed", e);<a name="line.633"></a>
-<span class="sourceLineNo">634</span>          }<a name="line.634"></a>
-<span class="sourceLineNo">635</span>        }<a name="line.635"></a>
-<span class="sourceLineNo">636</span>        scan = null;<a name="line.636"></a>
-<span class="sourceLineNo">637</span>        get = null;<a name="line.637"></a>
-<span class="sourceLineNo">638</span>        startKey = null;<a name="line.638"></a>
-<span class="sourceLineNo">639</span>      }<a name="line.639"></a>
-<span class="sourceLineNo">640</span>      return null;<a name="line.640"></a>
-<span class="sourceLineNo">641</span>    }<a name="line.641"></a>
-<span class="sourceLineNo">642</span>  }<a name="line.642"></a>
-<span class="sourceLineNo">643</span><a name="line.643"></a>
-<span class="sourceLineNo">644</span>  private static final int USAGE_EXIT_CODE = 1;<a name="line.644"></a>
-<span class="sourceLineNo">645</span>  private static final int INIT_ERROR_EXIT_CODE = 2;<a name="line.645"></a>
-<span class="sourceLineNo">646</span>  private static final int TIMEOUT_ERROR_EXIT_CODE = 3;<a name="line.646"></a>
-<span class="sourceLineNo">647</span>  private static final int ERROR_EXIT_CODE = 4;<a name="line.647"></a>
-<span class="sourceLineNo">648</span>  private static final int FAILURE_EXIT_CODE = 5;<a name="line.648"></a>
-<span class="sourceLineNo">649</span><a name="line.649"></a>
-<span class="sourceLineNo">650</span>  private static final long DEFAULT_INTERVAL = 60000;<a name="line.650"></a>
-<span class="sourceLineNo">651</span><a name="line.651"></a>
-<span class="sourceLineNo">652</span>  private static final long DEFAULT_TIMEOUT = 600000; // 10 mins<a name="line.652"></a>
-<span class="sourceLineNo">653</span>  private static final int MAX_THREADS_NUM = 16; // #threads to contact regions<a name="line.653"></a>
-<span class="sourceLineNo">654</span><a name="line.654"></a>
-<span class="sourceLineNo">655</span>  private static final Logger LOG = LoggerFactory.getLogger(Canary.class);<a name="line.655"></a>
-<span class="sourceLineNo">656</span><a name="line.656"></a>
-<span class="sourceLineNo">657</span>  public static final TableName DEFAULT_WRITE_TABLE_NAME = TableName.valueOf(<a name="line.657"></a>
-<span class="sourceLineNo">658</span>    NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "canary");<a name="line.658"></a>
-<span class="sourceLineNo">659</span><a name="line.659"></a>
-<span class="sourceLineNo">660</span>  private static final String CANARY_TABLE_FAMILY_NAME = "Test";<a name="line.660"></a>
-<span class="sourceLineNo">661</span><a name="line.661"></a>
-<span class="sourceLineNo">662</span>  private Configuration conf = null;<a name="line.662"></a>
-<span class="sourceLineNo">663</span>  private long interval = 0;<a name="line.663"></a>
-<span class="sourceLineNo">664</span>  private Sink sink = null;<a name="line.664"></a>
-<span class="sourceLineNo">665</span><a name="line.665"></a>
-<span class="sourceLineNo">666</span>  /**<a name="line.666"></a>
-<span class="sourceLineNo">667</span>   * True if we are to run in 'regionServer' mode.<a name="line.667"></a>
-<span class="sourceLineNo">668</span>   */<a name="line.668"></a>
-<span class="sourceLineNo">669</span>  private boolean regionServerMode = false;<a name="line.669"></a>
-<span class="sourceLineNo">670</span><a name="line.670"></a>
-<span class="sourceLineNo">671</span>  /**<a name="line.671"></a>
-<span class="sourceLineNo">672</span>   * True if we are to run in zookeeper 'mode'.<a name="line.672"></a>
-<span class="sourceLineNo">673</span>   */<a name="line.673"></a>
-<span class="sourceLineNo">674</span>  private boolean zookeeperMode = false;<a name="line.674"></a>
-<span class="sourceLineNo">675</span><a name="line.675"></a>
-<span class="sourceLineNo">676</span>  /**<a name="line.676"></a>
-<span class="sourceLineNo">677</span>   * This is a Map of table to timeout. The timeout is for reading all regions in the table; i.e.<a name="line.677"></a>
-<span class="sourceLineNo">678</span>   * we aggregate time to fetch each region and it needs to be less than this value else we<a name="line.678"></a>
-<span class="sourceLineNo">679</span>   * log an ERROR.<a name="line.679"></a>
-<span class="sourceLineNo">680</span>   */<a name="line.680"></a>
-<span class="sourceLineNo">681</span>  private HashMap&lt;String, Long&gt; configuredReadTableTimeouts = new HashMap&lt;&gt;();<a name="line.681"></a>
-<span class="sourceLineNo">682</span><a name="line.682"></a>
-<span class="sourceLineNo">683</span>  public static final String HBASE_CANARY_REGIONSERVER_ALL_REGIONS<a name="line.683"></a>
-<span class="sourceLineNo">684</span>          = "hbase.canary.regionserver_all_regions";<a name="line.684"></a>
-<span class="sourceLineNo">685</span><a name="line.685"></a>
-<span class="sourceLineNo">686</span>  public static final String HBASE_CANARY_REGION_WRITE_SNIFFING<a name="line.686"></a>
-<span class="sourceLineNo">687</span>          = "hbase.canary.region.write.sniffing";<a name="line.687"></a>
-<span class="sourceLineNo">688</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT<a name="line.688"></a>
-<span class="sourceLineNo">689</span>          = "hbase.canary.region.write.table.timeout";<a name="line.689"></a>
-<span class="sourceLineNo">690</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_NAME<a name="line.690"></a>
-<span class="sourceLineNo">691</span>          = "hbase.canary.region.write.table.name";<a name="line.691"></a>
-<span class="sourceLineNo">692</span>  public static final String HBASE_CANARY_REGION_READ_TABLE_TIMEOUT<a name="line.692"></a>
-<span class="sourceLineNo">693</span>          = "hbase.canary.region.read.table.timeout";<a name="line.693"></a>
-<span class="sourceLineNo">694</span><a name="line.694"></a>
-<span class="sourceLineNo">695</span>  public static final String HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES<a name="line.695"></a>
-<span class="sourceLineNo">696</span>          = "hbase.canary.zookeeper.permitted.failures";<a name="line.696"></a>
-<span class="sourceLineNo">697</span><a name="line.697"></a>
-<span class="sourceLineNo">698</span>  public static final String HBASE_CANARY_USE_REGEX = "hbase.canary.use.regex";<a name="line.698"></a>
-<span class="sourceLineNo">699</span>  public static final String HBASE_CANARY_TIMEOUT = "hbase.canary.timeout";<a name="line.699"></a>
-<span class="sourceLineNo">700</span>  public static final String HBASE_CANARY_FAIL_ON_ERROR = "hbase.canary.fail.on.error";<a name="line.700"></a>
-<span class="sourceLineNo">701</span><a name="line.701"></a>
+<span class="sourceLineNo">495</span>          sink.updateReadFailures(region == null? "NULL": region.getRegionNameAsString(),<a name="line.495"></a>
+<span class="sourceLineNo">496</span>              serverName == null? "NULL": serverName.getHostname());<a name="line.496"></a>
+<span class="sourceLineNo">497</span>        } finally {<a name="line.497"></a>
+<span class="sourceLineNo">498</span>          if (rs != null) {<a name="line.498"></a>
+<span class="sourceLineNo">499</span>            rs.close();<a name="line.499"></a>
+<span class="sourceLineNo">500</span>          }<a name="line.500"></a>
+<span class="sourceLineNo">501</span>          scan = null;<a name="line.501"></a>
+<span class="sourceLineNo">502</span>          get = null;<a name="line.502"></a>
+<span class="sourceLineNo">503</span>        }<a name="line.503"></a>
+<span class="sourceLineNo">504</span>      }<a name="line.504"></a>
+<span class="sourceLineNo">505</span>      try {<a name="line.505"></a>
+<span class="sourceLineNo">506</span>        table.close();<a name="line.506"></a>
+<span class="sourceLineNo">507</span>      } catch (IOException e) {<a name="line.507"></a>
+<span class="sourceLineNo">508</span>        LOG.error("Close table failed", e);<a name="line.508"></a>
+<span class="sourceLineNo">509</span>      }<a name="line.509"></a>
+<span class="sourceLineNo">510</span>      return null;<a name="line.510"></a>
+<span class="sourceLineNo">511</span>    }<a name="line.511"></a>
+<span class="sourceLineNo">512</span><a name="line.512"></a>
+<span class="sourceLineNo">513</span>    /**<a name="line.513"></a>
+<span class="sourceLineNo">514</span>     * Check writes for the canary table<a name="line.514"></a>
+<span class="sourceLineNo">515</span>     */<a name="line.515"></a>
+<span class="sourceLineNo">516</span>    private Void write() {<a name="line.516"></a>
+<span class="sourceLineNo">517</span>      Table table = null;<a name="line.517"></a>
+<span class="sourceLineNo">518</span>      TableDescriptor tableDesc = null;<a name="line.518"></a>
+<span class="sourceLineNo">519</span>      try {<a name="line.519"></a>
+<span class="sourceLineNo">520</span>        table = connection.getTable(region.getTable());<a name="line.520"></a>
+<span class="sourceLineNo">521</span>        tableDesc = table.getDescriptor();<a name="line.521"></a>
+<span class="sourceLineNo">522</span>        byte[] rowToCheck = region.getStartKey();<a name="line.522"></a>
+<span class="sourceLineNo">523</span>        if (rowToCheck.length == 0) {<a name="line.523"></a>
+<span class="sourceLineNo">524</span>          rowToCheck = new byte[]{0x0};<a name="line.524"></a>
+<span class="sourceLineNo">525</span>        }<a name="line.525"></a>
+<span class="sourceLineNo">526</span>        int writeValueSize =<a name="line.526"></a>
+<span class="sourceLineNo">527</span>            connection.getConfiguration().getInt(HConstants.HBASE_CANARY_WRITE_VALUE_SIZE_KEY, 10);<a name="line.527"></a>
+<span class="sourceLineNo">528</span>        for (ColumnFamilyDescriptor column : tableDesc.getColumnFamilies()) {<a name="line.528"></a>
+<span class="sourceLineNo">529</span>          Put put = new Put(rowToCheck);<a name="line.529"></a>
+<span class="sourceLineNo">530</span>          byte[] value = new byte[writeValueSize];<a name="line.530"></a>
+<span class="sourceLineNo">531</span>          Bytes.random(value);<a name="line.531"></a>
+<span class="sourceLineNo">532</span>          put.addColumn(column.getName(), HConstants.EMPTY_BYTE_ARRAY, value);<a name="line.532"></a>
+<span class="sourceLineNo">533</span><a name="line.533"></a>
+<span class="sourceLineNo">534</span>          LOG.debug("Writing to {} {} {} {}",<a name="line.534"></a>
+<span class="sourceLineNo">535</span>            tableDesc.getTableName(), region.getRegionNameAsString(), column.getNameAsString(),<a name="line.535"></a>
+<span class="sourceLineNo">536</span>            Bytes.toStringBinary(rowToCheck));<a name="line.536"></a>
+<span class="sourceLineNo">537</span>          try {<a name="line.537"></a>
+<span class="sourceLineNo">538</span>            long startTime = System.currentTimeMillis();<a name="line.538"></a>
+<span class="sourceLineNo">539</span>            table.put(put);<a name="line.539"></a>
+<span class="sourceLineNo">540</span>            long time = System.currentTimeMillis() - startTime;<a name="line.540"></a>
+<span class="sourceLineNo">541</span>            this.readWriteLatency.add(time);<a name="line.541"></a>
+<span class="sourceLineNo">542</span>            sink.publishWriteTiming(serverName, region, column, time);<a name="line.542"></a>
+<span class="sourceLineNo">543</span>          } catch (Exception e) {<a name="line.543"></a>
+<span class="sourceLineNo">544</span>            sink.publishWriteFailure(serverName, region, column, e);<a name="line.544"></a>
+<span class="sourceLineNo">545</span>          }<a name="line.545"></a>
+<span class="sourceLineNo">546</span>        }<a name="line.546"></a>
+<span class="sourceLineNo">547</span>        table.close();<a name="line.547"></a>
+<span class="sourceLineNo">548</span>      } catch (IOException e) {<a name="line.548"></a>
+<span class="sourceLineNo">549</span>        sink.publishWriteFailure(serverName, region, e);<a name="line.549"></a>
+<span class="sourceLineNo">550</span>        sink.updateWriteFailures(region.getRegionNameAsString(), serverName.getHostname() );<a name="line.550"></a>
+<span class="sourceLineNo">551</span>      }<a name="line.551"></a>
+<span class="sourceLineNo">552</span>      return null;<a name="line.552"></a>
+<span class="sourceLineNo">553</span>    }<a name="line.553"></a>
+<span class="sourceLineNo">554</span>  }<a name="line.554"></a>
+<span class="sourceLineNo">555</span><a name="line.555"></a>
+<span class="sourceLineNo">556</span>  /**<a name="line.556"></a>
+<span class="sourceLineNo">557</span>   * Run a single RegionServer Task and then exit.<a name="line.557"></a>
+<span class="sourceLineNo">558</span>   * Get one row from a region on the regionserver and output latency or the failure.<a name="line.558"></a>
+<span class="sourceLineNo">559</span>   */<a name="line.559"></a>
+<span class="sourceLineNo">560</span>  static class RegionServerTask implements Callable&lt;Void&gt; {<a name="line.560"></a>
+<span class="sourceLineNo">561</span>    private Connection connection;<a name="line.561"></a>
+<span class="sourceLineNo">562</span>    private String serverName;<a name="line.562"></a>
+<span class="sourceLineNo">563</span>    private RegionInfo region;<a name="line.563"></a>
+<span class="sourceLineNo">564</span>    private RegionServerStdOutSink sink;<a name="line.564"></a>
+<span class="sourceLineNo">565</span>    private AtomicLong successes;<a name="line.565"></a>
+<span class="sourceLineNo">566</span><a name="line.566"></a>
+<span class="sourceLineNo">567</span>    RegionServerTask(Connection connection, String serverName, RegionInfo region,<a name="line.567"></a>
+<span class="sourceLineNo">568</span>        RegionServerStdOutSink sink, AtomicLong successes) {<a name="line.568"></a>
+<span class="sourceLineNo">569</span>      this.connection = connection;<a name="line.569"></a>
+<span class="sourceLineNo">570</span>      this.serverName = serverName;<a name="line.570"></a>
+<span class="sourceLineNo">571</span>      this.region = region;<a name="line.571"></a>
+<span class="sourceLineNo">572</span>      this.sink = sink;<a name="line.572"></a>
+<span class="sourceLineNo">573</span>      this.successes = successes;<a name="line.573"></a>
+<span class="sourceLineNo">574</span>    }<a name="line.574"></a>
+<span class="sourceLineNo">575</span><a name="line.575"></a>
+<span class="sourceLineNo">576</span>    @Override<a name="line.576"></a>
+<span class="sourceLineNo">577</span>    public Void call() {<a name="line.577"></a>
+<span class="sourceLineNo">578</span>      TableName tableName = null;<a name="line.578"></a>
+<span class="sourceLineNo">579</span>      Table table = null;<a name="line.579"></a>
+<span class="sourceLineNo">580</span>      Get get = null;<a name="line.580"></a>
+<span class="sourceLineNo">581</span>      byte[] startKey = null;<a name="line.581"></a>
+<span class="sourceLineNo">582</span>      Scan scan = null;<a name="line.582"></a>
+<span class="sourceLineNo">583</span>      StopWatch stopWatch = new StopWatch();<a name="line.583"></a>
+<span class="sourceLineNo">584</span>      // monitor one region on every region server<a name="line.584"></a>
+<span class="sourceLineNo">585</span>      stopWatch.reset();<a name="line.585"></a>
+<span class="sourceLineNo">586</span>      try {<a name="line.586"></a>
+<span class="sourceLineNo">587</span>        tableName = region.getTable();<a name="line.587"></a>
+<span class="sourceLineNo">588</span>        table = connection.getTable(tableName);<a name="line.588"></a>
+<span class="sourceLineNo">589</span>        startKey = region.getStartKey();<a name="line.589"></a>
+<span class="sourceLineNo">590</span>        // Can't do a get on empty start row so do a Scan of first element if any instead.<a name="line.590"></a>
+<span class="sourceLineNo">591</span>        LOG.debug("Reading from {} {} {} {}",<a name="line.591"></a>
+<span class="sourceLineNo">592</span>          serverName, region.getTable(), region.getRegionNameAsString(),<a name="line.592"></a>
+<span class="sourceLineNo">593</span>          Bytes.toStringBinary(startKey));<a name="line.593"></a>
+<span class="sourceLineNo">594</span>        if (startKey.length &gt; 0) {<a name="line.594"></a>
+<span class="sourceLineNo">595</span>          get = new Get(startKey);<a name="line.595"></a>
+<span class="sourceLineNo">596</span>          get.setCacheBlocks(false);<a name="line.596"></a>
+<span class="sourceLineNo">597</span>          get.setFilter(new FirstKeyOnlyFilter());<a name="line.597"></a>
+<span class="sourceLineNo">598</span>          stopWatch.start();<a name="line.598"></a>
+<span class="sourceLineNo">599</span>          table.get(get);<a name="line.599"></a>
+<span class="sourceLineNo">600</span>          stopWatch.stop();<a name="line.600"></a>
+<span class="sourceLineNo">601</span>        } else {<a name="line.601"></a>
+<span class="sourceLineNo">602</span>          scan = new Scan();<a name="line.602"></a>
+<span class="sourceLineNo">603</span>          scan.setCacheBlocks(false);<a name="line.603"></a>
+<span class="sourceLineNo">604</span>          scan.setFilter(new FirstKeyOnlyFilter());<a name="line.604"></a>
+<span class="sourceLineNo">605</span>          scan.setCaching(1);<a name="line.605"></a>
+<span class="sourceLineNo">606</span>          scan.setMaxResultSize(1L);<a name="line.606"></a>
+<span class="sourceLineNo">607</span>          scan.setOneRowLimit();<a name="line.607"></a>
+<span class="sourceLineNo">608</span>          stopWatch.start();<a name="line.608"></a>
+<span class="sourceLineNo">609</span>          ResultScanner s = table.getScanner(scan);<a name="line.609"></a>
+<span class="sourceLineNo">610</span>          s.next();<a name="line.610"></a>
+<span class="sourceLineNo">611</span>          s.close();<a name="line.611"></a>
+<span class="sourceLineNo">612</span>          stopWatch.stop();<a name="line.612"></a>
+<span class="sourceLineNo">613</span>        }<a name="line.613"></a>
+<span class="sourceLineNo">614</span>        successes.incrementAndGet();<a name="line.614"></a>
+<span class="sourceLineNo">615</span>        sink.publishReadTiming(tableName.getNameAsString(), serverName, stopWatch.getTime());<a name="line.615"></a>
+<span class="sourceLineNo">616</span>      } catch (TableNotFoundException tnfe) {<a name="line.616"></a>
+<span class="sourceLineNo">617</span>        LOG.error("Table may be deleted", tnfe);<a name="line.617"></a>
+<span class="sourceLineNo">618</span>        // This is ignored because it doesn't imply that the regionserver is dead<a name="line.618"></a>
+<span class="sourceLineNo">619</span>      } catch (TableNotEnabledException tnee) {<a name="line.619"></a>
+<span class="sourceLineNo">620</span>        // This is considered a success since we got a response.<a name="line.620"></a>
+<span class="sourceLineNo">621</span>        successes.incrementAndGet();<a name="line.621"></a>
+<span class="sourceLineNo">622</span>        LOG.debug("The targeted table was disabled.  Assuming success.");<a name="line.622"></a>
+<span class="sourceLineNo">623</span>      } catch (DoNotRetryIOException dnrioe) {<a name="line.623"></a>
+<span class="sourceLineNo">624</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.624"></a>
+<span class="sourceLineNo">625</span>        LOG.error(dnrioe.toString(), dnrioe);<a name="line.625"></a>
+<span class="sourceLineNo">626</span>      } catch (IOException e) {<a name="line.626"></a>
+<span class="sourceLineNo">627</span>        sink.publishReadFailure(tableName.getNameAsString(), serverName);<a name="line.627"></a>
+<span class="sourceLineNo">628</span>        LOG.error(e.toString(), e);<a name="line.628"></a>
+<span class="sourceLineNo">629</span>      } finally {<a name="line.629"></a>
+<span class="sourceLineNo">630</span>        if (table != null) {<a name="line.630"></a>
+<span class="sourceLineNo">631</span>          try {<a name="line.631"></a>
+<span class="sourceLineNo">632</span>            table.close();<a name="line.632"></a>
+<span class="sourceLineNo">633</span>          } catch (IOException e) {/* DO NOTHING */<a name="line.633"></a>
+<span class="sourceLineNo">634</span>            LOG.error("Close table failed", e);<a name="line.634"></a>
+<span class="sourceLineNo">635</span>          }<a name="line.635"></a>
+<span class="sourceLineNo">636</span>        }<a name="line.636"></a>
+<span class="sourceLineNo">637</span>        scan = null;<a name="line.637"></a>
+<span class="sourceLineNo">638</span>        get = null;<a name="line.638"></a>
+<span class="sourceLineNo">639</span>        startKey = null;<a name="line.639"></a>
+<span class="sourceLineNo">640</span>      }<a name="line.640"></a>
+<span class="sourceLineNo">641</span>      return null;<a name="line.641"></a>
+<span class="sourceLineNo">642</span>    }<a name="line.642"></a>
+<span class="sourceLineNo">643</span>  }<a name="line.643"></a>
+<span class="sourceLineNo">644</span><a name="line.644"></a>
+<span class="sourceLineNo">645</span>  private static final int USAGE_EXIT_CODE = 1;<a name="line.645"></a>
+<span class="sourceLineNo">646</span>  private static final int INIT_ERROR_EXIT_CODE = 2;<a name="line.646"></a>
+<span class="sourceLineNo">647</span>  private static final int TIMEOUT_ERROR_EXIT_CODE = 3;<a name="line.647"></a>
+<span class="sourceLineNo">648</span>  private static final int ERROR_EXIT_CODE = 4;<a name="line.648"></a>
+<span class="sourceLineNo">649</span>  private static final int FAILURE_EXIT_CODE = 5;<a name="line.649"></a>
+<span class="sourceLineNo">650</span><a name="line.650"></a>
+<span class="sourceLineNo">651</span>  private static final long DEFAULT_INTERVAL = 60000;<a name="line.651"></a>
+<span class="sourceLineNo">652</span><a name="line.652"></a>
+<span class="sourceLineNo">653</span>  private static final long DEFAULT_TIMEOUT = 600000; // 10 mins<a name="line.653"></a>
+<span class="sourceLineNo">654</span>  private static final int MAX_THREADS_NUM = 16; // #threads to contact regions<a name="line.654"></a>
+<span class="sourceLineNo">655</span><a name="line.655"></a>
+<span class="sourceLineNo">656</span>  private static final Logger LOG = LoggerFactory.getLogger(Canary.class);<a name="line.656"></a>
+<span class="sourceLineNo">657</span><a name="line.657"></a>
+<span class="sourceLineNo">658</span>  public static final TableName DEFAULT_WRITE_TABLE_NAME = TableName.valueOf(<a name="line.658"></a>
+<span class="sourceLineNo">659</span>    NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "canary");<a name="line.659"></a>
+<span class="sourceLineNo">660</span><a name="line.660"></a>
+<span class="sourceLineNo">661</span>  private static final String CANARY_TABLE_FAMILY_NAME = "Test";<a name="line.661"></a>
+<span class="sourceLineNo">662</span><a name="line.662"></a>
+<span class="sourceLineNo">663</span>  private Configuration conf = null;<a name="line.663"></a>
+<span class="sourceLineNo">664</span>  private long interval = 0;<a name="line.664"></a>
+<span class="sourceLineNo">665</span>  private Sink sink = null;<a name="line.665"></a>
+<span class="sourceLineNo">666</span><a name="line.666"></a>
+<span class="sourceLineNo">667</span>  /**<a name="line.667"></a>
+<span class="sourceLineNo">668</span>   * True if we are to run in 'regionServer' mode.<a name="line.668"></a>
+<span class="sourceLineNo">669</span>   */<a name="line.669"></a>
+<span class="sourceLineNo">670</span>  private boolean regionServerMode = false;<a name="line.670"></a>
+<span class="sourceLineNo">671</span><a name="line.671"></a>
+<span class="sourceLineNo">672</span>  /**<a name="line.672"></a>
+<span class="sourceLineNo">673</span>   * True if we are to run in zookeeper 'mode'.<a name="line.673"></a>
+<span class="sourceLineNo">674</span>   */<a name="line.674"></a>
+<span class="sourceLineNo">675</span>  private boolean zookeeperMode = false;<a name="line.675"></a>
+<span class="sourceLineNo">676</span><a name="line.676"></a>
+<span class="sourceLineNo">677</span>  /**<a name="line.677"></a>
+<span class="sourceLineNo">678</span>   * This is a Map of table to timeout. The timeout is for reading all regions in the table; i.e.<a name="line.678"></a>
+<span class="sourceLineNo">679</span>   * we aggregate time to fetch each region and it needs to be less than this value else we<a name="line.679"></a>
+<span class="sourceLineNo">680</span>   * log an ERROR.<a name="line.680"></a>
+<span class="sourceLineNo">681</span>   */<a name="line.681"></a>
+<span class="sourceLineNo">682</span>  private HashMap&lt;String, Long&gt; configuredReadTableTimeouts = new HashMap&lt;&gt;();<a name="line.682"></a>
+<span class="sourceLineNo">683</span><a name="line.683"></a>
+<span class="sourceLineNo">684</span>  public static final String HBASE_CANARY_REGIONSERVER_ALL_REGIONS<a name="line.684"></a>
+<span class="sourceLineNo">685</span>          = "hbase.canary.regionserver_all_regions";<a name="line.685"></a>
+<span class="sourceLineNo">686</span><a name="line.686"></a>
+<span class="sourceLineNo">687</span>  public static final String HBASE_CANARY_REGION_WRITE_SNIFFING<a name="line.687"></a>
+<span class="sourceLineNo">688</span>          = "hbase.canary.region.write.sniffing";<a name="line.688"></a>
+<span class="sourceLineNo">689</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT<a name="line.689"></a>
+<span class="sourceLineNo">690</span>          = "hbase.canary.region.write.table.timeout";<a name="line.690"></a>
+<span class="sourceLineNo">691</span>  public static final String HBASE_CANARY_REGION_WRITE_TABLE_NAME<a name="line.691"></a>
+<span class="sourceLineNo">692</span>          = "hbase.canary.region.write.table.name";<a name="line.692"></a>
+<span class="sourceLineNo">693</span>  public static final String HBASE_CANARY_REGION_READ_TABLE_TIMEOUT<a name="line.693"></a>
+<span class="sourceLineNo">694</span>          = "hbase.canary.region.read.table.timeout";<a name="line.694"></a>
+<span class="sourceLineNo">695</span><a name="line.695"></a>
+<span class="sourceLineNo">696</span>  public static final String HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES<a name="line.696"></a>
+<span class="sourceLineNo">697</span>          = "hbase.canary.zookeeper.permitted.failures";<a name="line.697"></a>
+<span class="sourceLineNo">698</span><a name="line.698"></a>
+<span class="sourceLineNo">699</span>  public static final String HBASE_CANARY_USE_REGEX = "hbase.canary.use.regex";<a name="line.699"></a>
+<span class="sourceLineNo">700</span>  public static final String HBASE_CANARY_TIMEOUT = "hbase.canary.timeout";<a name="line.700"></a>
+<span class="sourceLineNo">701</span>  public static final String HBASE_CANARY_FAIL_ON_ERROR = "hbase.canary.fail.on.error";<a name="line.701"></a>
 <span class="sourceLineNo">702</span><a name="line.702"></a>
-<span class="sourceLineNo">703</span>  private ExecutorService executor; // threads to retrieve data from regionservers<a name="line.703"></a>
-<span class="sourceLineNo">704</span><a name="line.704"></a>
-<span class="sourceLineNo">705</span>  public CanaryTool() {<a name="line.705"></a>
-<span class="sourceLineNo">706</span>    this(new ScheduledThreadPoolExecutor(1));<a name="line.706"></a>
-<span class="sourceLineNo">707</span>  }<a name="line.707"></a>
-<span class="sourceLineNo">708</span><a name="line.708"></a>
-<span class="sourceLineNo">709</span>  public CanaryTool(ExecutorService executor) {<a name="line.709"></a>
-<span class="sourceLineNo">710</span>    this(executor, null);<a name="line.710"></a>
-<span class="sourceLineNo">711</span>  }<a name="line.711"></a>
-<span class="sourceLineNo">712</span><a name="line.712"></a>
-<span class="sourceLineNo">713</span>  @VisibleForTesting<a name="line.713"></a>
-<span class="sourceLineNo">714</span>  CanaryTool(ExecutorService executor, Sink sink) {<a name="line.714"></a>
-<span class="sourceLineNo">715</span>    this.executor = executor;<a name="line.715"></a>
-<span class="sourceLineNo">716</span>    this.sink = sink;<a name="line.716"></a>
-<span class="sourceLineNo">717</span>  }<a name="line.717"></a>
-<span class="sourceLineNo">718</span><a name="line.718"></a>
-<span class="sourceLineNo">719</span>  CanaryTool(Configuration conf, ExecutorService executor) {<a name="line.719"></a>
-<span class="sourceLineNo">720</span>    this(conf, executor, null);<a name="line.720"></a>
-<span class="sourceLineNo">721</span>  }<a name="line.721"></a>
-<span class="sourceLineNo">722</span><a name="line.722"></a>
-<span class="sourceLineNo">723</span>  CanaryTool(Configuration conf, ExecutorService executor, Sink sink) {<a name="line.723"></a>
-<span class="sourceLineNo">724</span>    this(executor, sink);<a name="line.724"></a>
-<span class="sourceLineNo">725</span>    setConf(conf);<a name="line.725"></a>
-<span class="sourceLineNo">726</span>  }<a name="line.726"></a>
-<span class="sourceLineNo">727</span><a name="line.727"></a>
-<span class="sourceLineNo">728</span>  @Override<a name="line.728"></a>
-<span class="sourceLineNo">729</span>  public Configuration getConf() {<a name="line.729"></a>
-<span class="sourceLineNo">730</span>    return conf;<a name="line.730"></a>
-<span class="sourceLineNo">731</span>  }<a name="line.731"></a>
-<span class="sourceLineNo">732</span><a name="line.732"></a>
-<span class="sourceLineNo">733</span>  @Override<a name="line.733"></a>
-<span class="sourceLineNo">734</span>  public void setConf(Configuration conf) {<a name="line.734"></a>
-<span class="sourceLineNo">735</span>    if (conf == null) {<a name="line.735"></a>
-<span class="sourceLineNo">736</span>      conf = HBaseConfiguration.create();<a name="line.736"></a>
-<span class="sourceLineNo">737</span>    }<a name="line.737"></a>
-<span class="sourceLineNo">738</span>    this.conf = conf;<a name="line.738"></a>
-<span class="sourceLineNo">739</span>  }<a name="line.739"></a>
-<span class="sourceLineNo">740</span><a name="line.740"></a>
-<span class="sourceLineNo">741</span>  private int parseArgs(String[] args) {<a name="line.741"></a>
-<span class="sourceLineNo">742</span>    int index = -1;<a name="line.742"></a>
-<span class="sourceLineNo">743</span>    long permittedFailures = 0;<a name="line.743"></a>
-<span class="sourceLineNo">744</span>    boolean regionServerAllRegions = false, writeSniffing = false;<a name="line.744"></a>
-<span class="sourceLineNo">745</span>    String readTableTimeoutsStr = null;<a name="line.745"></a>
-<span class="sourceLineNo">746</span><a name="line.746"></a>
-<span class="sourceLineNo">747</span>    // Process command line args<a name="line.747"></a>
-<span class="sourceLineNo">748</span>    for (int i = 0; i &lt; args.length; i++) {<a name="line.748"></a>
-<span class="sourceLineNo">749</span>      String cmd = args[i];<a name="line.749"></a>
-<span class="sourceLineNo">750</span><a name="line.750"></a>
-<span class="sourceLineNo">751</span>      if (cmd.startsWith("-")) {<a name="line.751"></a>
-<span class="sourceLineNo">752</span>        if (index &gt;= 0) {<a name="line.752"></a>
-<span class="sourceLineNo">753</span>          // command line args must be in the form: [opts] [table 1 [table 2 ...]]<a name="line.753"></a>
-<span class="sourceLineNo">754</span>          System.err.println("Invalid command line options");<a name="line.754"></a>
-<span class="sourceLineNo">755</span>          printUsageAndExit();<a name="line.755"></a>
-<span class="sourceLineNo">756</span>        }<a name="line.756"></a>
-<span class="sourceLineNo">757</span><a name="line.757"></a>
-<span class="sourceLineNo">758</span>        if (cmd.equals("-help") || cmd.equals("-h")) {<a name="line.758"></a>
-<span class="sourceLineNo">759</span>          // user asked for help, print the help and quit.<a name="line.759"></a>
-<span class="sourceLineNo">760</span>          printUsageAndExit();<a name="line.760"></a>
-<span class="sourceLineNo">761</span>        } else if (cmd.equals("-daemon") &amp;&amp; interval == 0) {<a name="line.761"></a>
-<span class="sourceLineNo">762</span>          // user asked for daemon mode, set a default interval between checks<a name="line.762"></a>
-<span class="sourceLineNo">763</span>          interval = DEFAULT_INTERVAL;<a name="line.763"></a>
-<span class="sourceLineNo">764</span>        } else if (cmd.equals("-interval")) {<a name="line.764"></a>
-<span class="sourceLineNo">765</span>          // user has specified an interval for canary breaths (-interval N)<a name="line.765"></a>
-<span class="sourceLineNo">766</span>          i++;<a name="line.766"></a>
-<span class="sourceLineNo">767</span><a name="line.767"></a>
-<span class="sourceLineNo">768</span>          if (i == args.length) {<a name="line.768"></a>
-<span class="sourceLineNo">769</span>            System.err.println("-interval takes a numeric seconds value argument.");<a name="line.769"></a>
-<span class="sourceLineNo">770</span>            printUsageAndExit();<a name="line.770"></a>
-<span class="sourceLineNo">771</span>          }<a name="line.771"></a>
-<span class="sourceLineNo">772</span><a name="line.772"></a>
-<span class="sourceLineNo">773</span>          try {<a name="line.773"></a>
-<span class="sourceLineNo">774</span>            interval = Long.parseLong(args[i]) * 1000;<a name="line.774"></a>
-<span class="sourceLineNo">775</span>          } catch (NumberFormatException e) {<a name="line.775"></a>
-<span class="sourceLineNo">776</span>            System.err.println("-interval needs a numeric value argument.");<a name="line.776"></a>
-<span class="sourceLineNo">777</span>            printUsageAndExit();<a name="line.777"></a>
-<span class="sourceLineNo">778</span>          }<a name="line.778"></a>
-<span class="sourceLineNo">779</span>        } else if (cmd.equals("-zookeeper")) {<a name="line.779"></a>
-<span class="sourceLineNo">780</span>          this.zookeeperMode = true;<a name="line.780"></a>
-<span class="sourceLineNo">781</span>        } else if(cmd.equals("-regionserver")) {<a name="line.781"></a>
-<span class="sourceLineNo">782</span>          this.regionServerMode = true;<a name="line.782"></a>
-<span class="sourceLineNo">783</span>        } else if(cmd.equals("-allRegions")) {<a name="line.783"></a>
-<span class="sourceLineNo">784</span>          conf.setBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, true);<a name="line.784"></a>
-<span class="sourceLineNo">785</span>          regionServerAllRegions = true;<a name="line.785"></a>
-<span class="sourceLineNo">786</span>        } else if(cmd.equals("-writeSniffing")) {<a name="line.786"></a>
-<span class="sourceLineNo">787</span>          writeSniffing = true;<a name="line.787"></a>
-<span class="sourceLineNo">788</span>          conf.setBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, true);<a name="line.788"></a>
-<span class="sourceLineNo">789</span>        } else if(cmd.equals("-treatFailureAsError") || cmd.equals("-failureAsError")) {<a name="line.789"></a>
-<span class="sourceLineNo">790</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.790"></a>
-<span class="sourceLineNo">791</span>        } else if (cmd.equals("-e")) {<a name="line.791"></a>
-<span class="sourceLineNo">792</span>          conf.setBoolean(HBASE_CANARY_USE_REGEX, true);<a name="line.792"></a>
-<span class="sourceLineNo">793</span>        } else if (cmd.equals("-t")) {<a name="line.793"></a>
-<span class="sourceLineNo">794</span>          i++;<a name="line.794"></a>
-<span class="sourceLineNo">795</span><a name="line.795"></a>
-<span class="sourceLineNo">796</span>          if (i == args.length) {<a name="line.796"></a>
-<span class="sourceLineNo">797</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.797"></a>
-<span class="sourceLineNo">798</span>            printUsageAndExit();<a name="line.798"></a>
-<span class="sourceLineNo">799</span>          }<a name="line.799"></a>
-<span class="sourceLineNo">800</span>          long timeout = 0;<a name="line.800"></a>
-<span class="sourceLineNo">801</span>          try {<a name="line.801"></a>
-<span class="sourceLineNo">802</span>            timeout = Long.parseLong(args[i]);<a name="line.802"></a>
-<span class="sourceLineNo">803</span>          } catch (NumberFormatException e) {<a name="line.803"></a>
-<span class="sourceLineNo">804</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.804"></a>
-<span class="sourceLineNo">805</span>            printUsageAndExit();<a name="line.805"></a>
-<span class="sourceLineNo">806</span>          }<a name="line.806"></a>
-<span class="sourceLineNo">807</span>          conf.setLong(HBASE_CANARY_TIMEOUT, timeout);<a name="line.807"></a>
-<span class="sourceLineNo">808</span>        } else if(cmd.equals("-writeTableTimeout")) {<a name="line.808"></a>
-<span class="sourceLineNo">809</span>          i++;<a name="line.809"></a>
-<span class="sourceLineNo">810</span><a name="line.810"></a>
-<span class="sourceLineNo">811</span>          if (i == args.length) {<a name="line.811"></a>
-<span class="sourceLineNo">812</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.812"></a>
-<span class="sourceLineNo">813</span>            printUsageAndExit();<a name="line.813"></a>
-<span class="sourceLineNo">814</span>          }<a name="line.814"></a>
-<span class="sourceLineNo">815</span>          long configuredWriteTableTimeout = 0;<a name="line.815"></a>
-<span class="sourceLineNo">816</span>          try {<a name="line.816"></a>
-<span class="sourceLineNo">817</span>            configuredWriteTableTimeout = Long.parseLong(args[i]);<a name="line.817"></a>
-<span class="sourceLineNo">818</span>          } catch (NumberFormatException e) {<a name="line.818"></a>
-<span class="sourceLineNo">819</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.819"></a>
-<span class="sourceLineNo">820</span>            printUsageAndExit();<a name="line.820"></a>
-<span class="sourceLineNo">821</span>          }<a name="line.821"></a>
-<span class="sourceLineNo">822</span>          conf.setLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, configuredWriteTableTimeout);<a name="line.822"></a>
-<span class="sourceLineNo">823</span>        } else if (cmd.equals("-writeTable")) {<a name="line.823"></a>
-<span class="sourceLineNo">824</span>          i++;<a name="line.824"></a>
-<span class="sourceLineNo">825</span><a name="line.825"></a>
-<span class="sourceLineNo">826</span>          if (i == args.length) {<a name="line.826"></a>
-<span class="sourceLineNo">827</span>            System.err.println("-writeTable takes a string tablename value argument.");<a name="line.827"></a>
-<span class="sourceLineNo">828</span>            printUsageAndExit();<a name="line.828"></a>
-<span class="sourceLineNo">829</span>          }<a name="line.829"></a>
-<span class="sourceLineNo">830</span>          conf.set(HBASE_CANARY_REGION_WRITE_TABLE_NAME, args[i]);<a name="line.830"></a>
-<span class="sourceLineNo">831</span>        } else if (cmd.equals("-f")) {<a name="line.831"></a>
-<span class="sourceLineNo">832</span>          i++;<a name="line.832"></a>
-<span class="sourceLineNo">833</span><a name="line.833"></a>
-<span class="sourceLineNo">834</span>          if (i == args.length) {<a name="line.834"></a>
-<span class="sourceLineNo">835</span>            System.err<a name="line.835"></a>
-<span class="sourceLineNo">836</span>                .println("-f needs a boolean value argument (true|false).");<a name="line.836"></a>
-<span class="sourceLineNo">837</span>            printUsageAndExit();<a name="line.837"></a>
-<span class="sourceLineNo">838</span>          }<a name="line.838"></a>
-<span class="sourceLineNo">839</span><a name="line.839"></a>
-<span class="sourceLineNo">840</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, Boolean.parseBoolean(args[i]));<a name="line.840"></a>
-<span class="sourceLineNo">841</span>        } else if (cmd.equals("-readTableTimeouts")) {<a name="line.841"></a>
-<span class="sourceLineNo">842</span>          i++;<a name="line.842"></a>
-<span class="sourceLineNo">843</span><a name="line.843"></a>
-<span class="sourceLineNo">844</span>          if (i == args.length) {<a name="line.844"></a>
-<span class="sourceLineNo">845</span>            System.err.println("-readTableTimeouts needs a comma-separated list of read " +<a name="line.845"></a>
-<span class="sourceLineNo">846</span>                "millisecond timeouts per table (without spaces).");<a name="line.846"></a>
-<span class="sourceLineNo">847</span>            printUsageAndExit();<a name="line.847"></a>
-<span class="sourceLineNo">848</span>          }<a name="line.848"></a>
-<span class="sourceLineNo">849</span>          readTableTimeoutsStr = args[i];<a name="line.849"></a>
-<span class="sourceLineNo">850</span>          conf.set(HBASE_CANARY_REGION_READ_TABLE_TIMEOUT, readTableTimeoutsStr);<a name="line.850"></a>
-<span class="sourceLineNo">851</span>        } else if (cmd.equals("-permittedZookeeperFailures")) {<a name="line.851"></a>
-<span class="sourceLineNo">852</span>          i++;<a name="line.852"></a>
-<span class="sourceLineNo">853</span><a name="line.853"></a>
-<span class="sourceLineNo">854</span>          if (i == args.length) {<a name="line.854"></a>
-<span class="sourceLineNo">855</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.855"></a>
-<span class="sourceLineNo">856</span>            printUsageAndExit();<a name="line.856"></a>
-<span class="sourceLineNo">857</span>          }<a name="line.857"></a>
-<span class="sourceLineNo">858</span>          try {<a name="line.858"></a>
-<span class="sourceLineNo">859</span>            permittedFailures = Long.parseLong(args[i]);<a name="line.859"></a>
-<span class="sourceLineNo">860</span>          } catch (NumberFormatException e) {<a name="line.860"></a>
-<span class="sourceLineNo">861</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.861"></a>
-<span class="sourceLineNo">862</span>            printUsageAndExit();<a name="line.862"></a>
-<span class="sourceLineNo">863</span>          }<a name="line.863"></a>
-<span class="sourceLineNo">864</span>          conf.setLong(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, permittedFailures);<a name="line.864"></a>
-<span class="sourceLineNo">865</span>        } else {<a name="line.865"></a>
-<span class="sourceLineNo">866</span>          // no options match<a name="line.866"></a>
-<span class="sourceLineNo">867</span>          System.err.println(cmd + " options is invalid.");<a name="line.867"></a>
-<span class="sourceLineNo">868</span>          printUsageAndExit();<a name="line.868"></a>
-<span class="sourceLineNo">869</span>        }<a name="line.869"></a>
-<span class="sourceLineNo">870</span>      } else if (index &lt; 0) {<a name="line.870"></a>
-<span class="sourceLineNo">871</span>        // keep track of first table name specified by the user<a name="line.871"></a>
-<span class="sourceLineNo">872</span>        index = i;<a name="line.872"></a>
-<span class="sourceLineNo">873</span>      }<a name="line.873"></a>
-<span class="sourceLineNo">874</span>    }<a name="line.874"></a>
-<span class="sourceLineNo">875</span>    if (regionServerAllRegions &amp;&amp; !this.regionServerMode) {<a name="line.875"></a>
-<span class="sourceLineNo">876</span>      System.err.println("-allRegions can only be specified in regionserver mode.");<a name="line.876"></a>
-<span class="sourceLineNo">877</span>      printUsageAndExit();<a name="line.877"></a>
-<span class="sourceLineNo">878</span>    }<a name="line.878"></a>
-<span class="sourceLineNo">879</span>    if (this.zookeeperMode) {<a name="line.879"></a>
-<span class="sourceLineNo">880</span>      if (this.regionServerMode || regionServerAllRegions || writeSniffing) {<a name="line.880"></a>
-<span class="sourceLineNo">881</span>        System.err.println("-zookeeper is exclusive and cannot be combined with "<a name="line.881"></a>
-<span class="sourceLineNo">882</span>            + "other modes.");<a name="line.882"></a>
-<span class="sourceLineNo">883</span>        printUsageAndExit();<a name="line.883"></a>
-<span class="sourceLineNo">884</span>      }<a name="line.884"></a>
-<span class="sourceLineNo">885</span>    }<a name="line.885"></a>
-<span class="sourceLineNo">886</span>    if (permittedFailures != 0 &amp;&amp; !this.zookeeperMode) {<a name="line.886"></a>
-<span class="sourceLineNo">887</span>      System.err.println("-permittedZookeeperFailures requires -zookeeper mode.");<a name="line.887"></a>
-<span class="sourceLineNo">888</span>      printUsageAndExit();<a name="line.888"></a>
-<span class="sourceLineNo">889</span>    }<a name="line.889"></a>
-<span class="sourceLineNo">890</span>    if (readTableTimeoutsStr != null &amp;&amp; (this.regionServerMode || this.zookeeperMode)) {<a name="line.890"></a>
-<span class="sourceLineNo">891</span>      System.err.println("-readTableTimeouts can only be configured in region mode.");<a name="line.891"></a>
-<span class="sourceLineNo">892</span>      printUsageAndExit();<a name="line.892"></a>
-<span class="sourceLineNo">893</span>    }<a name="line.893"></a>
-<span class="sourceLineNo">894</span>    return index;<a name="line.894"></a>
-<span class="sourceLineNo">895</span>  }<a name="line.895"></a>
-<span class="sourceLineNo">896</span><a name="line.896"></a>
-<span class="sourceLineNo">897</span>  @Override<a name="line.897"></a>
-<span class="sourceLineNo">898</span>  public int run(String[] args) throws Exception {<a name="line.898"></a>
-<span class="sourceLineNo">899</span>    int index = parseArgs(args);<a name="line.899"></a>
-<span class="sourceLineNo">900</span>    String[] monitorTargets = null;<a name="line.900"></a>
-<span class="sourceLineNo">901</span><a name="line.901"></a>
-<span class="sourceLineNo">902</span>    if (index &gt;= 0) {<a name="line.902"></a>
-<span class="sourceLineNo">903</span>      int length = args.length - index;<a name="line.903"></a>
-<span class="sourceLineNo">904</span>      monitorTargets = new String[length];<a name="line.904"></a>
-<span class="sourceLineNo">905</span>      System.arraycopy(args, index, monitorTargets, 0, length);<a name="line.905"></a>
-<span class="sourceLineNo">906</span>    }<a name="line.906"></a>
-<span class="sourceLineNo">907</span><a name="line.907"></a>
-<span class="sourceLineNo">908</span>    if (zookeeperMode) {<a name="line.908"></a>
-<span class="sourceLineNo">909</span>      return checkZooKeeper();<a name="line.909"></a>
-<span class="sourceLineNo">910</span>    } else if (regionServerMode) {<a name="line.910"></a>
-<span class="sourceLineNo">911</span>      return checkRegionServers(monitorTargets);<a name="line.911"></a>
-<span class="sourceLineNo">912</span>    } else {<a name="line.912"></a>
-<span class="sourceLineNo">913</span>      return checkRegions(monitorTargets);<a name="line.913"></a>
-<span class="sourceLineNo">914</span>    }<a name="line.914"></a>
-<span class="sourceLineNo">915</span>  }<a name="line.915"></a>
-<span class="sourceLineNo">916</span><a name="line.916"></a>
-<span class="sourceLineNo">917</span>  private int runMonitor(String[] monitorTargets) throws Exception {<a name="line.917"></a>
-<span class="sourceLineNo">918</span>    ChoreService choreService = null;<a name="line.918"></a>
-<span class="sourceLineNo">919</span><a name="line.919"></a>
-<span class="sourceLineNo">920</span>    // Launches chore for refreshing kerberos credentials if security is enabled.<a name="line.920"></a>
-<span class="sourceLineNo">921</span>    // Please see http://hbase.apache.org/book.html#_running_canary_in_a_kerberos_enabled_cluster<a name="line.921"></a>
-<span class="sourceLineNo">922</span>    // for more details.<a name="line.922"></a>
-<span class="sourceLineNo">923</span>    final ScheduledChore authChore = AuthUtil.getAuthChore(conf);<a name="line.923"></a>
-<span class="sourceLineNo">924</span>    if (authChore != null) {<a name="line.924"></a>
-<span class="sourceLineNo">925</span>      choreService = new ChoreService("CANARY_TOOL");<a name="line.925"></a>
-<span class="sourceLineNo">926</span>      choreService.scheduleChore(authChore);<a name="line.926"></a>
-<span class="sourceLineNo">927</span>    }<a name="line.927"></a>
-<span class="sourceLineNo">928</span><a name="line.928"></a>
-<span class="sourceLineNo">929</span>    // Start to prepare the stuffs<a name="line.929"></a>
-<span class="sourceLineNo">930</span>    Monitor monitor = null;<a name="line.930"></a>
-<span class="sourceLineNo">931</span>    Thread monitorThread;<a name="line.931"></a>
-<span class="sourceLineNo">932</span>    long startTime = 0;<a name="line.932"></a>
-<span class="sourceLineNo">933</span>    long currentTimeLength = 0;<a name="line.933"></a>
-<span class="sourceLineNo">934</span>    boolean failOnError = conf.getBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.934"></a>
-<span class="sourceLineNo">935</span>    long timeout = conf.getLong(HBASE_CANARY_TIMEOUT, DEFAULT_TIMEOUT);<a name="line.935"></a>
-<span class="sourceLineNo">936</span>    // Get a connection to use in below.<a name="line.936"></a>
-<span class="sourceLineNo">937</span>    try (Connection connection = ConnectionFactory.createConnection(this.conf)) {<a name="line.937"></a>
-<span class="sourceLineNo">938</span>      do {<a name="line.938"></a>
-<span class="sourceLineNo">939</span>        // Do monitor !!<a name="line.939"></a>
-<span class="sourceLineNo">940</span>        try {<a name="line.940"></a>
-<span class="sourceLineNo">941</span>          monitor = this.newMonitor(connection, monitorTargets);<a name="line.941"></a>
-<span class="sourceLineNo">942</span>          monitorThread = new Thread(monitor, "CanaryMonitor-" + System.currentTimeMillis());<a name="line.942"></a>
-<span class="sourceLineNo">943</span>          startTime = System.currentTimeMillis();<a name="line.943"></a>
-<span class="sourceLineNo">944</span>          monitorThread.start();<a name="line.944"></a>
-<span class="sourceLineNo">945</span>          while (!monitor.isDone()) {<a name="line.945"></a>
-<span class="sourceLineNo">946</span>            // wait for 1 sec<a name="line.946"></a>
-<span class="sourceLineNo">947</span>            Thread.sleep(1000);<a name="line.947"></a>
-<span class="sourceLineNo">948</span>            // exit if any error occurs<a name="line.948"></a>
-<span class="sourceLineNo">949</span>            if (failOnError &amp;&amp; monitor.hasError()) {<a name="line.949"></a>
-<span class="sourceLineNo">950</span>              monitorThread.interrupt();<a name="line.950"></a>
-<span class="sourceLineNo">951</span>              if (monitor.initialized) {<a name="line.951"></a>
-<span class="sourceLineNo">952</span>                return monitor.errorCode;<a name="line.952"></a>
-<span class="sourceLineNo">953</span>              } else {<a name="line.953"></a>
-<span class="sourceLineNo">954</span>                return INIT_ERROR_EXIT_CODE;<a name="line.954"></a>
-<span class="sourceLineNo">955</span>              }<a name="line.955"></a>
-<span class="sourceLineNo">956</span>            }<a name="line.956"></a>
-<span class="sourceLineNo">957</span>            currentTimeLength = System.currentTimeMillis() - startTime;<a name="line.957"></a>
-<span class="sourceLineNo">958</span>            if (currentTimeLength &gt; timeout) {<a name="line.958"></a>
-<span class="sourceLineNo">959</span>              LOG.error("The monitor is running too long (" + currentTimeLength<a name="line.959"></a>
-<span class="sourceLineNo">960</span>                  + ") after timeout limit:" + timeout<a name="line.960"></a>
-<span class="sourceLineNo">961</span>                  + " will be killed itself !!");<a name="line.961"></a>
-<span class="sourceLineNo">962</span>              if (monitor.initialized) {<a name="line.962"></a>
-<span class="sourceLineNo">963</span>                return TIMEOUT_ERROR_EXIT_CODE;<a name="line.963"></a>
-<span class="sourceLineNo">964</span>              } else {<a name="line.964"></a>
-<span class="sourceLineNo">965</span>                return INIT_ERROR_EXIT_CODE;<a name="line.965"></a>
-<span class="sourceLineNo">966</span>              }<a name="line.966"></a>
-<span class="sourceLineNo">967</span>            }<a name="line.967"></a>
-<span class="sourceLineNo">968</span>          }<a name="line.968"></a>
-<span class="sourceLineNo">969</span><a name="line.969"></a>
-<span class="sourceLineNo">970</span>          if (failOnError &amp;&amp; monitor.finalCheckForErrors()) {<a name="line.970"></a>
-<span class="sourceLineNo">971</span>            monitorThread.interrupt();<a name="line.971"></a>
-<span class="sourceLineNo">972</span>            return monitor.errorCode;<a name="line.972"></a>
-<span class="sourceLineNo">973</span>          }<a name="line.973"></a>
-<span class="sourceLineNo">974</span>        } finally {<a name="line.974"></a>
-<span class="sourceLineNo">975</span>          if (monitor != null) monitor.close();<a name="line.975"></a>
-<span class="sourceLineNo">976</span>        }<a name="line.976"></a>
-<span class="sourceLineNo">977</span><a name="line.977"></a>
-<span class="sourceLineNo">978</span>        Thread.sleep(interval);<a name="line.978"></a>
-<span class="sourceLineNo">979</span>      } while (interval &gt; 0);<a name="line.979"></a>
-<span class="sourceLineNo">980</span>    } // try-with-resources close<a name="line.980"></a>
-<span class="sourceLineNo">981</span><a name="line.981"></a>
-<span class="sourceLineNo">982</span>    if (choreService != null) {<a name="line.982"></a>
-<span class="sourceLineNo">983</span>      choreService.shutdown();<a name="line.983"></a>
-<span class="sourceLineNo">984</span>    }<a name="line.984"></a>
-<span class="sourceLineNo">985</span>    return monitor.errorCode;<a name="line.985"></a>
-<span class="sourceLineNo">986</span>  }<a name="line.986"></a>
-<span class="sourceLineNo">987</span><a name="line.987"></a>
-<span class="sourceLineNo">988</span>  @Override<a name="line.988"></a>
-<span class="sourceLineNo">989</span>  public Map&lt;String, String&gt; getReadFailures()  {<a name="line.989"></a>
-<span class="sourceLineNo">990</span>    return sink.getReadFailures();<a name="line.990"></a>
-<span class="sourceLineNo">991</span>  }<a name="line.991"></a>
-<span class="sourceLineNo">992</span><a name="line.992"></a>
-<span class="sourceLineNo">993</span>  @Override<a name="line.993"></a>
-<span class="sourceLineNo">994</span>  public Map&lt;String, String&gt; getWriteFailures()  {<a name="line.994"></a>
-<span class="sourceLineNo">995</span>    return sink.getWriteFailures();<a name="line.995"></a>
-<span class="sourceLineNo">996</span>  }<a name="line.996"></a>
-<span class="sourceLineNo">997</span><a name="line.997"></a>
-<span class="sourceLineNo">998</span>  private void printUsageAndExit() {<a name="line.998"></a>
-<span class="sourceLineNo">999</span>    System.err.println(<a name="line.999"></a>
-<span class="sourceLineNo">1000</span>      "Usage: canary [OPTIONS] [&lt;TABLE1&gt; [&lt;TABLE2]...] | [&lt;REGIONSERVER1&gt; [&lt;REGIONSERVER2]..]");<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>    System.err.println("Where [OPTIONS] are:");<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>    System.err.println(" -h,-help        show this help and exit.");<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>    System.err.println(" -regionserver   set 'regionserver mode'; gets row from random region on " +<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>        "server");<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>    System.err.println(" -allRegions     get from ALL regions when 'regionserver mode', not just " +<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>        "random one.");<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>    System.err.println(" -zookeeper      set 'zookeeper mode'; grab zookeeper.znode.parent on " +<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>        "each ensemble member");<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>    System.err.println(" -daemon         continuous check at defined intervals.");<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>    System.err.println(" -interval &lt;N&gt;   interval between checks in seconds");<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>    System.err.println(" -e              consider table/regionserver argument as regular " +<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>        "expression");<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>    System.err.println(" -f &lt;B&gt;          exit on first error; default=true");<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>    System.err.println(" -failureAsError treat read/write failure as error");<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>    System.err.println(" -t &lt;N&gt;          timeout for canary-test run; default=600000ms");<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>    System.err.println(" -writeSniffing  enable write sniffing");<a name="line.1016"></a>
-<span class="sourceLineNo">1017</span>    System.err.println(" -writeTable     the table used for write sniffing; default=hbase:canary");<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>    System.err.println(" -writeTableTimeout &lt;N&gt;  timeout for writeTable; default=600000ms");<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>    System.err.println(" -readTableTimeouts &lt;tableName&gt;=&lt;read timeout&gt;," +<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span>        "&lt;tableName&gt;=&lt;read timeout&gt;,...");<a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>    System.err.println("                comma-separated list of table read timeouts " +<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>        "(no spaces);");<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>    System.err.println("                logs 'ERROR' if takes longer. default=600000ms");<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>    System.err.println(" -permittedZookeeperFailures &lt;N&gt;  Ignore first N failures attempting to ");<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>    System.err.println("                connect to individual zookeeper nodes in ensemble");<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>    System.err.println("");<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>    System.err.println(" -D&lt;configProperty&gt;=&lt;value&gt; to assign or override configuration params");<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>    System.err.println(" -Dhbase.canary.read.raw.enabled=&lt;true/false&gt; Set to enable/disable " +<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>        "raw scan; default=false");<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span>    System.err.println("");<a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>    System.err.println("Canary runs in one of three modes: region (default), regionserver, or " +<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>        "zookeeper.");<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>    System.err.println("To sniff/probe all regions, pass no arguments.");<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>    System.err.println("To sniff/probe all regions of a table, pass tablename.");<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>    System.err.println("To sniff/probe regionservers, pass -regionserver, etc.");<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>    System.err.println("See http://hbase.apache.org/book.html#_canary for Canary documentation.");<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span>    System.exit(USAGE_EXIT_CODE);<a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>  }<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span><a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>  Sink getSink(Configuration configuration, Class clazz) {<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>    // In test context, this.sink might be set. Use it if non-null. For testing.<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span>    return this.sink != null? this.sink:<a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>        (Sink)ReflectionUtils.newInstance(configuration.getClass("hbase.canary.sink.class",<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>            clazz, Sink.class));<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>  }<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span><a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>  /**<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>   * Canary region mode-specific data structure which stores information about each region<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>   * to be scanned<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>   */<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>  public static class RegionTaskResult {<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>    private RegionInfo region;<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>    private TableName tableName;<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>    private ServerName serverName;<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>    private ColumnFamilyDescriptor column;<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>    private AtomicLong readLatency = null;<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>    private AtomicLong writeLatency = null;<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>    private boolean readSuccess = false;<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>    private boolean writeSuccess = false;<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span><a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>    public RegionTaskResult(RegionInfo region, TableName tableName, ServerName serverName,<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>        ColumnFamilyDescriptor column) {<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>      this.region = region;<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>      this.tableName = tableName;<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>      this.serverName = serverName;<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>      this.column = column;<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>    }<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span><a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>    public RegionInfo getRegionInfo() {<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>      return this.region;<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span>    }<a name="line.1071"></a>
-<span class="sourceLineNo">1072</span><a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>    public String getRegionNameAsString() {<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span>      return this.region.getRegionNameAsString();<a name="line.1074"></a>
-<span class="sourceLineNo">1075</span>    }<a name="line.1075"></a>
-<span class="sourceLineNo">1076</span><a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>    public TableName getTableName() {<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span>      return this.tableName;<a name="line.1078"></a>
-<span class="sourceLineNo">1079</span>    }<a name="line.1079"></a>
-<span class="sourceLineNo">1080</span><a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>    public String getTableNameAsString() {<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>      return this.tableName.getNameAsString();<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span>    }<a name="line.1083"></a>
-<span class="sourceLineNo">1084</span><a name="line.1084"></a>
-<span class="sourceLineNo">1085</span>    public ServerName getServerName() {<a name="line.1085"></a>
-<span class="sourceLineNo">1086</span>      return this.serverName;<a name="line.1086"></a>
-<span class="sourceLineNo">1087</span>    }<a name="line.1087"></a>
-<span class="sourceLineNo">1088</span><a name="line.1088"></a>
-<span class="sourceLineNo">1089</span>    public String getServerNameAsString() {<a name="line.1089"></a>
-<span class="sourceLineNo">1090</span>      return this.serverName.getServerName();<a name="line.1090"></a>
-<span class="sourceLineNo">1091</span>    }<a name="line.1091"></a>
-<span class="sourceLineNo">1092</span><a name="line.1092"></a>
-<span class="sourceLineNo">1093</span>    public ColumnFamilyDescriptor getColumnFamily() {<a name="line.1093"></a>
-<span class="sourceLineNo">1094</span>      return this.column;<a name="line.1094"></a>
-<span class="sourceLineNo">1095</span>    }<a name="line.1095"></a>
-<span class="sourceLineNo">1096</span><a name="line.1096"></a>
-<span class="sourceLineNo">1097</span>    public String getColumnFamilyNameAsString() {<a name="line.1097"></a>
-<span class="sourceLineNo">1098</span>      return this.column.getNameAsString();<a name="line.1098"></a>
-<span class="sourceLineNo">1099</span>    }<a name="line.1099"></a>
-<span class="sourceLineNo">1100</span><a name="line.1100"></a>
-<span class="sourceLineNo">1101</span>    public long getReadLatency() {<a name="line.1101"></a>
-<span class="sourceLineNo">1102</span>      if (this.readLatency == null) {<a name="line.1102"></a>
-<span class="sourceLineNo">1103</span>        return -1;<a name="line.1103"></a>
-<span class="sourceLineNo">1104</span>      }<a name="line.1104"></a>
-<span class="sourceLineNo">1105</span>      return this.readLatency.get();<a name="line.1105"></a>
-<span class="sourceLineNo">1106</span>    }<a name="line.1106"></a>
-<span class="sourceLineNo">1107</span><a name="line.1107"></a>
-<span class="sourceLineNo">1108</span>    public void setReadLatency(long readLatency) {<a name="line.1108"></a>
-<span class="sourceLineNo">1109</span>      if (this.readLatency != null) {<a name="line.1109"></a>
-<span class="sourceLineNo">1110</span>        this.readLatency.set(readLatency);<a name="line.1110"></a>
-<span class="sourceLineNo">1111</span>      } else {<a name="line.1111"></a>
-<span class="sourceLineNo">1112</span>        this.readLatency = new AtomicLong(readLatency);<a name="line.1112"></a>
-<span class="sourceLineNo">1113</span>      }<a name="line.1113"></a>
-<span class="sourceLineNo">1114</span>    }<a name="line.1114"></a>
-<span class="sourceLineNo">1115</span><a name="line.1115"></a>
-<span class="sourceLineNo">1116</span>    public long getWriteLatency() {<a name="line.1116"></a>
-<span class="sourceLineNo">1117</span>      if (this.writeLatency == null) {<a name="line.1117"></a>
-<span class="sourceLineNo">1118</span>        return -1;<a name="line.1118"></a>
-<span class="sourceLineNo">1119</span>      }<a name="line.1119"></a>
-<span class="sourceLineNo">1120</span>      return this.writeLatency.get();<a name="line.1120"></a>
-<span class="sourceLineNo">1121</span>    }<a name="line.1121"></a>
-<span class="sourceLineNo">1122</span><a name="line.1122"></a>
-<span class="sourceLineNo">1123</span>    public void setWriteLatency(long writeLatency) {<a name="line.1123"></a>
-<span class="sourceLineNo">1124</span>      if (this.writeLatency != null) {<a name="line.1124"></a>
-<span class="sourceLineNo">1125</span>        this.writeLatency.set(writeLatency);<a name="line.1125"></a>
-<span class="sourceLineNo">1126</span>      } else {<a name="line.1126"></a>
-<span class="sourceLineNo">1127</span>        this.writeLatency = new AtomicLong(writeLatency);<a name="line.1127"></a>
-<span class="sourceLineNo">1128</span>      }<a name="line.1128"></a>
-<span class="sourceLineNo">1129</span>    }<a name="line.1129"></a>
-<span class="sourceLineNo">1130</span><a name="line.1130"></a>
-<span class="sourceLineNo">1131</span>    public boolean isReadSuccess() {<a name="line.1131"></a>
-<span class="sourceLineNo">1132</span>      return this.readSuccess;<a name="line.1132"></a>
-<span class="sourceLineNo">1133</span>    }<a name="line.1133"></a>
-<span class="sourceLineNo">1134</span><a name="line.1134"></a>
-<span class="sourceLineNo">1135</span>    public void setReadSuccess() {<a name="line.1135"></a>
-<span class="sourceLineNo">1136</span>      this.readSuccess = true;<a name="line.1136"></a>
-<span class="sourceLineNo">1137</span>    }<a name="line.1137"></a>
-<span class="sourceLineNo">1138</span><a name="line.1138"></a>
-<span class="sourceLineNo">1139</span>    public boolean isWriteSuccess() {<a name="line.1139"></a>
-<span class="sourceLineNo">1140</span>      return this.writeSuccess;<a name="line.1140"></a>
-<span class="sourceLineNo">1141</span>    }<a name="line.1141"></a>
-<span class="sourceLineNo">1142</span><a name="line.1142"></a>
-<span class="sourceLineNo">1143</span>    public void setWriteSuccess() {<a name="line.1143"></a>
-<span class="sourceLineNo">1144</span>      this.writeSuccess = true;<a name="line.1144"></a>
-<span class="sourceLineNo">1145</span>    }<a name="line.1145"></a>
-<span class="sourceLineNo">1146</span>  }<a name="line.1146"></a>
-<span class="sourceLineNo">1147</span><a name="line.1147"></a>
-<span class="sourceLineNo">1148</span>  /**<a name="line.1148"></a>
-<span class="sourceLineNo">1149</span>   * A Factory method for {@link Monitor}.<a name="line.1149"></a>
-<span class="sourceLineNo">1150</span>   * Makes a RegionServerMonitor, or a ZooKeeperMonitor, or a RegionMonitor.<a name="line.1150"></a>
-<span class="sourceLineNo">1151</span>   * @return a Monitor instance<a name="line.1151"></a>
-<span class="sourceLineNo">1152</span>   */<a name="line.1152"></a>
-<span class="sourceLineNo">1153</span>  private Monitor newMonitor(final Connection connection, String[] monitorTargets) {<a name="line.1153"></a>
-<span class="sourceLineNo">1154</span>    Monitor monitor;<a name="line.1154"></a>
-<span class="sourceLineNo">1155</span>    boolean useRegExp = conf.getBoolean(HBASE_CANARY_USE_REGEX, false);<a name="line.1155"></a>
-<span class="sourceLineNo">1156</span>    boolean regionServerAllRegions<a name="line.1156"></a>
-<span class="sourceLineNo">1157</span>            = conf.getBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, false);<a name="line.1157"></a>
-<span class="sourceLineNo">1158</span>    boolean failOnError<a name="line.1158"></a>
-<span class="sourceLineNo">1159</span>            = conf.getBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.1159"></a>
-<span class="sourceLineNo">1160</span>    int permittedFailures<a name="line.1160"></a>
-<span class="sourceLineNo">1161</span>            = conf.getInt(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, 0);<a name="line.1161"></a>
-<span class="sourceLineNo">1162</span>    boolean writeSniffing<a name="line.1162"></a>
-<span class="sourceLineNo">1163</span>            = conf.getBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, false);<a name="line.1163"></a>
-<span class="sourceLineNo">1164</span>    String writeTableName = conf.get(HBASE_CANARY_REGION_WRITE_TABLE_NAME,<a name="line.1164"></a>
-<span class="sourceLineNo">1165</span>            DEFAULT_WRITE_TABLE_NAME.getNameAsString());<a name="line.1165"></a>
-<span class="sourceLineNo">1166</span>    long configuredWriteTableTimeout<a name="line.1166"></a>
-<span class="sourceLineNo">1167</span>            = conf.getLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, DEFAULT_TIMEOUT);<a name="line.1167"></a>
-<span class="sourceLineNo">1168</span><a name="line.1168"></a>
-<span class="sourceLineNo">1169</span>    if (this.regionServerMode) {<a name="line.1169"></a>
-<span class="sourceLineNo">1170</span>      monitor =<a name="line.1170"></a>
-<span class="sourceLineNo">1171</span>          new RegionServerMonitor(connection, monitorTargets, useRegExp,<a name="line.1171"></a>
-<span class="sourceLineNo">1172</span>              getSink(connection.getConfiguration(), RegionServerStdOutSink.class),<a name="line.1172"></a>
-<span class="sourceLineNo">1173</span>              this.executor, regionServerAllRegions,<a name="line.1173"></a>
-<span class="sourceLineNo">1174</span>              failOnError, permittedFailures);<a name="line.1174"></a>
-<span class="sourceLineNo">1175</span><a name="line.1175"></a>
-<span class="sourceLineNo">1176</span>    } else if (this.zookeeperMode) {<a name="line.1176"></a>
-<span class="sourceLineNo">1177</span>      monitor =<a name="line.1177"></a>
-<span class="sourceLineNo">1178</span>          new ZookeeperMonitor(connection, monitorTargets, useRegExp,<a name="line.1178"></a>
-<span class="sourceLineNo">1179</span>              getSink(connection.getConfiguration(), ZookeeperStdOutSink.class),<a name="line.1179"></a>
-<span class="sourceLineNo">1180</span>              this.executor, failOnError, permittedFailures);<a name="line.1180"></a>
-<span class="sourceLineNo">1181</span>    } else {<a name="line.1181"></a>
-<span class="sourceLineNo">1182</span>      monitor =<a name="line.1182"></a>
-<span class="sourceLineNo">1183</span>          new RegionMonitor(connection, monitorTargets, useRegExp,<a name="line.1183"></a>
-<span class="sourceLineNo">1184</span>              getSink(connection.getConfiguration(), RegionStdOutSink.class),<a name="line.1184"></a>
-<span class="sourceLineNo">1185</span>              this.executor, writeSniffing,<a name="line.1185"></a>
-<span class="sourceLineNo">1186</span>              TableName.valueOf(writeTableName), failOnError, configuredReadTableTimeouts,<a name="line.1186"></a>
-<span class="sourceLineNo">1187</span>              configuredWriteTableTimeout, permittedFailures);<a name="line.1187"></a>
-<span class="sourceLineNo">1188</span>    }<a name="line.1188"></a>
-<span class="sourceLineNo">1189</span>    return monitor;<a name="line.1189"></a>
-<span class="sourceLineNo">1190</span>  }<a name="line.1190"></a>
-<span class="sourceLineNo">1191</span><a name="line.1191"></a>
-<span class="sourceLineNo">1192</span>  private void populateReadTableTimeoutsMap(String configuredReadTableTimeoutsStr) {<a name="line.1192"></a>
-<span class="sourceLineNo">1193</span>    String[] tableTimeouts = configuredReadTableTimeoutsStr.split(",");<a name="line.1193"></a>
-<span class="sourceLineNo">1194</span>    for (String tT : tableTimeouts) {<a name="line.1194"></a>
-<span class="sourceLineNo">1195</span>      String[] nameTimeout = tT.split("=");<a name="line.1195"></a>
-<span class="sourceLineNo">1196</span>      if (nameTimeout.length &lt; 2) {<a name="line.1196"></a>
-<span class="sourceLineNo">1197</span>        throw new IllegalArgumentException("Each -readTableTimeouts argument must be of the form " +<a name="line.1197"></a>
-<span class="sourceLineNo">1198</span>            "&lt;tableName&gt;=&lt;read timeout&gt; (without spaces).");<a name="line.1198"></a>
-<span class="sourceLineNo">1199</span>      }<a name="line.1199"></a>
-<span class="sourceLineNo">1200</span>      long timeoutVal;<a name="line.1200"></a>
-<span class="sourceLineNo">1201</span>      try {<a name="line.1201"></a>
-<span class="sourceLineNo">1202</span>        timeoutVal = Long.parseLong(nameTimeout[1]);<a name="line.1202"></a>
-<span class="sourceLineNo">1203</span>      } catch (NumberFormatException e) {<a name="line.1203"></a>
-<span class="sourceLineNo">1204</span>        throw new IllegalArgumentException("-readTableTimeouts read timeout for each table" +<a name="line.1204"></a>
-<span class="sourceLineNo">1205</span>            " must be a numeric value argument.");<a name="line.1205"></a>
-<span class="sourceLineNo">1206</span>      }<a name="line.1206"></a>
-<span class="sourceLineNo">1207</span>      configuredReadTableTimeouts.put(nameTimeout[0], timeoutVal);<a name="line.1207"></a>
-<span class="sourceLineNo">1208</span>    }<a name="line.1208"></a>
-<span class="sourceLineNo">1209</span>  }<a name="line.1209"></a>
-<span class="sourceLineNo">1210</span>  /**<a name="line.1210"></a>
-<span class="sourceLineNo">1211</span>   * A Monitor super-class can be extended by users<a name="line.1211"></a>
-<span class="sourceLineNo">1212</span>   */<a name="line.1212"></a>
-<span class="sourceLineNo">1213</span>  public static abstract class Monitor implements Runnable, Closeable {<a name="line.1213"></a>
-<span class="sourceLineNo">1214</span>    protected Connection connection;<a name="line.1214"></a>
-<span class="sourceLineNo">1215</span>    protected Admin admin;<a name="line.1215"></a>
-<span class="sourceLineNo">1216</span>    /**<a name="line.1216"></a>
-<span class="sourceLineNo">1217</span>     * 'Target' dependent on 'mode'. Could be Tables or RegionServers or ZNodes.<a name="line.1217"></a>
-<span class="sourceLineNo">1218</span>     * Passed on the command-line as arguments.<a name="line.1218"></a>
-<span class="sourceLineNo">1219</span>     */<a name="line.1219"></a>
-<span class="sourceLineNo">1220</span>    protected String[] targets;<a name="line.1220"></a>
-<span class="sourceLineNo">1221</span>    protected boolean useRegExp;<a name="line.1221"></a>
-<span class="sourceLineNo">1222</span>    protected boolean treatFailureAsError;<a name="line.1222"></a>
-<span class="sourceLineNo">1223</span>    protected boolean initialized = false;<a name="line.1223"></a>
-<span class="sourceLineNo">1224</span><a name="line.1224"></a>
-<span class="sourceLineNo">1225</span>    protected boolean done = false;<a name="line.1225"></a>
-<span class="sourceLineNo">1226</span>    protected int errorCode = 0;<a name="line.1226"></a>
-<span class="sourceLineNo">1227</span>    protected long allowedFailures = 0;<a name="line.1227"></a>
-<span class="sourceLineNo">1228</span>    protected Sink sink;<a name="line.1228"></a>
-<span class="sourceLineNo">1229</span>    protected ExecutorService executor;<a name="line.1229"></a>
-<span class="sourceLineNo">1230</span><a name="line.1230"></a>
-<span class="sourceLineNo">1231</span>    public boolean isDone() {<a name="line.1231"></a>
-<span class="sourceLineNo">1232</span>      return done;<a name="line.1232"></a>
-<span class="sourceLineNo">1233</span>    }<a name="line.1233"></a>
-<span class="sourceLineNo">1234</span><a name="line.1234"></a>
-<span class="sourceLineNo">1235</span>    public boolean hasError() {<a name="line.1235"></a>
-<span class="sourceLineNo">1236</span>      return errorCode != 0;<a name="line.1236"></a>
-<span class="sourceLineNo">1237</span>    }<a name="line.1237"></a>
-<span class="sourceLineNo">1238</span><a name="line.1238"></a>
-<span class="sourceLineNo">1239</span>    public boolean finalCheckForErrors() {<a name="line.1239"></a>
-<span class="sourceLineNo">1240</span>      if (errorCode != 0) {<a name="line.1240"></a>
-<span class="sourceLineNo">1241</span>        return true;<a name="line.1241"></a>
-<span class="sourceLineNo">1242</span>      }<a name="line.1242"></a>
-<span class="sourceLineNo">1243</span>      if (treatFailureAsError &amp;&amp;<a name="line.1243"></a>
-<span class="sourceLineNo">1244</span>          (sink.getReadFailureCount() &gt; allowedFailures || sink.getWriteFailureCount() &gt; allowedFailures)) {<a name="line.1244"></a>
-<span class="sourceLineNo">1245</span>        LOG.error("Too many failures detected, treating failure as error, failing the Canary.");<a name="line.1245"></a>
-<span class="sourceLineNo">1246</span>        errorCode = FAILURE_EXIT_CODE;<a name="line.1246"></a>
-<span class="sourceLineNo">1247</span>        return true;<a name="line.1247"></a>
-<span class="sourceLineNo">1248</span>      }<a name="line.1248"></a>
-<span class="sourceLineNo">1249</span>      return false;<a name="line.1249"></a>
-<span class="sourceLineNo">1250</span>    }<a name="line.1250"></a>
-<span class="sourceLineNo">1251</span><a name="line.1251"></a>
-<span class="sourceLineNo">1252</span>    @Override<a name="line.1252"></a>
-<span class="sourceLineNo">1253</span>    public void close() throws IOException {<a name="line.1253"></a>
-<span class="sourceLineNo">1254</span>      if (this.admin != null) this.admin.close();<a name="line.1254"></a>
-<span class="sourceLineNo">1255</span>    }<a name="line.1255"></a>
-<span class="sourceLineNo">1256</span><a name="line.1256"></a>
-<span class="sourceLineNo">1257</span>    protected Monitor(Connection connection, String[] monitorTargets, boolean useRegExp, Sink sink,<a name="line.1257"></a>
-<span class="sourceLineNo">1258</span>        ExecutorService executor, boolean treatFailureAsError, long allowedFailures) {<a name="line.1258"></a>
-<span class="sourceLineNo">1259</span>      if (null == connection) throw new IllegalArgumentException("connection shall not be null");<a name="line.1259"></a>
-<span class="sourceLineNo">1260</span><a name="line.1260"></a>
-<span class="sourceLineNo">1261</span>      this.connection = connection;<a name="line.1261"></a>
-<span class="sourceLineNo">1262</span>      this.targets = monitorTargets;<a name="line.1262"></a>
-<span class="sourceLineNo">1263</span>      this.useRegExp = useRegExp;<a name="line.1263"></a>
-<span class="sourceLineNo">1264</span>      this.treatFailureAsError = treatFailureAsError;<a name="line.1264"></a>
-<span class="sourceLineNo">1265</span>      this.sink = sink;<a name="line.1265"></a>
-<span class="sourceLineNo">1266</span>      this.executor = executor;<a name="line.1266"></a>
-<span class="sourceLineNo">1267</span>      this.allowedFailures = allowedFailures;<a name="line.1267"></a>
-<span class="sourceLineNo">1268</span>    }<a name="line.1268"></a>
-<span class="sourceLineNo">1269</span><a name="line.1269"></a>
-<span class="sourceLineNo">1270</span>    @Override<a name="line.1270"></a>
-<span class="sourceLineNo">1271</span>    public abstract void run();<a name="line.1271"></a>
-<span class="sourceLineNo">1272</span><a name="line.1272"></a>
-<span class="sourceLineNo">1273</span>    protected boolean initAdmin() {<a name="line.1273"></a>
-<span class="sourceLineNo">1274</span>      if (null == this.admin) {<a name="line.1274"></a>
-<span class="sourceLineNo">1275</span>        try {<a name="line.1275"></a>
-<span class="sourceLineNo">1276</span>          this.admin = this.connection.getAdmin();<a name="line.1276"></a>
-<span class="sourceLineNo">1277</span>        } catch (Exception e) {<a name="line.1277"></a>
-<span class="sourceLineNo">1278</span>          LOG.error("Initial HBaseAdmin failed...", e);<a name="line.1278"></a>
-<span class="sourceLineNo">1279</span>          this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1279"></a>
-<span class="sourceLineNo">1280</span>        }<a name="line.1280"></a>
-<span class="sourceLineNo">1281</span>      } else if (admin.isAborted()) {<a name="line.1281"></a>
-<span class="sourceLineNo">1282</span>        LOG.error("HBaseAdmin aborted");<a name="line.1282"></a>
-<span class="sourceLineNo">1283</span>        this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1283"></a>
-<span class="sourceLineNo">1284</span>      }<a name="line.1284"></a>
-<span class="sourceLineNo">1285</span>      return !this.hasError();<a name="line.1285"></a>
-<span class="sourceLineNo">1286</span>    }<a name="line.1286"></a>
-<span class="sourceLineNo">1287</span>  }<a name="line.1287"></a>
-<span class="sourceLineNo">1288</span><a name="line.1288"></a>
-<span class="sourceLineNo">1289</span>  /**<a name="line.1289"></a>
-<span class="sourceLineNo">1290</span>   * A monitor for region mode.<a name="line.1290"></a>
-<span class="sourceLineNo">1291</span>   */<a name="line.1291"></a>
-<span class="sourceLineNo">1292</span>  private static class RegionMonitor extends Monitor {<a name="line.1292"></a>
-<span class="sourceLineNo">1293</span>    // 10 minutes<a name="line.1293"></a>
-<span class="sourceLineNo">1294</span>    private static final int DEFAULT_WRITE_TABLE_CHECK_PERIOD = 10 * 60 * 1000;<a name="line.1294"></a>
-<span class="sourceLineNo">1295</span>    // 1 days<a name="line.1295"></a>
-<span class="sourceLineNo">1296</span>    private static final int DEFAULT_WRITE_DATA_TTL = 24 * 60 * 60;<a name="line.1296"></a>
-<span class="sourceLineNo">1297</span><a name="line.1297"></a>
-<span class="sourceLineNo">1298</span>    private long lastCheckTime = -1;<a name="line.1298"></a>
-<span class="sourceLineNo">1299</span>    private boolean writeSniffing;<a name="line.1299"></a>
-<span class="sourceLineNo">1300</span>    private TableName writeTableName;<a name="line.1300"></a>
-<span class="sourceLineNo">1301</span>    private int writeDataTTL;<a name="line.1301"></a>
-<span class="sourceLineNo">1302</span>    private float regionsLowerLimit;<a name="line.1302"></a>
-<span class="sourceLineNo">1303</span>    private float regionsUpperLimit;<a name="line.1303"></a>
-<span class="sourceLineNo">1304</span>    private int checkPeriod;<a name="line.1304"></a>
-<span class="sourceLineNo">1305</span>    private boolean rawScanEnabled;<a name="line.1305"></a>
-<span class="sourceLineNo">1306</span><a name="line.1306"></a>
-<span class="sourceLineNo">1307</span>    /**<a name="line.1307"></a>
-<span class="sourceLineNo">1308</span>     * This is a timeout per table. If read of each region in the table aggregated takes longer<a name="line.1308"></a>
-<span class="sourceLineNo">1309</span>     * than what is configured here, we log an ERROR rather than just an INFO.<a name="line.1309"></a>
-<span class="sourceLineNo">1310</span>     */<a name="line.1310"></a>
-<span class="sourceLineNo">1311</span>    private HashMap&lt;String, Long&gt; configuredReadTableTimeouts;<a name="line.1311"></a>
-<span class="sourceLineNo">1312</span><a name="line.1312"></a>
-<span class="sourceLineNo">1313</span>    private long configuredWriteTableTimeout;<a name="line.1313"></a>
-<span class="sourceLineNo">1314</span><a name="line.1314"></a>
-<span class="sourceLineNo">1315</span>    public RegionMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1315"></a>
-<span class="sourceLineNo">1316</span>        Sink sink, ExecutorService executor, boolean writeSniffing, TableName writeTableName,<a name="line.1316"></a>
-<span class="sourceLineNo">1317</span>        boolean treatFailureAsError, HashMap&lt;String, Long&gt; configuredReadTableTimeouts,<a name="line.1317"></a>
-<span class="sourceLineNo">1318</span>        long configuredWriteTableTimeout,<a name="line.1318"></a>
-<span class="sourceLineNo">1319</span>        long allowedFailures) {<a name="line.1319"></a>
-<span class="sourceLineNo">1320</span>      super(connection, monitorTargets, useRegExp, sink, executor, treatFailureAsError,<a name="line.1320"></a>
-<span class="sourceLineNo">1321</span>          allowedFailures);<a name="line.1321"></a>
-<span class="sourceLineNo">1322</span>      Configuration conf = connection.getConfiguration();<a name="line.1322"></a>
-<span class="sourceLineNo">1323</span>      this.writeSniffing = writeSniffing;<a name="line.1323"></a>
-<span class="sourceLineNo">1324</span>      this.writeTableName = writeTableName;<a name="line.1324"></a>
-<span class="sourceLineNo">1325</span>      this.writeDataTTL =<a name="line.1325"></a>
-<span class="sourceLineNo">1326</span>          conf.getInt(HConstants.HBASE_CANARY_WRITE_DATA_TTL_KEY, DEFAULT_WRITE_DATA_TTL);<a name="line.1326"></a>
-<span class="sourceLineNo">1327</span>      this.regionsLowerLimit =<a name="line.1327"></a>
-<span class="sourceLineNo">1328</span>          conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY, 1.0f);<a name="line.1328"></a>
-<span class="sourceLineNo">1329</span>      this.regionsUpperLimit =<a name="line.1329"></a>
-<span class="sourceLineNo">1330</span>          conf.getFloat(HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_UPPERLIMIT_KEY, 1.5f);<a name="line.1330"></a>
-<span class="sourceLineNo">1331</span>      this.checkPeriod =<a name="line.1331"></a>
-<span class="sourceLineNo">1332</span>          conf.getInt(HConstants.HBASE_CANARY_WRITE_TABLE_CHECK_PERIOD_KEY,<a name="line.1332"></a>
-<span class="sourceLineNo">1333</span>            DEFAULT_WRITE_TABLE_CHECK_PERIOD);<a name="line.1333"></a>
-<span class="sourceLineNo">1334</span>      this.rawScanEnabled = conf.getBoolean(HConstants.HBASE_CANARY_READ_RAW_SCAN_KEY, false);<a name="line.1334"></a>
-<span class="sourceLineNo">1335</span>      this.configuredReadTableTimeouts = new HashMap&lt;&gt;(configuredReadTableTimeouts);<a name="line.1335"></a>
-<span class="sourceLineNo">1336</span>      this.configuredWriteTableTimeout = configuredWriteTableTimeout;<a name="line.1336"></a>
-<span class="sourceLineNo">1337</span>    }<a name="line.1337"></a>
-<span class="sourceLineNo">1338</span><a name="line.1338"></a>
-<span class="sourceLineNo">1339</span>    private RegionStdOutSink getSink() {<a name="line.1339"></a>
-<span class="sourceLineNo">1340</span>      if (!(sink instanceof RegionStdOutSink)) {<a name="line.1340"></a>
-<span class="sourceLineNo">1341</span>        throw new RuntimeException("Can only write to Region sink");<a name="line.1341"></a>
-<span class="sourceLineNo">1342</span>      }<a name="line.1342"></a>
-<span class="sourceLineNo">1343</span>      return ((RegionStdOutSink) sink);<a name="line.1343"></a>
-<span class="sourceLineNo">1344</span>    }<a name="line.1344"></a>
-<span class="sourceLineNo">1345</span><a name="line.1345"></a>
-<span class="sourceLineNo">1346</span>    @Override<a name="line.1346"></a>
-<span class="sourceLineNo">1347</span>    public void run() {<a name="line.1347"></a>
-<span class="sourceLineNo">1348</span>      if (this.initAdmin()) {<a name="line.1348"></a>
-<span class="sourceLineNo">1349</span>        try {<a name="line.1349"></a>
-<span class="sourceLineNo">1350</span>          List&lt;Future&lt;Void&gt;&gt; taskFutures = new LinkedList&lt;&gt;();<a name="line.1350"></a>
-<span class="sourceLineNo">1351</span>          RegionStdOutSink regionSink = this.getSink();<a name="line.1351"></a>
-<span class="sourceLineNo">1352</span>          if (this.targets != null &amp;&amp; this.targets.length &gt; 0) {<a name="line.1352"></a>
-<span class="sourceLineNo">1353</span>            String[] tables = generateMonitorTables(this.targets);<a name="line.1353"></a>
-<span class="sourceLineNo">1354</span>            // Check to see that each table name passed in the -readTableTimeouts argument is also<a name="line.1354"></a>
-<span class="sourceLineNo">1355</span>            // passed as a monitor target.<a name="line.1355"></a>
-<span class="sourceLineNo">1356</span>            if (!new HashSet&lt;&gt;(Arrays.asList(tables)).<a name="line.1356"></a>
-<span class="sourceLineNo">1357</span>                containsAll(this.configuredReadTableTimeouts.keySet())) {<a name="line.1357"></a>
-<span class="sourceLineNo">1358</span>              LOG.error("-readTableTimeouts can only specify read timeouts for monitor targets " +<a name="line.1358"></a>
-<span class="sourceLineNo">1359</span>                  "passed via command line.");<a name="line.1359"></a>
-<span class="sourceLineNo">1360</span>              this.errorCode = USAGE_EXIT_CODE;<a name="line.1360"></a>
-<span class="sourceLineNo">1361</span>              return;<a name="line.1361"></a>
-<span class="sourceLineNo">1362</span>            }<a name="line.1362"></a>
-<span class="sourceLineNo">1363</span>            this.initialized = true;<a name="line.1363"></a>
-<span class="sourceLineNo">1364</span>            for (String table : tables) {<a name="line.1364"></a>
-<span class="sourceLineNo">1365</span>              LongAdder readLatency = regionSink.initializeAndGetReadLatencyForTable(table);<a name="line.1365"></a>
-<span class="sourceLineNo">1366</span>              taskFutures.addAll(CanaryTool.sniff(admin, regionSink, table, executor, TaskType.READ,<a name="line.1366"></a>
-<span class="sourceLineNo">1367</span>                this.rawScanEnabled, readLatency));<a name="line.1367"></a>
-<span class="sourceLineNo">1368</span>            }<a name="line.1368"></a>
-<span class="sourceLineNo">1369</span>          } else {<a name="line.1369"></a>
-<span class="sourceLineNo">1370</span>            taskFutures.addAll(sniff(TaskType.READ, regionSink));<a name="line.1370"></a>
-<span class="sourceLineNo">1371</span>          }<a name="line.1371"></a>
-<span class="sourceLineNo">1372</span><a name="line.1372"></a>
-<span class="sourceLineNo">1373</span>          if (writeSniffing) {<a name="line.1373"></a>
-<span class="sourceLineNo">1374</span>            if (EnvironmentEdgeManager.currentTime() - lastCheckTime &gt; checkPeriod) {<a name="line.1374"></a>
-<span class="sourceLineNo">1375</span>              try {<a name="line.1375"></a>
-<span class="sourceLineNo">1376</span>                checkWriteTableDistribution();<a name="line.1376"></a>
-<span class="sourceLineNo">1377</span>              } catch (IOException e) {<a name="line.1377"></a>
-<span class="sourceLineNo">1378</span>                LOG.error("Check canary table distribution failed!", e);<a name="line.1378"></a>
-<span class="sourceLineNo">1379</span>              }<a name="line.1379"></a>
-<span class="sourceLineNo">1380</span>              lastCheckTime = EnvironmentEdgeManager.currentTime();<a name="line.1380"></a>
-<span class="sourceLineNo">1381</span>            }<a name="line.1381"></a>
-<span class="sourceLineNo">1382</span>            // sniff canary table with write operation<a name="line.1382"></a>
-<span class="sourceLineNo">1383</span>            regionSink.initializeWriteLatency();<a name="line.1383"></a>
-<span class="sourceLineNo">1384</span>            LongAdder writeTableLatency = regionSink.getWriteLatency();<a name="line.1384"></a>
-<span class="sourceLineNo">1385</span>            taskFutures.addAll(CanaryTool.sniff(admin, regionSink, admin.getDescriptor(writeTableName),<a name="line.1385"></a>
-<span class="sourceLineNo">1386</span>              executor, TaskType.WRITE, this.rawScanEnabled, writeTableLatency));<a name="line.1386"></a>
-<span class="sourceLineNo">1387</span>          }<a name="line.1387"></a>
-<span class="sourceLineNo">1388</span><a name="line.1388"></a>
-<span class="sourceLineNo">1389</span>          for (Future&lt;Void&gt; future : taskFutures) {<a name="line.1389"></a>
-<span class="sourceLineNo">1390</span>            try {<a name="line.1390"></a>
-<span class="sourceLineNo">1391</span>              future.get();<a name="line.1391"></a>
-<span class="sourceLineNo">1392</span>            } catch (ExecutionException e) {<a name="line.1392"></a>
-<span class="sourceLineNo">1393</span>              LOG.error("Sniff region failed!", e);<a name="line.1393"></a>
-<span class="sourceLineNo">1394</span>            }<a name="line.1394"></a>
-<span class="sourceLineNo">1395</span>          }<a name="line.1395"></a>
-<span class="sourceLineNo">1396</span>          Map&lt;String, LongAdder&gt; actualReadTableLatency = regionSink.getReadLatencyMap();<a name="line.1396"></a>
-<span class="sourceLineNo">1397</span>          for (Map.Entry&lt;String, Long&gt; entry : configuredReadTableTimeouts.entrySet()) {<a name="line.1397"></a>
-<span class="sourceLineNo">1398</span>            String tableName = entry.getKey();<a name="line.1398"></a>
-<span class="sourceLineNo">1399</span>            if (actualReadTableLatency.containsKey(tableName)) {<a name="line.1399"></a>
-<span class="sourceLineNo">1400</span>              Long actual = actualReadTableLatency.get(tableName).longValue();<a name="line.1400"></a>
-<span class="sourceLineNo">1401</span>              Long configured = entry.getValue();<a name="line.1401"></a>
-<span class="sourceLineNo">1402</span>              if (actual &gt; configured) {<a name="line.1402"></a>
-<span class="sourceLineNo">1403</span>                LOG.error("Read operation for {} took {}ms exceeded the configured read timeout." +<a name="line.1403"></a>
-<span class="sourceLineNo">1404</span>                    "(Configured read timeout {}ms.", tableName, actual, configured);<a name="line.1404"></a>
-<span class="sourceLineNo">1405</span>              } else {<a name="line.1405"></a>
-<span class="sourceLineNo">1406</span>                LOG.info("Read operation for {} took {}ms (Configured read timeout {}ms.",<a name="line.1406"></a>
-<span class="sourceLineNo">1407</span>                    tableName, actual, configured);<a name="line.1407"></a>
-<span class="sourceLineNo">1408</span>              }<a name="line.1408"></a>
-<span class="sourceLineNo">1409</span>            } else {<a name="line.1409"></a>
-<span class="sourceLineNo">1410</span>              LOG.error("Read operation for {} failed!", tableName);<a name="line.1410"></a>
-<span class="sourceLineNo">1411</span>            }<a name="line.1411"></a>
-<span class="sourceLineNo">1412</span>          }<a name="line.1412"></a>
-<span class="sourceLineNo">1413</span>          if (this.writeSniffing) {<a name="line.1413"></a>
-<span class="sourceLineNo">1414</span>            String writeTableStringName = this.writeTableName.getNameAsString();<a name="line.1414"></a>
-<span class="sourceLineNo">1415</span>            long actualWriteLatency = regionSink.getWriteLatency().longValue();<a name="line.1415"></a>
-<span class="sourceLineNo">1416</span>            LOG.info("Write operation for {} took {}ms. Configured write timeout {}ms.",<a name="line.1416"></a>
-<span class="sourceLineNo">1417</span>                writeTableStringName, actualWriteLatency, this.configuredWriteTableTimeout);<a name="line.1417"></a>
-<span class="sourceLineNo">1418</span>            // Check that the writeTable write operation latency does not exceed the configured timeout.<a name="line.1418"></a>
-<span class="sourceLineNo">1419</span>            if (actualWriteLatency &gt; this.configuredWriteTableTimeout) {<a name="line.1419"></a>
-<span class="sourceLineNo">1420</span>              LOG.error("Write operation for {} exceeded the configured write timeout.",<a name="line.1420"></a>
-<span class="sourceLineNo">1421</span>                  writeTableStringName);<a name="line.1421"></a>
-<span class="sourceLineNo">1422</span>            }<a name="line.1422"></a>
-<span class="sourceLineNo">1423</span>          }<a name="line.1423"></a>
-<span class="sourceLineNo">1424</span>        } catch (Exception e) {<a name="line.1424"></a>
-<span class="sourceLineNo">1425</span>          LOG.error("Run regionMonitor failed", e);<a name="line.1425"></a>
-<span class="sourceLineNo">1426</span>          this.errorCode = ERROR_EXIT_CODE;<a name="line.1426"></a>
-<span class="sourceLineNo">1427</span>        } finally {<a name="line.1427"></a>
-<span class="sourceLineNo">1428</span>          this.done = true;<a name="line.1428"></a>
-<span class="sourceLineNo">1429</span>        }<a name="line.1429"></a>
-<span class="sourceLineNo">1430</span>      }<a name="line.1430"></a>
-<span class="sourceLineNo">1431</span>      this.done = true;<a name="line.1431"></a>
-<span class="sourceLineNo">1432</span>    }<a name="line.1432"></a>
-<span class="sourceLineNo">1433</span><a name="line.1433"></a>
-<span class="sourceLineNo">1434</span>    /**<a name="line.1434"></a>
-<span class="sourceLineNo">1435</span>     * @return List of tables to use in test.<a name="line.1435"></a>
-<span class="sourceLineNo">1436</span>     */<a name="line.1436"></a>
-<span class="sourceLineNo">1437</span>    private String[] generateMonitorTables(String[] monitorTargets) throws IOException {<a name="line.1437"></a>
-<span class="sourceLineNo">1438</span>      String[] returnTables = null;<a name="line.1438"></a>
-<span class="sourceLineNo">1439</span><a name="line.1439"></a>
-<span class="sourceLineNo">1440</span>      if (this.useRegExp) {<a name="line.1440"></a>
-<span class="sourceLineNo">1441</span>        Pattern pattern = null;<a name="line.1441"></a>
-<span class="sourceLineNo">1442</span>        List&lt;TableDescriptor&gt; tds = null;<a name="line.1442"></a>
-<span class="sourceLineNo">1443</span>        Set&lt;String&gt; tmpTables = new TreeSet&lt;&gt;();<a name="line.1443"></a>
-<span class="sourceLineNo">1444</span>        try {<a name="line.1444"></a>
-<span class="sourceLineNo">1445</span>          LOG.debug(String.format("reading list of tables"));<a name="line.1445"></a>
-<span class="sourceLineNo">1446</span>          tds = this.admin.listTableDescriptors(pattern);<a name="line.1446"></a>
-<span class="sourceLineNo">1447</span>          if (tds == null) {<a name="line.1447"></a>
-<span class="sourceLineNo">1448</span>            tds = Collections.emptyList();<a name="line.1448"></a>
-<span class="sourceLineNo">1449</span>          }<a name="line.1449"></a>
-<span class="sourceLineNo">1450</span>          for (String monitorTarget : monitorTargets) {<a name="line.1450"></a>
-<span class="sourceLineNo">1451</span>            pattern = Pattern.compile(monitorTarget);<a name="line.1451"></a>
-<span class="sourceLineNo">1452</span>            for (TableDescriptor td : tds) {<a name="line.1452"></a>
-<span class="sourceLineNo">1453</span>              if (pattern.matcher(td.getTableName().getNameAsString()).matches()) {<a name="line.1453"></a>
-<span class="sourceLineNo">1454</span>                tmpTables.add(td.getTableName().getNameAsString());<a name="line.1454"></a>
-<span class="sourceLineNo">1455</span>              }<a name="line.1455"></a>
-<span class="sourceLineNo">1456</span>            }<a name="line.1456"></a>
-<span class="sourceLineNo">1457</span>          }<a name="line.1457"></a>
-<span class="sourceLineNo">1458</span>        } catch (IOException e) {<a name="line.1458"></a>
-<span class="sourceLineNo">1459</span>          LOG.error("Communicate with admin failed", e);<a name="line.1459"></a>
-<span class="sourceLineNo">1460</span>          throw e;<a name="line.1460"></a>
-<span class="sourceLineNo">1461</span>        }<a name="line.1461"></a>
-<span class="sourceLineNo">1462</span><a name="line.1462"></a>
-<span class="sourceLineNo">1463</span>        if (tmpTables.size() &gt; 0) {<a name="line.1463"></a>
-<span class="sourceLineNo">1464</span>          returnTables = tmpTables.toArray(new String[tmpTables.size()]);<a name="line.1464"></a>
-<span class="sourceLineNo">1465</span>        } else {<a name="line.1465"></a>
-<span class="sourceLineNo">1466</span>          String msg = "No HTable found, tablePattern:" + Arrays.toString(monitorTargets);<a name="line.1466"></a>
-<span class="sourceLineNo">1467</span>          LOG.error(msg);<a name="line.1467"></a>
-<span class="sourceLineNo">1468</span>          this.errorCode = INIT_ERROR_EXIT_CODE;<a name="line.1468"></a>
-<span class="sourceLineNo">1469</span>          throw new TableNotFoundException(msg);<a name="line.1469"></a>
-<span class="sourceLineNo">1470</span>        }<a name="line.1470"></a>
-<span class="sourceLineNo">1471</span>      } else {<a name="line.1471"></a>
-<span class="sourceLineNo">1472</span>        returnTables = monitorTargets;<a name="line.1472"></a>
-<span class="sourceLineNo">1473</span>      }<a name="line.1473"></a>
-<span class="sourceLineNo">1474</span><a name="line.1474"></a>
-<span class="sourceLineNo">1475</span>      return returnTables;<a name="line.1475"></a>
-<span class="sourceLineNo">1476</span>    }<a name="line.1476"></a>
-<span class="sourceLineNo">1477</span><a name="line.1477"></a>
-<span class="sourceLineNo">1478</span>    /*<a name="line.1478"></a>
-<span class="sourceLineNo">1479</span>     * Canary entry point to monitor all the tables.<a name="line.1479"></a>
-<span class="sourceLineNo">1480</span>     */<a name="line.1480"></a>
-<span class="sourceLineNo">1481</span>    private List&lt;Future&lt;Void&gt;&gt; sniff(TaskType taskType, RegionStdOutSink regionSink)<a name="line.1481"></a>
-<span class="sourceLineNo">1482</span>        throws Exception {<a name="line.1482"></a>
-<span class="sourceLineNo">1483</span>      LOG.debug("Reading list of tables");<a name="line.1483"></a>
-<span class="sourceLineNo">1484</span>      List&lt;Future&lt;Void&gt;&gt; taskFutures = new LinkedList&lt;&gt;();<a name="line.1484"></a>
-<span class="sourceLineNo">1485</span>      for (TableDescriptor td: admin.listTableDescriptors()) {<a name="line.1485"></a>
-<span class="sourceLineNo">1486</span>        if (admin.tableExists(td.getTableName()) &amp;&amp; admin.isTableEnabled(td.getTableName()) &amp;&amp;<a name="line.1486"></a>
-<span class="sourceLineNo">1487</span>            (!td.getTableName().equals(writeTableName))) {<a name="line.1487"></a>
-<span class="sourceLineNo">1488</span>          LongAdder readLatency =<a name="line.1488"></a>
-<span class="sourceLineNo">1489</span>              regionSink.initializeAndGetReadLatencyForTable(td.getTableName().getNameAsString());<a name="line.1489"></a>
-<span class="sourceLineNo">1490</span>          taskFutures.addAll(CanaryTool.sniff(admin, sink, td, executor, taskType, this.rawScanEnabled,<a name="line.1490"></a>
-<span class="sourceLineNo">1491</span>              readLatency));<a name="line.1491"></a>
-<span class="sourceLineNo">1492</span>        }<a name="line.1492"></a>
-<span class="sourceLineNo">1493</span>      }<a name="line.1493"></a>
-<span class="sourceLineNo">1494</span>      return taskFutures;<a name="line.1494"></a>
-<span class="sourceLineNo">1495</span>    }<a name="line.1495"></a>
-<span class="sourceLineNo">1496</span><a name="line.1496"></a>
-<span class="sourceLineNo">1497</span>    private void checkWriteTableDistribution() throws IOException {<a name="line.1497"></a>
-<span class="sourceLineNo">1498</span>      if (!admin.tableExists(writeTableName)) {<a name="line.1498"></a>
-<span class="sourceLineNo">1499</span>        int numberOfServers = admin.getRegionServers().size();<a name="line.1499"></a>
-<span class="sourceLineNo">1500</span>        if (numberOfServers == 0) {<a name="line.1500"></a>
-<span class="sourceLineNo">1501</span>          throw new IllegalStateException("No live regionservers");<a name="line.1501"></a>
-<span class="sourceLineNo">1502</span>        }<a name="line.1502"></a>
-<span class="sourceLineNo">1503</span>        createWriteTable(numberOfServers);<a name="line.1503"></a>
-<span class="sourceLineNo">1504</span>      }<a name="line.1504"></a>
-<span class="sourceLineNo">1505</span><a name="line.1505"></a>
-<span class="sourceLineNo">1506</span>      if (!admin.isTableEnabled(writeTableName)) {<a name="line.1506"></a>
-<span class="sourceLineNo">1507</span>        admin.enableTable(writeTableName);<a name="line.1507"></a>
-<span class="sourceLineNo">1508</span>      }<a name="line.1508"></a>
-<span class="sourceLineNo">1509</span><a name="line.1509"></a>
-<span class="sourceLineNo">1510</span>      ClusterMetrics status =<a name="line.1510"></a>
-<span class="sourceLineNo">1511</span>          admin.getClusterMetrics(EnumSet.of(Option.SERVERS_NAME, Option.MASTER));<a name="line.1511"></a>
-<span class="sourceLineNo">1512</span>      int numberOfServers = status.getServersName().size();<a name="line.1512"></a>
-<span class="sourceLineNo">1513</span>      if (status.getServersName().contains(status.getMasterName())) {<a name="line.1513"></a>
-<span class="sourceLineNo">1514</span>        numberOfServers -= 1;<a name="line.1514"></a>
-<span class="sourceLineNo">1515</span>      }<a name="line.1515"></a>
-<span class="sourceLineNo">1516</span><a name="line.1516"></a>
-<span class="sourceLineNo">1517</span>      List&lt;Pair&lt;RegionInfo, ServerName&gt;&gt; pairs =<a name="line.1517"></a>
-<span class="sourceLineNo">1518</span>          MetaTableAccessor.getTableRegionsAndLocations(connection, writeTableName);<a name="line.1518"></a>
-<span class="sourceLineNo">1519</span>      int numberOfRegions = pairs.size();<a name="line.1519"></a>
-<span class="sourceLineNo">1520</span>      if (numberOfRegions &lt; numberOfServers * regionsLowerLimit<a name="line.1520"></a>
-<span class="sourceLineNo">1521</span>          || numberOfRegions &gt; numberOfServers * regionsUpperLimit) {<a name="line.1521"></a>
-<span class="sourceLineNo">1522</span>        admin.disableTable(writeTableName);<a name="line.1522"></a>
-<span class="sourceLineNo">1523</span>        admin.deleteTable(writeTableName);<a name="line.1523"></a>
-<span class="sourceLineNo">1524</span>        createWriteTable(numberOfServers);<a name="line.1524"></a>
-<span class="sourceLineNo">1525</span>      }<a name="line.1525"></a>
-<span class="sourceLineNo">1526</span>      HashSet&lt;ServerName&gt; serverSet = new HashSet&lt;&gt;();<a name="line.1526"></a>
-<span class="sourceLineNo">1527</span>      for (Pair&lt;RegionInfo, ServerName&gt; pair : pairs) {<a name="line.1527"></a>
-<span class="sourceLineNo">1528</span>        serverSet.add(pair.getSecond());<a name="line.1528"></a>
-<span class="sourceLineNo">1529</span>      }<a name="line.1529"></a>
-<span class="sourceLineNo">1530</span>      int numberOfCoveredServers = serverSet.size();<a name="line.1530"></a>
-<span class="sourceLineNo">1531</span>      if (numberOfCoveredServers &lt; numberOfServers) {<a name="line.1531"></a>
-<span class="sourceLineNo">1532</span>        admin.balance();<a name="line.1532"></a>
-<span class="sourceLineNo">1533</span>      }<a name="line.1533"></a>
-<span class="sourceLineNo">1534</span>    }<a name="line.1534"></a>
-<span class="sourceLineNo">1535</span><a name="line.1535"></a>
-<span class="sourceLineNo">1536</span>    private void createWriteTable(int numberOfServers) throws IOException {<a name="line.1536"></a>
-<span class="sourceLineNo">1537</span>      int numberOfRegions = (int)(numberOfServers * regionsLowerLimit);<a name="line.1537"></a>
-<span class="sourceLineNo">1538</span>      LOG.info("Number of live regionservers {}, pre-splitting the canary table into {} regions " +<a name="line.1538"></a>
-<span class="sourceLineNo">1539</span>        "(current lower limit of regions per server is {} and you can change it with config {}).",<a name="line.1539"></a>
-<span class="sourceLineNo">1540</span>          numberOfServers, numberOfRegions, regionsLowerLimit,<a name="line.1540"></a>
-<span class="sourceLineNo">1541</span>          HConstants.HBASE_CANARY_WRITE_PERSERVER_REGIONS_LOWERLIMIT_KEY);<a name="line.1541"></a>
-<span class="sourceLineNo">1542</span>      HTableDescriptor desc = new HTableDescriptor(writeTableName);<a name="line.1542"></a>
-<span class="sourceLineNo">1543</span>      HColumnDescriptor family = new HColumnDescriptor(CANARY_TABLE_FAMILY_NAME);<a name="line.1543"></a>
-<span class="sourceLineNo">1544</span>      family.setMaxVersions(1);<a name="line.1544"></a>
-<span class="sourceLineNo">1545</span>      family.setTimeToLive(writeDataTTL);<a name="line.1545"></a>
-<span class="sourceLineNo">1546</span><a name="line.1546"></a>
-<span class="sourceLineNo">1547</span>      desc.addFamily(family);<a name="line.1547"></a>
-<span class="sourceLineNo">1548</span>      byte[][] splits = new RegionSplitter.HexStringSplit().split(numberOfRegions);<a name="line.1548"></a>
-<span class="sourceLineNo">1549</span>      admin.createTable(desc, splits);<a name="line.1549"></a>
-<span class="sourceLineNo">1550</span>    }<a name="line.1550"></a>
-<span class="sourceLineNo">1551</span>  }<a name="line.1551"></a>
-<span class="sourceLineNo">1552</span><a name="line.1552"></a>
-<span class="sourceLineNo">1553</span>  /**<a name="line.1553"></a>
-<span class="sourceLineNo">1554</span>   * Canary entry point for specified table.<a name="line.1554"></a>
-<span class="sourceLineNo">1555</span>   * @throws Exception<a name="line.1555"></a>
-<span class="sourceLineNo">1556</span>   */<a name="line.1556"></a>
-<span class="sourceLineNo">1557</span>  private static List&lt;Future&lt;Void&gt;&gt; sniff(final Admin admin, final Sink sink, String tableName,<a name="line.1557"></a>
-<span class="sourceLineNo">1558</span>      ExecutorService executor, TaskType taskType, boolean rawScanEnabled, LongAdder readLatency)<a name="line.1558"></a>
-<span class="sourceLineNo">1559</span>      throws Exception {<a name="line.1559"></a>
-<span class="sourceLineNo">1560</span>    LOG.debug("Checking table is enabled and getting table descriptor for table {}", tableName);<a name="line.1560"></a>
-<span class="sourceLineNo">1561</span>    if (admin.isTableEnabled(TableName.valueOf(tableName))) {<a name="line.1561"></a>
-<span class="sourceLineNo">1562</span>      return CanaryTool.sniff(admin, sink, admin.getDescriptor(TableName.valueOf(tableName)),<a name="line.1562"></a>
-<span class="sourceLineNo">1563</span>        executor, taskType, rawScanEnabled, readLatency);<a name="line.1563"></a>
-<span class="sourceLineNo">1564</span>    } else {<a name="line.1564"></a>
-<span class="sourceLineNo">1565</span>      LOG.warn("Table {} is not enabled", tableName);<a name="line.1565"></a>
-<span class="sourceLineNo">1566</span>    }<a name="line.1566"></a>
-<span class="sourceLineNo">1567</span>    return new LinkedList&lt;&gt;();<a name="line.1567"></a>
-<span class="sourceLineNo">1568</span>  }<a name="line.1568"></a>
-<span class="sourceLineNo">1569</span><a name="line.1569"></a>
-<span class="sourceLineNo">1570</span>  /*<a name="line.1570"></a>
-<span class="sourceLineNo">1571</span>   * Loops over regions of this table, and outputs information about the state.<a name="line.1571"></a>
-<span class="sourceLineNo">1572</span>   */<a name="line.1572"></a>
-<span class="sourceLineNo">1573</span>  private static List&lt;Future&lt;Void&gt;&gt; sniff(final Admin admin, final Sink sink,<a name="line.1573"></a>
-<span class="sourceLineNo">1574</span>      TableDescriptor tableDesc, ExecutorService executor, TaskType taskType,<a name="line.1574"></a>
-<span class="sourceLineNo">1575</span>      boolean rawScanEnabled, LongAdder rwLatency) throws Exception {<a name="line.1575"></a>
-<span class="sourceLineNo">1576</span>    LOG.debug("Reading list of regions for table {}", tableDesc.getTableName());<a name="line.1576"></a>
-<span class="sourceLineNo">1577</span>    try (Table table = admin.getConnection().getTable(tableDesc.getTableName())) {<a name="line.1577"></a>
-<span class="sourceLineNo">1578</span>      List&lt;RegionTask&gt; tasks = new ArrayList&lt;&gt;();<a name="line.1578"></a>
-<span class="sourceLineNo">1579</span>      try (RegionLocator regionLocator =<a name="line.1579"></a>
-<span class="sourceLineNo">1580</span>               admin.getConnection().getRegionLocator(tableDesc.getTableName())) {<a name="line.1580"></a>
-<span class="sourceLineNo">1581</span>        for (HRegionLocation location: regionLocator.getAllRegionLocations()) {<a name="line.1581"></a>
-<span class="sourceLineNo">1582</span>          ServerName rs = location.getServerName();<a name="line.1582"></a>
-<span class="sourceLineNo">1583</span>          RegionInfo region = location.getRegion();<a name="line.1583"></a>
-<span class="sourceLineNo">1584</span>          tasks.add(new RegionTask(admin.getConnection(), region, rs, (RegionStdOutSink)sink,<a name="line.1584"></a>
-<span class="sourceLineNo">1585</span>              taskType, rawScanEnabled, rwLatency));<a name="line.1585"></a>
-<span class="sourceLineNo">1586</span>          Map&lt;String, List&lt;RegionTaskResult&gt;&gt; regionMap = ((RegionStdOutSink) sink).getRegionMap();<a name="line.1586"></a>
-<span class="sourceLineNo">1587</span>          regionMap.put(region.getRegionNameAsString(), new ArrayList&lt;RegionTaskResult&gt;());<a name="line.1587"></a>
-<span class="sourceLineNo">1588</span>        }<a name="line.1588"></a>
-<span class="sourceLineNo">1589</span>        return executor.invokeAll(tasks);<a name="line.1589"></a>
-<span class="sourceLineNo">1590</span>      }<a name="line.1590"></a>
-<span class="sourceLineNo">1591</span>    } catch (TableNotFoundException e) {<a name="line.1591"></a>
-<span class="sourceLineNo">1592</span>      return Collections.EMPTY_LIST;<a name="line.1592"></a>
-<span class="sourceLineNo">1593</span>    }<a name="line.1593"></a>
-<span class="sourceLineNo">1594</span>  }<a name="line.1594"></a>
-<span class="sourceLineNo">1595</span><a name="line.1595"></a>
-<span class="sourceLineNo">1596</span>  //  monitor for zookeeper mode<a name="line.1596"></a>
-<span class="sourceLineNo">1597</span>  private static class ZookeeperMonitor extends Monitor {<a name="line.1597"></a>
-<span class="sourceLineNo">1598</span>    private List&lt;String&gt; hosts;<a name="line.1598"></a>
-<span class="sourceLineNo">1599</span>    private final String znode;<a name="line.1599"></a>
-<span class="sourceLineNo">1600</span>    private final int timeout;<a name="line.1600"></a>
-<span class="sourceLineNo">1601</span><a name="line.1601"></a>
-<span class="sourceLineNo">1602</span>    protected ZookeeperMonitor(Connection connection, String[] monitorTargets, boolean useRegExp,<a name="line.1602"></a>
-<span class="sourceLineNo">1603</span>        Sink sink, ExecutorService executor, boolean treatFailureAsError, long allowedFailures)  {<a name="line.1603"></a>
-<span class="sourceLineNo">1604</span>      super(connection, monitorTargets, useRegExp,<a name="line.1604"></a>
-<span class="sourceLineNo">1605</span>          sink, executor, treatFailureAsError, allowedFailures);<a name="line.1605"></a>
-<span class="sourceLineNo">1606</span>      Configuration configuration = connection.getConfiguration();<a name="line.1606"></a>
-<span class="sourceLineNo">1607</span>      znode =<a name="line.1607"></a>
-<span class="sourceLineNo">1608</span>          configuration.get(ZOOKEEPER_ZNODE_PARENT,<a name="line.1608"></a>
-<span class="sourceLineNo">1609</span>              DEFAULT_ZOOKEEPER_ZNODE_PARENT);<a name="line.1609"></a>
-<span class="sourceLineNo">1610</span>      timeout = configuration<a name="line.1610"></a>
-<span class="sourceLineNo">1611</span>          .getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT);<a name="line.1611"></a>
-<span class="sourceLineNo">1612</span>      ConnectStringParser parser =<a name="line.1612"></a>
-<span class="sourceLineNo">1613</span>          new ConnectStringParser(ZKConfig.getZKQuorumServersString(configuration));<a name="line.1613"></a>
-<span class="sourceLineNo">1614</span>      hosts = Lists.newArrayList();<a name="line.1614"></a>
-<span class="sourceLineNo">1615</span>      for (InetSocketAddress server : parser.getServerAddresses()) {<a name="line.1615"></a>
-<span class="sourceLineNo">1616</span>        hosts.add(server.toString());<a name="line.1616"></a>
-<span class="sourceLineNo">1617</span>      }<a name="line.1617"></a>
-<span class="sourceLineNo">1618</span>      if (allowedFailures &gt; (hosts.size() - 1) / 2) {<a name="line.1618"></a>
-<span class="sourceLineNo">1619</span>        LOG.warn("Confirm allowable number of failed ZooKeeper nodes, as quorum will " +<a name="line.1619"></a>
-<span class="sourceLineNo">1620</span>                        "already be lost. Setting of {} failures is unexpected for {} ensemble size.",<a name="line.1620"></a>
-<span class="sourceLineNo">1621</span>                allowedFailures, hosts.size());<a name="line.1621"></a>
+<span class="sourceLineNo">703</span><a name="line.703"></a>
+<span class="sourceLineNo">704</span>  private ExecutorService executor; // threads to retrieve data from regionservers<a name="line.704"></a>
+<span class="sourceLineNo">705</span><a name="line.705"></a>
+<span class="sourceLineNo">706</span>  public CanaryTool() {<a name="line.706"></a>
+<span class="sourceLineNo">707</span>    this(new ScheduledThreadPoolExecutor(1));<a name="line.707"></a>
+<span class="sourceLineNo">708</span>  }<a name="line.708"></a>
+<span class="sourceLineNo">709</span><a name="line.709"></a>
+<span class="sourceLineNo">710</span>  public CanaryTool(ExecutorService executor) {<a name="line.710"></a>
+<span class="sourceLineNo">711</span>    this(executor, null);<a name="line.711"></a>
+<span class="sourceLineNo">712</span>  }<a name="line.712"></a>
+<span class="sourceLineNo">713</span><a name="line.713"></a>
+<span class="sourceLineNo">714</span>  @VisibleForTesting<a name="line.714"></a>
+<span class="sourceLineNo">715</span>  CanaryTool(ExecutorService executor, Sink sink) {<a name="line.715"></a>
+<span class="sourceLineNo">716</span>    this.executor = executor;<a name="line.716"></a>
+<span class="sourceLineNo">717</span>    this.sink = sink;<a name="line.717"></a>
+<span class="sourceLineNo">718</span>  }<a name="line.718"></a>
+<span class="sourceLineNo">719</span><a name="line.719"></a>
+<span class="sourceLineNo">720</span>  CanaryTool(Configuration conf, ExecutorService executor) {<a name="line.720"></a>
+<span class="sourceLineNo">721</span>    this(conf, executor, null);<a name="line.721"></a>
+<span class="sourceLineNo">722</span>  }<a name="line.722"></a>
+<span class="sourceLineNo">723</span><a name="line.723"></a>
+<span class="sourceLineNo">724</span>  CanaryTool(Configuration conf, ExecutorService executor, Sink sink) {<a name="line.724"></a>
+<span class="sourceLineNo">725</span>    this(executor, sink);<a name="line.725"></a>
+<span class="sourceLineNo">726</span>    setConf(conf);<a name="line.726"></a>
+<span class="sourceLineNo">727</span>  }<a name="line.727"></a>
+<span class="sourceLineNo">728</span><a name="line.728"></a>
+<span class="sourceLineNo">729</span>  @Override<a name="line.729"></a>
+<span class="sourceLineNo">730</span>  public Configuration getConf() {<a name="line.730"></a>
+<span class="sourceLineNo">731</span>    return conf;<a name="line.731"></a>
+<span class="sourceLineNo">732</span>  }<a name="line.732"></a>
+<span class="sourceLineNo">733</span><a name="line.733"></a>
+<span class="sourceLineNo">734</span>  @Override<a name="line.734"></a>
+<span class="sourceLineNo">735</span>  public void setConf(Configuration conf) {<a name="line.735"></a>
+<span class="sourceLineNo">736</span>    if (conf == null) {<a name="line.736"></a>
+<span class="sourceLineNo">737</span>      conf = HBaseConfiguration.create();<a name="line.737"></a>
+<span class="sourceLineNo">738</span>    }<a name="line.738"></a>
+<span class="sourceLineNo">739</span>    this.conf = conf;<a name="line.739"></a>
+<span class="sourceLineNo">740</span>  }<a name="line.740"></a>
+<span class="sourceLineNo">741</span><a name="line.741"></a>
+<span class="sourceLineNo">742</span>  private int parseArgs(String[] args) {<a name="line.742"></a>
+<span class="sourceLineNo">743</span>    int index = -1;<a name="line.743"></a>
+<span class="sourceLineNo">744</span>    long permittedFailures = 0;<a name="line.744"></a>
+<span class="sourceLineNo">745</span>    boolean regionServerAllRegions = false, writeSniffing = false;<a name="line.745"></a>
+<span class="sourceLineNo">746</span>    String readTableTimeoutsStr = null;<a name="line.746"></a>
+<span class="sourceLineNo">747</span><a name="line.747"></a>
+<span class="sourceLineNo">748</span>    // Process command line args<a name="line.748"></a>
+<span class="sourceLineNo">749</span>    for (int i = 0; i &lt; args.length; i++) {<a name="line.749"></a>
+<span class="sourceLineNo">750</span>      String cmd = args[i];<a name="line.750"></a>
+<span class="sourceLineNo">751</span><a name="line.751"></a>
+<span class="sourceLineNo">752</span>      if (cmd.startsWith("-")) {<a name="line.752"></a>
+<span class="sourceLineNo">753</span>        if (index &gt;= 0) {<a name="line.753"></a>
+<span class="sourceLineNo">754</span>          // command line args must be in the form: [opts] [table 1 [table 2 ...]]<a name="line.754"></a>
+<span class="sourceLineNo">755</span>          System.err.println("Invalid command line options");<a name="line.755"></a>
+<span class="sourceLineNo">756</span>          printUsageAndExit();<a name="line.756"></a>
+<span class="sourceLineNo">757</span>        }<a name="line.757"></a>
+<span class="sourceLineNo">758</span><a name="line.758"></a>
+<span class="sourceLineNo">759</span>        if (cmd.equals("-help") || cmd.equals("-h")) {<a name="line.759"></a>
+<span class="sourceLineNo">760</span>          // user asked for help, print the help and quit.<a name="line.760"></a>
+<span class="sourceLineNo">761</span>          printUsageAndExit();<a name="line.761"></a>
+<span class="sourceLineNo">762</span>        } else if (cmd.equals("-daemon") &amp;&amp; interval == 0) {<a name="line.762"></a>
+<span class="sourceLineNo">763</span>          // user asked for daemon mode, set a default interval between checks<a name="line.763"></a>
+<span class="sourceLineNo">764</span>          interval = DEFAULT_INTERVAL;<a name="line.764"></a>
+<span class="sourceLineNo">765</span>        } else if (cmd.equals("-interval")) {<a name="line.765"></a>
+<span class="sourceLineNo">766</span>          // user has specified an interval for canary breaths (-interval N)<a name="line.766"></a>
+<span class="sourceLineNo">767</span>          i++;<a name="line.767"></a>
+<span class="sourceLineNo">768</span><a name="line.768"></a>
+<span class="sourceLineNo">769</span>          if (i == args.length) {<a name="line.769"></a>
+<span class="sourceLineNo">770</span>            System.err.println("-interval takes a numeric seconds value argument.");<a name="line.770"></a>
+<span class="sourceLineNo">771</span>            printUsageAndExit();<a name="line.771"></a>
+<span class="sourceLineNo">772</span>          }<a name="line.772"></a>
+<span class="sourceLineNo">773</span><a name="line.773"></a>
+<span class="sourceLineNo">774</span>          try {<a name="line.774"></a>
+<span class="sourceLineNo">775</span>            interval = Long.parseLong(args[i]) * 1000;<a name="line.775"></a>
+<span class="sourceLineNo">776</span>          } catch (NumberFormatException e) {<a name="line.776"></a>
+<span class="sourceLineNo">777</span>            System.err.println("-interval needs a numeric value argument.");<a name="line.777"></a>
+<span class="sourceLineNo">778</span>            printUsageAndExit();<a name="line.778"></a>
+<span class="sourceLineNo">779</span>          }<a name="line.779"></a>
+<span class="sourceLineNo">780</span>        } else if (cmd.equals("-zookeeper")) {<a name="line.780"></a>
+<span class="sourceLineNo">781</span>          this.zookeeperMode = true;<a name="line.781"></a>
+<span class="sourceLineNo">782</span>        } else if(cmd.equals("-regionserver")) {<a name="line.782"></a>
+<span class="sourceLineNo">783</span>          this.regionServerMode = true;<a name="line.783"></a>
+<span class="sourceLineNo">784</span>        } else if(cmd.equals("-allRegions")) {<a name="line.784"></a>
+<span class="sourceLineNo">785</span>          conf.setBoolean(HBASE_CANARY_REGIONSERVER_ALL_REGIONS, true);<a name="line.785"></a>
+<span class="sourceLineNo">786</span>          regionServerAllRegions = true;<a name="line.786"></a>
+<span class="sourceLineNo">787</span>        } else if(cmd.equals("-writeSniffing")) {<a name="line.787"></a>
+<span class="sourceLineNo">788</span>          writeSniffing = true;<a name="line.788"></a>
+<span class="sourceLineNo">789</span>          conf.setBoolean(HBASE_CANARY_REGION_WRITE_SNIFFING, true);<a name="line.789"></a>
+<span class="sourceLineNo">790</span>        } else if(cmd.equals("-treatFailureAsError") || cmd.equals("-failureAsError")) {<a name="line.790"></a>
+<span class="sourceLineNo">791</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, true);<a name="line.791"></a>
+<span class="sourceLineNo">792</span>        } else if (cmd.equals("-e")) {<a name="line.792"></a>
+<span class="sourceLineNo">793</span>          conf.setBoolean(HBASE_CANARY_USE_REGEX, true);<a name="line.793"></a>
+<span class="sourceLineNo">794</span>        } else if (cmd.equals("-t")) {<a name="line.794"></a>
+<span class="sourceLineNo">795</span>          i++;<a name="line.795"></a>
+<span class="sourceLineNo">796</span><a name="line.796"></a>
+<span class="sourceLineNo">797</span>          if (i == args.length) {<a name="line.797"></a>
+<span class="sourceLineNo">798</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.798"></a>
+<span class="sourceLineNo">799</span>            printUsageAndExit();<a name="line.799"></a>
+<span class="sourceLineNo">800</span>          }<a name="line.800"></a>
+<span class="sourceLineNo">801</span>          long timeout = 0;<a name="line.801"></a>
+<span class="sourceLineNo">802</span>          try {<a name="line.802"></a>
+<span class="sourceLineNo">803</span>            timeout = Long.parseLong(args[i]);<a name="line.803"></a>
+<span class="sourceLineNo">804</span>          } catch (NumberFormatException e) {<a name="line.804"></a>
+<span class="sourceLineNo">805</span>            System.err.println("-t takes a numeric milliseconds value argument.");<a name="line.805"></a>
+<span class="sourceLineNo">806</span>            printUsageAndExit();<a name="line.806"></a>
+<span class="sourceLineNo">807</span>          }<a name="line.807"></a>
+<span class="sourceLineNo">808</span>          conf.setLong(HBASE_CANARY_TIMEOUT, timeout);<a name="line.808"></a>
+<span class="sourceLineNo">809</span>        } else if(cmd.equals("-writeTableTimeout")) {<a name="line.809"></a>
+<span class="sourceLineNo">810</span>          i++;<a name="line.810"></a>
+<span class="sourceLineNo">811</span><a name="line.811"></a>
+<span class="sourceLineNo">812</span>          if (i == args.length) {<a name="line.812"></a>
+<span class="sourceLineNo">813</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.813"></a>
+<span class="sourceLineNo">814</span>            printUsageAndExit();<a name="line.814"></a>
+<span class="sourceLineNo">815</span>          }<a name="line.815"></a>
+<span class="sourceLineNo">816</span>          long configuredWriteTableTimeout = 0;<a name="line.816"></a>
+<span class="sourceLineNo">817</span>          try {<a name="line.817"></a>
+<span class="sourceLineNo">818</span>            configuredWriteTableTimeout = Long.parseLong(args[i]);<a name="line.818"></a>
+<span class="sourceLineNo">819</span>          } catch (NumberFormatException e) {<a name="line.819"></a>
+<span class="sourceLineNo">820</span>            System.err.println("-writeTableTimeout takes a numeric milliseconds value argument.");<a name="line.820"></a>
+<span class="sourceLineNo">821</span>            printUsageAndExit();<a name="line.821"></a>
+<span class="sourceLineNo">822</span>          }<a name="line.822"></a>
+<span class="sourceLineNo">823</span>          conf.setLong(HBASE_CANARY_REGION_WRITE_TABLE_TIMEOUT, configuredWriteTableTimeout);<a name="line.823"></a>
+<span class="sourceLineNo">824</span>        } else if (cmd.equals("-writeTable")) {<a name="line.824"></a>
+<span class="sourceLineNo">825</span>          i++;<a name="line.825"></a>
+<span class="sourceLineNo">826</span><a name="line.826"></a>
+<span class="sourceLineNo">827</span>          if (i == args.length) {<a name="line.827"></a>
+<span class="sourceLineNo">828</span>            System.err.println("-writeTable takes a string tablename value argument.");<a name="line.828"></a>
+<span class="sourceLineNo">829</span>            printUsageAndExit();<a name="line.829"></a>
+<span class="sourceLineNo">830</span>          }<a name="line.830"></a>
+<span class="sourceLineNo">831</span>          conf.set(HBASE_CANARY_REGION_WRITE_TABLE_NAME, args[i]);<a name="line.831"></a>
+<span class="sourceLineNo">832</span>        } else if (cmd.equals("-f")) {<a name="line.832"></a>
+<span class="sourceLineNo">833</span>          i++;<a name="line.833"></a>
+<span class="sourceLineNo">834</span><a name="line.834"></a>
+<span class="sourceLineNo">835</span>          if (i == args.length) {<a name="line.835"></a>
+<span class="sourceLineNo">836</span>            System.err<a name="line.836"></a>
+<span class="sourceLineNo">837</span>                .println("-f needs a boolean value argument (true|false).");<a name="line.837"></a>
+<span class="sourceLineNo">838</span>            printUsageAndExit();<a name="line.838"></a>
+<span class="sourceLineNo">839</span>          }<a name="line.839"></a>
+<span class="sourceLineNo">840</span><a name="line.840"></a>
+<span class="sourceLineNo">841</span>          conf.setBoolean(HBASE_CANARY_FAIL_ON_ERROR, Boolean.parseBoolean(args[i]));<a name="line.841"></a>
+<span class="sourceLineNo">842</span>        } else if (cmd.equals("-readTableTimeouts")) {<a name="line.842"></a>
+<span class="sourceLineNo">843</span>          i++;<a name="line.843"></a>
+<span class="sourceLineNo">844</span><a name="line.844"></a>
+<span class="sourceLineNo">845</span>          if (i == args.length) {<a name="line.845"></a>
+<span class="sourceLineNo">846</span>            System.err.println("-readTableTimeouts needs a comma-separated list of read " +<a name="line.846"></a>
+<span class="sourceLineNo">847</span>                "millisecond timeouts per table (without spaces).");<a name="line.847"></a>
+<span class="sourceLineNo">848</span>            printUsageAndExit();<a name="line.848"></a>
+<span class="sourceLineNo">849</span>          }<a name="line.849"></a>
+<span class="sourceLineNo">850</span>          readTableTimeoutsStr = args[i];<a name="line.850"></a>
+<span class="sourceLineNo">851</span>          conf.set(HBASE_CANARY_REGION_READ_TABLE_TIMEOUT, readTableTimeoutsStr);<a name="line.851"></a>
+<span class="sourceLineNo">852</span>        } else if (cmd.equals("-permittedZookeeperFailures")) {<a name="line.852"></a>
+<span class="sourceLineNo">853</span>          i++;<a name="line.853"></a>
+<span class="sourceLineNo">854</span><a name="line.854"></a>
+<span class="sourceLineNo">855</span>          if (i == args.length) {<a name="line.855"></a>
+<span class="sourceLineNo">856</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.856"></a>
+<span class="sourceLineNo">857</span>            printUsageAndExit();<a name="line.857"></a>
+<span class="sourceLineNo">858</span>          }<a name="line.858"></a>
+<span class="sourceLineNo">859</span>          try {<a name="line.859"></a>
+<span class="sourceLineNo">860</span>            permittedFailures = Long.parseLong(args[i]);<a name="line.860"></a>
+<span class="sourceLineNo">861</span>          } catch (NumberFormatException e) {<a name="line.861"></a>
+<span class="sourceLineNo">862</span>            System.err.println("-permittedZookeeperFailures needs a numeric value argument.");<a name="line.862"></a>
+<span class="sourceLineNo">863</span>            printUsageAndExit();<a name="line.863"></a>
+<span class="sourceLineNo">864</span>          }<a name="line.864"></a>
+<span class="sourceLineNo">865</span>          conf.setLong(HBASE_CANARY_ZOOKEEPER_PERMITTED_FAILURES, permittedFailures);<a name="line.865"></a>
+<span class="sourceLineNo">866</span>        } else {<a name="line.866"></a>
+<span class="sourceLineNo">867</span>          // no options match<a name="line.867"></a>
+<span class="sourceLineNo">868</span>          System.err.println(cmd + " options is invalid.");<a name="line.868"></a>
+<span class="sourceLineNo">869</span>          printUsageAndExit();<a name="line.869"></a>
+<span class="sourceLineNo">870</span>        }<a name="line.870"></a>
+<span class="sourceLineNo">871</span>      } else if (index &lt; 0) {<a name="line.871"></a>
+<span class="sourceLineNo">872</span>        // keep track of first table name specified by the user<a name="line.872"></a>
+<span class="sourceLineNo">873</span>        index = i;<a name="line.873"></a>
+<span class="sourceLineNo">874</span>      }<a name="line.874"></a>
+<span class="sourceLineNo">875</span>    }<a name="line.875"></a>
+<span class="sourceLineNo">876</span>    if (regionServerAllRegions &amp;&amp; !this.regionServerMode) {<a name="line.876"></a>
+<span class="sourceLineNo">877</span>      System.err.println("-allRegions can only be specified in regionserver mode.");<a name="line.877"></a>
+<span class="sourceLineNo">878</span>      printUsageAndExit();<a name="line.878"></a>
+<span class="sourceLineNo">879</span>    }<a name="line.879"></a>
+<span class="sourceLineNo">880</span>    if (this.zookeeperMode) {<a name="line.880"></a>
+<span class="sourceLineNo">881</span>      if (this.regionServerMode || regionServerAllRegions || writeSniffing) {<a name="line.881"></a>
+<span class="sourceLineNo">882</span>        System.err.println("-zookeeper is exclusive and cannot be combined with "<a name="line.882"></a>
+<span class="sourceLineNo">883</span>            + "other modes.");<a name="line.883"></a>
+<span class="sourceLineNo">884</span>        printUsageAndExit();<a name="line.884"></a>
+<span class="sourceLineNo">885</span>      }<a name="line.885"></a>
+<span class="sourceLineNo">886</span>    }<a name="line.886"></a>
+<span class="sourceLineNo">887</span>    if (permittedFailures != 0 &amp;&amp; !this.zookeeperMode) {<a name="line.887"></a>
+<span class="sourceLineNo">888</span>      System.err.println("-permittedZookeeperFailures requires -zookeeper mode.");<a name="line.888"></a>
+<span class="sourceLineNo">889</span>      printUsageAndExit();<a name="line.889"></a>
+<span class="sourceLineNo">890</span>    }<a name="line.890"></a>
+<span class="sourceLineNo">891</span>    if (readTableTimeoutsStr != null &amp;&amp; (this.regionServerMode || this.zookeeperMode)) {<a name="line.891"></a>
+<span class="sourceLineNo">892</span>      System.err.println("-readTableTimeouts can only be configured in region mode.");<a name="line.892"></a>
+<span class="sourceLineNo">893</span>      printUsageAndExit();<a name="line.893"></a>
+<span class="sourceLineNo">894</span>    }<a name="line.894"></a>
+<span class="sourceLineNo">895</span>    return index;<a name="line.895"></a>
+<span class="sourceLineNo">896</span>  }<a name="line.896"></a>
+<span class="sourceLineNo">897</span><a name="line.897"></a>
+<span class="sourceLineNo">898</span>  @Override<a name="line.898"></a>
+<span class="sourceLineNo">899</span>  public int run(String[] args) throws Exception {<a name="line.899"></a>
+<span class="sourceLineNo">900</span>    int index = parseArgs(args);<a name="line.900"></a>
+<span class="sourceLineNo">901</span>    String[] monitorTargets = null;<a name="line.901"></a>
+<span class="sourceLineNo">902</span><a name="line.902"></a>
+<span class="sourceLineNo">903</span>    if (index &gt;= 0) {<a name="line.903"></a>
+<span class="sourceLineNo">904</span>      int length = args.length - index;<a name="line.904"></a>
+<span class="sourceLineNo">905</span>      monitorTargets = new String[length];<a name="line.905"></a>
+<span class="sourceLineNo">906</span>      System.arraycopy(args, index, monitorTargets, 0, length);<a name="line.906"></a>
+<span class="sourceLineNo">907</span>    }<a name="line.907"></a>
+<span class="sourceLineNo">908</span><a name="line.908"></a>
+<span class="sourceLineNo">909</span>    if (zookeeperMode) {<a name="line.909"></a>
+<span class="sourceLineNo">910</span>      return checkZooKeeper();<a name="line.910"></a>
+<span class="sourceLineNo">911</span>    } else if (regionServerMode) {<a name="line.911"></a>
+<span class="sourceLineNo">912</span>      return checkRegionServers(monitorTargets);<a name="line.912"></a>
+<span class="sourceLineNo">913</span>    } else {<a name="line.913"></a>
+<span class="sourceLineNo">914</span>      return checkRegions(monitorTargets);<a name="line.914"></a>
+<span class="sourceLineNo">915</span>    }<a name="line.915"></a>
+<span class="sourceLineNo">916</span>  }<a name="line.916"></a>
+<span class="sourceLineNo">917</span><a name="line.917"></a>
+<span class="sourceLineNo">918</span>  private int runMonitor(String[] monitorTargets) throws Exception {<a name="line.918"></a>
+<span class="sourceLineNo">919</span>    ChoreService choreService = null;<a name="line.919"></a>
+<span class="sourceLineNo">920</span><a name="line.920"></a>
+<span class="sourceLineNo">921</span>    // Launches chore for refreshing kerberos credentials if security is enabled.<a name="line.921"></a>
+<span class="sourceLineNo">922</span>