Index: src/test/org/apache/hadoop/hbase/TestRootPath.java =================================================================== --- src/test/org/apache/hadoop/hbase/TestRootPath.java (revision 0) +++ src/test/org/apache/hadoop/hbase/TestRootPath.java (revision 0) @@ -0,0 +1,42 @@ +/** + * Copyright 2008 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hbase; + +import junit.framework.TestCase; + +import java.io.IOException; + +/** + * Test requirement that root directory must be a URI + */ +public class TestRootPath extends TestCase { + /** The test */ + public void testRootPath() { + HBaseConfiguration conf = new HBaseConfiguration(); + conf.set(HConstants.HBASE_DIR, "/hbase"); + try { + new HMaster(conf); + fail(); + } catch (IOException e) { + // Expected. + } + } +} Index: src/java/org/apache/hadoop/hbase/HMaster.java =================================================================== --- src/java/org/apache/hadoop/hbase/HMaster.java (revision 648354) +++ src/java/org/apache/hadoop/hbase/HMaster.java (working copy) @@ -22,6 +22,8 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.reflect.Constructor; +import java.net.URI; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -880,6 +882,21 @@ public HMaster(Path rd, HServerAddress address, HBaseConfiguration conf) throws IOException { this.conf = conf; + try { + URI rootURI = new URI(rd.toString()); + String scheme = rootURI.getScheme(); + if (scheme == null) { + IOException io = + new IOException("Root directory does not contain a scheme"); + LOG.fatal("Not starting HMaster because:", io); + throw io; + } + } catch (URISyntaxException e) { + IOException io = new IOException("Root directory path is not a valid URI"); + io.initCause(e); + LOG.fatal("Not starting HMaster because:", io); + throw io; + } this.rootdir = rd; this.threadWakeFrequency = conf.getInt(THREAD_WAKE_FREQUENCY, 10 * 1000); // The filesystem hbase wants to use is probably not what is set into