From b975bdc489ccbc5011ac4b383a9ee1fdd95c5f93 Mon Sep 17 00:00:00 2001 From: Jonathan Hsieh Date: Mon, 4 Jun 2012 10:06:54 +0000 Subject: [PATCH] HBASE-5874 When 'fs.default.name' not configured, the hbck tool and Merge tool throws IllegalArgumentException (fulin wang) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1345902 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/hadoop/hbase/util/HBaseFsck.java | 6 +++++- .../src/main/java/org/apache/hadoop/hbase/util/Merge.java | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index 8221e142e1c..2c9d6d28a4b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase.util; import java.io.IOException; +import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -2992,7 +2993,10 @@ public class HBaseFsck { // create a fsck object Configuration conf = HBaseConfiguration.create(); - conf.set("fs.defaultFS", conf.get(HConstants.HBASE_DIR)); + Path hbasedir = new Path(conf.get(HConstants.HBASE_DIR)); + URI defaultFs = hbasedir.getFileSystem(conf).getUri(); + conf.set("fs.defaultFS", defaultFs.toString()); // for hadoop 0.21+ + conf.set("fs.default.name", defaultFs.toString()); // for hadoop 0.20 HBaseFsck fsck = new HBaseFsck(conf); long sleepBeforeRerun = DEFAULT_SLEEP_BEFORE_RERUN; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java index 0800099e484..14afdeb8c28 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java @@ -384,8 +384,12 @@ public class Merge extends Configured implements Tool { } private void usage() { - System.err.println( - "Usage: bin/hbase merge \n"); + System.err + .println("For hadoop 0.20, Usage: bin/hbase org.apache.hadoop.hbase.util.Merge " + + "[-Dfs.default.name=hdfs://nn:port] \n"); + System.err + .println("For hadoop 0.21+, Usage: bin/hbase org.apache.hadoop.hbase.util.Merge " + + "[-Dfs.defaultFS=hdfs://nn:port] \n"); } public static void main(String[] args) {