incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [07/27] git commit: Added write metrics for mutations.
Date Fri, 09 Aug 2013 17:24:12 GMT
Added write metrics for mutations.


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

Branch: refs/heads/0.2.0-newtypesystem
Commit: 92577b413712e8ac6daa60eb85cc90af3e49d0a6
Parents: e4cdf5d
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Wed Aug 7 10:50:00 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Aug 7 10:50:00 2013 -0400

----------------------------------------------------------------------
 .../org/apache/blur/manager/IndexManager.java   | 32 +++++++++++++-------
 .../java/org/apache/blur/shell/TopCommand.java  | 18 +++++++++++
 .../org/apache/blur/shell/top.properties        |  8 ++++-
 3 files changed, 46 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/92577b41/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
index 3ad2502..9c04cbb 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
@@ -137,8 +137,10 @@ public class IndexManager {
   private BlurPartitioner _blurPartitioner = new BlurPartitioner();
   private BlurFilterCache _filterCache = new DefaultBlurFilterCache();
   private long _defaultParallelCallTimeout = TimeUnit.MINUTES.toMillis(1);
-  private Meter _recordsMeter;
-  private Meter _rowMeter;
+  private Meter _readRecordsMeter;
+  private Meter _readRowMeter;
+  private Meter _writeRecordsMeter;
+  private Meter _writeRowMeter;
   private Meter _queriesExternalMeter;
   private Meter _queriesInternalMeter;
   private Timer _fetchTimer;
@@ -152,9 +154,11 @@ public class IndexManager {
   }
 
   public void init() {
-    _recordsMeter = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, BLUR, "Read Records/s"),
"Records/s",
-        TimeUnit.SECONDS);
-    _rowMeter = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, BLUR, "Read Row/s"), "Row/s",
TimeUnit.SECONDS);
+    _readRecordsMeter = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, BLUR, "Read Records/s"),
"Records/s", TimeUnit.SECONDS);
+    _readRowMeter = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, BLUR, "Read Row/s"),
"Row/s", TimeUnit.SECONDS);
+    _writeRecordsMeter = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, BLUR, "Write Records/s"),
"Records/s", TimeUnit.SECONDS);
+    _writeRowMeter = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, BLUR, "Write Row/s"),
"Row/s", TimeUnit.SECONDS);
+    
     _queriesExternalMeter = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, BLUR, "External
Queries/s"),
         "External Queries/s", TimeUnit.SECONDS);
     _queriesInternalMeter = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, BLUR, "Internal
Queries/s"),
@@ -234,11 +238,11 @@ public class IndexManager {
       fetchRow(searcher.getIndexReader(), table, shard, selector, fetchResult, highlightQuery,
analyzer, _maxHeapPerRowFetch);
       if (fetchResult.rowResult != null) {
         if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records
!= null) {
-          _recordsMeter.mark(fetchResult.rowResult.row.records.size());
+          _readRecordsMeter.mark(fetchResult.rowResult.row.records.size());
         }
-        _rowMeter.mark();
+        _readRowMeter.mark();
       } else if (fetchResult.recordResult != null) {
-        _recordsMeter.mark();
+        _readRecordsMeter.mark();
       }
     } catch (Exception e) {
       LOG.error("Unknown error while trying to fetch row.", e);
@@ -899,7 +903,7 @@ public class IndexManager {
       switch (type) {
       case REPLACE_ROW:
         Row row = MutationHelper.getRowFromMutations(mutation.rowId, mutation.recordMutations);
-        blurIndex.replaceRow(waitVisiblity, mutation.wal, row);
+        blurIndex.replaceRow(waitVisiblity, mutation.wal, updateMetrics(row));
         break;
       case UPDATE_ROW:
         doUpdateRowMutation(mutation, blurIndex);
@@ -943,7 +947,7 @@ public class IndexManager {
     switch (type) {
     case REPLACE_ROW:
       Row row = MutationHelper.getRowFromMutations(mutation.rowId, mutation.recordMutations);
-      blurIndex.replaceRow(mutation.waitToBeVisible, mutation.wal, row);
+      blurIndex.replaceRow(mutation.waitToBeVisible, mutation.wal, updateMetrics(row));
       break;
     case UPDATE_ROW:
       doUpdateRowMutation(mutation, blurIndex);
@@ -956,6 +960,12 @@ public class IndexManager {
     }
   }
 
+  private Row updateMetrics(Row row) {
+    _writeRowMeter.mark();
+    _writeRecordsMeter.mark(row.getRecords().size());
+    return row;
+  }
+
   private void doUpdateRowMutation(RowMutation mutation, BlurIndex blurIndex) throws BlurException,
IOException {
     FetchResult fetchResult = new FetchResult();
     Selector selector = new Selector();
@@ -1009,7 +1019,7 @@ public class IndexManager {
       }
 
       // Finally, replace the existing row with the new row we have built.
-      blurIndex.replaceRow(mutation.waitToBeVisible, mutation.wal, newRow);
+      blurIndex.replaceRow(mutation.waitToBeVisible, mutation.wal, updateMetrics(newRow));
     } else {
       throw new BException("Mutation cannot update row that does not exist.", mutation);
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/92577b41/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 f325bdb..c7e952b 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
@@ -162,6 +162,7 @@ public class TopCommand extends Command {
     }
 
     do {
+      int lineCount = 0;
       StringBuilder output = new StringBuilder();
       if (quit.get()) {
         return;
@@ -169,6 +170,8 @@ public class TopCommand extends Command {
         showHelp(output, labels, helpMap);
       } 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()) {
           String shardServer = e.getKey();
@@ -177,6 +180,10 @@ public class TopCommand extends Command {
           if (metrics == null) {
             String line = String.format("%" + longestServerName + "s*%n", shardServer);
             output.append(line);
+            lineCount++;
+            if (tooLong(lineCount)) {
+              break SERVER;
+            }
           } else {
             Object[] cols = new Object[labels.length];
             int c = 0;
@@ -195,6 +202,10 @@ public class TopCommand extends Command {
               sb.append(" %10s");
             }
             output.append(truncate(String.format(sb.toString(), cols)) + "\n");
+            lineCount++;
+            if (tooLong(lineCount)) {
+              break SERVER;
+            }
           }
         }
       }
@@ -231,6 +242,13 @@ public class TopCommand extends Command {
     } while (reader != null);
   }
 
+  private boolean tooLong(int lineCount) {
+    if (lineCount >= _height) {
+      return true;
+    }
+    return false;
+  }
+
   private boolean isHelpName(String key) {
     return key.endsWith(HELP);
   }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/92577b41/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 e153ada..c1d765c 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
@@ -1,4 +1,4 @@
-top.columns=SHARD_SERVER,SL,HU,IM,EQ,IQ,RO,RE,CH,CM,CE,CS,TC,IC,SC
+top.columns=SHARD_SERVER,SL,HU,IM,EQ,IQ,RO,RE,WO,WE,CH,CM,CE,CS,TC,IC,SC
 top.sizes=IM,SL
 
 top.SHARD_SERVER.shortname=Shard Server
@@ -6,8 +6,10 @@ top.SC.shortname=seg cnt
 top.IC.shortname=idx cnt
 top.TC.shortname=tble cnt
 top.RE.shortname=rd rec
+top.WE.shortname=wr rec
 top.IM.shortname=idx mem
 top.RO.shortname=rd row
+top.WO.shortname=wr row
 top.CS.shortname=bc size
 top.CE.shortname=bc evt
 top.CM.shortname=bc miss
@@ -25,7 +27,9 @@ 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.WE.longname="org.apache.blur":type="Blur",name="Write Records/s"
 top.RO.longname="org.apache.blur":type="Blur",name="Read Row/s"
+top.WO.longname="org.apache.blur":type="Blur",name="Write 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"
@@ -42,6 +46,8 @@ top.CE.help=Block Cache Evictions/s - The number of 8k block evictions (One
Minu
 top.CS.help=Block Cache Size - The total block size
 top.RE.help=Read Records/s - The number of records read per second (One Minute Average)
 top.RO.help=Read Row/s - The number of rows read per second (One Minute Average)
+top.WE.help=Write Records/s - The number of records write per second (One Minute Average)
+top.WO.help=Write Row/s - The number of rows write per second (One Minute Average)
 top.IM.help=Index Memory Usage - The index heap usage
 top.TC.help=Table Count - The number of tables
 top.IC.help=Index Count - The number of indexes


Mime
View raw message