hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject [1/2] hadoop git commit: HADOOP-11579. Documentation for truncate. Contributed by Konstantin Shvachko.
Date Wed, 11 Feb 2015 18:08:49 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 38333c8f2 -> 04789db74


HADOOP-11579. Documentation for truncate. Contributed by Konstantin Shvachko.

Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ada7791e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ada7791e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ada7791e

Branch: refs/heads/branch-2
Commit: ada7791ef4d41f68e23ce96cca0382ffcf0657b5
Parents: 38333c8
Author: Konstantin V Shvachko <shv@apache.org>
Authored: Wed Feb 11 10:03:54 2015 -0800
Committer: Konstantin V Shvachko <shv@apache.org>
Committed: Wed Feb 11 10:03:54 2015 -0800

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  2 ++
 .../src/site/apt/FileSystemShell.apt.vm         | 20 +++++++++++
 .../src/site/markdown/filesystem/filesystem.md  | 35 ++++++++++++++++++++
 3 files changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ada7791e/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 3a19676..2d8c7c2 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -183,6 +183,8 @@ Release 2.7.0 - UNRELEASED
     HADOOP-11520. Clean incomplete multi-part uploads in S3A tests.
     (Thomas Demoor via stevel)
 
+    HADOOP-11579. Documentation for truncate. (shv)
+
   OPTIMIZATIONS
 
     HADOOP-11323. WritableComparator#compare keeps reference to byte array.

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ada7791e/hadoop-common-project/hadoop-common/src/site/apt/FileSystemShell.apt.vm
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/site/apt/FileSystemShell.apt.vm b/hadoop-common-project/hadoop-common/src/site/apt/FileSystemShell.apt.vm
index c8b4b54..0f8cf58 100644
--- a/hadoop-common-project/hadoop-common/src/site/apt/FileSystemShell.apt.vm
+++ b/hadoop-common-project/hadoop-common/src/site/apt/FileSystemShell.apt.vm
@@ -669,3 +669,23 @@ touchz
 
    Exit Code:
    Returns 0 on success and -1 on error.
+
+* truncate
+
+   Usage: <<<hadoop fs -truncate [-w] <length> <paths> >>>
+
+   Truncate all files that match the specified file pattern to the
+   specified length.
+
+   Options:
+
+     * The -w flag requests that the command waits for block recovery
+       to complete, if necessary. Without -w flag the file may remain
+       unclosed for some time while the recovery is in progress.
+       During this time file cannot be reopened for append.
+
+   Example:
+
+     * <<<hadoop fs -truncate 55 /user/hadoop/file1 /user/hadoop/file2>>>
+
+     * <<<hadoop fs -truncate -w 127 hdfs://nn1.example.com/user/hadoop/file1>>>

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ada7791e/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
b/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
index e59fa1b..84e3755 100644
--- a/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
+++ b/hadoop-common-project/hadoop-common/src/site/markdown/filesystem/filesystem.md
@@ -831,3 +831,38 @@ HDFS's restrictions may be an implementation detail of how it implements
 a sequence. As no other filesystem in the Hadoop core codebase
 implements this method, there is no way to distinguish implementation detail.
 from specification.
+
+
+### `boolean truncate(Path p, long newLength)`
+
+Truncate file `p` to the specified `newLength`.
+
+Implementations MAY throw `UnsupportedOperationException`.
+
+#### Preconditions
+
+    if not exists(FS, p) : raise FileNotFoundException
+
+    if isDir(FS, p) : raise [FileNotFoundException, IOException]
+
+    if newLength < 0 || newLength > len(FS.Files[p]) : raise HadoopIllegalArgumentException
+
+HDFS: The source file MUST be closed.
+Truncate cannot be performed on a file, which is open for writing or appending.
+
+#### Postconditions
+
+    FS' where:
+        len(FS.Files[p]) = newLength
+
+Return: `true`, if truncation is finished and the file can be immediately
+opened for appending, or `false` otherwise.
+
+HDFS: HDFS reutrns `false` to indicate that a background process of adjusting
+the length of the last block has been started, and clients should wait for it
+to complete before they can proceed with further file updates.
+
+#### Concurrency
+
+If an input stream is open when truncate() occurs, the outcome of read
+operations related to the part of the file being truncated is undefined.


Mime
View raw message