diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkSplitLogWorkerCoordination.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkSplitLogWorkerCoordination.java index 32df146..af56eec 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkSplitLogWorkerCoordination.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coordination/ZkSplitLogWorkerCoordination.java @@ -70,7 +70,7 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements private static final Log LOG = LogFactory.getLog(ZkSplitLogWorkerCoordination.class); - private static final int checkInterval = 5000; // 5 seconds + private static final int checkInterval = 10000; // 10 seconds private static final int FAILED_TO_OWN_TASK = -1; private SplitLogWorker worker; @@ -107,7 +107,7 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements LOG.debug("tasks arrived or departed"); synchronized (taskReadyLock) { taskReadySeq++; - taskReadyLock.notify(); + taskReadyLock.notifyAll(); } } } @@ -441,8 +441,7 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements } SplitLogCounters.tot_wkr_task_grabing.incrementAndGet(); synchronized (taskReadyLock) { - while (seq_start == taskReadySeq) { - taskReadyLock.wait(checkInterval); + if (seq_start == taskReadySeq) { if (server != null) { // check to see if we have stale recovering regions in our internal memory state Map recoveringRegions = server.getRecoveringRegions(); @@ -474,6 +473,9 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements } } } + taskReadyLock.wait(checkInterval); + } else { + taskReadyLock.wait(1000); } } } @@ -481,23 +483,15 @@ public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements private List getTaskList() throws InterruptedException { List childrenPaths = null; - long sleepTime = 1000; - // It will be in loop till it gets the list of children or - // it will come out if worker thread exited. - while (!shouldStop) { - try { - childrenPaths = - ZKUtil.listChildrenAndWatchForNewChildren(watcher, - watcher.splitLogZNode); - if (childrenPaths != null) { - return childrenPaths; - } - } catch (KeeperException e) { - LOG.warn("Could not get children of znode " + watcher.splitLogZNode, e); + try { + childrenPaths = + ZKUtil.listChildrenAndWatchForNewChildren(watcher, + watcher.splitLogZNode); + if (childrenPaths != null) { + return childrenPaths; } - LOG.debug("Retry listChildren of znode " + watcher.splitLogZNode - + " after sleep for " + sleepTime + "ms!"); - Thread.sleep(sleepTime); + } catch (KeeperException e) { + LOG.warn("Could not get children of znode " + watcher.splitLogZNode, e); } return childrenPaths; }