Repository: incubator-blur Updated Branches: refs/heads/master fb0368de8 -> 36b2cda32
Fixing bug in cache value buffer pool where every block allocation was creating a new array blocking queue. Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/36b2cda3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/36b2cda3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/36b2cda3 Branch: refs/heads/master Commit: 36b2cda32efd48f78de9f146e4b2119e94eac360 Parents: fb0368d Author: Aaron McCurry <[email protected]> Authored: Thu Feb 5 08:27:21 2015 -0500 Committer: Aaron McCurry <[email protected]> Committed: Thu Feb 5 08:27:21 2015 -0500 ---------------------------------------------------------------------- .../blur/store/blockcache_v2/CacheValueBufferPool.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/36b2cda3/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/CacheValueBufferPool.java ---------------------------------------------------------------------- diff --git a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/CacheValueBufferPool.java b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/CacheValueBufferPool.java index 968edab..7cfbd0c 100644 --- a/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/CacheValueBufferPool.java +++ b/blur-store/src/main/java/org/apache/blur/store/blockcache_v2/CacheValueBufferPool.java @@ -30,6 +30,8 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; +import org.apache.blur.log.Log; +import org.apache.blur.log.LogFactory; import org.apache.blur.store.blockcache_v2.BaseCache.STORE; import org.apache.blur.store.blockcache_v2.cachevalue.ByteArrayCacheValue; import org.apache.blur.store.blockcache_v2.cachevalue.UnsafeCacheValue; @@ -40,6 +42,8 @@ import com.yammer.metrics.core.MetricName; public class CacheValueBufferPool implements Closeable { + private static final Log LOG = LogFactory.getLog(CacheValueBufferPool.class); + private final STORE _store; private final ConcurrentMap<Integer, BlockingQueue<CacheValue>> _cacheValuePool = new ConcurrentHashMap<Integer, BlockingQueue<CacheValue>>(); private final int _capacity; @@ -67,7 +71,7 @@ public class CacheValueBufferPool implements Closeable { } private BlockingQueue<CacheValue> getPool(int cacheBlockSize) { - BlockingQueue<CacheValue> blockingQueue = _cacheValuePool.get(_cacheValuePool); + BlockingQueue<CacheValue> blockingQueue = _cacheValuePool.get(cacheBlockSize); if (blockingQueue == null) { blockingQueue = buildNewBlockQueue(cacheBlockSize); } @@ -75,7 +79,9 @@ public class CacheValueBufferPool implements Closeable { } private BlockingQueue<CacheValue> buildNewBlockQueue(int cacheBlockSize) { - _cacheValuePool.putIfAbsent(cacheBlockSize, new ArrayBlockingQueue<CacheValue>(_capacity)); + LOG.info("Allocating new ArrayBlockingQueue with capacity [{0}]", _capacity); + BlockingQueue<CacheValue> value = new ArrayBlockingQueue<CacheValue>(_capacity); + _cacheValuePool.putIfAbsent(cacheBlockSize, value); return _cacheValuePool.get(cacheBlockSize); }
