hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r705338 - in /hadoop/hbase/trunk: ./ src/java/org/apache/hadoop/hbase/client/ src/java/org/apache/hadoop/hbase/ipc/ src/java/org/apache/hadoop/hbase/master/ src/java/org/apache/hadoop/hbase/regionserver/
Date Thu, 16 Oct 2008 19:45:19 GMT
Author: jimk
Date: Thu Oct 16 12:45:17 2008
New Revision: 705338

URL: http://svn.apache.org/viewvc?rev=705338&view=rev
Log:
HBASE-919   Master and Region Server need to provide root region location if they are using
HTable

Added:
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerConnection.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerConnectionManager.java
Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HMasterRegionInterface.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=705338&r1=705337&r2=705338&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Thu Oct 16 12:45:17 2008
@@ -31,6 +31,8 @@
                log java.io.IOException: Could not get block locations. Aborting...
    HBASE-926   If no master, regionservers should hang out rather than fail on
                connection and shut themselves down
+   HBASE-919   Master and Region Server need to provide root region location if
+               they are using HTable
 
   IMPROVEMENTS
    HBASE-901   Add a limit to key length, check key and value length on client side

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=705338&r1=705337&r2=705338&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java Thu
Oct 16 12:45:17 2008
@@ -62,11 +62,9 @@
  */
 public class HConnectionManager implements HConstants {
   /*
-   * Private. Not instantiable.
+   * Not instantiable.
    */
-  private HConnectionManager() {
-    super();
-  }
+  protected HConnectionManager() {}
   
   // A Map of master HServerAddress -> connection information for that instance
   // Note that although the Map is synchronized, the objects it contains
@@ -109,7 +107,7 @@
   }
 
   /* Encapsulates finding the servers for an HBase instance */
-  private static class TableServers implements HConnection, HConstants {
+  private static class TableServers implements ServerConnection, HConstants {
     private static final Log LOG = LogFactory.getLog(TableServers.class);
     private final Class<? extends HRegionInterface> serverInterfaceClass;
     private final long pause;
@@ -168,11 +166,16 @@
     }
 
     private long getPauseTime(int tries) {
-      if (tries >= HConstants.RETRY_BACKOFF.length)
-        tries = HConstants.RETRY_BACKOFF.length - 1;
-      return this.pause * HConstants.RETRY_BACKOFF[tries];
+      int ntries = tries;
+      if (ntries >= HConstants.RETRY_BACKOFF.length)
+        ntries = HConstants.RETRY_BACKOFF.length - 1;
+      return this.pause * HConstants.RETRY_BACKOFF[ntries];
     }
 
+    public void setRootRegionLocation(HRegionLocation rootRegion) {
+      this.rootRegionLocation = rootRegion;
+    }
+    
     public HMasterInterface getMaster() throws MasterNotRunningException {
       HServerAddress masterLocation = null;
       synchronized (this.masterLock) {
@@ -366,8 +369,7 @@
     implements MetaScanner.MetaScannerVisitor {
         byte[] tableName;
         HTableDescriptor result;
-        //TODO: change visibility to protected
-        public HTableDescriptorFinder(byte[] tableName) {
+        protected HTableDescriptorFinder(byte[] tableName) {
           this.tableName = tableName;
         }
         public boolean processRow(RowResult rowResult) throws IOException {

Added: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerConnection.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerConnection.java?rev=705338&view=auto
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerConnection.java (added)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerConnection.java Thu Oct
16 12:45:17 2008
@@ -0,0 +1,36 @@
+/**
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import org.apache.hadoop.hbase.HRegionLocation;
+
+/**
+ * Used by master and region server, so that they do not need to wait for the
+ * cluster to be up to get a connection.
+ */
+public interface ServerConnection extends HConnection {
+
+  /**
+   * Set root region location in connection
+   * @param rootRegion
+   */
+  public void setRootRegionLocation(HRegionLocation rootRegion);
+}

Added: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerConnectionManager.java?rev=705338&view=auto
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerConnectionManager.java
(added)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerConnectionManager.java
Thu Oct 16 12:45:17 2008
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import org.apache.hadoop.hbase.HBaseConfiguration;
+
+/**
+ * Used by server processes to expose HServerConnection method
+ * setRootRegionLocation
+ */
+public class ServerConnectionManager extends HConnectionManager {
+  /*
+   * Not instantiable
+   */
+  private ServerConnectionManager() {}
+
+  /**
+   * Get the connection object for the instance specified by the configuration
+   * If no current connection exists, create a new connection for that instance
+   * @param conf
+   * @return HConnection object for the instance specified by the configuration
+   */
+  public static ServerConnection getConnection(HBaseConfiguration conf) {
+    return (ServerConnection) HConnectionManager.getConnection(conf);
+  }
+}

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HMasterRegionInterface.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HMasterRegionInterface.java?rev=705338&r1=705337&r2=705338&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HMasterRegionInterface.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HMasterRegionInterface.java Thu
Oct 16 12:45:17 2008
@@ -26,6 +26,7 @@
 import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.HMsg;
 import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HServerAddress;
 
 /**
  * HRegionServers interact with the HMasterRegionInterface to report on local 
@@ -67,4 +68,11 @@
   public HMsg[] regionServerReport(HServerInfo info, HMsg msgs[], 
     HRegionInfo mostLoadedRegions[])
   throws IOException;
+
+  /**
+   * @return Root region region server address. Unlike
+   * HMasterInterface.findRootRegion, does not wait until all regions are 
+   * assigned.
+   */
+  public HServerAddress getRootRegionLocation();
 }
\ No newline at end of file

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java?rev=705338&r1=705337&r2=705338&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java Thu Oct 16 12:45:17
2008
@@ -52,8 +52,8 @@
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
 import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.client.HConnection;
-import org.apache.hadoop.hbase.client.HConnectionManager;
+import org.apache.hadoop.hbase.client.ServerConnection;
+import org.apache.hadoop.hbase.client.ServerConnectionManager;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.io.RowResult;
 import org.apache.hadoop.hbase.ipc.HMasterInterface;
@@ -116,7 +116,7 @@
   private final Server server;
   private final HServerAddress address;
 
-  final HConnection connection;
+  final ServerConnection connection;
 
   final int metaRescanInterval;
   
@@ -224,7 +224,7 @@
     this.address = new HServerAddress(server.getListenerAddress());
     conf.set(MASTER_ADDRESS, address.toString());
 
-    this.connection = HConnectionManager.getConnection(conf);
+    this.connection = ServerConnectionManager.getConnection(conf);
 
     this.metaRescanInterval =
       conf.getInt("hbase.master.meta.thread.rescanfrequency", 60 * 1000);
@@ -679,7 +679,11 @@
   }
 
   public HServerAddress findRootRegion() {
-    return regionManager.getRootRegionLocation();
+    HServerAddress rootServer = null;
+    if (regionManager.allRegionsAssigned()) {
+      rootServer = regionManager.getRootRegionLocation();
+    }
+    return rootServer;
   }
 
   /*

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=705338&r1=705337&r2=705338&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/ServerManager.java Thu Oct
16 12:45:17 2008
@@ -43,6 +43,7 @@
 import org.apache.hadoop.hbase.Leases;
 import org.apache.hadoop.hbase.LeaseListener;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionLocation;
 
 /**
  * The ServerManager class manages info about region servers - HServerInfo, 
@@ -444,7 +445,10 @@
 
       if (region.isRootRegion()) {
         // Store the Root Region location (in memory)
-        master.regionManager.setRootRegionLocation(serverInfo.getServerAddress());
+        HServerAddress rootServer = serverInfo.getServerAddress();
+        master.connection.setRootRegionLocation(
+            new HRegionLocation(region, rootServer));
+        master.regionManager.setRootRegionLocation(rootServer);
       } else {
         // Note that the table has been assigned and is waiting for the
         // meta table to be updated.
@@ -470,6 +474,7 @@
         LOG.fatal("root region is marked offline");
         master.shutdown();
       }
+      master.connection.setRootRegionLocation(null);
       master.regionManager.unassignRootRegion();
 
     } else {

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=705338&r1=705337&r2=705338&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Thu
Oct 16 12:45:17 2008
@@ -57,6 +57,7 @@
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HMsg;
 import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.HServerLoad;
@@ -72,6 +73,8 @@
 import org.apache.hadoop.hbase.UnknownRowLockException;
 import org.apache.hadoop.hbase.ValueOverMaxLengthException;
 import org.apache.hadoop.hbase.Leases.LeaseStillHeldException;
+import org.apache.hadoop.hbase.client.ServerConnection;
+import org.apache.hadoop.hbase.client.ServerConnectionManager;
 import org.apache.hadoop.hbase.filter.RowFilterInterface;
 import org.apache.hadoop.hbase.io.BatchOperation;
 import org.apache.hadoop.hbase.io.BatchUpdate;
@@ -117,6 +120,9 @@
   
   protected final HServerInfo serverInfo;
   protected final HBaseConfiguration conf;
+
+  private final ServerConnection connection;
+  private final AtomicBoolean haveRootRegion = new AtomicBoolean(false);
   private FileSystem fs;
   private Path rootDir;
   private final Random rand = new Random();
@@ -226,6 +232,7 @@
     this.abortRequested = false;
     this.fsOk = true;
     this.conf = conf;
+    this.connection = ServerConnectionManager.getConnection(conf);
 
     this.isOnline = false;
 
@@ -486,7 +493,7 @@
     join();
     LOG.info(Thread.currentThread().getName() + " exiting");
   }
-  
+
   /*
    * Run init. Sets up hlog and starts up all server threads.
    * @param c Extra configuration.
@@ -626,6 +633,17 @@
    * the end of the main HRegionServer run loop.
    */
   private void housekeeping() {
+    // Try to get the root region location from the master. 
+    if (!haveRootRegion.get()) {
+      HServerAddress rootServer = hbaseMaster.getRootRegionLocation();
+      if (rootServer != null) {
+        // By setting the root region location, we bypass the wait imposed on
+        // HTable for all regions being assigned.
+        this.connection.setRootRegionLocation(
+            new HRegionLocation(HRegionInfo.ROOT_REGIONINFO, rootServer));
+        haveRootRegion.set(true);
+      }
+    }
     // If the todo list has > 0 messages, iterate looking for open region
     // messages. Send the master a message that we're working on its
     // processing so it doesn't assign the region elsewhere.



Mime
View raw message