Repository: incubator-blur Updated Branches: refs/heads/master 5d064cbed -> 897e95b74
Fix blur-console memory leak closes apache/incubator-blur#4 Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/897e95b7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/897e95b7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/897e95b7 Branch: refs/heads/master Commit: 897e95b744247007863b50d241e739eef269026e Parents: 5d064cb Author: Chris Rohr <[email protected]> Authored: Sun Oct 26 14:28:50 2014 -0400 Committer: Chris Rohr <[email protected]> Committed: Sun Oct 26 14:28:50 2014 -0400 ---------------------------------------------------------------------- .../blur/console/util/CachingBlurClient.java | 40 ++++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/897e95b7/blur-console/src/main/java/org/apache/blur/console/util/CachingBlurClient.java ---------------------------------------------------------------------- diff --git a/blur-console/src/main/java/org/apache/blur/console/util/CachingBlurClient.java b/blur-console/src/main/java/org/apache/blur/console/util/CachingBlurClient.java index f722330..5bc048b 100644 --- a/blur-console/src/main/java/org/apache/blur/console/util/CachingBlurClient.java +++ b/blur-console/src/main/java/org/apache/blur/console/util/CachingBlurClient.java @@ -71,16 +71,20 @@ public class CachingBlurClient { public void run() { boolean run = true; while (run) { - cleanup(clusterListCache); - cleanup(tableListCache); - cleanup(queryListCache); - cleanup(queryStatusCache); - cleanup(tableDescriptionCache); - cleanup(tableStatsCache); - cleanup(schemaCache); - cleanup(controllerListCache); - cleanup(shardListCache); - log.info("Cache: " + cacheHits + " hits, " + cacheMisses + " misses"); + try { + cleanup(clusterListCache); + cleanup(tableListCache); + cleanup(queryListCache); + cleanup(queryStatusCache); + cleanup(tableDescriptionCache); + cleanup(tableStatsCache); + cleanup(schemaCache); + cleanup(controllerListCache); + cleanup(shardListCache); + log.info("Cache: " + cacheHits + " hits, " + cacheMisses + " misses"); + } catch (Exception e) { + log.error("Error cleaning up all caches", e); + } try { Thread.sleep(timeout * 2); } catch (InterruptedException e) { @@ -96,14 +100,18 @@ public class CachingBlurClient { private void cleanup(Map<String, Item> cache) { if (cache != null) { - synchronized (cache) { - Iterator<Map.Entry<String, Item>> iterator = cache.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry<String, Item> entry = iterator.next(); - if (entry.getValue().expired(timeout)) { - iterator.remove(); + try { + synchronized (cache) { + Iterator<Map.Entry<String, Item>> iterator = cache.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry<String, Item> entry = iterator.next(); + if (entry.getValue().expired(timeout)) { + iterator.remove(); + } } } + } catch (Exception e) { + log.error("Error cleaning up cache", e); } } }
