hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1353012 - in /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util: HBaseFsck.java hbck/OfflineMetaRepair.java
Date Fri, 22 Jun 2012 19:58:16 GMT
Author: tedyu
Date: Fri Jun 22 19:58:16 2012
New Revision: 1353012

URL: http://svn.apache.org/viewvc?rev=1353012&view=rev
Log:
HBASE-6236 Offline meta repair fails if the HBase base mount point is on a different cluster/volume
than its parent in a ViewFS or similar FS (Aditya)


Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRepair.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?rev=1353012&r1=1353011&r2=1353012&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Fri Jun
22 19:58:16 2012
@@ -145,6 +145,9 @@ public class HBaseFsck {
   private static final int DEFAULT_OVERLAPS_TO_SIDELINE = 2;
   private static final int DEFAULT_MAX_MERGE = 5;
 
+  private static final String DEFAULT_SIDELINE_DIR = ".hbcktmp-" + 
+                                          System.currentTimeMillis();
+  
   /**********************
    * Internal resources
    **********************/
@@ -155,7 +158,6 @@ public class HBaseFsck {
   private HBaseAdmin admin;
   private HTable meta;
   private ScheduledThreadPoolExecutor executor; // threads to retrieve data from regionservers
-  private long startMillis = System.currentTimeMillis();
 
   /***********
    * Options
@@ -176,6 +178,7 @@ public class HBaseFsck {
   private int maxMerge = DEFAULT_MAX_MERGE; // maximum number of overlapping regions to merge
   private int maxOverlapsToSideline = DEFAULT_OVERLAPS_TO_SIDELINE; // maximum number of
overlapping regions to sideline
   private boolean sidelineBigOverlaps = false; // sideline overlaps with >maxMerge regions
+  private Path sidelineDir = null;
 
   private boolean rerun = false; // if we tried to fix something, rerun hbck
   private static boolean summary = false; // if we want to print less output
@@ -820,7 +823,7 @@ public class HBaseFsck {
 
     // we can rebuild, move old root and meta out of the way and start
     LOG.info("HDFS regioninfo's seems good.  Sidelining old .META.");
-    sidelineOldRootAndMeta();
+    Path backupDir = sidelineOldRootAndMeta();
 
     LOG.info("Creating new .META.");
     HRegion meta = createNewRootAndMeta();
@@ -836,6 +839,7 @@ public class HBaseFsck {
     meta.close();
     meta.getLog().closeAndDelete();
     LOG.info("Success! .META. table rebuilt.");
+    LOG.info("Old -ROOT- and .META. are moved into " + backupDir);
     return true;
   }
 
@@ -859,11 +863,11 @@ public class HBaseFsck {
   }
 
   private Path getSidelineDir() throws IOException {
-    Path hbaseDir = FSUtils.getRootDir(conf);
-    Path hbckDir = new Path(hbaseDir.getParent(), "hbck");
-    Path backupDir = new Path(hbckDir, hbaseDir.getName() + "-"
-        + startMillis);
-    return backupDir;
+    if (sidelineDir == null) {
+      Path hbaseDir = FSUtils.getRootDir(conf);
+      sidelineDir = new Path(hbaseDir, DEFAULT_SIDELINE_DIR);
+    }
+    return sidelineDir;
   }
 
   /**
@@ -961,8 +965,7 @@ public class HBaseFsck {
     // put current -ROOT- and .META. aside.
     Path hbaseDir = new Path(conf.get(HConstants.HBASE_DIR));
     FileSystem fs = hbaseDir.getFileSystem(conf);
-    Path backupDir = new Path(hbaseDir.getParent(), hbaseDir.getName() + "-"
-        + startMillis);
+    Path backupDir = getSidelineDir();
     fs.mkdirs(backupDir);
 
     sidelineTable(fs, HConstants.ROOT_TABLE_NAME, hbaseDir, backupDir);
@@ -2984,6 +2987,14 @@ public class HBaseFsck {
     timelag = seconds * 1000; // convert to milliseconds
   }
 
+  /**
+   * 
+   * @param sidelineDir - HDFS path to sideline data
+   */
+  public void setSidelineDir(String sidelineDir) {
+    this.sidelineDir = new Path(sidelineDir);
+  }
+  
   protected static void printUsageAndExit() {
     System.err.println("Usage: fsck [opts] {only tables}");
     System.err.println(" where [opts] are:");

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRepair.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRepair.java?rev=1353012&r1=1353011&r2=1353012&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRepair.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRepair.java
Fri Jun 22 19:58:16 2012
@@ -47,6 +47,8 @@ public class OfflineMetaRepair {
     System.err
         .println("   -details          Display full report of all regions.");
     System.err.println("   -base <hdfs://>   Base Hbase Data directory");
+    System.err
+        .println("   -backup <hdfs://> HDFS path to backup existing meta and root.");
     System.err.println("   -fix              Auto fix as many problems as possible");
     System.err.println("   -fixHoles         Auto fix as region holes");
     Runtime.getRuntime().exit(-2);
@@ -81,6 +83,9 @@ public class OfflineMetaRepair {
         conf.set(HConstants.HBASE_DIR, path);
         conf.set("fs.defaultFS", conf.get(HConstants.HBASE_DIR));
         conf.set("fs.default.name", conf.get(HConstants.HBASE_DIR));
+      } else if (cmd.equals("-backup")) {
+        i++;
+        fsck.setSidelineDir(args[i]);        
       } else if (cmd.equals("-fixHoles")) {
         fixHoles = true;
       } else if (cmd.equals("-fix")) {



Mime
View raw message