HBASE-1386 NPE in housekeeping

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@772703 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-05-07 16:47:39 +00:00
parent 6940db02c9
commit bc6ad67d67
2 changed files with 12 additions and 5 deletions

View File

@ -115,6 +115,7 @@ Release 0.20.0 - Unreleased
HBASE-1377 RS address is null in master web UI
HBASE-1344 WARN IllegalStateException: Cannot set a region as open if it has
not been pending
HBASE-1386 NPE in housekeeping
IMPROVEMENTS
HBASE-1089 Add count of regions on filesystem to master UI; add percentage

View File

@ -1124,6 +1124,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
}
return true;
}
/*
* Run some housekeeping tasks before we go into 'hibernation' sleeping at
* the end of the main HRegionServer run loop.
@ -1132,12 +1133,16 @@ public class HRegionServer implements HConstants, HRegionInterface,
// If the todo list has > 0 messages, iterate looking for open region
// messages. Send the master a message that we're working on its
// processing so it doesn't assign the region elsewhere.
if (this.toDo.size() <= 0) {
if (this.toDo.isEmpty()) {
return;
}
// This iterator is 'safe'. We are guaranteed a view on state of the
// queue at time iterator was taken out. Apparently goes from oldest.
for (ToDoEntry e: this.toDo) {
HMsg msg = e.msg;
if (msg == null) {
LOG.warn("Message is empty: " + e);
}
if (e.msg.isType(HMsg.Type.MSG_REGION_OPEN)) {
addProcessingMessage(e.msg.getRegionInfo());
}
@ -1299,15 +1304,16 @@ public class HRegionServer implements HConstants, HRegionInterface,
/*
* Data structure to hold a HMsg and retries count.
*/
private static class ToDoEntry {
protected int tries;
private static final class ToDoEntry {
protected volatile int tries;
protected final HMsg msg;
ToDoEntry(HMsg msg) {
ToDoEntry(final HMsg msg) {
this.tries = 0;
this.msg = msg;
}
}
final BlockingQueue<ToDoEntry> toDo = new LinkedBlockingQueue<ToDoEntry>();
private Worker worker;
private Thread workerThread;