cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1032815 - in /cassandra/branches/cassandra-0.7: ./ lib/ lib/licenses/ src/java/org/apache/cassandra/cache/
Date Tue, 09 Nov 2010 02:17:44 GMT
Author: jbellis
Date: Tue Nov  9 02:17:44 2010
New Revision: 1032815

URL: http://svn.apache.org/viewvc?rev=1032815&view=rev
Log:
upgrade to ConcurrentLinkedHashMap 1.1
patch by mdennis; reviewed by jbellis for CASSANDRA-975

Added:
    cassandra/branches/cassandra-0.7/lib/concurrentlinkedhashmap-lru-1.1.jar   (with props)
    cassandra/branches/cassandra-0.7/lib/licenses/concurrentlinkedhashmap-lru-1.1.txt
      - copied unchanged from r1030284, cassandra/branches/cassandra-0.7/lib/licenses/clhm-production.txt
Removed:
    cassandra/branches/cassandra-0.7/lib/clhm-production.jar
    cassandra/branches/cassandra-0.7/lib/licenses/clhm-production.txt
Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cache/InstrumentedCache.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1032815&r1=1032814&r2=1032815&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Tue Nov  9 02:17:44 2010
@@ -18,6 +18,7 @@ dev
  * enable skipping bad rows on LazilyCompacted path (CASSANDRA-1702)
  * r/m extra subcomparator line in cli keyspaces output (CASSANDRA-1712)
  * add read repair chance to cli "show keyspaces"
+ * upgrade to ConcurrentLinkedHashMap 1.1 (CASSANDRA-975)
 
 
 0.7.0-beta3

Added: cassandra/branches/cassandra-0.7/lib/concurrentlinkedhashmap-lru-1.1.jar
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/lib/concurrentlinkedhashmap-lru-1.1.jar?rev=1032815&view=auto
==============================================================================
Binary file - no diff available.

Propchange: cassandra/branches/cassandra-0.7/lib/concurrentlinkedhashmap-lru-1.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cache/InstrumentedCache.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cache/InstrumentedCache.java?rev=1032815&r1=1032814&r2=1032815&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cache/InstrumentedCache.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cache/InstrumentedCache.java
Tue Nov  9 02:17:44 2010
@@ -24,11 +24,13 @@ package org.apache.cassandra.cache;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 
-import com.reardencommerce.kernel.collections.shared.evictable.ConcurrentLinkedHashMap;
+import com.googlecode.concurrentlinkedhashmap.Weighers;
+import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
 
 public class InstrumentedCache<K, V>
 {
-    private int capacity;
+    public static final int DEFAULT_CONCURENCY_LEVEL = 64;
+
     private final ConcurrentLinkedHashMap<K, V> map;
     private final AtomicLong requests = new AtomicLong(0);
     private final AtomicLong hits = new AtomicLong(0);
@@ -38,8 +40,17 @@ public class InstrumentedCache<K, V>
 
     public InstrumentedCache(int capacity)
     {
-        this.capacity = capacity;
-        map = ConcurrentLinkedHashMap.create(ConcurrentLinkedHashMap.EvictionPolicy.SECOND_CHANCE,
capacity);
+        this(capacity, DEFAULT_CONCURENCY_LEVEL);
+    }
+
+    public InstrumentedCache(int capacity, int concurency)
+    {
+        map = new ConcurrentLinkedHashMap.Builder<K, V>()
+                .weigher(Weighers.<V>singleton())
+                .initialCapacity(capacity)
+                .maximumWeightedCapacity(capacity)
+                .concurrencyLevel(concurency)
+                .build();
     }
 
     public void put(K key, V value)
@@ -68,7 +79,7 @@ public class InstrumentedCache<K, V>
 
     public int getCapacity()
     {
-        return capacity;
+        return map.capacity();
     }
 
     public boolean isCapacitySetManually()
@@ -79,7 +90,6 @@ public class InstrumentedCache<K, V>
     public void updateCapacity(int capacity)
     {
         map.setCapacity(capacity);
-        this.capacity = capacity;
     }
 
     public void setCapacity(int capacity)



Mime
View raw message