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 thrift cache size as a metric.
Date Sun, 01 Mar 2015 19:04:40 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master 5f16374ef -> a8413052c


Adding thrift cache size as a metric.


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

Branch: refs/heads/master
Commit: a8413052cc56e2b5bba117d62fae861b68313799
Parents: 5f16374
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Mar 1 14:04:38 2015 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Mar 1 14:04:38 2015 -0500

----------------------------------------------------------------------
 .../org/apache/blur/server/cache/ThriftCache.java   | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/a8413052/blur-core/src/main/java/org/apache/blur/server/cache/ThriftCache.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/server/cache/ThriftCache.java b/blur-core/src/main/java/org/apache/blur/server/cache/ThriftCache.java
index 7093a6a..bf6237b 100644
--- a/blur-core/src/main/java/org/apache/blur/server/cache/ThriftCache.java
+++ b/blur-core/src/main/java/org/apache/blur/server/cache/ThriftCache.java
@@ -16,11 +16,7 @@
  */
 package org.apache.blur.server.cache;
 
-import static org.apache.blur.metrics.MetricsConstants.EVICTION;
-import static org.apache.blur.metrics.MetricsConstants.HIT;
-import static org.apache.blur.metrics.MetricsConstants.MISS;
-import static org.apache.blur.metrics.MetricsConstants.ORG_APACHE_BLUR;
-import static org.apache.blur.metrics.MetricsConstants.THRIFT_CACHE;
+import static org.apache.blur.metrics.MetricsConstants.*;
 
 import java.util.Iterator;
 import java.util.Map.Entry;
@@ -41,6 +37,7 @@ import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
 import com.googlecode.concurrentlinkedhashmap.EntryWeigher;
 import com.googlecode.concurrentlinkedhashmap.EvictionListener;
 import com.yammer.metrics.Metrics;
+import com.yammer.metrics.core.Gauge;
 import com.yammer.metrics.core.Meter;
 import com.yammer.metrics.core.MetricName;
 
@@ -61,6 +58,12 @@ public class ThriftCache {
     _hits = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, THRIFT_CACHE, HIT), HIT, TimeUnit.SECONDS);
     _misses = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, THRIFT_CACHE, MISS), MISS,
TimeUnit.SECONDS);
     _evictions = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, THRIFT_CACHE, EVICTION),
EVICTION, TimeUnit.SECONDS);
+    Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, THRIFT_CACHE, SIZE), new Gauge<Long>()
{
+      @Override
+      public Long value() {
+        return _cacheMap.weightedSize();
+      }
+    });
     _cacheMap = new ConcurrentLinkedHashMap.Builder<ThriftCacheKey<?>, ThriftCacheValue<?>>()
         .weigher(new EntryWeigher<ThriftCacheKey<?>, ThriftCacheValue<?>>()
{
           @Override
@@ -110,7 +113,8 @@ public class ThriftCache {
     return value.getValue(clazz);
   }
 
-  public <K extends TBase<?, ?>> ThriftCacheKey<K> getKey(String table,
int[] shards, K tkey, Class<K> clazz) throws BlurException {
+  public <K extends TBase<?, ?>> ThriftCacheKey<K> getKey(String table,
int[] shards, K tkey, Class<K> clazz)
+      throws BlurException {
     User user = UserContext.getUser();
     return new ThriftCacheKey<K>(user, table, shards, tkey, clazz);
   }


Mime
View raw message