Index: src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReader.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReader.java (revision 0) +++ src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReader.java (revision 0) @@ -0,0 +1,81 @@ +/** + * Copyright 2010 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.catalog; + +import java.io.IOException; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.hbase.Abortable; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.HServerAddress; +import org.apache.hadoop.hbase.client.HTable; +import org.apache.hadoop.hbase.client.ServerConnection; +import org.apache.hadoop.hbase.client.ServerConnectionManager; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.Pair; +import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Test {@link MetaReader} + */ +public class TestMetaReader { + private static final Log LOG = LogFactory.getLog(TestMetaReader.class); + private final static HBaseTestingUtility UTIL = new HBaseTestingUtility(); + + @BeforeClass public static void beforeClass() throws Exception { + UTIL.startMiniCluster(); + } + + @AfterClass public static void afterClass() throws IOException { + UTIL.shutdownMiniCluster(); + } + + @Test public void testGetRegion() throws IOException { + final String name = "testGetRegion"; + final byte [] nameBytes = Bytes.toBytes(name); + HTable t = UTIL.createTable(nameBytes, HConstants.CATALOG_FAMILY); + UTIL.createMultiRegions(t, HConstants.CATALOG_FAMILY); + final AtomicBoolean abort = new AtomicBoolean(false); + Abortable abortable = new Abortable() { + @Override + public void abort(String why, Throwable e) { + LOG.info(why, e); + abort.set(true); + } + }; + ZooKeeperWatcher zkw = new ZooKeeperWatcher(UTIL.getConfiguration(), name, + abortable); + ServerConnection connection = + ServerConnectionManager.getConnection(UTIL.getConfiguration()); + CatalogTracker ct = new CatalogTracker(zkw, connection, abortable); + List regions = MetaReader.getTableRegions(ct, nameBytes); + Pair pair = + MetaReader.getRegion(ct, regions.get(0).getRegionName()); + pair = MetaReader.getRegion(ct, HRegionInfo.FIRST_META_REGIONINFO.getRegionName()); + } +} Index: src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java (revision 0) +++ src/test/java/org/apache/hadoop/hbase/util/TestFSUtils.java (revision 0) @@ -0,0 +1,44 @@ +/** + * Copyright 2010 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.util; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hdfs.MiniDFSCluster; +import org.junit.Test; + +/** + * Test {@link FSUtils}. + */ +public class TestFSUtils { + @Test public void testIsHDFS() throws Exception { + HBaseTestingUtility htu = new HBaseTestingUtility(); + assertFalse(FSUtils.isHDFS(htu.getConfiguration())); + MiniDFSCluster cluster = null; + try { + cluster = htu.startMiniDFSCluster(1); + assertTrue(FSUtils.isHDFS(htu.getConfiguration())); + } finally { + if (cluster != null) cluster.shutdown(); + } + } +} Index: src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (revision 991708) +++ src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (working copy) @@ -80,6 +80,21 @@ * @throws IOException */ public CatalogTracker(final ZooKeeperWatcher zk, + final ServerConnection connection, final Abortable abortable) + throws IOException { + this(zk, connection, abortable, 0); + } + + /** + * Constructs the catalog tracker. Find current state of catalog tables and + * begin active tracking by executing {@link #start()}. + * @param zk + * @param connection server connection + * @param abortable if fatal exception + * @param defaultTimeout Timeout to use. + * @throws IOException + */ + public CatalogTracker(final ZooKeeperWatcher zk, final ServerConnection connection, final Abortable abortable, final int defaultTimeout) throws IOException { @@ -285,7 +300,7 @@ } if(getMetaServerConnection(true) == null) { throw new NotAllMetaRegionsOnlineException( - "Timed out (" + timeout + "ms"); + "Timed out (" + timeout + "ms)"); } return metaLocation; } Index: src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java (revision 991708) +++ src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java (working copy) @@ -155,8 +155,9 @@ throws IOException { Get get = new Get(regionName); get.addFamily(HConstants.CATALOG_FAMILY); - Result r = catalogTracker.waitForMetaServerConnectionDefault().get( - CatalogTracker.META_REGION, get); + byte [] meta = Bytes.equals(regionName, HConstants.META_TABLE_NAME)? + CatalogTracker.ROOT_REGION: CatalogTracker.META_REGION; + Result r = catalogTracker.waitForMetaServerConnectionDefault().get(meta, get); if(r == null || r.isEmpty()) { return null; } Index: src/main/java/org/apache/hadoop/hbase/util/FSUtils.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (revision 991708) +++ src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (working copy) @@ -590,6 +590,16 @@ return append; } + /** + * @param conf + * @return True if this filesystem whose scheme is 'hdfs'. + * @throws IOException + */ + public static boolean isHDFS(final Configuration conf) throws IOException { + FileSystem fs = FileSystem.get(conf); + String scheme = fs.getUri().getScheme(); + return scheme.equalsIgnoreCase("hdfs"); + } /* * Recover file lease. Used when a file might be suspect to be had been left open by another process. p Index: src/main/java/org/apache/hadoop/hbase/client/HConnection.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/HConnection.java (revision 991734) +++ src/main/java/org/apache/hadoop/hbase/client/HConnection.java (working copy) @@ -108,7 +108,7 @@ * lives in. * @param tableName name of the table row is in * @param row row key you're trying to find the region of - * @return HRegionLocation that describes where to find the reigon in + * @return HRegionLocation that describes where to find the region in * question * @throws IOException if a remote or network exception occurs */ Index: src/main/resources/hbase-webapps/master/master.jsp =================================================================== --- src/main/resources/hbase-webapps/master/master.jsp (revision 991708) +++ src/main/resources/hbase-webapps/master/master.jsp (working copy) @@ -47,7 +47,7 @@ for details. <% } %> -<% if (!FSUtils.isAppendSupported(conf)) { %> +<% if (!FSUtils.isAppendSupported(conf) && FSUtils.isHDFS(conf)) { %>
You are currently running the HMaster without HDFS append support enabled. This may result in data loss.