From 0dcf30557513c8764988806fca0eb7a37f994037 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Sat, 17 Apr 2010 02:34:16 +0000 Subject: [PATCH] HBASE-2458 Client stuck in TreeMap,remove git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@935111 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 + .../hadoop/hbase/util/SoftValueSortedMap.java | 40 +++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 1854854b3de..5c003901998 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -273,6 +273,8 @@ Release 0.21.0 - Unreleased (Kannan Muthukkaruppan via Stack) HBASE-2451 .META. by-passes cache; BLOCKCACHE=>'false' HBASE-2453 Revisit compaction policies after HBASE-2248 commit + (Jonathan Gray via Stack) + HBASE-2458 Client stuck in TreeMap,remove (Todd Lipcon via Stack) IMPROVEMENTS HBASE-1760 Cleanup TODOs in HTable diff --git a/core/src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java b/core/src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java index 1525f256729..671850573b4 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java +++ b/core/src/main/java/org/apache/hadoop/hbase/util/SoftValueSortedMap.java @@ -67,7 +67,7 @@ public class SoftValueSortedMap implements SortedMap { * Internally these call checkReferences on each access. * @return How many references cleared. */ - public int checkReferences() { + private int checkReferences() { int i = 0; for (Object obj; (obj = this.rq.poll()) != null;) { i++; @@ -77,7 +77,7 @@ public class SoftValueSortedMap implements SortedMap { return i; } - public V put(K key, V value) { + public synchronized V put(K key, V value) { checkReferences(); SoftValue oldValue = this.internalMap.put(key, new SoftValue(key, value, this.rq)); @@ -85,12 +85,12 @@ public class SoftValueSortedMap implements SortedMap { } @SuppressWarnings("unchecked") - public void putAll(Map map) { + public synchronized void putAll(Map map) { throw new RuntimeException("Not implemented"); } @SuppressWarnings({"SuspiciousMethodCalls"}) - public V get(Object key) { + public synchronized V get(Object key) { checkReferences(); SoftValue value = this.internalMap.get(key); if (value == null) { @@ -103,74 +103,74 @@ public class SoftValueSortedMap implements SortedMap { return value.get(); } - public V remove(Object key) { + public synchronized V remove(Object key) { checkReferences(); SoftValue value = this.internalMap.remove(key); return value == null ? null : value.get(); } - public boolean containsKey(Object key) { + public synchronized boolean containsKey(Object key) { checkReferences(); return this.internalMap.containsKey(key); } - public boolean containsValue(Object value) { + public synchronized boolean containsValue(Object value) { /* checkReferences(); return internalMap.containsValue(value);*/ throw new UnsupportedOperationException("Don't support containsValue!"); } - public K firstKey() { + public synchronized K firstKey() { checkReferences(); return internalMap.firstKey(); } - public K lastKey() { + public synchronized K lastKey() { checkReferences(); return internalMap.lastKey(); } - public SoftValueSortedMap headMap(K key) { + public synchronized SoftValueSortedMap headMap(K key) { checkReferences(); return new SoftValueSortedMap(this.internalMap.headMap(key)); } - public SoftValueSortedMap tailMap(K key) { + public synchronized SoftValueSortedMap tailMap(K key) { checkReferences(); return new SoftValueSortedMap(this.internalMap.tailMap(key)); } - public SoftValueSortedMap subMap(K fromKey, K toKey) { + public synchronized SoftValueSortedMap subMap(K fromKey, K toKey) { checkReferences(); return new SoftValueSortedMap(this.internalMap.subMap(fromKey, toKey)); } - public boolean isEmpty() { + public synchronized boolean isEmpty() { checkReferences(); return this.internalMap.isEmpty(); } - public int size() { + public synchronized int size() { checkReferences(); return this.internalMap.size(); } - public void clear() { + public synchronized void clear() { checkReferences(); this.internalMap.clear(); } - public Set keySet() { + public synchronized Set keySet() { checkReferences(); return this.internalMap.keySet(); } @SuppressWarnings("unchecked") - public Comparator comparator() { + public synchronized Comparator comparator() { return this.internalMap.comparator(); } - public Set> entrySet() { + public synchronized Set> entrySet() { checkReferences(); Set>> entries = this.internalMap.entrySet(); Set> real_entries = new TreeSet>(); @@ -180,7 +180,7 @@ public class SoftValueSortedMap implements SortedMap { return real_entries; } - public Collection values() { + public synchronized Collection values() { checkReferences(); Collection> softValues = this.internalMap.values(); ArrayList hardValues = new ArrayList(); @@ -189,4 +189,4 @@ public class SoftValueSortedMap implements SortedMap { } return hardValues; } -} \ No newline at end of file +}