HBASE-10205 ConcurrentModificationException in BucketAllocator (Arjen Roodselaar and Chunhui Shen)

This commit is contained in:
stack 2014-08-06 15:56:31 -07:00
parent cae7d76646
commit e17a3ca091
2 changed files with 9 additions and 7 deletions

View File

@ -20,7 +20,7 @@
package org.apache.hadoop.hbase.io.hfile.bucket;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
@ -174,13 +174,13 @@ public final class BucketAllocator {
private int sizeIndex;
BucketSizeInfo(int sizeIndex) {
bucketList = new ArrayList<Bucket>();
freeBuckets = new ArrayList<Bucket>();
completelyFreeBuckets = new ArrayList<Bucket>();
bucketList = new LinkedList<Bucket>();
freeBuckets = new LinkedList<Bucket>();
completelyFreeBuckets = new LinkedList<Bucket>();
this.sizeIndex = sizeIndex;
}
public void instantiateBucket(Bucket b) {
public synchronized void instantiateBucket(Bucket b) {
assert b.isUninstantiated() || b.isCompletelyFree();
b.reconfigure(sizeIndex, bucketSizes, bucketCapacity);
bucketList.add(b);
@ -230,7 +230,7 @@ public final class BucketAllocator {
return b;
}
private void removeBucket(Bucket b) {
private synchronized void removeBucket(Bucket b) {
assert b.isCompletelyFree();
bucketList.remove(b);
freeBuckets.remove(b);
@ -246,7 +246,7 @@ public final class BucketAllocator {
if (b.isCompletelyFree()) completelyFreeBuckets.add(b);
}
public IndexStatistics statistics() {
public synchronized IndexStatistics statistics() {
long free = 0, used = 0;
for (Bucket b : bucketList) {
free += b.freeCount();

View File

@ -658,6 +658,8 @@ public class BucketCache implements BlockCache, HeapSize {
+ StringUtils.byteDesc(memory));
}
} catch (Throwable t) {
LOG.warn("Failed freeing space", t);
} finally {
cacheStats.evict();
freeInProgress = false;