From e2cd6750204db2c617a790658a6f14d3aa79566c Mon Sep 17 00:00:00 2001 From: ramkrishna Date: Mon, 23 Apr 2012 16:47:04 +0000 Subject: [PATCH] HBASE-5635 If getTaskList() returns null, splitlogWorker would go down and it won't serve any requests (Ram) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1329322 13f79535-47bb-0310-9956-ffa450edef68 --- .../hbase/regionserver/SplitLogWorker.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java b/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java index f183076b545..8ea342f4559 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java @@ -469,25 +469,31 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable { private List getTaskList() { - for (int i = 0; i < zkretries; i++) { + 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 (!exitWorker) { try { - return (ZKUtil.listChildrenAndWatchForNewChildren(this.watcher, - this.watcher.splitLogZNode)); - } catch (KeeperException e) { - LOG.warn("Could not get children of znode " + - this.watcher.splitLogZNode, e); - try { - Thread.sleep(1000); - } catch (InterruptedException e1) { - LOG.warn("Interrupted while trying to get task list ...", e1); - Thread.currentThread().interrupt(); - return null; + childrenPaths = ZKUtil.listChildrenAndWatchForNewChildren(this.watcher, + this.watcher.splitLogZNode); + if (childrenPaths != null) { + return childrenPaths; } + } catch (KeeperException e) { + LOG.warn("Could not get children of znode " + + this.watcher.splitLogZNode, e); + } + try { + LOG.debug("Retry listChildren of znode " + this.watcher.splitLogZNode + + " after sleep for " + sleepTime + "ms!"); + Thread.sleep(sleepTime); + } catch (InterruptedException e1) { + LOG.warn("Interrupted while trying to get task list ...", e1); + Thread.currentThread().interrupt(); } } - LOG.warn("Tried " + zkretries + " times, still couldn't fetch " + - "children of " + watcher.splitLogZNode + " giving up"); - return null; + return childrenPaths; }