hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject svn commit: r1581910 - in /hbase/branches/0.96/hbase-server/src: main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
Date Wed, 26 Mar 2014 16:23:25 GMT
Author: mbertozzi
Date: Wed Mar 26 16:23:25 2014
New Revision: 1581910

URL: http://svn.apache.org/r1581910
Log:
HBASE-10825 Add copy-from option to ExportSnapshot

Modified:
    hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
    hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java

Modified: hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java?rev=1581910&r1=1581909&r2=1581910&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
(original)
+++ hbase/branches/0.96/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java
Wed Mar 26 16:23:25 2014
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.snapshot
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -665,6 +666,8 @@ public final class ExportSnapshot extend
     int filesMode = 0;
     int mappers = 0;
 
+    Configuration conf = getConf();
+
     // Process command line args
     for (int i = 0; i < args.length; i++) {
       String cmd = args[i];
@@ -673,6 +676,11 @@ public final class ExportSnapshot extend
           snapshotName = args[++i];
         } else if (cmd.equals("-copy-to")) {
           outputRoot = new Path(args[++i]);
+        } else if (cmd.equals("-copy-from")) {
+          Path sourceDir = new Path(args[++i]);
+          URI defaultFs = sourceDir.getFileSystem(conf).getUri();
+          FSUtils.setFsDefault(conf, new Path(defaultFs));
+          FSUtils.setRootDir(conf, sourceDir);
         } else if (cmd.equals("-no-checksum-verify")) {
           verifyChecksum = false;
         } else if (cmd.equals("-mappers")) {
@@ -707,10 +715,11 @@ public final class ExportSnapshot extend
       printUsageAndExit();
     }
 
-    Configuration conf = getConf();
     Path inputRoot = FSUtils.getRootDir(conf);
-    FileSystem inputFs = FileSystem.get(conf);
+    FileSystem inputFs = FileSystem.get(inputRoot.toUri(), conf);
+    LOG.debug("inputFs=" + inputFs.getUri().toString() + " inputRoot=" + inputRoot);
     FileSystem outputFs = FileSystem.get(outputRoot.toUri(), conf);
+    LOG.debug("outputFs=" + outputFs.getUri().toString() + " outputRoot=" + outputRoot.toString());
 
     Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, inputRoot);
     Path snapshotTmpDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshotName, outputRoot);
@@ -803,6 +812,7 @@ public final class ExportSnapshot extend
     System.err.println("  -h|-help                Show this help and exit.");
     System.err.println("  -snapshot NAME          Snapshot to restore.");
     System.err.println("  -copy-to NAME           Remote destination hdfs://");
+    System.err.println("  -copy-from NAME         Input folder hdfs:// (default hbase.rootdir)");
     System.err.println("  -no-checksum-verify     Do not verify checksum.");
     System.err.println("  -overwrite              Rewrite the snapshot manifest if already
exists");
     System.err.println("  -chuser USERNAME        Change the owner of the files to the specified
one.");
@@ -814,6 +824,10 @@ public final class ExportSnapshot extend
     System.err.println("  hbase " + getClass().getName() + " \\");
     System.err.println("    -snapshot MySnapshot -copy-to hdfs://srv2:8082/hbase \\");
     System.err.println("    -chuser MyUser -chgroup MyGroup -chmod 700 -mappers 16");
+    System.err.println();
+    System.err.println("  hbase " + getClass().getName() + " \\");
+    System.err.println("    -snapshot MySnapshot -copy-from hdfs://srv2:8082/hbase \\");
+    System.err.println("    -copy-to hdfs://srv1:50070/hbase \\");
     System.exit(1);
   }
 

Modified: hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java?rev=1581910&r1=1581909&r2=1581910&view=diff
==============================================================================
--- hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
(original)
+++ hbase/branches/0.96/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestExportSnapshot.java
Wed Mar 26 16:23:25 2014
@@ -319,8 +319,10 @@ public class TestExportSnapshot {
     conf.setBoolean(ExportSnapshot.CONF_TEST_RETRY, retry);
 
     // Export Snapshot
+    Path sourceDir = TEST_UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
     int res = ExportSnapshot.innerMain(conf, new String[] {
       "-snapshot", Bytes.toString(snapshotName),
+      "-copy-from", sourceDir.toString(),
       "-copy-to", copyDir.toString()
     });
     return res;



Mime
View raw message