Index: src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (revision 1222611) +++ src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (working copy) @@ -36,6 +36,7 @@ import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Set; +import java.util.SortedMap; import java.util.TreeMap; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; @@ -1084,7 +1085,7 @@ // Cut the cache so that we only get the part that could contain // regions that match our key - SoftValueSortedMap matchingRegions = + SortedMap matchingRegions = tableLocations.headMap(row); // if that portion of the map is empty, then we're done. otherwise, @@ -1127,7 +1128,7 @@ */ void deleteCachedLocation(final byte [] tableName, final byte [] row) { synchronized (this.cachedRegionLocations) { - SoftValueSortedMap tableLocations = + Map tableLocations = getTableLocations(tableName); // start to examine the cache. we can only do cache actions // if there's something in the cache for this table. @@ -1159,7 +1160,7 @@ if (!cachedServers.contains(server)) { return; } - for (SoftValueSortedMap tableLocations : + for (Map tableLocations : cachedRegionLocations.values()) { for (Entry e : tableLocations.entrySet()) { if (e.getValue().getServerAddress().toString().equals(server)) { @@ -1217,7 +1218,7 @@ private void cacheLocation(final byte [] tableName, final HRegionLocation location) { byte [] startKey = location.getRegionInfo().getStartKey(); - SoftValueSortedMap tableLocations = + Map tableLocations = getTableLocations(tableName); boolean hasNewCache = false; synchronized (this.cachedRegionLocations) { @@ -1685,7 +1686,7 @@ int getNumberOfCachedRegionLocations(final byte[] tableName) { Integer key = Bytes.mapKey(tableName); synchronized (this.cachedRegionLocations) { - SoftValueSortedMap tableLocs = + Map tableLocs = this.cachedRegionLocations.get(key); if (tableLocs == null) { Index: src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java (revision 1222611) +++ src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java (working copy) @@ -28,8 +28,8 @@ import java.util.Map; import java.util.Set; import java.util.SortedMap; -import java.util.TreeMap; -import java.util.TreeSet; +import java.util.concurrent.ConcurrentNavigableMap; +import java.util.concurrent.ConcurrentSkipListMap; /** * A SortedMap implementation that uses Soft Reference values @@ -40,12 +40,12 @@ * @param value class */ public class SoftValueSortedMap implements SortedMap { - private final SortedMap> internalMap; + private final ConcurrentNavigableMap> internalMap; private final ReferenceQueue rq = new ReferenceQueue(); /** Constructor */ public SoftValueSortedMap() { - this(new TreeMap>()); + this(new ConcurrentSkipListMap>()); } /** @@ -53,13 +53,13 @@ * @param c comparator */ public SoftValueSortedMap(final Comparator c) { - this(new TreeMap>(c)); + this(new ConcurrentSkipListMap>(c)); } /** For headMap and tailMap support * @param original object to wrap */ - private SoftValueSortedMap(SortedMap> original) { + private SoftValueSortedMap(ConcurrentNavigableMap> original) { this.internalMap = original; } @@ -117,8 +117,6 @@ } public synchronized boolean containsValue(Object value) { -/* checkReferences(); - return internalMap.containsValue(value);*/ throw new UnsupportedOperationException("Don't support containsValue!"); } @@ -132,47 +130,47 @@ return internalMap.lastKey(); } - public synchronized SoftValueSortedMap headMap(K key) { + public SoftValueSortedMap headMap(K key) { checkReferences(); return new SoftValueSortedMap(this.internalMap.headMap(key)); } - public synchronized SoftValueSortedMap tailMap(K key) { + public SoftValueSortedMap tailMap(K key) { checkReferences(); return new SoftValueSortedMap(this.internalMap.tailMap(key)); } - public synchronized SoftValueSortedMap subMap(K fromKey, K toKey) { + public SoftValueSortedMap subMap(K fromKey, K toKey) { checkReferences(); return new SoftValueSortedMap(this.internalMap.subMap(fromKey, toKey)); } - public synchronized boolean isEmpty() { + public boolean isEmpty() { checkReferences(); return this.internalMap.isEmpty(); } - public synchronized int size() { + public int size() { checkReferences(); return this.internalMap.size(); } - public synchronized void clear() { + public void clear() { checkReferences(); this.internalMap.clear(); } - public synchronized Set keySet() { + public Set keySet() { checkReferences(); return this.internalMap.keySet(); } @SuppressWarnings("unchecked") - public synchronized Comparator comparator() { + public Comparator comparator() { return this.internalMap.comparator(); } - public synchronized Set> entrySet() { + public Set> entrySet() { checkReferences(); Set>> entries = this.internalMap.entrySet(); Set> realEntries = new LinkedHashSet>(); @@ -182,7 +180,7 @@ return realEntries; } - public synchronized Collection values() { + public Collection values() { checkReferences(); Collection> softValues = this.internalMap.values(); ArrayList hardValues = new ArrayList();