HADOOP-12193. Rename Touchz.java to Touch.java.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/81a1e6b2 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/81a1e6b2 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/81a1e6b2 Branch: refs/heads/YARN-2928 Commit: 81a1e6b26b03420774fe9e25be708b7f6620ed60 Parents: 3440a98 Author: Andrew Wang <[email protected]> Authored: Tue Jul 7 11:12:29 2015 -0700 Committer: Zhijie Shen <[email protected]> Committed: Mon Jul 13 11:43:27 2015 -0700 ---------------------------------------------------------------------- hadoop-common-project/hadoop-common/CHANGES.txt | 2 + .../java/org/apache/hadoop/fs/shell/Touch.java | 84 ++++++++++++++++++++ .../java/org/apache/hadoop/fs/shell/Touchz.java | 84 -------------------- 3 files changed, 86 insertions(+), 84 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/81a1e6b2/hadoop-common-project/hadoop-common/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 194e2e3..af6e3fe 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -684,6 +684,8 @@ Release 2.8.0 - UNRELEASED HADOOP-11974. Fix FIONREAD #include on Solaris (Alan Burlison via Colin P. McCabe) + HADOOP-12193. Rename Touchz.java to Touch.java. (wang) + OPTIMIZATIONS HADOOP-11785. Reduce the number of listStatus operation in distcp http://git-wip-us.apache.org/repos/asf/hadoop/blob/81a1e6b2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touch.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touch.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touch.java new file mode 100644 index 0000000..72a463a --- /dev/null +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touch.java @@ -0,0 +1,84 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.fs.shell; + +import java.io.IOException; +import java.util.LinkedList; + +import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.classification.InterfaceStability; +import org.apache.hadoop.fs.PathIOException; +import org.apache.hadoop.fs.PathIsDirectoryException; +import org.apache.hadoop.fs.PathNotFoundException; + +/** + * Unix touch like commands + */ [email protected] [email protected] + +class Touch extends FsCommand { + public static void registerCommands(CommandFactory factory) { + factory.addClass(Touchz.class, "-touchz"); + } + + /** + * (Re)create zero-length file at the specified path. + * This will be replaced by a more UNIX-like touch when files may be + * modified. + */ + public static class Touchz extends Touch { + public static final String NAME = "touchz"; + public static final String USAGE = "<path> ..."; + public static final String DESCRIPTION = + "Creates a file of zero length " + + "at <path> with current time as the timestamp of that <path>. " + + "An error is returned if the file exists with non-zero length\n"; + + @Override + protected void processOptions(LinkedList<String> args) { + CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE); + cf.parse(args); + } + + @Override + protected void processPath(PathData item) throws IOException { + if (item.stat.isDirectory()) { + // TODO: handle this + throw new PathIsDirectoryException(item.toString()); + } + if (item.stat.getLen() != 0) { + throw new PathIOException(item.toString(), "Not a zero-length file"); + } + touchz(item); + } + + @Override + protected void processNonexistentPath(PathData item) throws IOException { + if (!item.parentExists()) { + throw new PathNotFoundException(item.toString()); + } + touchz(item); + } + + private void touchz(PathData item) throws IOException { + item.fs.create(item.path).close(); + } + } +} http://git-wip-us.apache.org/repos/asf/hadoop/blob/81a1e6b2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touchz.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touchz.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touchz.java deleted file mode 100644 index 7925a0f..0000000 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/Touchz.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.fs.shell; - -import java.io.IOException; -import java.util.LinkedList; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.fs.PathIOException; -import org.apache.hadoop.fs.PathIsDirectoryException; -import org.apache.hadoop.fs.PathNotFoundException; - -/** - * Unix touch like commands - */ [email protected] [email protected] - -class Touch extends FsCommand { - public static void registerCommands(CommandFactory factory) { - factory.addClass(Touchz.class, "-touchz"); - } - - /** - * (Re)create zero-length file at the specified path. - * This will be replaced by a more UNIX-like touch when files may be - * modified. - */ - public static class Touchz extends Touch { - public static final String NAME = "touchz"; - public static final String USAGE = "<path> ..."; - public static final String DESCRIPTION = - "Creates a file of zero length " + - "at <path> with current time as the timestamp of that <path>. " + - "An error is returned if the file exists with non-zero length\n"; - - @Override - protected void processOptions(LinkedList<String> args) { - CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE); - cf.parse(args); - } - - @Override - protected void processPath(PathData item) throws IOException { - if (item.stat.isDirectory()) { - // TODO: handle this - throw new PathIsDirectoryException(item.toString()); - } - if (item.stat.getLen() != 0) { - throw new PathIOException(item.toString(), "Not a zero-length file"); - } - touchz(item); - } - - @Override - protected void processNonexistentPath(PathData item) throws IOException { - if (!item.parentExists()) { - throw new PathNotFoundException(item.toString()); - } - touchz(item); - } - - private void touchz(PathData item) throws IOException { - item.fs.create(item.path).close(); - } - } -}
