incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/4] git commit: Shell improvements.
Date Wed, 12 Jun 2013 12:26:57 GMT
Updated Branches:
  refs/heads/master 96ba686c6 -> 1bf69537c


Shell improvements.


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

Branch: refs/heads/master
Commit: b08249c455e0559300f09aea52ad15fecab55b2a
Parents: 96ba686
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Jun 11 15:47:45 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Jun 11 15:47:45 2013 -0400

----------------------------------------------------------------------
 .../blur/shell/ShardServerLayoutCommand.java    |  9 +++-
 .../apache/blur/shell/TableStatsCommand.java    | 46 ++++++++++++++++++--
 2 files changed, 50 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b08249c4/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
b/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
index 1b66f4d..e0ebd45 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/ShardServerLayoutCommand.java
@@ -19,6 +19,9 @@
 package org.apache.blur.shell;
 
 import java.io.PrintWriter;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.generated.Blur;
@@ -32,8 +35,10 @@ public class ShardServerLayoutCommand extends Command {
       throw new CommandException("Invalid args: " + help());
     }
     String tablename = args[1];
-
-    out.println(client.shardServerLayout(tablename));
+    Map<String, String> shardServerLayout = new TreeMap<String,String>( client.shardServerLayout(tablename));
+    for (Entry<String,String> e : shardServerLayout.entrySet()) {
+      out.println(e.getKey() + " on " + e.getValue());  
+    }
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b08249c4/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
index 5d20ec3..95ba985 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/TableStatsCommand.java
@@ -23,17 +23,57 @@ import java.io.PrintWriter;
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.generated.Blur;
 import org.apache.blur.thrift.generated.BlurException;
+import org.apache.blur.thrift.generated.TableStats;
 
 public class TableStatsCommand extends Command {
+  private static final double _1KB = 1000;
+  private static final double _1MB = _1KB * 1000;
+  private static final double _1GB = _1MB * 1000;
+  private static final double _1TB = _1GB * 1000;
+  private static final double _1PB = _1TB * 1000;
+
   @Override
-  public void doit(PrintWriter out, Blur.Iface client, String[] args)
-      throws CommandException, TException, BlurException {
+  public void doit(PrintWriter out, Blur.Iface client, String[] args) throws CommandException,
TException,
+      BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());
     }
     String tablename = args[1];
 
-    out.println(client.tableStats(tablename));
+    TableStats tableStats = client.tableStats(tablename);
+    long bytes = tableStats.getBytes();
+//    long queries = tableStats.getQueries();
+    long recordCount = tableStats.getRecordCount();
+    long rowCount = tableStats.getRowCount();
+    //Queries is an unknown value now.
+//    out.println("Queries      : " + queries);
+    out.println("Row Count    : " + rowCount);
+    out.println("Record Count : " + recordCount);
+    out.println("Table Size   : " + humanize(bytes));
+  }
+
+  private String humanize(long bytes) {
+    double result = bytes / _1PB;
+    if (((long) result) > 0) {
+      return result + " PB";
+    }
+    result = bytes / _1TB;
+    if (((long) result) > 0) {
+      return result + " TB";
+    }
+    result = bytes / _1GB;
+    if (((long) result) > 0) {
+      return result + " GB";
+    }
+    result = bytes / _1MB;
+    if (((long) result) > 0) {
+      return result + " MB";
+    }
+    result = bytes / _1KB;
+    if (((long) result) > 0) {
+      return result + " KB";
+    }
+    return result + " Bytes";
   }
 
   @Override


Mime
View raw message