Index: src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (revision 1222641) +++ src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (working copy) @@ -29,9 +29,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.NoSuchElementException; -import java.util.Map.Entry; import java.util.Set; +import java.util.SortedMap; import java.util.TreeSet; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; @@ -1052,7 +1053,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, @@ -1061,7 +1062,7 @@ if (!matchingRegions.isEmpty()) { HRegionLocation possibleRegion = null; try { - possibleRegion = matchingRegions.get(matchingRegions.lastKey()); + possibleRegion = matchingRegions.get(matchingRegions.lastKey()); } catch (NoSuchElementException nsee) { LOG.warn("checkReferences() might have removed the key", nsee); } @@ -1095,7 +1096,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. @@ -1155,7 +1156,7 @@ private void cacheLocation(final byte [] tableName, final HRegionLocation location) { byte [] startKey = location.getRegionInfo().getStartKey(); - SoftValueSortedMap tableLocations = + Map tableLocations = getTableLocations(tableName); if (tableLocations.put(startKey, location) == null) { LOG.debug("Cached location for " + @@ -1483,7 +1484,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 1222641) +++ src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java (working copy) @@ -27,8 +27,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 @@ -39,12 +39,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>()); } /** @@ -52,13 +52,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; } @@ -78,7 +78,7 @@ return i; } - public synchronized V put(K key, V value) { + public V put(K key, V value) { checkReferences(); SoftValue oldValue = this.internalMap.put(key, new SoftValue(key, value, this.rq)); @@ -86,12 +86,12 @@ } @SuppressWarnings("unchecked") - public synchronized void putAll(Map map) { + public void putAll(Map map) { throw new RuntimeException("Not implemented"); } @SuppressWarnings({"SuspiciousMethodCalls"}) - public synchronized V get(Object key) { + public V get(Object key) { checkReferences(); SoftValue value = this.internalMap.get(key); if (value == null) { @@ -104,78 +104,76 @@ return value.get(); } - public synchronized V remove(Object key) { + public V remove(Object key) { checkReferences(); SoftValue value = this.internalMap.remove(key); return value == null ? null : value.get(); } - public synchronized boolean containsKey(Object key) { + public boolean containsKey(Object key) { checkReferences(); return this.internalMap.containsKey(key); } - public synchronized boolean containsValue(Object value) { -/* checkReferences(); - return internalMap.containsValue(value);*/ + public boolean containsValue(Object value) { throw new UnsupportedOperationException("Don't support containsValue!"); } - public synchronized K firstKey() { + public K firstKey() { checkReferences(); return internalMap.firstKey(); } - public synchronized K lastKey() { + public K lastKey() { checkReferences(); 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() { throw new RuntimeException("Not implemented"); } - public synchronized Collection values() { + public Collection values() { checkReferences(); Collection> softValues = this.internalMap.values(); ArrayList hardValues = new ArrayList();