Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A1DC9D018 for ; Mon, 2 Jul 2012 17:57:40 +0000 (UTC) Received: (qmail 85813 invoked by uid 500); 2 Jul 2012 17:57:40 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 85773 invoked by uid 500); 2 Jul 2012 17:57:40 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 85761 invoked by uid 99); 2 Jul 2012 17:57:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2012 17:57:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2012 17:57:39 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F3157238896F for ; Mon, 2 Jul 2012 17:57:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1356379 - in /hbase/branches/0.94: pom.xml src/main/java/org/apache/hadoop/hbase/io/hfile/slab/SingleSizeCache.java Date: Mon, 02 Jul 2012 17:57:18 -0000 To: commits@hbase.apache.org From: larsh@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120702175718.F3157238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: larsh Date: Mon Jul 2 17:57:17 2012 New Revision: 1356379 URL: http://svn.apache.org/viewvc?rev=1356379&view=rev Log: HBASE-5955 Guava 11 drops MapEvictionListener and Hadoop 2.0.0-alpha requires it Modified: hbase/branches/0.94/pom.xml hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/slab/SingleSizeCache.java Modified: hbase/branches/0.94/pom.xml URL: http://svn.apache.org/viewvc/hbase/branches/0.94/pom.xml?rev=1356379&r1=1356378&r2=1356379&view=diff ============================================================================== --- hbase/branches/0.94/pom.xml (original) +++ hbase/branches/0.94/pom.xml Mon Jul 2 17:57:17 2012 @@ -977,7 +977,7 @@ 2.1 1.6 2.1.2 - r09 + 11.0.2 1.8.8 5.5.23 2.1 Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/slab/SingleSizeCache.java URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/slab/SingleSizeCache.java?rev=1356379&r1=1356378&r2=1356379&view=diff ============================================================================== --- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/slab/SingleSizeCache.java (original) +++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/io/hfile/slab/SingleSizeCache.java Mon Jul 2 17:57:17 2012 @@ -38,8 +38,9 @@ import org.apache.hadoop.hbase.util.Byte import org.apache.hadoop.hbase.util.ClassSize; import org.apache.hadoop.util.StringUtils; -import com.google.common.collect.MapEvictionListener; -import com.google.common.collect.MapMaker; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; /** * SingleSizeCache is a slab allocated cache that caches elements up to a single @@ -91,18 +92,30 @@ public class SingleSizeCache implements // This evictionListener is called whenever the cache automatically // evicts // something. - MapEvictionListener listener = new MapEvictionListener() { - @Override - public void onEviction(BlockCacheKey key, CacheablePair value) { - timeSinceLastAccess.set(System.nanoTime() - - value.recentlyAccessed.get()); - stats.evict(); - doEviction(key, value); - } - }; + RemovalListener listener = + new RemovalListener() { + @Override + public void onRemoval( + RemovalNotification notification) { + if (!notification.wasEvicted()) { + // Only process removals by eviction, not by replacement or + // explicit removal + return; + } + CacheablePair value = notification.getValue(); + timeSinceLastAccess.set(System.nanoTime() + - value.recentlyAccessed.get()); + stats.evict(); + doEviction(notification.getKey(), value); + } + }; + + backingMap = CacheBuilder.newBuilder() + .maximumSize(numBlocks - 1) + .removalListener(listener) + .build() + .asMap(); - backingMap = new MapMaker().maximumSize(numBlocks - 1) - .evictionListener(listener).makeMap(); }