hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1467706 - in /hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs: FileSystem.java shell/SnapshotCommands.java
Date Sat, 13 Apr 2013 21:41:34 GMT
Author: szetszwo
Date: Sat Apr 13 21:41:33 2013
New Revision: 1467706

URL: http://svn.apache.org/r1467706
Log:
HDFS-4692. Use timestamp as default snapshot names.

Modified:
    hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
    hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/SnapshotCommands.java

Modified: hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java?rev=1467706&r1=1467705&r2=1467706&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
(original)
+++ hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java
Sat Apr 13 21:41:33 2013
@@ -2266,11 +2266,21 @@ public abstract class FileSystem extends
   }
 
   /**
+   * Create a snapshot with a default name.
+   * @param path The directory where snapshots will be taken.
+   * @return the snapshot path.
+   */
+  public final Path createSnapshot(Path path) throws IOException {
+    return createSnapshot(path, null);
+  }
+
+  /**
    * Create a snapshot
    * @param path The directory where snapshots will be taken.
    * @param snapshotName The name of the snapshot
+   * @return the snapshot path.
    */
-  public void createSnapshot(Path path, String snapshotName)
+  public Path createSnapshot(Path path, String snapshotName)
       throws IOException {
     throw new UnsupportedOperationException(getClass().getSimpleName()
         + " doesn't support createSnapshot");

Modified: hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/SnapshotCommands.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/SnapshotCommands.java?rev=1467706&r1=1467705&r2=1467706&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/SnapshotCommands.java
(original)
+++ hadoop/common/branches/HDFS-2802/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/SnapshotCommands.java
Sat Apr 13 21:41:33 2013
@@ -49,10 +49,10 @@ class SnapshotCommands extends FsCommand
    */
   public static class CreateSnapshot extends FsCommand {
     public static final String NAME = CREATE_SNAPSHOT;
-    public static final String USAGE = "<snapshotDir> <snapshotName>";
+    public static final String USAGE = "<snapshotDir> [<snapshotName>]";
     public static final String DESCRIPTION = "Create a snapshot on a directory";
 
-    private String snapshotName;
+    private String snapshotName = null;
 
     @Override
     protected void processPath(PathData item) throws IOException {
@@ -63,12 +63,15 @@ class SnapshotCommands extends FsCommand
     
     @Override
     protected void processOptions(LinkedList<String> args) throws IOException {
-      if (args.size() != 2) {
-        throw new IOException("args number not 2:" + args.size());
+      if (args.size() == 0) {
+        throw new IllegalArgumentException("<snapshotDir> is missing.");
+      } 
+      if (args.size() > 2) {
+        throw new IllegalArgumentException("Too many arguements.");
+      }
+      if (args.size() == 2) {
+        snapshotName = args.removeLast();
       }
-      snapshotName = args.removeLast();
-      // TODO: name length check  
-
     }
 
     @Override
@@ -108,8 +111,6 @@ class SnapshotCommands extends FsCommand
         throw new IOException("args number not 2: " + args.size());
       }
       snapshotName = args.removeLast();
-      // TODO: name length check
-
     }
 
     @Override
@@ -151,8 +152,6 @@ class SnapshotCommands extends FsCommand
       }
       newName = args.removeLast();
       oldName = args.removeLast();
-      
-      // TODO: new name length check
     }
 
     @Override



Mime
View raw message