You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by an...@apache.org on 2016/03/24 05:24:51 UTC

hbase git commit: HBASE-15524 Fix NPE in client-side metrics

Repository: hbase
Updated Branches:
  refs/heads/master fd5c0934b -> db3ba652f


HBASE-15524 Fix NPE in client-side metrics


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

Branch: refs/heads/master
Commit: db3ba652f88083b0b1c57b4857f11fce7ae5b131
Parents: fd5c093
Author: Mikhail Antonov <an...@apache.org>
Authored: Wed Mar 23 21:23:54 2016 -0700
Committer: Mikhail Antonov <an...@apache.org>
Committed: Wed Mar 23 21:23:54 2016 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/client/AsyncProcess.java       | 26 +++++++++++++++++---
 .../hadoop/hbase/client/MetricsConnection.java  |  4 ++-
 2 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/db3ba652/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
index cb45cf7..142e2a0 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
@@ -1190,9 +1190,15 @@ class AsyncProcess {
         byte[] row = e.getValue().iterator().next().getAction().getRow();
         // Do not use the exception for updating cache because it might be coming from
         // any of the regions in the MultiAction.
-        if (tableName != null) {
-          connection.updateCachedLocations(tableName, regionName, row,
+        try {
+          if (tableName != null) {
+            connection.updateCachedLocations(tableName, regionName, row,
               ClientExceptionsUtil.isMetaClearingException(t) ? null : t, server);
+          }
+        } catch (Throwable ex) {
+          // That should never happen, but if it did, we want to make sure
+          // we still process errors
+          LOG.error("Couldn't update cached region locations: " + ex);
         }
         for (Action<Row> action : e.getValue()) {
           Retry retry = manageError(
@@ -1317,8 +1323,14 @@ class AsyncProcess {
             // Register corresponding failures once per server/once per region.
             if (!regionFailureRegistered) {
               regionFailureRegistered = true;
-              connection.updateCachedLocations(
+              try {
+                connection.updateCachedLocations(
                   tableName, regionName, row.getRow(), result, server);
+              } catch (Throwable ex) {
+                // That should never happen, but if it did, we want to make sure
+                // we still process errors
+                LOG.error("Couldn't update cached region locations: " + ex);
+              }
             }
             if (failureCount == 0) {
               errorsByServer.reportServerError(server);
@@ -1372,8 +1384,14 @@ class AsyncProcess {
           // for every possible exception that comes through, however.
           connection.clearCaches(server);
         } else {
-          connection.updateCachedLocations(
+          try {
+            connection.updateCachedLocations(
               tableName, region, actions.get(0).getAction().getRow(), throwable, server);
+          } catch (Throwable ex) {
+            // That should never happen, but if it did, we want to make sure
+            // we still process errors
+            LOG.error("Couldn't update cached region locations: " + ex);
+          }
         }
         failureCount += actions.size();
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/db3ba652/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java
index 4467417..53a3326 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java
@@ -63,6 +63,7 @@ public class MetricsConnection implements StatisticTrackable {
   private static final String MEMLOAD_BASE = "memstoreLoad_";
   private static final String HEAP_BASE = "heapOccupancy_";
   private static final String CACHE_BASE = "cacheDroppingExceptions_";
+  private static final String UNKNOWN_EXCEPTION = "UnknownException";
   private static final String CLIENT_SVC = ClientService.getDescriptor().getName();
 
   /** A container class for collecting details about the RPC call as it percolates. */
@@ -464,7 +465,8 @@ public class MetricsConnection implements StatisticTrackable {
   }
 
   public void incrCacheDroppingExceptions(Object exception) {
-    getMetric(CACHE_BASE + exception.getClass().getSimpleName(),
+    getMetric(CACHE_BASE +
+      (exception == null? UNKNOWN_EXCEPTION : exception.getClass().getSimpleName()),
       cacheDroppingExceptions, counterFactory).inc();
   }
 }