incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/2] git commit: Fixing a NPE in the top command
Date Wed, 20 Nov 2013 15:28:03 GMT
Updated Branches:
  refs/heads/master 4f0ec84aa -> 8a31b8efc


Fixing a NPE in the top command


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/681b40e9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/681b40e9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/681b40e9

Branch: refs/heads/master
Commit: 681b40e97ad4a22df16ee4d2f516dd6810660896
Parents: 4f0ec84
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Wed Nov 20 10:23:02 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Nov 20 10:27:54 2013 -0500

----------------------------------------------------------------------
 .../java/org/apache/blur/shell/TopCommand.java   | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/681b40e9/blur-shell/src/main/java/org/apache/blur/shell/TopCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/TopCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/TopCommand.java
index a4b67aa..0c7bb10 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/TopCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/TopCommand.java
@@ -171,9 +171,8 @@ public class TopCommand extends Command {
       } else {
         output.append(truncate(String.format(header.toString(), (Object[]) labels)) + "\n");
         lineCount++;
-        SERVER:
-        for (Entry<String, AtomicReference<Client>> e : new TreeMap<String,
AtomicReference<Client>>(shardClients)
-            .entrySet()) {
+        SERVER: for (Entry<String, AtomicReference<Client>> e : new TreeMap<String,
AtomicReference<Client>>(
+            shardClients).entrySet()) {
           String shardServer = e.getKey();
           AtomicReference<Client> ref = e.getValue();
           Map<String, Metric> metrics = getMetrics(shardServer, ref, keys);
@@ -193,10 +192,18 @@ public class TopCommand extends Command {
             for (int i = 1; i < labels.length; i++) {
               String mn = metricNames.get(labels[i]);
               Metric metric = metrics.get(mn);
-              Map<String, Double> doubleMap = metric.getDoubleMap();
-              Double value = doubleMap.get("oneMinuteRate");
+              Double value;
+              if (metric == null) {
+                value = null;
+              } else {
+                Map<String, Double> doubleMap = metric.getDoubleMap();
+                value = doubleMap.get("oneMinuteRate");
+                if (value == null) {
+                  value = doubleMap.get("value");
+                }
+              }
               if (value == null) {
-                value = doubleMap.get("value");
+                value = 0.0;
               }
               cols[c++] = humanize(value, sizes.contains(mn));
               sb.append(" %10s");


Mime
View raw message