incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Adding in descriptions to the top labels.
Date Sun, 28 Jul 2013 19:32:16 GMT
Updated Branches:
  refs/heads/master 4b5f5c074 -> d0170266f


Adding in descriptions to the top labels.


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

Branch: refs/heads/master
Commit: d0170266fdd0c45e2ffce7096bb89836eb86fcd4
Parents: 4b5f5c0
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Jul 28 15:32:06 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Jul 28 15:32:06 2013 -0400

----------------------------------------------------------------------
 .../java/org/apache/blur/shell/TopCommand.java  | 25 +++++++++++++++-----
 .../org/apache/blur/shell/top.properties        | 16 -------------
 2 files changed, 19 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d0170266/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 ca6eee8..6b1d508 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
@@ -49,6 +49,7 @@ import org.apache.blur.thrift.generated.Metric;
 
 public class TopCommand extends Command {
 
+  private static final String HELP = ".help";
   private static final String TOP = "top.";
   private static final String LONGNAME = ".longname";
   private static final String SHORTNAME = ".shortname";
@@ -98,6 +99,7 @@ public class TopCommand extends Command {
     }
 
     Map<String, String> metricNames = new HashMap<String, String>();
+    Map<String, String> helpMap = new HashMap<String, String>();
     Set<Object> keySet = properties.keySet();
     for (Object k : keySet) {
       String key = k.toString();
@@ -105,6 +107,14 @@ public class TopCommand extends Command {
         String shortName = getShortName(key, properties);
         String longName = getLongName(getLongNameKey(key), properties);
         metricNames.put(shortName, longName);
+      } else if (isHelpName(key)) {
+        int indexOf = key.indexOf(HELP);
+        String strKey = key.substring(0, indexOf);
+        Object shortNameKey = properties.get(strKey + SHORTNAME);
+        Object helpMessage = properties.get(key);
+        if (shortNameKey != null && helpMessage != null) {
+          helpMap.put(shortNameKey.toString(), helpMessage.toString());
+        }
       }
     }
 
@@ -157,7 +167,7 @@ public class TopCommand extends Command {
       if (quit.get()) {
         return;
       } else if (help.get()) {
-        showHelp(output, labels, metricNames);
+        showHelp(output, labels, helpMap);
       } else {
         output.append(truncate(String.format(header.toString(), (Object[]) labels)));
         for (Entry<String, AtomicReference<Client>> e : new TreeMap<String,
AtomicReference<Client>>(shardClients)
@@ -210,7 +220,7 @@ public class TopCommand extends Command {
         Terminal terminal = reader.getTerminal();
         _height = terminal.getHeight() - 2;
         _width = terminal.getWidth() - 2;
-        
+
         List<String> currentShardServerList = new ArrayList<String>(client.shardServerList(cluster));
         Collections.sort(currentShardServerList);
         if (!shardServerList.equals(currentShardServerList)) {
@@ -221,6 +231,10 @@ public class TopCommand extends Command {
     } while (reader != null);
   }
 
+  private boolean isHelpName(String key) {
+    return key.endsWith(HELP);
+  }
+
   private void close(Map<String, AtomicReference<Client>> shardClients) {
     for (AtomicReference<Client> client : shardClients.values()) {
       tryToClose(client);
@@ -320,15 +334,14 @@ public class TopCommand extends Command {
     return key.endsWith(SHORTNAME);
   }
 
-  private void showHelp(StringBuilder output, Object[] labels, Map<String, String>
metricNames) {
+  private void showHelp(StringBuilder output, Object[] labels, Map<String, String>
helpMap) {
     output.append("Help\n");
-
     for (int i = 0; i < labels.length; i++) {
       String shortName = (String) labels[i];
-      String longName = metricNames.get(shortName);
+      String helpMessage = helpMap.get(shortName);
       output.append(String.format("%15s", shortName));
       output.append(" - ");
-      output.append(longName);
+      output.append(helpMessage);
       output.append('\n');
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/d0170266/blur-shell/src/main/resources/org/apache/blur/shell/top.properties
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/resources/org/apache/blur/shell/top.properties b/blur-shell/src/main/resources/org/apache/blur/shell/top.properties
index 9f3cbe2..e153ada 100644
--- a/blur-shell/src/main/resources/org/apache/blur/shell/top.properties
+++ b/blur-shell/src/main/resources/org/apache/blur/shell/top.properties
@@ -33,22 +33,6 @@ top.SC.longname="org.apache.blur":type="Blur",scope="default",name="Segment
Coun
 top.SL.longname="org.apache.blur":type="System",name="Load Average"
 top.HU.longname="org.apache.blur":type="JVM",name="Heap Used"
 
-top.SHARD_SERVER.longname=Shard Server
-top.IQ.longname="org.apache.blur":type="Blur",name="Internal Queries/s"
-top.EQ.longname="org.apache.blur":type="Blur",name="External Queries/s"
-top.CH.longname="org.apache.blur":type="Cache",name="Hit"
-top.CM.longname="org.apache.blur":type="Cache",name="Miss"
-top.CE.longname="org.apache.blur":type="Cache",name="Eviction"
-top.CS.longname="org.apache.blur":type="Cache",name="Size"
-top.RE.longname="org.apache.blur":type="Blur",name="Read Records/s"
-top.RO.longname="org.apache.blur":type="Blur",name="Read Row/s"
-top.IM.longname="org.apache.blur":type="Blur",scope="default",name="Index Memory Usage"
-top.TC.longname="org.apache.blur":type="Blur",scope="default",name="Table Count"
-top.IC.longname="org.apache.blur":type="Blur",scope="default",name="Index Count"
-top.SC.longname="org.apache.blur":type="Blur",scope="default",name="Segment Count"
-top.SL.longname="org.apache.blur":type="System",name="Load Average"
-top.HU.longname="org.apache.blur":type="JVM",name="Heap Used"
-
 top.SHARD_SERVER.help=Shard Server - * indicates that the server is offline
 top.IQ.help=Internal Queries/s - This counts every shard query (One Minute Average)
 top.EQ.help=External Queries/s - This counts every query request no matter the number of
shards (One Minute Average)


Mime
View raw message