Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 76742200B52 for ; Mon, 25 Jul 2016 19:26:04 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 75310160A8F; Mon, 25 Jul 2016 17:26:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BB012160A67 for ; Mon, 25 Jul 2016 19:26:03 +0200 (CEST) Received: (qmail 36435 invoked by uid 500); 25 Jul 2016 17:25:49 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 34379 invoked by uid 99); 25 Jul 2016 17:25:49 -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, 25 Jul 2016 17:25:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DF29DE0100; Mon, 25 Jul 2016 17:25:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vvasudev@apache.org To: common-commits@hadoop.apache.org Date: Mon, 25 Jul 2016 17:26:28 -0000 Message-Id: <7ad721a7df3d47a3a9b3b116bc6b07bb@git.apache.org> In-Reply-To: <52a7d86ef7ac443fa0d5c238213d8430@git.apache.org> References: <52a7d86ef7ac443fa0d5c238213d8430@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [42/50] [abbrv] hadoop git commit: HADOOP-13406 S3AFileSystem: Consider reusing filestatus in delete() and mkdirs(). Contributed by Rajesh Balamohan archived-at: Mon, 25 Jul 2016 17:26:04 -0000 HADOOP-13406 S3AFileSystem: Consider reusing filestatus in delete() and mkdirs(). Contributed by Rajesh Balamohan Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/be9e46b4 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/be9e46b4 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/be9e46b4 Branch: refs/heads/YARN-3926 Commit: be9e46b42dd1ed0b2295bd36a7d81d5ee6dffc25 Parents: 7052ca8 Author: Steve Loughran Authored: Mon Jul 25 14:40:55 2016 +0100 Committer: Steve Loughran Committed: Mon Jul 25 14:45:03 2016 +0100 ---------------------------------------------------------------------- .../org/apache/hadoop/fs/s3a/S3AFileSystem.java | 32 +++++++++----------- 1 file changed, 15 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/be9e46b4/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java ---------------------------------------------------------------------- diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java index 10595e2..075f36c 100644 --- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java +++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java @@ -739,7 +739,7 @@ public class S3AFileSystem extends FileSystem { } else { copyFile(srcKey, dstKey, srcStatus.getLen()); } - delete(src, false); + innerDelete(srcStatus, false); } else { LOG.debug("rename: renaming directory {} to {}", src, dst); @@ -1065,16 +1065,20 @@ public class S3AFileSystem extends FileSystem { */ public boolean delete(Path f, boolean recursive) throws IOException { try { - return innerDelete(f, recursive); + return innerDelete(getFileStatus(f), recursive); + } catch (FileNotFoundException e) { + LOG.debug("Couldn't delete {} - does not exist", f); + instrumentation.errorIgnored(); + return false; } catch (AmazonClientException e) { throw translateException("delete", f, e); } } /** - * Delete a path. See {@link #delete(Path, boolean)}. + * Delete an object. See {@link #delete(Path, boolean)}. * - * @param f the path to delete. + * @param status fileStatus object * @param recursive if path is a directory and set to * true, the directory is deleted else throws an exception. In * case of a file the recursive can be set to either true or false. @@ -1082,17 +1086,10 @@ public class S3AFileSystem extends FileSystem { * @throws IOException due to inability to delete a directory or file. * @throws AmazonClientException on failures inside the AWS SDK */ - private boolean innerDelete(Path f, boolean recursive) throws IOException, - AmazonClientException { + private boolean innerDelete(S3AFileStatus status, boolean recursive) + throws IOException, AmazonClientException { + Path f = status.getPath(); LOG.debug("Delete path {} - recursive {}", f , recursive); - S3AFileStatus status; - try { - status = getFileStatus(f); - } catch (FileNotFoundException e) { - LOG.debug("Couldn't delete {} - does not exist", f); - instrumentation.errorIgnored(); - return false; - } String key = pathToKey(f); @@ -1318,8 +1315,9 @@ public class S3AFileSystem extends FileSystem { throws IOException, FileAlreadyExistsException, AmazonClientException { LOG.debug("Making directory: {}", f); incrementStatistic(INVOCATION_MKDIRS); + FileStatus fileStatus; try { - FileStatus fileStatus = getFileStatus(f); + fileStatus = getFileStatus(f); if (fileStatus.isDirectory()) { return true; @@ -1327,10 +1325,10 @@ public class S3AFileSystem extends FileSystem { throw new FileAlreadyExistsException("Path is a file: " + f); } } catch (FileNotFoundException e) { - Path fPart = f; + Path fPart = f.getParent(); do { try { - FileStatus fileStatus = getFileStatus(fPart); + fileStatus = getFileStatus(fPart); if (fileStatus.isDirectory()) { break; } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org