HADOOP-1797 Fix NPEs in MetaScanner constructor
git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@571333 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
12a62a6333
commit
aba565a228
|
@ -58,9 +58,7 @@ public class HMemcache {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public HMemcache() {
|
public HMemcache() {}
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** represents the state of the memcache at a specified point in time */
|
/** represents the state of the memcache at a specified point in time */
|
||||||
static class Snapshot {
|
static class Snapshot {
|
||||||
|
@ -320,7 +318,7 @@ public class HMemcache {
|
||||||
// Generate list of iterators
|
// Generate list of iterators
|
||||||
HStoreKey firstKey = new HStoreKey(firstRow);
|
HStoreKey firstKey = new HStoreKey(firstRow);
|
||||||
for(int i = 0; i < backingMaps.length; i++) {
|
for(int i = 0; i < backingMaps.length; i++) {
|
||||||
keyIterators[i] = (firstRow.getLength() != 0)?
|
keyIterators[i] = (/*firstRow != null &&*/ firstRow.getLength() != 0)?
|
||||||
backingMaps[i].tailMap(firstKey).keySet().iterator():
|
backingMaps[i].tailMap(firstKey).keySet().iterator():
|
||||||
backingMaps[i].keySet().iterator();
|
backingMaps[i].keySet().iterator();
|
||||||
while(getNext(i)) {
|
while(getNext(i)) {
|
||||||
|
|
|
@ -208,6 +208,7 @@ public class HRegion implements HConstants {
|
||||||
|
|
||||||
final int memcacheFlushSize;
|
final int memcacheFlushSize;
|
||||||
final int blockingMemcacheSize;
|
final int blockingMemcacheSize;
|
||||||
|
protected final long threadWakeFrequency;
|
||||||
private final HLocking lock = new HLocking();
|
private final HLocking lock = new HLocking();
|
||||||
private long desiredMaxFileSize;
|
private long desiredMaxFileSize;
|
||||||
private final long maxSequenceId;
|
private final long maxSequenceId;
|
||||||
|
@ -244,6 +245,7 @@ public class HRegion implements HConstants {
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
this.regionInfo = regionInfo;
|
this.regionInfo = regionInfo;
|
||||||
this.memcache = new HMemcache();
|
this.memcache = new HMemcache();
|
||||||
|
this.threadWakeFrequency = conf.getLong(THREAD_WAKE_FREQUENCY, 10 * 1000);
|
||||||
|
|
||||||
// Declare the regionName. This is a unique string for the region, used to
|
// Declare the regionName. This is a unique string for the region, used to
|
||||||
// build a unique filename.
|
// build a unique filename.
|
||||||
|
@ -1055,25 +1057,29 @@ public class HRegion implements HConstants {
|
||||||
* the notify.
|
* the notify.
|
||||||
*/
|
*/
|
||||||
private synchronized void checkResources() {
|
private synchronized void checkResources() {
|
||||||
if (checkCommitsSinceFlush()) {
|
boolean blocked = false;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.warn("Blocking updates for '" + Thread.currentThread().getName() +
|
while (!checkCommitsSinceFlush()) {
|
||||||
|
if (!blocked) {
|
||||||
|
LOG.info("Blocking updates for '" + Thread.currentThread().getName() +
|
||||||
"': Memcache size " +
|
"': Memcache size " +
|
||||||
StringUtils.humanReadableInt(this.memcache.getSize()) +
|
StringUtils.humanReadableInt(this.memcache.getSize()) +
|
||||||
" is >= than blocking " +
|
" is >= than blocking " +
|
||||||
StringUtils.humanReadableInt(this.blockingMemcacheSize) + " size");
|
StringUtils.humanReadableInt(this.blockingMemcacheSize) + " size");
|
||||||
while (!checkCommitsSinceFlush()) {
|
}
|
||||||
|
|
||||||
|
blocked = true;
|
||||||
try {
|
try {
|
||||||
wait();
|
wait(threadWakeFrequency);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// continue;
|
// continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG.warn("Unblocking updates for '" + Thread.currentThread().getName() +
|
if (blocked) {
|
||||||
|
LOG.info("Unblocking updates for '" + Thread.currentThread().getName() +
|
||||||
"'");
|
"'");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @return True if commits since flush is under the blocking threshold.
|
* @return True if commits since flush is under the blocking threshold.
|
||||||
|
|
Loading…
Reference in New Issue