From a0415141f9a9453f8db4a88deb267f994a6c1420 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 27 Mar 2014 23:53:46 +0000 Subject: [PATCH] HBASE-10853 NPE in RSRpcServices.get on trunk git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1582553 13f79535-47bb-0310-9956-ffa450edef68 --- .../hbase/regionserver/RSRpcServices.java | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java index faf9561248a..c30b520cbf8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java @@ -404,8 +404,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler, region.getCoprocessorHost().postAppend(append, r); } } - regionServer.metricsRegionServer.updateAppend( - EnvironmentEdgeManager.currentTimeMillis() - before); + if (regionServer.metricsRegionServer != null) { + regionServer.metricsRegionServer.updateAppend( + EnvironmentEdgeManager.currentTimeMillis() - before); + } return r; } @@ -438,8 +440,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler, r = region.getCoprocessorHost().postIncrement(increment, r); } } - regionServer.metricsRegionServer.updateIncrement( - EnvironmentEdgeManager.currentTimeMillis() - before); + if (regionServer.metricsRegionServer != null) { + regionServer.metricsRegionServer.updateIncrement( + EnvironmentEdgeManager.currentTimeMillis() - before); + } return r; } @@ -609,12 +613,14 @@ public class RSRpcServices implements HBaseRPCErrorHandler, builder.addResultOrException(getResultOrException(ie, mutations.get(i).getIndex())); } } - long after = EnvironmentEdgeManager.currentTimeMillis(); - if (batchContainsPuts) { - regionServer.metricsRegionServer.updatePut(after - before); - } - if (batchContainsDelete) { - regionServer.metricsRegionServer.updateDelete(after - before); + if (regionServer.metricsRegionServer != null) { + long after = EnvironmentEdgeManager.currentTimeMillis(); + if (batchContainsPuts) { + regionServer.metricsRegionServer.updatePut(after - before); + } + if (batchContainsDelete) { + regionServer.metricsRegionServer.updateDelete(after - before); + } } } @@ -649,12 +655,14 @@ public class RSRpcServices implements HBaseRPCErrorHandler, } return region.batchReplay(mArray); } finally { - long after = EnvironmentEdgeManager.currentTimeMillis(); - if (batchContainsPuts) { - regionServer.metricsRegionServer.updatePut(after - before); - } - if (batchContainsDelete) { - regionServer.metricsRegionServer.updateDelete(after - before); + if (regionServer.metricsRegionServer != null) { + long after = EnvironmentEdgeManager.currentTimeMillis(); + if (batchContainsPuts) { + regionServer.metricsRegionServer.updatePut(after - before); + } + if (batchContainsDelete) { + regionServer.metricsRegionServer.updateDelete(after - before); + } } } } @@ -1334,8 +1342,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler, } catch (IOException ie) { throw new ServiceException(ie); } finally { - regionServer.metricsRegionServer.updateReplay( - EnvironmentEdgeManager.currentTimeMillis() - before); + if (regionServer.metricsRegionServer != null) { + regionServer.metricsRegionServer.updateReplay( + EnvironmentEdgeManager.currentTimeMillis() - before); + } } } @@ -1574,8 +1584,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler, } catch (IOException ie) { throw new ServiceException(ie); } finally { - regionServer.metricsRegionServer.updateGet( - EnvironmentEdgeManager.currentTimeMillis() - before); + if (regionServer.metricsRegionServer != null) { + regionServer.metricsRegionServer.updateGet( + EnvironmentEdgeManager.currentTimeMillis() - before); + } } }