Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4335FD20A for ; Fri, 8 Mar 2013 22:37:58 +0000 (UTC) Received: (qmail 26893 invoked by uid 500); 8 Mar 2013 22:37:58 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 26840 invoked by uid 500); 8 Mar 2013 22:37:58 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 26832 invoked by uid 99); 8 Mar 2013 22:37:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Mar 2013 22:37:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Mar 2013 22:37:45 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 203A22388A33; Fri, 8 Mar 2013 22:37:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1454607 [2/3] - in /hbase/trunk: hbase-client/src/main/java/org/apache/hadoop/hbase/ hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/ hbase-client/src/main/java/org/apache/hadoop/hbase/client/ hbase-client/src/main/java/org/apac... Date: Fri, 08 Mar 2013 22:37:20 -0000 To: commits@hbase.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130308223724.203A22388A33@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java Fri Mar 8 22:37:19 2013 @@ -37,16 +37,14 @@ import org.apache.zookeeper.KeeperExcept */ @InterfaceAudience.Private public class MetaServerShutdownHandler extends ServerShutdownHandler { - private final boolean carryingRoot; private final boolean carryingMeta; private static final Log LOG = LogFactory.getLog(MetaServerShutdownHandler.class); public MetaServerShutdownHandler(final Server server, final MasterServices services, final DeadServer deadServers, final ServerName serverName, - final boolean carryingRoot, final boolean carryingMeta) { + final boolean carryingMeta) { super(server, services, deadServers, serverName, EventType.M_META_SERVER_SHUTDOWN, true); - this.carryingRoot = carryingRoot; this.carryingMeta = carryingMeta; } @@ -65,22 +63,7 @@ public class MetaServerShutdownHandler e } // Assign root and meta if we were carrying them. - if (isCarryingRoot()) { // -ROOT- - // Check again: region may be assigned to other where because of RIT - // timeout - if (this.services.getAssignmentManager().isCarryingRoot(serverName)) { - LOG.info("Server " + serverName - + " was carrying ROOT. Trying to assign."); - this.services.getAssignmentManager().regionOffline( - HRegionInfo.ROOT_REGIONINFO); - verifyAndAssignRootWithRetries(); - } else { - LOG.info("ROOT has been assigned to otherwhere, skip assigning."); - } - } - - // Carrying meta? - if (isCarryingMeta()) { + if (isCarryingMeta()) { // .META. // Check again: region may be assigned to other where because of RIT // timeout if (this.services.getAssignmentManager().isCarryingMeta(serverName)) { @@ -88,37 +71,37 @@ public class MetaServerShutdownHandler e + " was carrying META. Trying to assign."); this.services.getAssignmentManager().regionOffline( HRegionInfo.FIRST_META_REGIONINFO); - this.services.getAssignmentManager().assignMeta(); + verifyAndAssignMetaWithRetries(); } else { LOG.info("META has been assigned to otherwhere, skip assigning."); } - } super.process(); } + /** - * Before assign the ROOT region, ensure it haven't + * Before assign the META region, ensure it haven't * been assigned by other place *

- * Under some scenarios, the ROOT region can be opened twice, so it seemed online + * Under some scenarios, the META region can be opened twice, so it seemed online * in two regionserver at the same time. - * If the ROOT region has been assigned, so the operation can be canceled. + * If the META region has been assigned, so the operation can be canceled. * @throws InterruptedException * @throws IOException * @throws KeeperException */ - private void verifyAndAssignRoot() - throws InterruptedException, IOException, KeeperException { + private void verifyAndAssignMeta() + throws InterruptedException, IOException, KeeperException { long timeout = this.server.getConfiguration(). - getLong("hbase.catalog.verification.timeout", 1000); - if (!this.server.getCatalogTracker().verifyRootRegionLocation(timeout)) { - this.services.getAssignmentManager().assignRoot(); - } else if (serverName.equals(server.getCatalogTracker().getRootLocation())) { + getLong("hbase.catalog.verification.timeout", 1000); + if (!this.server.getCatalogTracker().verifyMetaRegionLocation(timeout)) { + this.services.getAssignmentManager().assignMeta(); + } else if (serverName.equals(server.getCatalogTracker().getMetaLocation())) { throw new IOException("-ROOT- is onlined on the dead server " + serverName); } else { LOG.info("Skip assigning -ROOT-, because it is online on the " - + server.getCatalogTracker().getRootLocation()); + + server.getCatalogTracker().getMetaLocation()); } } @@ -126,7 +109,7 @@ public class MetaServerShutdownHandler e * Failed many times, shutdown processing * @throws IOException */ - private void verifyAndAssignRootWithRetries() throws IOException { + private void verifyAndAssignMetaWithRetries() throws IOException { int iTimes = this.server.getConfiguration().getInt( "hbase.catalog.verification.retries", 10); @@ -136,14 +119,14 @@ public class MetaServerShutdownHandler e int iFlag = 0; while (true) { try { - verifyAndAssignRoot(); + verifyAndAssignMeta(); break; } catch (KeeperException e) { - this.server.abort("In server shutdown processing, assigning root", e); + this.server.abort("In server shutdown processing, assigning meta", e); throw new IOException("Aborting", e); } catch (Exception e) { if (iFlag >= iTimes) { - this.server.abort("verifyAndAssignRoot failed after" + iTimes + this.server.abort("verifyAndAssignMeta failed after" + iTimes + " times retries, aborting", e); throw new IOException("Aborting", e); } @@ -159,10 +142,6 @@ public class MetaServerShutdownHandler e } } - boolean isCarryingRoot() { - return this.carryingRoot; - } - boolean isCarryingMeta() { return this.carryingMeta; } Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java Fri Mar 8 22:37:19 2013 @@ -45,9 +45,8 @@ public class OpenedRegionHandler extends private final int expectedVersion; private enum OpenedPriority { - ROOT (1), - META (2), - USER (3); + META (1), + USER (2); private final int value; OpenedPriority(int value) { @@ -66,9 +65,7 @@ public class OpenedRegionHandler extends this.regionInfo = regionInfo; this.sn = sn; this.expectedVersion = expectedVersion; - if(regionInfo.isRootRegion()) { - priority = OpenedPriority.ROOT; - } else if(regionInfo.isMetaRegion()) { + if(regionInfo.isMetaRegion()) { priority = OpenedPriority.META; } else { priority = OpenedPriority.USER; Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java Fri Mar 8 22:37:19 2013 @@ -88,13 +88,6 @@ public class ServerShutdownHandler exten } /** - * @return True if the server we are processing was carrying -ROOT- - */ - boolean isCarryingRoot() { - return false; - } - - /** * @return True if the server we are processing was carrying .META. */ boolean isCarryingMeta() { @@ -130,8 +123,8 @@ public class ServerShutdownHandler exten serverName + ", will retry", ioe); } // We don't want worker thread in the MetaServerShutdownHandler - // executor pool to block by waiting availability of -ROOT- - // and .META. server. Otherwise, it could run into the following issue: + // executor pool to block by waiting availability of .META. + // Otherwise, it could run into the following issue: // 1. The current MetaServerShutdownHandler instance For RS1 waits for the .META. // to come online. // 2. The newly assigned .META. region server RS2 was shutdown right after @@ -150,7 +143,7 @@ public class ServerShutdownHandler exten // If AssignmentManager hasn't finished rebuilding user regions, // we are not ready to assign dead regions either. So we re-queue up // the dead server for further processing too. - if (isCarryingRoot() || isCarryingMeta() // -ROOT- or .META. + if (isCarryingMeta() // .META. || !services.getAssignmentManager().isFailoverCleanupDone()) { this.services.getServerManager().processDeadServer(serverName); return; Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Fri Mar 8 22:37:19 2013 @@ -4078,13 +4078,14 @@ public class HRegion implements HeapSize /** * Inserts a new region's meta information into the passed * meta region. Used by the HMaster bootstrap code adding - * new table to ROOT table. + * new table to META table. * * @param meta META HRegion to be updated * @param r HRegion to add to meta * * @throws IOException */ + // TODO remove since only test and merge use this public static void addRegionToMETA(HRegion meta, HRegion r) throws IOException { meta.checkResources(); @@ -5113,13 +5114,9 @@ public class HRegion implements HeapSize final boolean majorCompact) throws IOException { HRegion region = null; - String rootStr = Bytes.toString(HConstants.ROOT_TABLE_NAME); String metaStr = Bytes.toString(HConstants.META_TABLE_NAME); // Currently expects tables have one region only. - if (p.getName().startsWith(rootStr)) { - region = HRegion.newHRegion(p, log, fs, c, HRegionInfo.ROOT_REGIONINFO, - HTableDescriptor.ROOT_TABLEDESC, null); - } else if (p.getName().startsWith(metaStr)) { + if (p.getName().startsWith(metaStr)) { region = HRegion.newHRegion(p, log, fs, c, HRegionInfo.FIRST_META_REGIONINFO, HTableDescriptor.META_TABLEDESC, null); } else { @@ -5186,10 +5183,10 @@ public class HRegion implements HeapSize * is based on the size of the store. */ public byte[] checkSplit() { - // Can't split ROOT/META + // Can't split META if (this.getRegionInfo().isMetaTable()) { if (shouldForceSplit()) { - LOG.warn("Cannot split root/meta regions in HBase 0.20 and above"); + LOG.warn("Cannot split meta region in HBase 0.20 and above"); } return null; } Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Fri Mar 8 22:37:19 2013 @@ -46,7 +46,6 @@ import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentSkipListMap; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantReadWriteLock; import javax.management.ObjectName; @@ -179,10 +178,8 @@ import org.apache.hadoop.hbase.regionser import org.apache.hadoop.hbase.regionserver.compactions.CompactionProgress; import org.apache.hadoop.hbase.regionserver.handler.CloseMetaHandler; import org.apache.hadoop.hbase.regionserver.handler.CloseRegionHandler; -import org.apache.hadoop.hbase.regionserver.handler.CloseRootHandler; import org.apache.hadoop.hbase.regionserver.handler.OpenMetaHandler; import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; -import org.apache.hadoop.hbase.regionserver.handler.OpenRootHandler; import org.apache.hadoop.hbase.regionserver.snapshot.RegionServerSnapshotManager; import org.apache.hadoop.hbase.regionserver.wal.HLog; import org.apache.hadoop.hbase.regionserver.wal.HLogFactory; @@ -202,11 +199,11 @@ import org.apache.hadoop.hbase.util.Thre import org.apache.hadoop.hbase.util.VersionInfo; import org.apache.hadoop.hbase.zookeeper.ClusterStatusTracker; import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; -import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; import org.apache.hadoop.hbase.zookeeper.ZKClusterId; import org.apache.hadoop.hbase.zookeeper.ZKUtil; import org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker; import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; +import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker; import org.apache.hadoop.ipc.RemoteException; import org.apache.hadoop.metrics.util.MBeanUtil; import org.apache.hadoop.net.DNS; @@ -312,7 +309,6 @@ public class HRegionServer implements Cl protected final Configuration conf; - protected final AtomicBoolean haveRootRegion = new AtomicBoolean(false); private boolean useHBaseChecksum; // verify hbase checksums? private Path rootDir; @@ -567,7 +563,7 @@ public class HRegionServer implements Cl /** * Utility used ensuring higher quality of service for priority rpcs; e.g. - * rpcs to .META. and -ROOT-, etc. + * rpcs to .META., etc. */ class QosFunction implements Function { private final Map annotatedQos; @@ -968,7 +964,7 @@ public class HRegionServer implements Cl LOG.info("stopping server " + this.serverNameFromMasterPOV); } // Interrupt catalog tracker here in case any regions being opened out in - // handlers are stuck waiting on meta or root. + // handlers are stuck waiting on meta. if (this.catalogTracker != null) this.catalogTracker.stop(); // stop the snapshot handler, forcefully killing all running tasks @@ -1027,8 +1023,7 @@ public class HRegionServer implements Cl } private boolean containsMetaTableRegions() { - return onlineRegions.containsKey(HRegionInfo.ROOT_REGIONINFO.getEncodedName()) - || onlineRegions.containsKey(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName()); + return onlineRegions.containsKey(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName()); } private boolean areAllUserRegionsOffline() { @@ -1534,14 +1529,10 @@ public class HRegionServer implements Cl this.service = new ExecutorService(getServerName().toString()); this.service.startExecutorService(ExecutorType.RS_OPEN_REGION, conf.getInt("hbase.regionserver.executor.openregion.threads", 3)); - this.service.startExecutorService(ExecutorType.RS_OPEN_ROOT, - conf.getInt("hbase.regionserver.executor.openroot.threads", 1)); this.service.startExecutorService(ExecutorType.RS_OPEN_META, conf.getInt("hbase.regionserver.executor.openmeta.threads", 1)); this.service.startExecutorService(ExecutorType.RS_CLOSE_REGION, conf.getInt("hbase.regionserver.executor.closeregion.threads", 3)); - this.service.startExecutorService(ExecutorType.RS_CLOSE_ROOT, - conf.getInt("hbase.regionserver.executor.closeroot.threads", 1)); this.service.startExecutorService(ExecutorType.RS_CLOSE_META, conf.getInt("hbase.regionserver.executor.closemeta.threads", 1)); if (conf.getBoolean(StoreScanner.STORESCANNER_PARALLEL_SEEK_ENABLE, false)) { @@ -1708,13 +1699,10 @@ public class HRegionServer implements Cl LOG.error("No sequence number found when opening " + r.getRegionNameAsString()); openSeqNum = 0; } - // Update ZK, ROOT or META - if (r.getRegionInfo().isRootRegion()) { - RootRegionTracker.setRootLocation(getZooKeeper(), - this.serverNameFromMasterPOV); - } else if (r.getRegionInfo().isMetaRegion()) { - MetaEditor.updateMetaLocation(ct, r.getRegionInfo(), - this.serverNameFromMasterPOV, openSeqNum); + // Update ZK, or META + if (r.getRegionInfo().isMetaRegion()) { + MetaRegionTracker.setMetaLocation(getZooKeeper(), + this.serverNameFromMasterPOV); } else { MetaEditor.updateRegionLocation(ct, r.getRegionInfo(), this.serverNameFromMasterPOV, openSeqNum); @@ -1974,28 +1962,24 @@ public class HRegionServer implements Cl } /** - * Close root and meta regions if we carry them + * Close meta region if we carry it * @param abort Whether we're running an abort. */ void closeMetaTableRegions(final boolean abort) { HRegion meta = null; - HRegion root = null; this.lock.writeLock().lock(); try { for (Map.Entry e: onlineRegions.entrySet()) { HRegionInfo hri = e.getValue().getRegionInfo(); - if (hri.isRootRegion()) { - root = e.getValue(); - } else if (hri.isMetaRegion()) { + if (hri.isMetaRegion()) { meta = e.getValue(); } - if (meta != null && root != null) break; + if (meta != null) break; } } finally { this.lock.writeLock().unlock(); } if (meta != null) closeRegionIgnoreErrors(meta.getRegionInfo(), abort); - if (root != null) closeRegionIgnoreErrors(root.getRegionInfo(), abort); } /** @@ -2490,9 +2474,7 @@ public class HRegionServer implements Cl CloseRegionHandler crh; final HRegionInfo hri = actualRegion.getRegionInfo(); - if (hri.isRootRegion()) { - crh = new CloseRootHandler(this, this, hri, abort, zk, versionOfClosingNode); - } else if (hri.isMetaRegion()) { + if (hri.isMetaRegion()) { crh = new CloseMetaHandler(this, this, hri, abort, zk, versionOfClosingNode); } else { crh = new CloseRegionHandler(this, this, hri, abort, zk, versionOfClosingNode, sn); @@ -3487,10 +3469,7 @@ public class HRegionServer implements Cl if (previous == null) { // If there is no action in progress, we can submit a specific handler. // Need to pass the expected version in the constructor. - if (region.isRootRegion()) { - this.service.submit(new OpenRootHandler(this, this, region, htd, - versionOfOfflineNode)); - } else if (region.isMetaRegion()) { + if (region.isMetaRegion()) { this.service.submit(new OpenMetaHandler(this, this, region, htd, versionOfOfflineNode)); } else { Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java Fri Mar 8 22:37:19 2013 @@ -218,7 +218,7 @@ public class OpenRegionHandler extends E } /** - * Update ZK, ROOT or META. This can take a while if for example the + * Update ZK or META. This can take a while if for example the * .META. is not available -- if server hosting .META. crashed and we are * waiting on it to come back -- so run in a thread and keep updating znode * state meantime so master doesn't timeout our region-in-transition. Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java Fri Mar 8 22:37:19 2013 @@ -205,9 +205,9 @@ public class AccessController extends Ba HRegionInfo hri = e.getRegion().getRegionInfo(); byte[] tableName = hri.getTableName(); - // 1. All users need read access to .META. and -ROOT- tables. + // 1. All users need read access to .META. table. // this is a very common operation, so deal with it quickly. - if (hri.isRootRegion() || hri.isMetaRegion()) { + if (hri.isMetaRegion()) { if (permRequest == Permission.Action.READ) { return AuthResult.allow(request, "All users allowed", user, permRequest, tableName, families); @@ -225,7 +225,7 @@ public class AccessController extends Ba // e.g. When a table is removed an entry is removed from .META. and _acl_ // and the user need to be allowed to write on both tables. if (permRequest == Permission.Action.WRITE && - (hri.isRootRegion() || hri.isMetaRegion() || + (hri.isMetaRegion() || Bytes.equals(tableName, AccessControlLists.ACL_GLOBAL_NAME)) && (authManager.authorize(user, Permission.Action.CREATE) || authManager.authorize(user, Permission.Action.ADMIN))) Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java Fri Mar 8 22:37:19 2013 @@ -453,7 +453,7 @@ public abstract class FSUtils { throws IOException, DeserializationException { String version = getVersion(fs, rootdir); if (version == null) { - if (!rootRegionExists(fs, rootdir)) { + if (!metaRegionExists(fs, rootdir)) { // rootDir is empty (no version file and no root region) // just create new version file (HBASE-1195) setVersion(fs, rootdir, wait, retries); @@ -774,10 +774,10 @@ public abstract class FSUtils { * @return true if exists * @throws IOException e */ - public static boolean rootRegionExists(FileSystem fs, Path rootdir) + public static boolean metaRegionExists(FileSystem fs, Path rootdir) throws IOException { Path rootRegionDir = - HRegion.getRegionDir(rootdir, HRegionInfo.ROOT_REGIONINFO); + HRegion.getRegionDir(rootdir, HRegionInfo.FIRST_META_REGIONINFO); return fs.exists(rootRegionDir); } Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Fri Mar 8 22:37:19 2013 @@ -94,7 +94,7 @@ import org.apache.hadoop.hbase.util.HBas import org.apache.hadoop.hbase.util.hbck.HFileCorruptionChecker; import org.apache.hadoop.hbase.util.hbck.TableIntegrityErrorHandler; import org.apache.hadoop.hbase.util.hbck.TableIntegrityErrorHandlerImpl; -import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; +import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker; import org.apache.hadoop.hbase.zookeeper.ZKTableReadOnly; import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; import org.apache.hadoop.security.AccessControlException; @@ -197,7 +197,7 @@ public class HBaseFsck extends Configure private boolean fixReferenceFiles = false; // fix lingering reference store file // limit checking/fixes to listed tables, if empty attempt to check/fix all - // -ROOT- and .META. are always checked + // .META. are always checked private Set tablesIncluded = new HashSet(); 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 @@ -234,7 +234,7 @@ public class HBaseFsck extends Configure * If tablesIncluded is empty, this map contains all tables. * Otherwise, it contains only meta tables and tables in tablesIncluded, * unless checkMetaOnly is specified, in which case, it contains only - * the meta tables (.META. and -ROOT-). + * the meta table */ private SortedMap tablesInfo = new ConcurrentSkipListMap(); @@ -258,7 +258,7 @@ public class HBaseFsck extends Configure errors = getErrorReporter(conf); int numThreads = conf.getInt("hbasefsck.numthreads", MAX_NUM_THREADS); - executor = new ScheduledThreadPoolExecutor(numThreads); + executor = new ScheduledThreadPoolExecutor(numThreads, Threads.newDaemonThreadFactory("hbasefsck")); } /** @@ -692,8 +692,7 @@ public class HBaseFsck extends Configure String tableName = td.getNameAsString(); errors.detail(" Table: " + tableName + "\t" + (td.isReadOnly() ? "ro" : "rw") + "\t" + - (td.isRootRegion() ? "ROOT" : - (td.isMetaRegion() ? "META" : " ")) + "\t" + + (td.isMetaRegion() ? "META" : " ") + "\t" + " families: " + td.getFamilies().size()); } } @@ -918,23 +917,14 @@ public class HBaseFsck extends Configure * * @return an open .META. HRegion */ - private HRegion createNewRootAndMeta() throws IOException { - Path rootdir = FSUtils.getRootDir(getConf()); + private HRegion createNewMeta() throws IOException { + Path rootdir = FSUtils.getRootDir(getConf()); Configuration c = getConf(); - HRegionInfo rootHRI = new HRegionInfo(HRegionInfo.ROOT_REGIONINFO); - MasterFileSystem.setInfoFamilyCachingForRoot(false); HRegionInfo metaHRI = new HRegionInfo(HRegionInfo.FIRST_META_REGIONINFO); MasterFileSystem.setInfoFamilyCachingForMeta(false); - HRegion root = HRegion.createHRegion(rootHRI, rootdir, c, - HTableDescriptor.ROOT_TABLEDESC); HRegion meta = HRegion.createHRegion(metaHRI, rootdir, c, HTableDescriptor.META_TABLEDESC); - MasterFileSystem.setInfoFamilyCachingForRoot(true); MasterFileSystem.setInfoFamilyCachingForMeta(true); - - // Add first region from the META table to the ROOT region. - HRegion.addRegionToMETA(root, meta); - HRegion.closeHRegion(root); return meta; } @@ -950,9 +940,8 @@ public class HBaseFsck extends Configure for (Entry e : tablesInfo.entrySet()) { String name = e.getKey(); - // skip "-ROOT-" and ".META." - if (Bytes.compareTo(Bytes.toBytes(name), HConstants.ROOT_TABLE_NAME) == 0 - || Bytes.compareTo(Bytes.toBytes(name), HConstants.META_TABLE_NAME) == 0) { + // skip ".META." + if (Bytes.compareTo(Bytes.toBytes(name), HConstants.META_TABLE_NAME) == 0) { continue; } @@ -1032,24 +1021,24 @@ public class HBaseFsck extends Configure } } - // we can rebuild, move old root and meta out of the way and start + // we can rebuild, move old meta out of the way and start LOG.info("HDFS regioninfo's seems good. Sidelining old .META."); - Path backupDir = sidelineOldRootAndMeta(); + Path backupDir = sidelineOldMeta(); LOG.info("Creating new .META."); - HRegion meta = createNewRootAndMeta(); + HRegion meta = createNewMeta(); // populate meta List puts = generatePuts(tablesInfo); if (puts == null) { LOG.fatal("Problem encountered when creating new .META. entries. " + - "You may need to restore the previously sidelined -ROOT- and .META."); + "You may need to restore the previously sidelined .META."); return false; } meta.put(puts.toArray(new Put[0])); HRegion.closeHRegion(meta); LOG.info("Success! .META. table rebuilt."); - LOG.info("Old -ROOT- and .META. are moved into " + backupDir); + LOG.info("Old .META. is moved into " + backupDir); return true; } @@ -1189,29 +1178,19 @@ public class HBaseFsck extends Configure /** * @return Path to backup of original directory */ - Path sidelineOldRootAndMeta() throws IOException { - // put current -ROOT- and .META. aside. + Path sidelineOldMeta() throws IOException { + // put current .META. aside. Path hbaseDir = FSUtils.getRootDir(getConf()); FileSystem fs = hbaseDir.getFileSystem(getConf()); Path backupDir = getSidelineDir(); fs.mkdirs(backupDir); - sidelineTable(fs, HConstants.ROOT_TABLE_NAME, hbaseDir, backupDir); try { sidelineTable(fs, HConstants.META_TABLE_NAME, hbaseDir, backupDir); } catch (IOException e) { - LOG.error("Attempt to sideline meta failed, attempt to revert...", e); - try { - // move it back. - sidelineTable(fs, HConstants.ROOT_TABLE_NAME, backupDir, hbaseDir); - LOG.warn("... revert succeed. -ROOT- and .META. still in " - + "original state."); - } catch (IOException ioe) { - LOG.fatal("... failed to sideline root and meta and failed to restore " - + "prevoius state. Currently in inconsistent state. To restore " - + "try to rename -ROOT- in " + backupDir.getName() + " to " - + hbaseDir.getName() + ".", ioe); - } + LOG.fatal("... failed to sideline meta. Currently in inconsistent state. To restore " + + "try to rename .META. in " + backupDir.getName() + " to " + + hbaseDir.getName() + ".", e); throw e; // throw original exception } return backupDir; @@ -1268,7 +1247,6 @@ public class HBaseFsck extends Configure foundVersionFile = true; } else { if ((!checkMetaOnly && isTableIncluded(dirName)) || - dirName.equals("-ROOT-") || dirName.equals(".META.")) { tableDirs.add(file); } @@ -1312,31 +1290,29 @@ public class HBaseFsck extends Configure } /** - * Record the location of the ROOT region as found in ZooKeeper, - * as if it were in a META table. This is so that we can check - * deployment of ROOT. - */ - private boolean recordRootRegion() throws IOException { - HRegionLocation rootLocation = connection.locateRegion( - HConstants.ROOT_TABLE_NAME, HConstants.EMPTY_START_ROW); - - // Check if Root region is valid and existing - if (rootLocation == null || rootLocation.getRegionInfo() == null || - rootLocation.getHostname() == null) { - errors.reportError(ERROR_CODE.NULL_ROOT_REGION, - "Root Region or some of its attributes are null."); + * Record the location of the META region as found in ZooKeeper. + */ + private boolean recordMetaRegion() throws IOException { + HRegionLocation metaLocation = connection.locateRegion( + HConstants.META_TABLE_NAME, HConstants.EMPTY_START_ROW); + + // Check if Meta region is valid and existing + if (metaLocation == null || metaLocation.getRegionInfo() == null || + metaLocation.getHostname() == null) { + errors.reportError(ERROR_CODE.NULL_META_REGION, + "META region or some of its attributes are null."); return false; } ServerName sn; try { - sn = getRootRegionServerName(); + sn = getMetaRegionServerName(); } catch (KeeperException e) { throw new IOException(e); } MetaEntry m = - new MetaEntry(rootLocation.getRegionInfo(), sn, System.currentTimeMillis()); + new MetaEntry(metaLocation.getRegionInfo(), sn, System.currentTimeMillis()); HbckInfo hbInfo = new HbckInfo(m); - regionInfoMap.put(rootLocation.getRegionInfo().getEncodedName(), hbInfo); + regionInfoMap.put(metaLocation.getRegionInfo().getEncodedName(), hbInfo); return true; } @@ -1356,12 +1332,12 @@ public class HBaseFsck extends Configure }); } - private ServerName getRootRegionServerName() + private ServerName getMetaRegionServerName() throws IOException, KeeperException { ZooKeeperWatcher zkw = createZooKeeperWatcher(); ServerName sn = null; try { - sn = RootRegionTracker.getRootRegionLocation(zkw); + sn = MetaRegionTracker.getMetaRegionLocation(zkw); } finally { zkw.close(); } @@ -2524,14 +2500,14 @@ public class HBaseFsck extends Configure } /** - * Scan .META. and -ROOT-, adding all regions found to the regionInfo map. + * Scan .META., adding all regions found to the regionInfo map. * @throws IOException if an error is encountered */ boolean loadMetaEntries() throws IOException { // get a list of all regions from the master. This involves // scanning the META table - if (!recordRootRegion()) { + if (!recordMetaRegion()) { // Will remove later if we can fix it errors.reportError("Fatal error: unable to get root region location. Exiting..."); return false; @@ -2563,7 +2539,7 @@ public class HBaseFsck extends Configure } HRegionInfo hri = pair.getFirst(); if (!(isTableIncluded(hri.getTableNameAsString()) - || hri.isMetaRegion() || hri.isRootRegion())) { + || hri.isMetaRegion())) { return true; } PairOfSameType daughters = HRegionInfo.getDaughterRegions(result); @@ -2586,11 +2562,6 @@ public class HBaseFsck extends Configure } } }; - - // Scan -ROOT- to pick up META regions - MetaScanner.metaScan(getConf(), visitor, null, null, - Integer.MAX_VALUE, HConstants.ROOT_TABLE_NAME); - if (!checkMetaOnly) { // Scan .META. to pick up user regions MetaScanner.metaScan(getConf(), visitor); @@ -2874,7 +2845,7 @@ public class HBaseFsck extends Configure public interface ErrorReporter { public static enum ERROR_CODE { - UNKNOWN, NO_META_REGION, NULL_ROOT_REGION, NO_VERSION_FILE, NOT_IN_META_HDFS, NOT_IN_META, + UNKNOWN, NO_META_REGION, NULL_META_REGION, NO_VERSION_FILE, NOT_IN_META_HDFS, NOT_IN_META, NOT_IN_META_OR_DEPLOYED, NOT_IN_HDFS_OR_DEPLOYED, NOT_IN_HDFS, SERVER_DOES_NOT_MATCH_META, NOT_DEPLOYED, MULTI_DEPLOYED, SHOULD_NOT_BE_DEPLOYED, MULTI_META_REGION, RS_CONNECT_FAILURE, FIRST_REGION_STARTKEY_NOT_EMPTY, LAST_REGION_ENDKEY_NOT_EMPTY, DUPE_STARTKEYS, @@ -3419,8 +3390,8 @@ public class HBaseFsck extends Configure out.println(" -sleepBeforeRerun Sleep this many seconds" + " before checking if the fix worked if run with -fix"); out.println(" -summary Print only summary of the tables and status."); - out.println(" -metaonly Only check the state of ROOT and META tables."); - out.println(" -sidelineDir HDFS path to backup existing meta and root."); + out.println(" -metaonly Only check the state of the .META. table."); + out.println(" -sidelineDir HDFS path to backup existing meta."); out.println(""); out.println(" Metadata Repair options: (expert features, use with caution!)"); Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java Fri Mar 8 22:37:19 2013 @@ -121,7 +121,7 @@ class HMerge { throw new IllegalStateException( "Can not compact META table if instance is on-line"); } - new OfflineMerger(conf, fs).process(); + // TODO reenable new OfflineMerger(conf, fs).process(); } else { if(!masterIsRunning) { throw new IllegalStateException( @@ -333,90 +333,4 @@ class HMerge { } } } - - /** Instantiated to compact the meta region */ - private static class OfflineMerger extends Merger { - private final List metaRegions = new ArrayList(); - private final HRegion root; - - OfflineMerger(Configuration conf, FileSystem fs) - throws IOException { - super(conf, fs, HConstants.META_TABLE_NAME); - - Path rootDir = FSUtils.getRootDir(conf); - - // Scan root region to find all the meta regions - root = HRegion.openHRegion(conf, fs, rootDir, HRegionInfo.ROOT_REGIONINFO, - HTableDescriptor.ROOT_TABLEDESC, hlog); - - Scan scan = new Scan(); - scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); - InternalScanner rootScanner = root.getScanner(scan); - - try { - List results = new ArrayList(); - boolean hasMore; - do { - hasMore = rootScanner.next(results); - for(KeyValue kv: results) { - HRegionInfo info = HRegionInfo.parseFromOrNull(kv.getValue()); - if (info != null) { - metaRegions.add(info); - } - } - } while (hasMore); - } finally { - rootScanner.close(); - try { - root.close(); - - } catch(IOException e) { - LOG.error(e); - } - } - } - - @Override - protected HRegionInfo[] next() { - HRegionInfo[] results = null; - if (metaRegions.size() > 0) { - results = metaRegions.toArray(new HRegionInfo[metaRegions.size()]); - metaRegions.clear(); - } - return results; - } - - @Override - protected void updateMeta(final byte [] oldRegion1, - final byte [] oldRegion2, HRegion newRegion) - throws IOException { - byte[][] regionsToDelete = {oldRegion1, oldRegion2}; - for(int r = 0; r < regionsToDelete.length; r++) { - Delete delete = new Delete(regionsToDelete[r]); - delete.deleteColumns(HConstants.CATALOG_FAMILY, - HConstants.REGIONINFO_QUALIFIER); - delete.deleteColumns(HConstants.CATALOG_FAMILY, - HConstants.SERVER_QUALIFIER); - delete.deleteColumns(HConstants.CATALOG_FAMILY, - HConstants.STARTCODE_QUALIFIER); - delete.deleteColumns(HConstants.CATALOG_FAMILY, - HConstants.SPLITA_QUALIFIER); - delete.deleteColumns(HConstants.CATALOG_FAMILY, - HConstants.SPLITB_QUALIFIER); - root.delete(delete, true); - - if(LOG.isDebugEnabled()) { - LOG.debug("updated columns in row: " + Bytes.toStringBinary(regionsToDelete[r])); - } - } - HRegionInfo newInfo = newRegion.getRegionInfo(); - newInfo.setOffline(true); - - Put put = MetaEditor.makePutFromRegionInfo(newInfo); - root.put(put); - if(LOG.isDebugEnabled()) { - LOG.debug("updated columns in row: " + Bytes.toStringBinary(newRegion.getRegionName())); - } - } - } } Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java Fri Mar 8 22:37:19 2013 @@ -109,23 +109,10 @@ public class Merge extends Configured im this.utils = new MetaUtils(getConf()); this.rootdir = FSUtils.getRootDir(getConf()); try { - if (isMetaTable) { - mergeTwoMetaRegions(); - } else { - mergeTwoRegions(); - } + mergeTwoRegions(); return 0; } catch (Exception e) { LOG.fatal("Merge failed", e); - utils.scanMetaRegion(HRegionInfo.FIRST_META_REGIONINFO, - new MetaUtils.ScannerListener() { - public boolean processRow(HRegionInfo info) { - System.err.println(info.toString()); - return true; - } - } - ); - return -1; } finally { @@ -141,155 +128,56 @@ public class Merge extends Configured im } /* - * Merge two meta regions. This is unlikely to be needed soon as we have only - * seend the meta table split once and that was with 64MB regions. With 256MB - * regions, it will be some time before someone has enough data in HBase to - * split the meta region and even less likely that a merge of two meta - * regions will be needed, but it is included for completeness. - */ - private void mergeTwoMetaRegions() throws IOException { - HRegion rootRegion = utils.getRootRegion(); - Get get = new Get(region1); - get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); - Result result1 = rootRegion.get(get); - Preconditions.checkState(!result1.isEmpty(), "First region cells can not be null"); - HRegionInfo info1 = HRegionInfo.getHRegionInfo(result1); - - get = new Get(region2); - get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); - Result result2 = rootRegion.get(get); - Preconditions.checkState(!result2.isEmpty(), "Second region cells can not be null"); - HRegionInfo info2 = HRegionInfo.getHRegionInfo(result2); - HRegion merged = merge(HTableDescriptor.META_TABLEDESC, info1, rootRegion, info2, rootRegion); - LOG.info("Adding " + merged.getRegionInfo() + " to " + - rootRegion.getRegionInfo()); - HRegion.addRegionToMETA(rootRegion, merged); - merged.close(); - } - - private static class MetaScannerListener - implements MetaUtils.ScannerListener { - private final byte [] region1; - private final byte [] region2; - private HRegionInfo meta1 = null; - private HRegionInfo meta2 = null; - - MetaScannerListener(final byte [] region1, final byte [] region2) { - this.region1 = region1; - this.region2 = region2; - } - - public boolean processRow(HRegionInfo info) { - if (meta1 == null && HRegion.rowIsInRange(info, region1)) { - meta1 = info; - } - if (region2 != null && meta2 == null && - HRegion.rowIsInRange(info, region2)) { - meta2 = info; - } - return meta1 == null || (region2 != null && meta2 == null); - } - - HRegionInfo getMeta1() { - return meta1; - } - - HRegionInfo getMeta2() { - return meta2; - } - } - - /* * Merges two regions from a user table. */ private void mergeTwoRegions() throws IOException { LOG.info("Merging regions " + Bytes.toStringBinary(this.region1) + " and " + Bytes.toStringBinary(this.region2) + " in table " + Bytes.toString(this.tableName)); - // Scan the root region for all the meta regions that contain the regions - // we're merging. - MetaScannerListener listener = new MetaScannerListener(region1, region2); - this.utils.scanRootRegion(listener); - HRegionInfo meta1 = listener.getMeta1(); - if (meta1 == null) { - throw new IOException("Could not find meta region for " + Bytes.toStringBinary(region1)); - } - HRegionInfo meta2 = listener.getMeta2(); - if (meta2 == null) { - throw new IOException("Could not find meta region for " + Bytes.toStringBinary(region2)); - } - LOG.info("Found meta for region1 " + Bytes.toStringBinary(meta1.getRegionName()) + - ", meta for region2 " + Bytes.toStringBinary(meta2.getRegionName())); - HRegion metaRegion1 = this.utils.getMetaRegion(meta1); + HRegion meta = this.utils.getMetaRegion(); Get get = new Get(region1); get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); - Result result1 = metaRegion1.get(get); + Result result1 = meta.get(get); Preconditions.checkState(!result1.isEmpty(), "First region cells can not be null"); HRegionInfo info1 = HRegionInfo.getHRegionInfo(result1); if (info1 == null) { throw new NullPointerException("info1 is null using key " + - Bytes.toStringBinary(region1) + " in " + meta1); - } - - HRegion metaRegion2; - if (Bytes.equals(meta1.getRegionName(), meta2.getRegionName())) { - metaRegion2 = metaRegion1; - } else { - metaRegion2 = utils.getMetaRegion(meta2); + Bytes.toStringBinary(region1) + " in " + meta); } get = new Get(region2); get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); - Result result2 = metaRegion2.get(get); + Result result2 = meta.get(get); Preconditions.checkState(!result2.isEmpty(), "Second region cells can not be null"); HRegionInfo info2 = HRegionInfo.getHRegionInfo(result2); if (info2 == null) { - throw new NullPointerException("info2 is null using key " + meta2); + throw new NullPointerException("info2 is null using key " + meta); } HTableDescriptor htd = FSTableDescriptors.getTableDescriptor(FileSystem.get(getConf()), this.rootdir, this.tableName); - HRegion merged = merge(htd, info1, metaRegion1, info2, metaRegion2); - - // Now find the meta region which will contain the newly merged region + HRegion merged = merge(htd, meta, info1, info2); - listener = new MetaScannerListener(merged.getRegionName(), null); - utils.scanRootRegion(listener); - HRegionInfo mergedInfo = listener.getMeta1(); - if (mergedInfo == null) { - throw new IOException("Could not find meta region for " + - Bytes.toStringBinary(merged.getRegionName())); - } - HRegion mergeMeta; - if (Bytes.equals(mergedInfo.getRegionName(), meta1.getRegionName())) { - mergeMeta = metaRegion1; - } else if (Bytes.equals(mergedInfo.getRegionName(), meta2.getRegionName())) { - mergeMeta = metaRegion2; - } else { - mergeMeta = utils.getMetaRegion(mergedInfo); - } LOG.info("Adding " + merged.getRegionInfo() + " to " + - mergeMeta.getRegionInfo()); + meta.getRegionInfo()); - HRegion.addRegionToMETA(mergeMeta, merged); + HRegion.addRegionToMETA(meta, merged); merged.close(); } /* * Actually merge two regions and update their info in the meta region(s) - * If the meta is split, meta1 may be different from meta2. (and we may have - * to scan the meta if the resulting merged region does not go in either) * Returns HRegion object for newly merged region */ - private HRegion merge(final HTableDescriptor htd, HRegionInfo info1, - HRegion meta1, HRegionInfo info2, HRegion meta2) + private HRegion merge(final HTableDescriptor htd, HRegion meta, + HRegionInfo info1, HRegionInfo info2) throws IOException { if (info1 == null) { throw new IOException("Could not find " + Bytes.toStringBinary(region1) + " in " + - Bytes.toStringBinary(meta1.getRegionName())); + Bytes.toStringBinary(meta.getRegionName())); } if (info2 == null) { throw new IOException("Cound not find " + Bytes.toStringBinary(region2) + " in " + - Bytes.toStringBinary(meta2.getRegionName())); + Bytes.toStringBinary(meta.getRegionName())); } HRegion merged = null; HLog log = utils.getLog(); @@ -312,8 +200,8 @@ public class Merge extends Configured im // Remove the old regions from meta. // HRegion.merge has already deleted their files - removeRegionFromMeta(meta1, info1); - removeRegionFromMeta(meta2, info2); + removeRegionFromMeta(meta, info1); + removeRegionFromMeta(meta, info2); this.mergeInfo = merged.getRegionInfo(); return merged; Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java (original) +++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java Fri Mar 8 22:37:19 2013 @@ -31,7 +31,6 @@ import org.apache.commons.logging.LogFac import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; @@ -62,7 +61,7 @@ public class MetaUtils { private final Configuration conf; private FileSystem fs; private HLog log; - private HRegion rootRegion; + private HRegion metaRegion; private Map metaRegions = Collections.synchronizedSortedMap( new TreeMap(Bytes.BYTES_COMPARATOR)); @@ -80,7 +79,7 @@ public class MetaUtils { public MetaUtils(Configuration conf) throws IOException { this.conf = conf; conf.setInt("hbase.client.retries.number", 1); - this.rootRegion = null; + this.metaRegion = null; initialize(); } @@ -107,31 +106,14 @@ public class MetaUtils { } /** - * @return HRegion for root region + * @return HRegion for meta region * @throws IOException e */ - public HRegion getRootRegion() throws IOException { - if (this.rootRegion == null) { - openRootRegion(); + public HRegion getMetaRegion() throws IOException { + if (this.metaRegion == null) { + openMetaRegion(); } - return this.rootRegion; - } - - /** - * Open or return cached opened meta region - * - * @param metaInfo HRegionInfo for meta region - * @return meta HRegion - * @throws IOException e - */ - public HRegion getMetaRegion(HRegionInfo metaInfo) throws IOException { - HRegion meta = metaRegions.get(metaInfo.getRegionName()); - if (meta == null) { - meta = openMetaRegion(metaInfo); - LOG.info("OPENING META " + meta.toString()); - this.metaRegions.put(metaInfo.getRegionName(), meta); - } - return meta; + return this.metaRegion; } /** @@ -140,13 +122,13 @@ public class MetaUtils { * MetaUtils edit session. */ public void shutdown() { - if (this.rootRegion != null) { + if (this.metaRegion != null) { try { - this.rootRegion.close(); + this.metaRegion.close(); } catch (IOException e) { - LOG.error("closing root region", e); + LOG.error("closing meta region", e); } finally { - this.rootRegion = null; + this.metaRegion = null; } } try { @@ -171,229 +153,14 @@ public class MetaUtils { } } - /** - * Used by scanRootRegion and scanMetaRegion to call back the caller so it - * can process the data for a row. - */ - public interface ScannerListener { - /** - * Callback so client of scanner can process row contents - * - * @param info HRegionInfo for row - * @return false to terminate the scan - * @throws IOException e - */ - public boolean processRow(HRegionInfo info) throws IOException; - } - - /** - * Scans the root region. For every meta region found, calls the listener with - * the HRegionInfo of the meta region. - * - * @param listener method to be called for each meta region found - * @throws IOException e - */ - public void scanRootRegion(ScannerListener listener) throws IOException { - // Open root region so we can scan it - if (this.rootRegion == null) { - openRootRegion(); + private synchronized HRegion openMetaRegion() throws IOException { + if (this.metaRegion != null) { + return this.metaRegion; } - scanMetaRegion(this.rootRegion, listener); - } - - /** - * Scan the passed in metaregion m invoking the passed - * listener per row found. - * @param r region - * @param listener scanner listener - * @throws IOException e - */ - public void scanMetaRegion(final HRegion r, final ScannerListener listener) - throws IOException { - Scan scan = new Scan(); - scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); - InternalScanner s = r.getScanner(scan); - try { - List results = new ArrayList(); - boolean hasNext = true; - do { - hasNext = s.next(results); - HRegionInfo info = null; - for (KeyValue kv: results) { - info = HRegionInfo.parseFromOrNull(kv.getValue()); - if (info == null) { - LOG.warn("Region info is null for row " + - Bytes.toStringBinary(kv.getRow()) + " in table " + - r.getTableDesc().getNameAsString()); - } - continue; - } - if (!listener.processRow(info)) { - break; - } - results.clear(); - } while (hasNext); - } finally { - s.close(); - } - } - - /** - * Scans a meta region. For every region found, calls the listener with - * the HRegionInfo of the region. - * TODO: Use Visitor rather than Listener pattern. Allow multiple Visitors. - * Use this everywhere we scan meta regions: e.g. in metascanners, in close - * handling, etc. Have it pass in the whole row, not just HRegionInfo. - *

Use for reading meta only. Does not close region when done. - * Use {@link #getMetaRegion(HRegionInfo)} instead if writing. Adds - * meta region to list that will get a close on {@link #shutdown()}. - * - * @param metaRegionInfo HRegionInfo for meta region - * @param listener method to be called for each meta region found - * @throws IOException e - */ - public void scanMetaRegion(HRegionInfo metaRegionInfo, - ScannerListener listener) - throws IOException { - // Open meta region so we can scan it - HRegion metaRegion = openMetaRegion(metaRegionInfo); - scanMetaRegion(metaRegion, listener); - } - - private synchronized HRegion openRootRegion() throws IOException { - if (this.rootRegion != null) { - return this.rootRegion; - } - this.rootRegion = HRegion.openHRegion(HRegionInfo.ROOT_REGIONINFO, - HTableDescriptor.ROOT_TABLEDESC, getLog(), + this.metaRegion = HRegion.openHRegion(HRegionInfo.FIRST_META_REGIONINFO, + HTableDescriptor.META_TABLEDESC, getLog(), this.conf); - this.rootRegion.compactStores(); - return this.rootRegion; - } - - private HRegion openMetaRegion(HRegionInfo metaInfo) throws IOException { - HRegion meta = HRegion.openHRegion(metaInfo, HTableDescriptor.META_TABLEDESC, - getLog(), this.conf); - meta.compactStores(); - return meta; - } - - /** - * Set a single region on/offline. - * This is a tool to repair tables that have offlined tables in their midst. - * Can happen on occasion. Use at your own risk. Call from a bit of java - * or jython script. This method is 'expensive' in that it creates a - * {@link HTable} instance per invocation to go against .META. - * @param c A configuration that has its hbase.master - * properly set. - * @param row Row in the catalog .META. table whose HRegionInfo's offline - * status we want to change. - * @param onlineOffline Pass true to OFFLINE the region. - * @throws IOException e - */ - public static void changeOnlineStatus (final Configuration c, - final byte [] row, final boolean onlineOffline) - throws IOException { - HTable t = new HTable(c, HConstants.META_TABLE_NAME); - Get get = new Get(row); - get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); - Result res = t.get(get); - KeyValue [] kvs = res.raw(); - if(kvs.length <= 0) { - throw new IOException("no information for row " + Bytes.toString(row)); - } - HRegionInfo info = HRegionInfo.getHRegionInfo(res); - if (info == null) { - throw new IOException("no information for row " + Bytes.toString(row)); - } - - info.setOffline(onlineOffline); - MetaEditor.addRegionToMeta(t, info); - - Delete delete = new Delete(row); - delete.deleteColumns(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER); - delete.deleteColumns(HConstants.CATALOG_FAMILY, - HConstants.STARTCODE_QUALIFIER); - - t.delete(delete); - } - - /** - * Update COL_REGIONINFO in meta region r with HRegionInfo hri - * - * @param r region - * @param hri region info - * @throws IOException e - */ - public void updateMETARegionInfo(HRegion r, final HRegionInfo hri) - throws IOException { - if (LOG.isDebugEnabled()) { - Get get = new Get(hri.getRegionName()); - get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); - Result res = r.get(get); - KeyValue [] kvs = res.raw(); - if(kvs.length <= 0) { - return; - } - - HRegionInfo h = HRegionInfo.getHRegionInfo(res); - if (h == null) { - return; - } - LOG.debug("Old " + Bytes.toString(HConstants.CATALOG_FAMILY) + ":" + - Bytes.toString(HConstants.REGIONINFO_QUALIFIER) + " for " + - hri.toString() + " in " + r.toString() + " is: " + h.toString()); - } - - Put put = MetaEditor.makePutFromRegionInfo(hri); - r.put(put); - - if (LOG.isDebugEnabled()) { - Get get = new Get(hri.getRegionName()); - get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); - Result res = r.get(get); - KeyValue [] kvs = res.raw(); - if(kvs.length <= 0) { - return; - } - HRegionInfo h = HRegionInfo.getHRegionInfo(res); - if (h == null) { - return; - } - LOG.debug("New " + Bytes.toString(HConstants.CATALOG_FAMILY) + ":" + - Bytes.toString(HConstants.REGIONINFO_QUALIFIER) + " for " + - hri.toString() + " in " + r.toString() + " is: " + h.toString()); - } - } - - /** - * @return List of {@link HRegionInfo} rows found in the ROOT or META - * catalog table. - * @param tableName Name of table to go looking for. - * @throws IOException e - * @see #getMetaRegion(HRegionInfo) - */ - public List getMETARows(final byte [] tableName) - throws IOException { - final List result = new ArrayList(); - // If passed table name is META, then return the root region. - if (Bytes.equals(HConstants.META_TABLE_NAME, tableName)) { - result.add(openRootRegion().getRegionInfo()); - return result; - } - // Return all meta regions that contain the passed tablename. - scanRootRegion(new ScannerListener() { - private final Log SL_LOG = LogFactory.getLog(this.getClass()); - - public boolean processRow(HRegionInfo info) throws IOException { - SL_LOG.debug("Testing " + info); - if (Bytes.equals(info.getTableName(), - HConstants.META_TABLE_NAME)) { - result.add(info); - return false; - } - return true; - }}); - return result; + this.metaRegion.compactStores(); + return this.metaRegion; } } Modified: hbase/trunk/hbase-server/src/main/resources/hbase-webapps/master/table.jsp URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/resources/hbase-webapps/master/table.jsp?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/resources/hbase-webapps/master/table.jsp (original) +++ hbase/trunk/hbase-server/src/main/resources/hbase-webapps/master/table.jsp Fri Mar 8 22:37:19 2013 @@ -41,7 +41,7 @@ String tableName = request.getParameter("name"); HTable table = new HTable(conf, tableName); String tableHeader = "

Table Regions

"; - ServerName rl = master.getCatalogTracker().getRootLocation(); + ServerName rl = master.getCatalogTracker().getMetaLocation(); boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false); boolean readOnly = conf.getBoolean("hbase.master.ui.readonly", false); Map frags = null; @@ -191,22 +191,7 @@
<% - if(tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME))) { -%> -<%= tableHeader %> -<% - String url = "http://" + rl.getHostname() + ":" + infoPort + "/"; -%> -
- - - - - - -
NameRegion ServerStart KeyEnd KeyRequests
<%= tableName %><%= rl.getHostname() %>:<%= rl.getPort() %>--
-<% - } else if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) { + if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) { %> <%= tableHeader %> <% Modified: hbase/trunk/hbase-server/src/main/ruby/hbase/admin.rb URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/ruby/hbase/admin.rb?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/ruby/hbase/admin.rb (original) +++ hbase/trunk/hbase-server/src/main/ruby/hbase/admin.rb Fri Mar 8 22:37:19 2013 @@ -313,7 +313,6 @@ module Hbase def describe(table_name) tables = @admin.listTables.to_a tables << org.apache.hadoop.hbase.HTableDescriptor::META_TABLEDESC - tables << org.apache.hadoop.hbase.HTableDescriptor::ROOT_TABLEDESC tables.each do |t| # Found the table Modified: hbase/trunk/hbase-server/src/main/ruby/hbase/table.rb URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/ruby/hbase/table.rb?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/main/ruby/hbase/table.rb (original) +++ hbase/trunk/hbase-server/src/main/ruby/hbase/table.rb Fri Mar 8 22:37:19 2013 @@ -459,7 +459,7 @@ EOF # Checks if current table is one of the 'meta' tables def is_meta_table? tn = @table.table_name - org.apache.hadoop.hbase.util.Bytes.equals(tn, org.apache.hadoop.hbase.HConstants::META_TABLE_NAME) || org.apache.hadoop.hbase.util.Bytes.equals(tn, org.apache.hadoop.hbase.HConstants::ROOT_TABLE_NAME) + org.apache.hadoop.hbase.util.Bytes.equals(tn, org.apache.hadoop.hbase.HConstants::META_TABLE_NAME) end # Returns family and (when has it) qualifier for a column name Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java (original) +++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java Fri Mar 8 22:37:19 2013 @@ -60,7 +60,6 @@ public abstract class HBaseTestCase exte private boolean localfs = false; protected static Path testDir = null; protected FileSystem fs = null; - protected HRegion root = null; protected HRegion meta = null; protected static final char FIRST_CHAR = 'a'; protected static final char LAST_CHAR = 'z'; @@ -656,17 +655,13 @@ public abstract class HBaseTestCase exte * method. It does cleanup. * @throws IOException */ - protected void createRootAndMetaRegions() throws IOException { - root = HRegion.createHRegion(HRegionInfo.ROOT_REGIONINFO, testDir, - conf, HTableDescriptor.ROOT_TABLEDESC); + protected void createMetaRegion() throws IOException { meta = HRegion.createHRegion(HRegionInfo.FIRST_META_REGIONINFO, testDir, conf, HTableDescriptor.META_TABLEDESC); - HRegion.addRegionToMETA(root, meta); } protected void closeRootAndMeta() throws IOException { HRegion.closeHRegion(meta); - HRegion.closeHRegion(root); } public static void assertByteEquals(byte[] expected, Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java (original) +++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java Fri Mar 8 22:37:19 2013 @@ -290,7 +290,7 @@ public class TestDrainingServer { private static boolean isAllRegionsOnline() { return TEST_UTIL.getMiniHBaseCluster().countServedRegions() == - (COUNT_OF_REGIONS + 2 /*catalog regions*/); + (COUNT_OF_REGIONS + 1 /*catalog regions*/); } } Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionRebalancing.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionRebalancing.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionRebalancing.java (original) +++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionRebalancing.java Fri Mar 8 22:37:19 2013 @@ -188,7 +188,7 @@ public class TestRegionRebalancing { if (!(avg > 2.0 && serverLoad <= avgLoadPlusSlop && serverLoad >= avgLoadMinusSlop)) { for (HRegionInfo hri : ProtobufUtil.getOnlineRegions(server)) { - if (hri.isMetaRegion() || hri.isRootRegion()) serverLoad--; + if (hri.isMetaRegion()) serverLoad--; // LOG.debug(hri.getRegionNameAsString()); } if (!(serverLoad <= avgLoadPlusSlop && serverLoad >= avgLoadMinusSlop)) { @@ -234,7 +234,7 @@ public class TestRegionRebalancing { * Wait until all the regions are assigned. */ private void waitForAllRegionsAssigned() throws IOException { - int totalRegions = HBaseTestingUtility.KEYS.length+2; + int totalRegions = HBaseTestingUtility.KEYS.length+1; while (getRegionCount() < totalRegions) { // while (!cluster.getMaster().allRegionsAssigned()) { LOG.debug("Waiting for there to be "+ totalRegions +" regions, but there are " + getRegionCount() + " right now."); Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java (original) +++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java Fri Mar 8 22:37:19 2013 @@ -54,7 +54,7 @@ import org.apache.hadoop.hbase.protobuf. import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetResponse; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Threads; -import org.apache.hadoop.hbase.zookeeper.RootRegionTracker; +import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker; import org.apache.hadoop.hbase.zookeeper.ZKUtil; import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher; import org.apache.hadoop.util.Progressable; @@ -132,22 +132,22 @@ public class TestCatalogTracker { HConnection connection = Mockito.mock(HConnection.class); constructAndStartCatalogTracker(connection); try { - RootRegionTracker.setRootLocation(this.watcher, - new ServerName("example.com", 1234, System.currentTimeMillis())); + MetaRegionTracker.setMetaLocation(this.watcher, + new ServerName("example.com", 1234, System.currentTimeMillis())); } finally { - // Clean out root location or later tests will be confused... they presume + // Clean out meta location or later tests will be confused... they presume // start fresh in zk. - RootRegionTracker.deleteRootLocation(this.watcher); + MetaRegionTracker.deleteMetaLocation(this.watcher); } } /** - * Test interruptable while blocking wait on root and meta. + * Test interruptable while blocking wait on meta. * @throws IOException * @throws ServiceException * @throws InterruptedException */ - @Test public void testInterruptWaitOnMetaAndRoot() + @Test public void testInterruptWaitOnMeta() throws IOException, InterruptedException, ServiceException { final ClientProtocol client = Mockito.mock(ClientProtocol.class); HConnection connection = mockConnection(null, client); @@ -155,8 +155,6 @@ public class TestCatalogTracker { Mockito.when(client.get((RpcController)Mockito.any(), (GetRequest)Mockito.any())). thenReturn(GetResponse.newBuilder().build()); final CatalogTracker ct = constructAndStartCatalogTracker(connection); - ServerName hsa = ct.getRootLocation(); - Assert.assertNull(hsa); ServerName meta = ct.getMetaLocation(); Assert.assertNull(meta); Thread t = new Thread() { @@ -182,86 +180,6 @@ public class TestCatalogTracker { } } - /** - * Test for HBASE-4288. Throw an IOE when trying to verify meta region and - * prove it doesn't cause master shutdown. - * @see HBASE-4288 - * @throws IOException - * @throws InterruptedException - * @throws KeeperException - */ - @Test - public void testServerNotRunningIOException() - throws IOException, InterruptedException, KeeperException, ServiceException { - // Mock an Admin and a Client. - final AdminProtocol admin = Mockito.mock(AdminProtocol.class); - final ClientProtocol client = Mockito.mock(ClientProtocol.class); - HConnection connection = mockConnection(admin, client); - try { - // If a 'getRegionInfo' is called on mocked AdminProtocol, throw IOE - // the first time. 'Succeed' the second time we are called. - GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder(); - builder.setRegionInfo(HRegionInfo.convert(new HRegionInfo(Bytes.toBytes("test")))); - Mockito.when(admin.getRegionInfo((RpcController)Mockito.any(), - (GetRegionInfoRequest)Mockito.any())).thenThrow( - new ServiceException(new IOException("Server not running, aborting"))). - thenReturn(builder.build()); - - // After we encounter the above 'Server not running', we should catch the - // IOE and go into retrying for the meta mode. We'll do gets on -ROOT- to - // get new meta location. Return something so this 'get' succeeds - // (here we mock up getRegionServerWithRetries, the wrapper around - // the actual get). - - // TODO: Refactor. This method has been moved out of HConnection. - // It works for now but has been deprecated. - Mockito.when(connection.getRegionServerWithRetries((ServerCallable)Mockito.any())). - thenReturn(getMetaTableRowResult()); - - Mockito.when(client.get((RpcController)Mockito.any(), (GetRequest)Mockito.any())). - thenReturn(GetResponse.newBuilder().build()); - // Now start up the catalogtracker with our doctored Connection. - final CatalogTracker ct = constructAndStartCatalogTracker(connection); - try { - // Set a location for root and meta. - RootRegionTracker.setRootLocation(this.watcher, SN); - ct.setMetaLocation(SN); - // Call the method that HBASE-4288 calls. It will try and verify the - // meta location and will fail on first attempt then go into a long wait. - // So, do this in a thread and then reset meta location to break it out - // of its wait after a bit of time. - final AtomicBoolean metaSet = new AtomicBoolean(false); - final CountDownLatch latch = new CountDownLatch(1); - Thread t = new Thread() { - @Override - public void run() { - try { - latch.countDown(); - metaSet.set(ct.waitForMeta(100000) != null); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }; - t.start(); - latch.await(); - Threads.sleep(1); - // Now reset the meta as though it were redeployed. - ct.setMetaLocation(SN); - t.join(); - Assert.assertTrue(metaSet.get()); - } finally { - // Clean out root and meta locations or later tests will be confused... - // they presume start fresh in zk. - ct.resetMetaLocation(); - RootRegionTracker.deleteRootLocation(this.watcher); - } - } finally { - // Clear out our doctored connection or could mess up subsequent tests. - HConnectionManager.deleteConnection(UTIL.getConfiguration()); - } - } - private void testVerifyMetaRegionLocationWithException(Exception ex) throws IOException, InterruptedException, KeeperException, ServiceException { // Mock an ClientProtocol. @@ -274,14 +192,14 @@ public class TestCatalogTracker { // Now start up the catalogtracker with our doctored Connection. final CatalogTracker ct = constructAndStartCatalogTracker(connection); try { - RootRegionTracker.setRootLocation(this.watcher, SN); + MetaRegionTracker.setMetaLocation(this.watcher, SN); long timeout = UTIL.getConfiguration(). getLong("hbase.catalog.verification.timeout", 1000); Assert.assertFalse(ct.verifyMetaRegionLocation(timeout)); } finally { - // Clean out root location or later tests will be confused... they + // Clean out meta location or later tests will be confused... they // presume start fresh in zk. - RootRegionTracker.deleteRootLocation(this.watcher); + MetaRegionTracker.deleteMetaLocation(this.watcher); } } finally { // Clear out our doctored connection or could mess up subsequent tests. @@ -323,14 +241,14 @@ public class TestCatalogTracker { } /** - * Test get of root region fails properly if nothing to connect to. + * Test get of meta region fails properly if nothing to connect to. * @throws IOException * @throws InterruptedException * @throws KeeperException * @throws ServiceException */ @Test - public void testVerifyRootRegionLocationFails() + public void testVerifyMetaRegionLocationFails() throws IOException, InterruptedException, KeeperException, ServiceException { HConnection connection = Mockito.mock(HConnection.class); ServiceException connectException = @@ -343,130 +261,54 @@ public class TestCatalogTracker { thenReturn(implementation); final CatalogTracker ct = constructAndStartCatalogTracker(connection); try { - RootRegionTracker.setRootLocation(this.watcher, - new ServerName("example.com", 1234, System.currentTimeMillis())); - Assert.assertFalse(ct.verifyRootRegionLocation(100)); + MetaRegionTracker.setMetaLocation(this.watcher, + new ServerName("example.com", 1234, System.currentTimeMillis())); + Assert.assertFalse(ct.verifyMetaRegionLocation(100)); } finally { - // Clean out root location or later tests will be confused... they presume + // Clean out meta location or later tests will be confused... they presume // start fresh in zk. - RootRegionTracker.deleteRootLocation(this.watcher); + MetaRegionTracker.deleteMetaLocation(this.watcher); } } @Test (expected = NotAllMetaRegionsOnlineException.class) - public void testTimeoutWaitForRoot() + public void testTimeoutWaitForMeta() throws IOException, InterruptedException { HConnection connection = Mockito.mock(HConnection.class); final CatalogTracker ct = constructAndStartCatalogTracker(connection); - ct.waitForRoot(100); - } - - @Test (expected = RetriesExhaustedException.class) - public void testTimeoutWaitForMeta() - throws IOException, InterruptedException { - HConnection connection = - HConnectionTestingUtility.getMockedConnection(UTIL.getConfiguration()); - try { - final CatalogTracker ct = constructAndStartCatalogTracker(connection); - ct.waitForMeta(100); - } finally { - HConnectionManager.deleteConnection(UTIL.getConfiguration()); - } + ct.waitForMeta(100); } /** - * Test waiting on root w/ no timeout specified. + * Test waiting on meat w/ no timeout specified. * @throws IOException * @throws InterruptedException * @throws KeeperException */ - @Test public void testNoTimeoutWaitForRoot() + @Test public void testNoTimeoutWaitForMeta() throws IOException, InterruptedException, KeeperException { HConnection connection = Mockito.mock(HConnection.class); final CatalogTracker ct = constructAndStartCatalogTracker(connection); - ServerName hsa = ct.getRootLocation(); + ServerName hsa = ct.getMetaLocation(); Assert.assertNull(hsa); - // Now test waiting on root location getting set. + // Now test waiting on meta location getting set. Thread t = new WaitOnMetaThread(ct); startWaitAliveThenWaitItLives(t, 1); - // Set a root location. - hsa = setRootLocation(); + // Set a meta location. + hsa = setMetaLocation(); // Join the thread... should exit shortly. t.join(); - // Now root is available. - Assert.assertTrue(ct.getRootLocation().equals(hsa)); + // Now meta is available. + Assert.assertTrue(ct.getMetaLocation().equals(hsa)); } - private ServerName setRootLocation() throws KeeperException { - RootRegionTracker.setRootLocation(this.watcher, SN); + private ServerName setMetaLocation() throws KeeperException { + MetaRegionTracker.setMetaLocation(this.watcher, SN); return SN; } /** - * Test waiting on meta w/ no timeout specified. - * @throws Exception - */ - @Ignore // Can't make it work reliably on all platforms; mockito gets confused - // Throwing: org.mockito.exceptions.misusing.WrongTypeOfReturnValue: - // Result cannot be returned by locateRegion() - // If you plug locateRegion, it then throws for incCounter, and if you plug - // that ... and so one. - @Test public void testNoTimeoutWaitForMeta() - throws Exception { - // Mock an HConnection and a AdminProtocol implementation. Have the - // HConnection return the HRI. Have the HRI return a few mocked up responses - // to make our test work. - // Mock an AdminProtocol. - final AdminProtocol implementation = Mockito.mock(AdminProtocol.class); - HConnection connection = mockConnection(implementation, null); - try { - // Now the ct is up... set into the mocks some answers that make it look - // like things have been getting assigned. Make it so we'll return a - // location (no matter what the Get is). Same for getHRegionInfo -- always - // just return the meta region. - final Result result = getMetaTableRowResult(); - - // TODO: Refactor. This method has been moved out of HConnection. - // It works for now but has been deprecated. - Mockito.when(connection.getRegionServerWithRetries((ServerCallable)Mockito.any())). - thenReturn(result); - GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder(); - builder.setRegionInfo(HRegionInfo.convert(HRegionInfo.FIRST_META_REGIONINFO)); - Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(), - (GetRegionInfoRequest)Mockito.any())).thenReturn(builder.build()); - final CatalogTracker ct = constructAndStartCatalogTracker(connection); - ServerName hsa = ct.getMetaLocation(); - Assert.assertNull(hsa); - - // Now test waiting on meta location getting set. - Thread t = new WaitOnMetaThread(ct) { - @Override - void doWaiting() throws InterruptedException { - this.ct.waitForMeta(); - } - }; - startWaitAliveThenWaitItLives(t, 1000); - - // This should trigger wake up of meta wait (Its the removal of the meta - // region unassigned node that triggers catalogtrackers that a meta has - // been assigned). - String node = ct.getMetaNodeTracker().getNode(); - ZKUtil.createAndFailSilent(this.watcher, node); - MetaEditor.updateMetaLocation(ct, HRegionInfo.FIRST_META_REGIONINFO, SN, 0); - ZKUtil.deleteNode(this.watcher, node); - // Go get the new meta location. waitForMeta gets and verifies meta. - Assert.assertTrue(ct.waitForMeta(10000).equals(SN)); - // Join the thread... should exit shortly. - t.join(); - // Now meta is available. - Assert.assertTrue(ct.waitForMeta(10000).equals(SN)); - } finally { - HConnectionManager.deleteConnection(UTIL.getConfiguration()); - } - } - - /** * @param admin An {@link AdminProtocol} instance; you'll likely * want to pass a mocked HRS; can be null. * @param client A mocked ClientProtocol instance, can be null @@ -537,7 +379,6 @@ public class TestCatalogTracker { /** * Wait on META. - * Default is wait on -ROOT-. */ class WaitOnMetaThread extends Thread { final CatalogTracker ct; @@ -559,7 +400,7 @@ public class TestCatalogTracker { void doWaiting() throws InterruptedException { try { - while (this.ct.waitForRoot(100) == null); + while (this.ct.waitForMeta(100) == null); } catch (NotAllMetaRegionsOnlineException e) { // Ignore. } Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaMigrationConvertingToPB.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaMigrationConvertingToPB.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaMigrationConvertingToPB.java (original) +++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaMigrationConvertingToPB.java Fri Mar 8 22:37:19 2013 @@ -56,6 +56,7 @@ import org.junit.Test; import org.junit.experimental.categories.Category; /** + * TODO reenable the tests once a migration path is figured without ROOT * Test migration that changes HRI serialization into PB. Tests by bringing up a cluster from actual * data from a 0.92 cluster, as well as manually downgrading and then upgrading the META info. * @deprecated Remove after 0.96 @@ -168,7 +169,7 @@ public class TestMetaMigrationConverting TEST_UTIL.shutdownMiniCluster(); } - @Test + //@Test public void testMetaUpdatedFlagInROOT() throws Exception { HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster(); boolean metaUpdated = MetaMigrationConvertingToPB. @@ -177,7 +178,7 @@ public class TestMetaMigrationConverting verifyMetaRowsAreUpdated(master.getCatalogTracker()); } - @Test + //@Test public void testMetaMigration() throws Exception { LOG.info("Starting testMetaMigration"); final byte [] FAMILY = Bytes.toBytes("family"); @@ -224,7 +225,7 @@ public class TestMetaMigrationConverting * rows and migrate any pending rows at startup. * @throws Exception */ - @Test + //@Test public void testMasterCrashDuringMetaMigration() throws Exception { final byte[] FAMILY = Bytes.toBytes("family"); HTableDescriptor htd = new HTableDescriptor("testMasterCrashDuringMetaMigration"); @@ -293,7 +294,7 @@ public class TestMetaMigrationConverting p.add(HConstants.CATALOG_FAMILY, HConstants.META_VERSION_QUALIFIER, Bytes.toBytes(META_VERSION_092)); - MetaEditor.putToRootTable(ct, p); + // TODO wire this MetaEditor.putToRootTable(ct, p); LOG.info("Downgraded -ROOT- meta version=" + META_VERSION_092); } Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java (original) +++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java Fri Mar 8 22:37:19 2013 @@ -42,7 +42,7 @@ import org.junit.Test; import org.junit.experimental.categories.Category; /** - * Test {@link MetaReader}, {@link MetaEditor}, and {@link RootLocationEditor}. + * Test {@link MetaReader}, {@link MetaEditor}. */ @Category(MediumTests.class) public class TestMetaReaderEditor { @@ -218,8 +218,6 @@ public class TestMetaReaderEditor { assertTrue(regions.size() >= 1); assertTrue(MetaReader.getTableRegionsAndLocations(CT, Bytes.toString(HConstants.META_TABLE_NAME)).size() >= 1); - assertTrue(MetaReader.getTableRegionsAndLocations(CT, - Bytes.toString(HConstants.ROOT_TABLE_NAME)).size() == 1); } @Test public void testTableExists() throws IOException { @@ -234,8 +232,6 @@ public class TestMetaReaderEditor { assertFalse(MetaReader.tableExists(CT, name)); assertTrue(MetaReader.tableExists(CT, Bytes.toString(HConstants.META_TABLE_NAME))); - assertTrue(MetaReader.tableExists(CT, - Bytes.toString(HConstants.ROOT_TABLE_NAME))); } @Test public void testGetRegion() throws IOException, InterruptedException { @@ -245,11 +241,6 @@ public class TestMetaReaderEditor { Pair pair = MetaReader.getRegion(CT, Bytes.toBytes("nonexistent-region")); assertNull(pair); - // Test it works getting a region from meta/root. - pair = - MetaReader.getRegion(CT, HRegionInfo.FIRST_META_REGIONINFO.getRegionName()); - assertEquals(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName(), - pair.getFirst().getEncodedName()); LOG.info("Finished " + name); } Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1454607&r1=1454606&r2=1454607&view=diff ============================================================================== --- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original) +++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Fri Mar 8 22:37:19 2013 @@ -1621,18 +1621,4 @@ public class TestAdmin { ct.stop(); } } - - @Test - public void testRootTableSplit() throws Exception { - ServerName serverName = TEST_UTIL.getMiniHBaseCluster().getServerHoldingRoot(); - Scan s = new Scan(); - HTable rootTable = new HTable(TEST_UTIL.getConfiguration(), HConstants.ROOT_TABLE_NAME); - ResultScanner scanner = rootTable.getScanner(s); - Result metaEntry = scanner.next(); - this.admin.split(HConstants.ROOT_TABLE_NAME, metaEntry.getRow()); - Thread.sleep(1000); - List onlineRegions = this.admin.getOnlineRegions(serverName); - assertTrue(onlineRegions != null && onlineRegions.contains(HRegionInfo.ROOT_REGIONINFO)); - } - }