incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fixed BLUR-417
Date Mon, 16 Mar 2015 13:36:34 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master 177d09795 -> dede09fc1


Fixed BLUR-417


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

Branch: refs/heads/master
Commit: dede09fc10fb543e7b6d67d1e9fc772c2f64f574
Parents: 177d097
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Mar 16 09:36:30 2015 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Mar 16 09:36:30 2015 -0400

----------------------------------------------------------------------
 .../org/apache/blur/server/cache/ShardsKey.java | 61 ++++++++++++++
 .../apache/blur/server/cache/ThriftCache.java   | 84 +++++++++++++++++++-
 .../blur/server/cache/ThriftCacheKey.java       | 50 +++++-------
 .../blur/server/cache/ThriftCacheKeyTest.java   | 81 ++++++++-----------
 .../apache/blur/metrics/MetricsConstants.java   |  2 +
 5 files changed, 200 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/dede09fc/blur-core/src/main/java/org/apache/blur/server/cache/ShardsKey.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/server/cache/ShardsKey.java b/blur-core/src/main/java/org/apache/blur/server/cache/ShardsKey.java
new file mode 100644
index 0000000..7d7f930
--- /dev/null
+++ b/blur-core/src/main/java/org/apache/blur/server/cache/ShardsKey.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.blur.server.cache;
+
+import java.util.Arrays;
+
+public class ShardsKey {
+
+  private final int[] _shards;
+
+  public ShardsKey(int[] shards) {
+    Arrays.sort(shards);
+    _shards = shards;
+  }
+
+  public int[] getShards() {
+    return _shards;
+  }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + Arrays.hashCode(_shards);
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (getClass() != obj.getClass())
+      return false;
+    ShardsKey other = (ShardsKey) obj;
+    if (!Arrays.equals(_shards, other._shards))
+      return false;
+    return true;
+  }
+
+  @Override
+  public String toString() {
+    return "ShardKey [_shards=" + Arrays.toString(_shards) + "]";
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/dede09fc/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 3050d1e..8b377cc 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,20 @@
  */
 package org.apache.blur.server.cache;
 
-import static org.apache.blur.metrics.MetricsConstants.*;
+import static org.apache.blur.metrics.MetricsConstants.COUNT;
+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.SIZE;
+import static org.apache.blur.metrics.MetricsConstants.THRIFT_CACHE;
+import static org.apache.blur.metrics.MetricsConstants.THRIFT_CACHE_ATTRIBUTE_MAP;
 
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.TimeUnit;
@@ -35,6 +44,7 @@ import org.apache.blur.trace.Tracer;
 import org.apache.blur.user.User;
 import org.apache.blur.user.UserContext;
 
+import com.google.common.collect.MapMaker;
 import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
 import com.googlecode.concurrentlinkedhashmap.EntryWeigher;
 import com.googlecode.concurrentlinkedhashmap.EvictionListener;
@@ -57,6 +67,9 @@ public class ThriftCache {
   private static final Log LOG = LogFactory.getLog(ThriftCache.class);
 
   private final ConcurrentLinkedHashMap<ThriftCacheKey<?>, ThriftCacheValue<?>>
_cacheMap;
+  private final ConcurrentMap<Map<String, String>, Map<String, String>>
_attributeKeys;
+  private final ConcurrentMap<ShardsKey, ShardsKey> _shardsKeys;
+  private final ConcurrentMap<String, ClassObj<?>> _classObjMap = new ConcurrentHashMap<String,
ClassObj<?>>();
   private final ConcurrentMap<String, Long> _lastModTimestamps = new ConcurrentHashMap<String,
Long>();
   private final Meter _hits;
   private final Meter _misses;
@@ -66,6 +79,8 @@ public class ThriftCache {
   private final AtomicLong _evictionsAtomicLong;
 
   public ThriftCache(long totalNumberOfBytes) {
+    _attributeKeys = new MapMaker().weakKeys().makeMap();
+    _shardsKeys = new MapMaker().weakKeys().makeMap();
     _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);
@@ -75,6 +90,18 @@ public class ThriftCache {
         return _cacheMap.weightedSize();
       }
     });
+    Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, THRIFT_CACHE, COUNT), new Gauge<Long>()
{
+      @Override
+      public Long value() {
+        return (long) _cacheMap.size();
+      }
+    });
+    Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, THRIFT_CACHE_ATTRIBUTE_MAP, COUNT),
new Gauge<Long>() {
+      @Override
+      public Long value() {
+        return (long) _attributeKeys.size();
+      }
+    });
     _cacheMap = new ConcurrentLinkedHashMap.Builder<ThriftCacheKey<?>, ThriftCacheValue<?>>()
         .weigher(new EntryWeigher<ThriftCacheKey<?>, ThriftCacheValue<?>>()
{
           @Override
@@ -140,12 +167,65 @@ public class ThriftCache {
         Trace.param(T_KEY, tkey), Trace.param(CLASS, clazz));
     try {
       User user = UserContext.getUser();
-      return new ThriftCacheKey<K>(user, table, shards, tkey, clazz);
+      Map<String, String> userAttributes = getUserAttributes(user);
+      ClassObj<K> classObj = getClassObj(clazz);
+      ShardsKey shardsKey = getShardsKey(shards);
+      return new ThriftCacheKey<K>(userAttributes, table, shardsKey, tkey, classObj);
     } finally {
       trace.done();
     }
   }
 
+  private ShardsKey getShardsKey(int[] shards) {
+    ShardsKey shardsKey = new ShardsKey(shards);
+    ShardsKey insternalShardsKey = _shardsKeys.get(shardsKey);
+    if (insternalShardsKey != null) {
+      return insternalShardsKey;
+    }
+    insternalShardsKey = _shardsKeys.putIfAbsent(shardsKey, shardsKey);
+    if (insternalShardsKey == null) {
+      return shardsKey;
+    } else {
+      return insternalShardsKey;
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private <T> ClassObj<T> getClassObj(Class<T> clazz) {
+    String name = clazz.getName();
+    ClassObj<T> classObj = (ClassObj<T>) _classObjMap.get(name);
+    if (classObj != null) {
+      return classObj;
+    }
+    classObj = new ClassObj<T>(clazz);
+    ClassObj<T> currentValue = (ClassObj<T>) _classObjMap.putIfAbsent(name, classObj);
+    if (currentValue == null) {
+      return classObj;
+    }
+    return currentValue;
+  }
+
+  private Map<String, String> getUserAttributes(User user) {
+    if (user == null) {
+      return null;
+    }
+    Map<String, String> attributes = user.getAttributes();
+    if (attributes == null) {
+      return null;
+    }
+    if (!(attributes instanceof TreeMap)) {
+      attributes = new TreeMap<String, String>();
+    }
+    Map<String, String> internalInstance = _attributeKeys.get(attributes);
+    if (internalInstance == null) {
+      internalInstance = _attributeKeys.putIfAbsent(attributes, attributes);
+      if (internalInstance == null) {
+        return attributes;
+      }
+    }
+    return internalInstance;
+  }
+
   public void clearTable(String table) {
     synchronized (_lastModTimestamps) {
       _lastModTimestamps.put(table, System.nanoTime());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/dede09fc/blur-core/src/main/java/org/apache/blur/server/cache/ThriftCacheKey.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/server/cache/ThriftCacheKey.java b/blur-core/src/main/java/org/apache/blur/server/cache/ThriftCacheKey.java
index 5c55ecf..6f9fced 100644
--- a/blur-core/src/main/java/org/apache/blur/server/cache/ThriftCacheKey.java
+++ b/blur-core/src/main/java/org/apache/blur/server/cache/ThriftCacheKey.java
@@ -16,38 +16,30 @@
  */
 package org.apache.blur.server.cache;
 
-import java.util.Arrays;
 import java.util.Map;
-import java.util.TreeMap;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TBase;
 import org.apache.blur.thrift.generated.BlurException;
-import org.apache.blur.user.User;
 
 public class ThriftCacheKey<T extends TBase<?, ?>> {
 
+  // * bytes for Object plus 8 bytes per reference plus 8 bytes for timestamp.
+  private static final int OVERHEAD = 8 + (5 * 8) + 8;
+
   private final Map<String, String> _attributes;
   private final String _table;
-  private final int[] _shards;
+  private final ShardsKey _shards;
   private final ClassObj<T> _clazz;
   private final ThriftCacheValue<T> _key;
 
   // not apart of the key for equally
   private final transient long _timestamp;
 
-  public ThriftCacheKey(User user, String table, int[] shards, T t, Class<T> clazz)
throws BlurException {
+  public ThriftCacheKey(Map<String, String> userAttributes, String table, ShardsKey
shards, T t, ClassObj<T> clazz)
+      throws BlurException {
     _timestamp = System.nanoTime();
-    _clazz = new ClassObj<T>(clazz);
-    if (user != null) {
-      Map<String, String> attributes = user.getAttributes();
-      if (attributes == null) {
-        _attributes = attributes;
-      } else {
-        _attributes = new TreeMap<String, String>(user.getAttributes());
-      }
-    } else {
-      _attributes = null;
-    }
+    _clazz = clazz;
+    _attributes = userAttributes;
     _table = table;
     _shards = shards;
     _key = new ThriftCacheValue<T>(t);
@@ -61,19 +53,8 @@ public class ThriftCacheKey<T extends TBase<?, ?>> {
     return _table;
   }
 
-  @Override
-  public String toString() {
-    try {
-      return "ThriftCacheKey [_attributes=" + _attributes + ", _table=" + _table
-          + ", _shards=" + Arrays.toString(_shards) + ", _clazz=" + _clazz + ", _key="
-          + _key.getValue(_clazz.getClazz()) + ", _timestamp=" + _timestamp + "]";
-    } catch (BlurException e) {
-      throw new RuntimeException(e);
-    }
-  }
-
   public int size() {
-    return _key.size();
+    return _key.size() + OVERHEAD;
   }
 
   @Override
@@ -83,7 +64,7 @@ public class ThriftCacheKey<T extends TBase<?, ?>> {
     result = prime * result + ((_attributes == null) ? 0 : _attributes.hashCode());
     result = prime * result + ((_clazz == null) ? 0 : _clazz.hashCode());
     result = prime * result + ((_key == null) ? 0 : _key.hashCode());
-    result = prime * result + Arrays.hashCode(_shards);
+    result = prime * result + ((_shards == null) ? 0 : _shards.hashCode());
     result = prime * result + ((_table == null) ? 0 : _table.hashCode());
     return result;
   }
@@ -112,7 +93,10 @@ public class ThriftCacheKey<T extends TBase<?, ?>> {
         return false;
     } else if (!_key.equals(other._key))
       return false;
-    if (!Arrays.equals(_shards, other._shards))
+    if (_shards == null) {
+      if (other._shards != null)
+        return false;
+    } else if (!_shards.equals(other._shards))
       return false;
     if (_table == null) {
       if (other._table != null)
@@ -122,4 +106,10 @@ public class ThriftCacheKey<T extends TBase<?, ?>> {
     return true;
   }
 
+  @Override
+  public String toString() {
+    return "ThriftCacheKey [_attributes=" + _attributes + ", _table=" + _table + ", _shards="
+ _shards + ", _clazz="
+        + _clazz + ", _key=" + _key + ", _timestamp=" + _timestamp + "]";
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/dede09fc/blur-core/src/test/java/org/apache/blur/server/cache/ThriftCacheKeyTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/server/cache/ThriftCacheKeyTest.java
b/blur-core/src/test/java/org/apache/blur/server/cache/ThriftCacheKeyTest.java
index a3416f9..1741da4 100644
--- a/blur-core/src/test/java/org/apache/blur/server/cache/ThriftCacheKeyTest.java
+++ b/blur-core/src/test/java/org/apache/blur/server/cache/ThriftCacheKeyTest.java
@@ -16,7 +16,9 @@
  */
 package org.apache.blur.server.cache;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -25,21 +27,19 @@ import java.util.TreeSet;
 
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurQuery;
-import org.apache.blur.user.User;
 import org.junit.Test;
 
 public class ThriftCacheKeyTest {
 
   @Test
   public void test1() throws BlurException {
-    User user = null;
     String table = "t";
     BlurQuery bq1 = new BlurQuery();
     BlurQuery bq2 = new BlurQuery();
-    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(user, table,
new int[] { 0, 1 }, bq1,
-        BlurQuery.class);
-    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(user, table,
new int[] { 0, 1 }, bq2,
-        BlurQuery.class);
+    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(null, table,
new ShardsKey(new int[] { 0, 1 }), bq1,
+        new ClassObj<BlurQuery>(BlurQuery.class));
+    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(null, table,
new ShardsKey(new int[] { 0, 1 }), bq2,
+        new ClassObj<BlurQuery>(BlurQuery.class));
 
     assertEquals(key1, key2);
     assertEquals(key1.hashCode(), key2.hashCode());
@@ -47,12 +47,11 @@ public class ThriftCacheKeyTest {
 
   @Test
   public void test2() throws BlurException {
-    User user = null;
     String table = "t";
-    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(user, table,
new int[] { 0, 1 }, null,
-        BlurQuery.class);
-    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(user, table,
new int[] { 0, 1 }, null,
-        BlurQuery.class);
+    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(null, table,
new ShardsKey(new int[] { 0, 1 }),
+        null, new ClassObj<BlurQuery>(BlurQuery.class));
+    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(null, table,
new ShardsKey(new int[] { 0, 1 }),
+        null, new ClassObj<BlurQuery>(BlurQuery.class));
 
     assertEquals(key1, key2);
     assertEquals(key1.hashCode(), key2.hashCode());
@@ -60,14 +59,13 @@ public class ThriftCacheKeyTest {
 
   @Test
   public void test3() throws BlurException {
-    User user = new User("test", null);
     String table = "t";
     BlurQuery bq1 = new BlurQuery();
     BlurQuery bq2 = new BlurQuery();
-    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(user, table,
new int[] { 0, 1 }, bq1,
-        BlurQuery.class);
-    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(user, table,
new int[] { 0, 1 }, bq2,
-        BlurQuery.class);
+    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(null, table,
new ShardsKey(new int[] { 0, 1 }), bq1,
+        new ClassObj<BlurQuery>(BlurQuery.class));
+    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(null, table,
new ShardsKey(new int[] { 0, 1 }), bq2,
+        new ClassObj<BlurQuery>(BlurQuery.class));
 
     assertEquals(key1, key2);
     assertEquals(key1.hashCode(), key2.hashCode());
@@ -75,14 +73,13 @@ public class ThriftCacheKeyTest {
 
   @Test
   public void test4() throws BlurException {
-    User user = new User("test", map("a", "b"));
     String table = "t";
     BlurQuery bq1 = new BlurQuery();
     BlurQuery bq2 = new BlurQuery();
-    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(user, table,
new int[] { 0, 1 }, bq1,
-        BlurQuery.class);
-    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(user, table,
new int[] { 0, 1 }, bq2,
-        BlurQuery.class);
+    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(map("a", "b"),
table, new ShardsKey(
+        new int[] { 0, 1 }), bq1, new ClassObj<BlurQuery>(BlurQuery.class));
+    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(map("a", "b"),
table, new ShardsKey(
+        new int[] { 0, 1 }), bq2, new ClassObj<BlurQuery>(BlurQuery.class));
 
     assertEquals(key1, key2);
     assertEquals(key1.hashCode(), key2.hashCode());
@@ -90,30 +87,26 @@ public class ThriftCacheKeyTest {
 
   @Test
   public void test5a() throws BlurException {
-    User user1 = new User("test1", null);
-    User user2 = new User("test2", null);
     String table = "t";
     BlurQuery bq1 = new BlurQuery();
     BlurQuery bq2 = new BlurQuery();
-    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(user1, table,
new int[] { 0, 1 }, bq1,
-        BlurQuery.class);
-    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(user2, table,
new int[] { 0, 1 }, bq2,
-        BlurQuery.class);
+    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(null, table,
new ShardsKey(new int[] { 0, 1 }), bq1,
+        new ClassObj<BlurQuery>(BlurQuery.class));
+    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(null, table,
new ShardsKey(new int[] { 0, 1 }), bq2,
+        new ClassObj<BlurQuery>(BlurQuery.class));
     assertTrue(key1.equals(key2));
     assertTrue(key1.hashCode() == key2.hashCode());
   }
 
   @Test
   public void test5b() throws BlurException {
-    User user1 = new User("test1", null);
-    User user2 = new User("test1", null);
     String table = "t";
     BlurQuery bq1 = new BlurQuery();
     BlurQuery bq2 = new BlurQuery();
-    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(user1, table,
new int[] { 0, 1 }, bq1,
-        BlurQuery.class);
-    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(user2, table,
new int[] { 0, 2 }, bq2,
-        BlurQuery.class);
+    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(null, table,
new ShardsKey(new int[] { 0, 1 }), bq1,
+        new ClassObj<BlurQuery>(BlurQuery.class));
+    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(null, table,
new ShardsKey(new int[] { 0, 2 }), bq2,
+        new ClassObj<BlurQuery>(BlurQuery.class));
 
     assertFalse(key1.equals(key2));
     assertFalse(key1.hashCode() == key2.hashCode());
@@ -121,15 +114,13 @@ public class ThriftCacheKeyTest {
 
   @Test
   public void test6() throws BlurException {
-    User user1 = new User("test1", map("a", "b"));
-    User user2 = new User("test1", map("a", "c"));
     String table = "t";
     BlurQuery bq1 = new BlurQuery();
     BlurQuery bq2 = new BlurQuery();
-    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(user1, table,
new int[] { 0, 1 }, bq1,
-        BlurQuery.class);
-    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(user2, table,
new int[] { 0, 1 }, bq2,
-        BlurQuery.class);
+    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(map("a", "b"),
table, new ShardsKey(
+        new int[] { 0, 1 }), bq1, new ClassObj<BlurQuery>(BlurQuery.class));
+    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(map("a", "c"),
table, new ShardsKey(
+        new int[] { 0, 1 }), bq2, new ClassObj<BlurQuery>(BlurQuery.class));
 
     assertFalse(key1.equals(key2));
     assertFalse(key1.hashCode() == key2.hashCode());
@@ -137,15 +128,13 @@ public class ThriftCacheKeyTest {
 
   @Test
   public void test7() throws BlurException {
-    User user1 = new User("test1", map("a", "b"));
-    User user2 = new User("test2", map("a", "b"));
     String table = "t";
     BlurQuery bq1 = new BlurQuery();
     BlurQuery bq2 = new BlurQuery();
-    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(user1, table,
new int[] { 0, 1 }, bq1,
-        BlurQuery.class);
-    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(user2, table,
new int[] { 0, 1 }, bq2,
-        BlurQuery.class);
+    ThriftCacheKey<BlurQuery> key1 = new ThriftCacheKey<BlurQuery>(map("a", "b"),
table, new ShardsKey(
+        new int[] { 0, 1 }), bq1, new ClassObj<BlurQuery>(BlurQuery.class));
+    ThriftCacheKey<BlurQuery> key2 = new ThriftCacheKey<BlurQuery>(map("a", "b"),
table, new ShardsKey(
+        new int[] { 0, 1 }), bq2, new ClassObj<BlurQuery>(BlurQuery.class));
 
     assertTrue(key1.equals(key2));
     assertTrue(key1.hashCode() == key2.hashCode());

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/dede09fc/blur-util/src/main/java/org/apache/blur/metrics/MetricsConstants.java
----------------------------------------------------------------------
diff --git a/blur-util/src/main/java/org/apache/blur/metrics/MetricsConstants.java b/blur-util/src/main/java/org/apache/blur/metrics/MetricsConstants.java
index da6f874..da52617 100644
--- a/blur-util/src/main/java/org/apache/blur/metrics/MetricsConstants.java
+++ b/blur-util/src/main/java/org/apache/blur/metrics/MetricsConstants.java
@@ -46,6 +46,8 @@ public class MetricsConstants {
   public static final String MISS = "Miss";
   public static final String CACHE = "Cache";
   public static final String THRIFT_CACHE = "ThriftCache";
+  public static final String COUNT = "Count";
+  public static final String THRIFT_CACHE_ATTRIBUTE_MAP = "ThriftCacheAttributeMap";
   public static final String HDFS_KV = "HDFS-KV";
   public static final String DEEP_PAGING_CACHE = "DeepPagingCache";
   public static final String CACHE_POOL = "CachePool";


Mime
View raw message