From 0bacb85a4a7e62202d1618c548c980ec50ba653b Mon Sep 17 00:00:00 2001 From: xvrl Date: Wed, 16 Jan 2013 19:18:14 -0800 Subject: [PATCH] fix duplicate keys, shutdown gracefully and make sure we check all multiget keys in memcached benchmark --- .../client/cache/MemcachedCacheBrokerBenchmark.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/test/java/com/metamx/druid/client/cache/MemcachedCacheBrokerBenchmark.java b/client/src/test/java/com/metamx/druid/client/cache/MemcachedCacheBrokerBenchmark.java index d0b34af57df..14bd9fdc998 100644 --- a/client/src/test/java/com/metamx/druid/client/cache/MemcachedCacheBrokerBenchmark.java +++ b/client/src/test/java/com/metamx/druid/client/cache/MemcachedCacheBrokerBenchmark.java @@ -44,8 +44,6 @@ public class MemcachedCacheBrokerBenchmark extends SimpleBenchmark // disable compression transcoder.setCompressionThreshold(Integer.MAX_VALUE); - System.out.println(String.format("Using memcached hosts [%s]", hosts)); - client = new MemcachedClient( new ConnectionFactoryBuilder().setProtocol(ConnectionFactoryBuilder.Protocol.BINARY) .setHashAlg(DefaultHashAlgorithm.FNV1A_64_HASH) @@ -72,14 +70,13 @@ public class MemcachedCacheBrokerBenchmark extends SimpleBenchmark @Override protected void tearDown() throws Exception { - client.flush(); - client.shutdown(); + client.shutdown(1, TimeUnit.MINUTES); } public void timePutObjects(int reps) { for(int i = 0; i < reps; ++i) { for(int k = 0; k < objectCount; ++k) { - String key = BASE_KEY + i; + String key = BASE_KEY + k; cache.put(IDENTIFIER, key.getBytes(), randBytes); } // make sure the write queue is empty @@ -109,7 +106,10 @@ public class MemcachedCacheBrokerBenchmark extends SimpleBenchmark keys.add(Pair.of(IDENTIFIER, ByteBuffer.wrap(key.getBytes()))); } Map, byte[]> results = cache.getBulk(keys); - for(byte[] bytes : results.values()) count += bytes.length; + for(Pair key : keys) { + byte[] bytes = results.get(key); + count += bytes.length; + } } return count; }