Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1B68018FF0 for ; Mon, 13 Jul 2015 22:34:28 +0000 (UTC) Received: (qmail 22485 invoked by uid 500); 13 Jul 2015 22:34:27 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 22418 invoked by uid 500); 13 Jul 2015 22:34:27 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 22409 invoked by uid 99); 13 Jul 2015 22:34:27 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Jul 2015 22:34:27 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A8FBDE0019; Mon, 13 Jul 2015 22:34:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: szetszwo@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HDFS-8541. Mover should exit with NO_MOVE_PROGRESS if there is no move progress. Contributed by Surendra Singh Lilhore Date: Mon, 13 Jul 2015 22:34:27 +0000 (UTC) Repository: hadoop Updated Branches: refs/heads/branch-2 2e455d4d8 -> d8d6d69b0 HDFS-8541. Mover should exit with NO_MOVE_PROGRESS if there is no move progress. Contributed by Surendra Singh Lilhore Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d8d6d69b Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d8d6d69b Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d8d6d69b Branch: refs/heads/branch-2 Commit: d8d6d69b093f96a59cc587751c73d9e892ac51b2 Parents: 2e455d4 Author: Tsz-Wo Nicholas Sze Authored: Mon Jul 13 15:12:26 2015 -0700 Committer: Tsz-Wo Nicholas Sze Committed: Mon Jul 13 15:13:14 2015 -0700 ---------------------------------------------------------------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/balancer/Dispatcher.java | 18 +++++++++++++ .../apache/hadoop/hdfs/server/mover/Mover.java | 27 +++++++++++++++----- .../hadoop/hdfs/server/mover/TestMover.java | 2 +- 4 files changed, 43 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/d8d6d69b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 8725b99..925a85e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -377,6 +377,9 @@ Release 2.8.0 - UNRELEASED HDFS-8751. Remove setBlocks API from INodeFile and misc code cleanup. (Zhe Zhang via jing9) + HDFS-8541. Mover should exit with NO_MOVE_PROGRESS if there is no move + progress. (Surendra Singh Lilhore via szetszwo) + OPTIMIZATIONS HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than http://git-wip-us.apache.org/repos/asf/hadoop/blob/d8d6d69b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java index 05c458a..b0fac35 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Dispatcher.java @@ -319,6 +319,7 @@ public class Dispatcher { sendRequest(out, eb, accessToken); receiveResponse(in); nnc.getBytesMoved().addAndGet(block.getNumBytes()); + target.getDDatanode().setHasSuccess(); LOG.info("Successfully moved " + this); } catch (IOException e) { LOG.warn("Failed to move " + this + ": " + e.getMessage()); @@ -502,6 +503,7 @@ public class Dispatcher { /** blocks being moved but not confirmed yet */ private final List pendings; private volatile boolean hasFailure = false; + private volatile boolean hasSuccess = false; private final int maxConcurrentMoves; @Override @@ -575,6 +577,10 @@ public class Dispatcher { void setHasFailure() { this.hasFailure = true; } + + void setHasSuccess() { + this.hasSuccess = true; + } } /** A node that can be the sources of a block move */ @@ -967,6 +973,18 @@ public class Dispatcher { } /** + * @return true if some moves are success. + */ + public static boolean checkForSuccess( + Iterable targets) { + boolean hasSuccess = false; + for (StorageGroup t : targets) { + hasSuccess |= t.getDDatanode().hasSuccess; + } + return hasSuccess; + } + + /** * Decide if the block is a good candidate to be moved from source to target. * A block is a good candidate if * 1. the block is not in the process of being moved/has not been moved; http://git-wip-us.apache.org/repos/asf/hadoop/blob/d8d6d69b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/mover/Mover.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/mover/Mover.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/mover/Mover.java index 344b9fc..afacebb 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/mover/Mover.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/mover/Mover.java @@ -269,10 +269,14 @@ public class Mover { // wait for pending move to finish and retry the failed migration boolean hasFailed = Dispatcher.waitForMoveCompletion(storages.targets .values()); - if (hasFailed) { + boolean hasSuccess = Dispatcher.checkForSuccess(storages.targets + .values()); + if (hasFailed && !hasSuccess) { if (retryCount.get() == retryMaxAttempts) { - throw new IOException("Failed to move some block's after " + result.setRetryFailed(); + LOG.error("Failed to move some block's after " + retryMaxAttempts + " retries."); + return result; } else { retryCount.incrementAndGet(); } @@ -713,10 +717,12 @@ public class Mover { private boolean hasRemaining; private boolean noBlockMoved; + private boolean retryFailed; Result() { hasRemaining = false; noBlockMoved = true; + retryFailed = false; } boolean isHasRemaining() { @@ -735,16 +741,25 @@ public class Mover { this.noBlockMoved = noBlockMoved; } + void setRetryFailed() { + this.retryFailed = true; + } + /** - * @return SUCCESS if all moves are success and there is no remaining move. + * @return NO_MOVE_PROGRESS if no progress in move after some retry. Return + * SUCCESS if all moves are success and there is no remaining move. * Return NO_MOVE_BLOCK if there moves available but all the moves * cannot be scheduled. Otherwise, return IN_PROGRESS since there * must be some remaining moves. */ ExitStatus getExitStatus() { - return !isHasRemaining() ? ExitStatus.SUCCESS - : isNoBlockMoved() ? ExitStatus.NO_MOVE_BLOCK - : ExitStatus.IN_PROGRESS; + if (retryFailed) { + return ExitStatus.NO_MOVE_PROGRESS; + } else { + return !isHasRemaining() ? ExitStatus.SUCCESS + : isNoBlockMoved() ? ExitStatus.NO_MOVE_BLOCK + : ExitStatus.IN_PROGRESS; + } } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/d8d6d69b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/mover/TestMover.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/mover/TestMover.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/mover/TestMover.java index 899b5c0..d3d814c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/mover/TestMover.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/mover/TestMover.java @@ -404,7 +404,7 @@ public class TestMover { int rc = ToolRunner.run(conf, new Mover.Cli(), new String[] {"-p", file.toString()}); Assert.assertEquals("Movement should fail after some retry", - ExitStatus.IO_EXCEPTION.getExitCode(), rc); + ExitStatus.NO_MOVE_PROGRESS.getExitCode(), rc); } finally { cluster.shutdown(); }