You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2012/05/03 08:20:28 UTC

svn commit: r1333319 [4/4] - in /hbase/trunk/src: main/jamon/org/apache/hadoop/hbase/tmpl/master/ main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/ main/java/org/apache/hadoop/hbase/ main/java/org/apache/hadoop/hbase/ipc/ main/java/org/apache/hadoo...

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1333319&r1=1333318&r2=1333319&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Thu May  3 06:20:26 2012
@@ -67,7 +67,6 @@ import org.apache.hadoop.hbase.HDFSBlock
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HServerInfo;
-import org.apache.hadoop.hbase.HServerLoad;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.NotServingRegionException;
@@ -112,7 +111,6 @@ import org.apache.hadoop.hbase.ipc.Copro
 import org.apache.hadoop.hbase.ipc.HBaseRPC;
 import org.apache.hadoop.hbase.ipc.HBaseRPCErrorHandler;
 import org.apache.hadoop.hbase.ipc.HBaseRpcMetrics;
-import org.apache.hadoop.hbase.ipc.HMasterRegionInterface;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 import org.apache.hadoop.hbase.ipc.Invocation;
 import org.apache.hadoop.hbase.ipc.ProtocolSignature;
@@ -147,7 +145,6 @@ import org.apache.hadoop.hbase.zookeeper
 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.io.MapWritable;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.metrics.util.MBeanUtil;
@@ -156,9 +153,24 @@ import org.apache.hadoop.util.Reflection
 import org.apache.hadoop.util.StringUtils;
 import org.apache.zookeeper.KeeperException;
 import org.codehaus.jackson.map.ObjectMapper;
+import com.google.protobuf.ServiceException;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.ServerLoad;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.Coprocessor;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionLoad;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType;
+import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerReportRequest;
+import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorRequest;
+import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerStartupRequest;
+import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse;
+import org.apache.hadoop.hbase.ipc.RegionServerStatusProtocol;
 
 import com.google.common.base.Function;
 import com.google.common.collect.Lists;
+import com.google.protobuf.ByteString;
 
 /**
  * HRegionServer makes a set of HRegions available to clients. It checks in with
@@ -191,7 +203,7 @@ public class HRegionServer extends Regio
   protected final int numRegionsToReport;
 
   // Remote HMaster
-  private HMasterRegionInterface hbaseMaster;
+  private RegionServerStatusProtocol hbaseMaster;
 
   // Server to handle client requests. Default access so can be accessed by
   // unit tests.
@@ -589,7 +601,7 @@ public class HRegionServer extends Regio
       // Try and register with the Master; tell it we are here.  Break if
       // server is stopped or the clusterup flag is down or hdfs went wacky.
       while (keepLooping()) {
-        MapWritable w = reportForDuty();
+        RegionServerStartupResponse w = reportForDuty();
         if (w == null) {
           LOG.warn("reportForDuty failed; sleeping and then retrying.");
           this.sleeper.sleep();
@@ -737,15 +749,18 @@ public class HRegionServer extends Regio
 
   void tryRegionServerReport()
   throws IOException {
-    HServerLoad hsl = buildServerLoad();
+    HBaseProtos.ServerLoad sl = buildServerLoad();
     // Why we do this?
     this.requestCount.set(0);
     try {
-      this.hbaseMaster.regionServerReport(this.serverNameFromMasterPOV.getVersionedBytes(), hsl);
-    } catch (IOException ioe) {
-      if (ioe instanceof RemoteException) {
-        ioe = ((RemoteException)ioe).unwrapRemoteException();
-      }
+      RegionServerReportRequest.Builder request = RegionServerReportRequest.newBuilder();
+      ServerName sn = ServerName.parseVersionedServerName(
+        this.serverNameFromMasterPOV.getVersionedBytes());
+      request.setServer(ProtobufUtil.toServerName(sn));
+      request.setLoad(sl);
+      this.hbaseMaster.regionServerReport(null, request.build());
+    } catch (ServiceException se) {
+      IOException ioe = ProtobufUtil.getRemoteException(se);
       if (ioe instanceof YouAreDeadException) {
         // This will be caught and handled as a fatal error in run()
         throw ioe;
@@ -756,19 +771,26 @@ public class HRegionServer extends Regio
     }
   }
 
-  HServerLoad buildServerLoad() {
+  HBaseProtos.ServerLoad buildServerLoad() {
     Collection<HRegion> regions = getOnlineRegionsLocalContext();
-    TreeMap<byte [], HServerLoad.RegionLoad> regionLoads =
-      new TreeMap<byte [], HServerLoad.RegionLoad>(Bytes.BYTES_COMPARATOR);
-    for (HRegion region: regions) {
-      regionLoads.put(region.getRegionName(), createRegionLoad(region));
-    }
     MemoryUsage memory =
       ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
-    return new HServerLoad(requestCount.get(),(int)metrics.getRequests(),
-      (int)(memory.getUsed() / 1024 / 1024),
-      (int) (memory.getMax() / 1024 / 1024), regionLoads,
-      this.hlog.getCoprocessorHost().getCoprocessors());
+
+    HBaseProtos.ServerLoad.Builder serverLoad = HBaseProtos.ServerLoad.newBuilder();
+    serverLoad.setRequestsPerSecond((int)metrics.getRequests());
+    serverLoad.setTotalNumberOfRequests(requestCount.get());
+    serverLoad.setUsedHeapMB((int)(memory.getUsed() / 1024 / 1024));
+    serverLoad.setMaxHeapMB((int) (memory.getMax() / 1024 / 1024));
+    Set<String> coprocessors = this.hlog.getCoprocessorHost().getCoprocessors();
+    for (String coprocessor : coprocessors) {
+      serverLoad.addCoprocessors(
+        Coprocessor.newBuilder().setName(coprocessor).build());
+    }
+    for (HRegion region : regions) {
+      serverLoad.addRegionLoads(createRegionLoad(region));
+    }
+
+    return serverLoad.build();
   }
 
   String getOnlineRegionsAsPrintableString() {
@@ -858,14 +880,14 @@ public class HRegionServer extends Regio
    *
    * @param c Extra configuration.
    */
-  protected void handleReportForDutyResponse(final MapWritable c)
+  protected void handleReportForDutyResponse(final RegionServerStartupResponse c)
   throws IOException {
     try {
-      for (Map.Entry<Writable, Writable> e :c.entrySet()) {
-        String key = e.getKey().toString();
+      for (NameStringPair e : c.getMapEntriesList()) {
+        String key = e.getName();
         // The hostname the master sees us as.
         if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
-          String hostnameFromMasterPOV = e.getValue().toString();
+          String hostnameFromMasterPOV = e.getValue();
           this.serverNameFromMasterPOV = new ServerName(hostnameFromMasterPOV,
             this.isa.getPort(), this.startcode);
           LOG.info("Master passed us hostname to use. Was=" +
@@ -943,7 +965,7 @@ public class HRegionServer extends Regio
    *
    * @throws IOException
    */
-  private HServerLoad.RegionLoad createRegionLoad(final HRegion r) {
+  private RegionLoad createRegionLoad(final HRegion r) {
     byte[] name = r.getRegionName();
     int stores = 0;
     int storefiles = 0;
@@ -980,20 +1002,38 @@ public class HRegionServer extends Regio
           (int) (store.getTotalStaticBloomSize() / 1024);
       }
     }
-    return new HServerLoad.RegionLoad(name, stores, storefiles,
-        storeUncompressedSizeMB,
-        storefileSizeMB, memstoreSizeMB, storefileIndexSizeMB, rootIndexSizeKB,
-        totalStaticIndexSizeKB, totalStaticBloomSizeKB,
-        (int) r.readRequestsCount.get(), (int) r.writeRequestsCount.get(),
-        totalCompactingKVs, currentCompactedKVs,
-        r.getCoprocessorHost().getCoprocessors());
+    RegionLoad.Builder regionLoad = RegionLoad.newBuilder();
+    RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder();
+    regionSpecifier.setType(RegionSpecifierType.REGION_NAME);
+    regionSpecifier.setValue(ByteString.copyFrom(name));
+    regionLoad.setRegionSpecifier(regionSpecifier.build())
+      .setStores(stores)
+      .setStorefiles(storefiles)
+      .setStoreUncompressedSizeMB(storeUncompressedSizeMB)
+      .setStorefileSizeMB(storefileSizeMB)
+      .setMemstoreSizeMB(memstoreSizeMB)
+      .setStorefileIndexSizeMB(storefileIndexSizeMB)
+      .setRootIndexSizeKB(rootIndexSizeKB)
+      .setTotalStaticIndexSizeKB(totalStaticIndexSizeKB)
+      .setTotalStaticBloomSizeKB(totalStaticBloomSizeKB)
+      .setReadRequestsCount((int) r.readRequestsCount.get())
+      .setWriteRequestsCount((int) r.writeRequestsCount.get())
+      .setTotalCompactingKVs(totalCompactingKVs)
+      .setCurrentCompactedKVs(currentCompactedKVs);
+    Set<String> coprocessors = r.getCoprocessorHost().getCoprocessors();
+    for (String coprocessor : coprocessors) {
+      regionLoad.addCoprocessors(
+        Coprocessor.newBuilder().setName(coprocessor).build());
+    }
+
+    return regionLoad.build();
   }
 
   /**
    * @param encodedRegionName
    * @return An instance of RegionLoad.
    */
-  public HServerLoad.RegionLoad createRegionLoad(final String encodedRegionName) {
+  public RegionLoad createRegionLoad(final String encodedRegionName) {
     HRegion r = null;
     r = this.onlineRegions.get(encodedRegionName);
     return r != null ? createRegionLoad(r) : null;
@@ -1507,8 +1547,14 @@ public class HRegionServer extends Regio
         msg += "\nCause:\n" + StringUtils.stringifyException(cause);
       }
       if (hbaseMaster != null) {
+        ReportRSFatalErrorRequest.Builder builder =
+          ReportRSFatalErrorRequest.newBuilder();
+        ServerName sn =
+          ServerName.parseVersionedServerName(this.serverNameFromMasterPOV.getVersionedBytes());
+        builder.setServer(ProtobufUtil.toServerName(sn));
+        builder.setErrorMessage(msg);
         hbaseMaster.reportRSFatalError(
-            this.serverNameFromMasterPOV.getVersionedBytes(), msg);
+          null,builder.build());
       }
     } catch (Throwable t) {
       LOG.warn("Unable to report fatal error to master", t);
@@ -1588,7 +1634,7 @@ public class HRegionServer extends Regio
   private ServerName getMaster() {
     ServerName masterServerName = null;
     long previousLogTime = 0;
-    HMasterRegionInterface master = null;
+    RegionServerStatusProtocol master = null;
     boolean refresh = false; // for the first time, use cached data
     while (keepLooping() && master == null) {
       masterServerName = this.masterAddressManager.getMasterAddress(refresh);
@@ -1614,8 +1660,8 @@ public class HRegionServer extends Regio
       try {
         // Do initial RPC setup. The final argument indicates that the RPC
         // should retry indefinitely.
-        master = (HMasterRegionInterface) HBaseRPC.waitForProxy(
-            HMasterRegionInterface.class, HMasterRegionInterface.VERSION,
+        master = (RegionServerStatusProtocol) HBaseRPC.waitForProxy(
+            RegionServerStatusProtocol.class, RegionServerStatusProtocol.VERSION,
             isa, this.conf, -1,
             this.rpcTimeout, this.rpcTimeout);
       } catch (IOException e) {
@@ -1658,8 +1704,8 @@ public class HRegionServer extends Regio
    * null if we failed to register.
    * @throws IOException
    */
-  private MapWritable reportForDuty() throws IOException {
-    MapWritable result = null;
+  private RegionServerStartupResponse reportForDuty() throws IOException {
+    RegionServerStartupResponse result = null;
     ServerName masterServerName = getMaster();
     if (masterServerName == null) return result;
     try {
@@ -1668,18 +1714,20 @@ public class HRegionServer extends Regio
         "with port=" + this.isa.getPort() + ", startcode=" + this.startcode);
       long now = EnvironmentEdgeManager.currentTimeMillis();
       int port = this.isa.getPort();
-      result = this.hbaseMaster.regionServerStartup(port, this.startcode, now);
-    } catch (RemoteException e) {
-      IOException ioe = e.unwrapRemoteException();
+      RegionServerStartupRequest.Builder request = RegionServerStartupRequest.newBuilder();
+      request.setPort(port);
+      request.setServerStartCode(this.startcode);
+      request.setServerCurrentTime(now);
+      result = this.hbaseMaster.regionServerStartup(null, request.build());
+    } catch (ServiceException se) {
+      IOException ioe = ProtobufUtil.getRemoteException(se);
       if (ioe instanceof ClockOutOfSyncException) {
         LOG.fatal("Master rejected startup because clock is out of sync", ioe);
         // Re-throw IOE will cause RS to abort
         throw ioe;
       } else {
-        LOG.warn("remote error telling master we are up", e);
+        LOG.warn("error telling master we are up", se);
       }
-    } catch (IOException e) {
-      LOG.warn("error telling master we are up", e);
     }
     return result;
   }
@@ -3295,8 +3343,9 @@ public class HRegionServer extends Regio
 
   // used by org/apache/hbase/tmpl/regionserver/RSStatusTmpl.jamon (HBASE-4070).
   public String[] getCoprocessors() {
-    HServerLoad hsl = buildServerLoad();
-    return hsl == null? null: hsl.getCoprocessors();
+    HBaseProtos.ServerLoad sl = buildServerLoad();
+    return sl == null? null:
+      ServerLoad.getRegionServerCoprocessors(new ServerLoad(sl));
   }
 
   /**

Added: hbase/trunk/src/main/protobuf/RegionServerStatus.proto
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/protobuf/RegionServerStatus.proto?rev=1333319&view=auto
==============================================================================
--- hbase/trunk/src/main/protobuf/RegionServerStatus.proto (added)
+++ hbase/trunk/src/main/protobuf/RegionServerStatus.proto Thu May  3 06:20:26 2012
@@ -0,0 +1,85 @@
+/**
+ * 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.
+ */
+
+// This file contains protocol buffers that are used for MasterRegionProtocol.
+
+option java_package = "org.apache.hadoop.hbase.protobuf.generated";
+option java_outer_classname = "RegionServerStatusProtos";
+option java_generic_services = true;
+option java_generate_equals_and_hash = true;
+option optimize_for = SPEED;
+
+import "hbase.proto";
+
+message RegionServerStartupRequest {
+  /** Port number this regionserver is up on */
+  required uint32 port = 1;
+
+  /** This servers' startcode */
+  required uint64 serverStartCode = 2;
+
+  /** Current time of the region server in ms */
+  required uint64 serverCurrentTime = 3;
+}
+
+message RegionServerStartupResponse {
+  /**
+   * Configuration for the regionserver to use: e.g. filesystem,
+   * hbase rootdir, the hostname to use creating the RegionServer ServerName,
+   * etc
+   */
+  repeated NameStringPair mapEntries = 1;
+}
+
+message RegionServerReportRequest {
+  required ServerName server = 1;
+
+  /** load the server is under */
+  optional ServerLoad load = 2;
+}
+
+message RegionServerReportResponse {
+}
+
+message ReportRSFatalErrorRequest {
+  /** name of the server experiencing the error */
+  required ServerName server = 1;
+
+  /** informative text to expose in the master logs and UI */
+  required string errorMessage = 2;
+}
+
+message ReportRSFatalErrorResponse {
+}
+
+service RegionServerStatusService {
+  /** Called when a region server first starts. */
+  rpc regionServerStartup(RegionServerStartupRequest)
+    returns(RegionServerStartupResponse);
+
+  /** Called to report the load the RegionServer is under. */
+  rpc regionServerReport(RegionServerReportRequest)
+    returns(RegionServerReportResponse);
+
+  /**
+   * Called by a region server to report a fatal error that is causing it to
+   * abort.
+   */
+  rpc reportRSFatalError(ReportRSFatalErrorRequest)
+    returns(ReportRSFatalErrorResponse);
+}

Modified: hbase/trunk/src/main/protobuf/hbase.proto
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/protobuf/hbase.proto?rev=1333319&r1=1333318&r2=1333319&view=diff
==============================================================================
--- hbase/trunk/src/main/protobuf/hbase.proto (original)
+++ hbase/trunk/src/main/protobuf/hbase.proto Thu May  3 06:20:26 2012
@@ -54,6 +54,85 @@ message RegionSpecifier {
   }
 }
 
+message RegionLoad {
+  /** the region specifier */
+  required RegionSpecifier regionSpecifier = 1;
+
+  /** the number of stores for the region */
+  optional uint32 stores = 2;
+
+  /** the number of storefiles for the region */
+  optional uint32 storefiles = 3;
+
+  /** the total size of the store files for the region, uncompressed, in MB */
+  optional uint32 storeUncompressedSizeMB = 4;
+
+  /** the current total size of the store files for the region, in MB */
+  optional uint32 storefileSizeMB = 5;
+
+  /** the current size of the memstore for the region, in MB */
+  optional uint32 memstoreSizeMB = 6;
+
+  /**
+   * The current total size of root-level store file indexes for the region,
+   * in MB. The same as {@link #rootIndexSizeKB} but in MB.
+   */
+  optional uint32 storefileIndexSizeMB = 7;
+
+  /** the current total read requests made to region */
+  optional uint64 readRequestsCount = 8;
+
+  /** the current total write requests made to region */
+  optional uint64 writeRequestsCount = 9;
+
+  /** the total compacting key values in currently running compaction */
+  optional uint64 totalCompactingKVs = 10;
+
+  /** the completed count of key values in currently running compaction */
+  optional uint64 currentCompactedKVs = 11;
+
+   /** The current total size of root-level indexes for the region, in KB. */
+  optional uint32 rootIndexSizeKB = 12;
+
+  /** The total size of all index blocks, not just the root level, in KB. */
+  optional uint32 totalStaticIndexSizeKB = 13;
+
+  /**
+   * The total size of all Bloom filter blocks, not just loaded into the
+   * block cache, in KB.
+   */
+  optional uint32 totalStaticBloomSizeKB = 14;
+
+  /** Region-level coprocessors. */
+  repeated Coprocessor coprocessors = 15;
+}
+
+/* Server-level protobufs */
+
+message ServerLoad {
+  /** Number of requests per second since last report. */
+  optional uint32 requestsPerSecond = 1;
+
+  /** Total Number of requests from the start of the region server. */
+  optional uint32 totalNumberOfRequests = 2;
+
+  /** the amount of used heap, in MB. */
+  optional uint32 usedHeapMB = 3;
+
+  /** the maximum allowable size of the heap, in MB. */
+  optional uint32 maxHeapMB = 4;
+
+  /** Information on the load of individual regions. */
+  repeated RegionLoad regionLoads = 5;
+
+  /**
+   * Regionserver-level coprocessors, e.g., WALObserver implementations.
+   * Region-level coprocessors, on the other hand, are stored inside RegionLoad
+   * objects.
+   */
+  repeated Coprocessor coprocessors = 6;
+}
+
 /**
  * A range of time. Both from and to are Java time
  * stamp in milliseconds. If you don't specify a time
@@ -104,6 +183,10 @@ message ServerName {
 
 // Comment data structures
 
+message Coprocessor {
+  required string name = 1;
+}
+
 message NameStringPair {
   required string name = 1;
   required string value = 2;

Modified: hbase/trunk/src/main/resources/hbase-webapps/master/table.jsp
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/resources/hbase-webapps/master/table.jsp?rev=1333319&r1=1333318&r2=1333319&view=diff
==============================================================================
--- hbase/trunk/src/main/resources/hbase-webapps/master/table.jsp (original)
+++ hbase/trunk/src/main/resources/hbase-webapps/master/table.jsp Thu May  3 06:20:26 2012
@@ -29,12 +29,14 @@
   import="org.apache.hadoop.hbase.HServerAddress"
   import="org.apache.hadoop.hbase.ServerName"
   import="org.apache.hadoop.hbase.HServerInfo"
-  import="org.apache.hadoop.hbase.HServerLoad"
-  import="org.apache.hadoop.hbase.HServerLoad.RegionLoad"
+  import="org.apache.hadoop.hbase.ServerLoad;"
+  import="org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionLoad"
   import="org.apache.hadoop.hbase.io.ImmutableBytesWritable"
   import="org.apache.hadoop.hbase.master.HMaster" 
   import="org.apache.hadoop.hbase.util.Bytes"
   import="org.apache.hadoop.hbase.util.FSUtils"
+  import="org.apache.hadoop.hbase.protobuf.ProtobufUtil"
+  import="java.util.List"
   import="java.util.Map"
   import="org.apache.hadoop.hbase.HConstants"%><%
   HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
@@ -176,11 +178,15 @@
     String urlRegionServer = null;
 
     if (addr != null) {
-      HServerLoad sl = master.getServerManager().getLoad(addr);
+      ServerLoad sl = master.getServerManager().getLoad(addr);
       if (sl != null) {
-        Map<byte[], RegionLoad> map = sl.getRegionsLoad();
-        if (map.containsKey(regionInfo.getRegionName())) {
-          req = map.get(regionInfo.getRegionName()).getRequestsCount();
+        List<RegionLoad> list = sl.getRegionLoadsList();
+        byte [] regionName = regionInfo.getRegionName();
+        for (RegionLoad rgLoad : list) {
+          if (rgLoad.getRegionSpecifier().getValue().toByteArray().equals(regionName)) {
+            req = ProtobufUtil.getTotalRequestsCount(rgLoad);
+            break;
+          }
         }
         // This port might be wrong if RS actually ended up using something else.
         urlRegionServer =

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java?rev=1333319&r1=1333318&r2=1333319&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java Thu May  3 06:20:26 2012
@@ -32,6 +32,7 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hbase.client.HConnectionManager;
 import org.apache.hadoop.hbase.master.HMaster;
+import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.security.User;
@@ -112,7 +113,8 @@ public class MiniHBaseCluster {
      */
 
     @Override
-    protected void handleReportForDutyResponse(MapWritable c) throws IOException {
+    protected void handleReportForDutyResponse(
+        final RegionServerStartupResponse c) throws IOException {
       super.handleReportForDutyResponse(c);
       // Run this thread to shutdown our filesystem on way out.
       this.shutdownThread = new SingleFileSystemShutdownThread(getFileSystem());

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java?rev=1333319&r1=1333318&r2=1333319&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java Thu May  3 06:20:26 2012
@@ -26,14 +26,16 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.*;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.regionserver.HRegion;
+import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.ServerLoad;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionLoad;
 
 import javax.tools.*;
 import java.io.*;
 import java.util.*;
-import java.util.Arrays;
 import java.util.jar.*;
 
 import org.junit.*;
@@ -550,22 +552,21 @@ public class TestClassLoading {
 
   /**
    * return the subset of all regionservers
-   * (actually returns set of HServerLoads)
+   * (actually returns set of ServerLoads)
    * which host some region in a given table.
    * used by assertAllRegionServers() below to
    * test reporting of loaded coprocessors.
    * @param tableName : given table.
    * @return subset of all servers.
    */
-  Map<ServerName, HServerLoad> serversForTable(String tableName) {
-    Map<ServerName, HServerLoad> serverLoadHashMap =
-        new HashMap<ServerName, HServerLoad>();
-    for(Map.Entry<ServerName,HServerLoad> server:
+  Map<ServerName, ServerLoad> serversForTable(String tableName) {
+    Map<ServerName, ServerLoad> serverLoadHashMap =
+        new HashMap<ServerName, ServerLoad>();
+    for(Map.Entry<ServerName,ServerLoad> server:
         TEST_UTIL.getMiniHBaseCluster().getMaster().getServerManager().
             getOnlineServers().entrySet()) {
-      for(Map.Entry<byte[], HServerLoad.RegionLoad> region:
-          server.getValue().getRegionsLoad().entrySet()) {
-        if (region.getValue().getNameAsString().equals(tableName)) {
+      for (RegionLoad region : server.getValue().getRegionLoadsList()) {
+        if (Bytes.toString(region.getRegionSpecifier().getValue().toByteArray()).equals(tableName)) {
           // this server server hosts a region of tableName: add this server..
           serverLoadHashMap.put(server.getKey(),server.getValue());
           // .. and skip the rest of the regions that it hosts.
@@ -578,7 +579,7 @@ public class TestClassLoading {
 
   void assertAllRegionServers(String[] expectedCoprocessors, String tableName)
       throws InterruptedException {
-    Map<ServerName, HServerLoad> servers;
+    Map<ServerName, ServerLoad> servers;
     String[] actualCoprocessors = null;
     boolean success = false;
     for(int i = 0; i < 5; i++) {
@@ -591,8 +592,9 @@ public class TestClassLoading {
         servers = serversForTable(tableName);
       }
       boolean any_failed = false;
-      for(Map.Entry<ServerName,HServerLoad> server: servers.entrySet()) {
-        actualCoprocessors = server.getValue().getCoprocessors();
+      for(Map.Entry<ServerName,ServerLoad> server: servers.entrySet()) {
+        actualCoprocessors =
+          ServerLoad.getAllCoprocessors(server.getValue());
         if (!Arrays.equals(actualCoprocessors, expectedCoprocessors)) {
           LOG.debug("failed comparison: actual: " +
               Arrays.toString(actualCoprocessors) +

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java?rev=1333319&r1=1333318&r2=1333319&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java Thu May  3 06:20:26 2012
@@ -34,7 +34,7 @@ import org.apache.hadoop.hbase.HBaseConf
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.HServerLoad;
+import org.apache.hadoop.hbase.ServerLoad;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.RegionTransition;
 import org.apache.hadoop.hbase.Server;
@@ -128,9 +128,9 @@ public class TestAssignmentManager {
     this.serverManager = Mockito.mock(ServerManager.class);
     Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
     Mockito.when(this.serverManager.isServerOnline(SERVERNAME_B)).thenReturn(true);
-    final Map<ServerName, HServerLoad> onlineServers = new HashMap<ServerName, HServerLoad>();
-    onlineServers.put(SERVERNAME_B, new HServerLoad());
-    onlineServers.put(SERVERNAME_A, new HServerLoad());
+    final Map<ServerName, ServerLoad> onlineServers = new HashMap<ServerName, ServerLoad>();
+    onlineServers.put(SERVERNAME_B, ServerLoad.EMPTY_SERVERLOAD);
+    onlineServers.put(SERVERNAME_A, ServerLoad.EMPTY_SERVERLOAD);
     Mockito.when(this.serverManager.getOnlineServersList()).thenReturn(
         new ArrayList<ServerName>(onlineServers.keySet()));
     Mockito.when(this.serverManager.getOnlineServers()).thenReturn(onlineServers);

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMXBean.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMXBean.java?rev=1333319&r1=1333318&r2=1333319&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMXBean.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMXBean.java Thu May  3 06:20:26 2012
@@ -24,7 +24,7 @@ import java.util.Set;
 import junit.framework.Assert;
 
 import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HServerLoad;
+import org.apache.hadoop.hbase.ServerLoad;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.MediumTests;
 import org.junit.AfterClass;
@@ -48,7 +48,7 @@ public class TestMXBean {
     TEST_UTIL.shutdownMiniCluster();
   }
 
-  private void verifyRegionServers(Map<String, HServerLoad> regions) {
+  private void verifyRegionServers(Map<String, ServerLoad> regions) {
     Set<String> expected = new HashSet<String>();
     for (int i = 0; i < 4; ++i) {
       HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(i);
@@ -56,7 +56,7 @@ public class TestMXBean {
     }
 
     int found = 0;
-    for (java.util.Map.Entry<String, HServerLoad> entry : regions.entrySet()) {
+    for (java.util.Map.Entry<String, ServerLoad> entry : regions.entrySet()) {
       if (expected.contains(entry.getKey())) {
         ++found;
       }

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java?rev=1333319&r1=1333318&r2=1333319&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java Thu May  3 06:20:26 2012
@@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.HBaseTest
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HServerLoad;
+import org.apache.hadoop.hbase.ServerLoad;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.ZooKeeperConnectionException;
@@ -46,9 +47,13 @@ import org.apache.hadoop.hbase.zookeeper
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.hadoop.hbase.MediumTests;
-import org.apache.hadoop.io.MapWritable;
-import org.apache.hadoop.io.Text;
 import org.apache.zookeeper.KeeperException;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
+import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerReportRequest;
+import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerStartupRequest;
+import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse;
+import com.google.protobuf.ServiceException;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -127,7 +132,7 @@ public class TestMasterNoCluster {
    */
   @Test
   public void testFailover()
-  throws IOException, KeeperException, InterruptedException {
+  throws IOException, KeeperException, InterruptedException, ServiceException {
     final long now = System.currentTimeMillis();
     // Names for our three servers.  Make the port numbers match hostname.
     // Will come in use down in the server when we need to figure how to respond.
@@ -209,7 +214,11 @@ public class TestMasterNoCluster {
       while (!master.isRpcServerOpen()) Threads.sleep(10);
       // Fake master that there are regionservers out there.  Report in.
       for (int i = 0; i < sns.length; i++) {
-        master.regionServerReport(sns[i].getVersionedBytes(), new HServerLoad());
+        RegionServerReportRequest.Builder request = RegionServerReportRequest.newBuilder();;
+        ServerName sn = ServerName.parseVersionedServerName(sns[i].getVersionedBytes());
+        request.setServer(ProtobufUtil.toServerName(sn));
+        request.setLoad(ServerLoad.EMPTY_SERVERLOAD.getServerLoadPB());
+        master.regionServerReport(null, request.build());
       }
       // Master should now come up.
       while (!master.isInitialized()) {Threads.sleep(10);}
@@ -229,10 +238,11 @@ public class TestMasterNoCluster {
    * @throws KeeperException
    * @throws InterruptedException
    * @throws DeserializationException 
+   * @throws ServiceException
    */
   @Test
   public void testCatalogDeploys()
-  throws IOException, KeeperException, InterruptedException, DeserializationException {
+  throws IOException, KeeperException, InterruptedException, DeserializationException, ServiceException {
     final Configuration conf = TESTUTIL.getConfiguration();
     final long now = System.currentTimeMillis();
     // Name for our single mocked up regionserver.
@@ -286,11 +296,19 @@ public class TestMasterNoCluster {
       // Wait till master is up ready for RPCs.
       while (!master.isRpcServerOpen()) Threads.sleep(10);
       // Fake master that there is a regionserver out there.  Report in.
-      MapWritable mw = master.regionServerStartup(rs0.getServerName().getPort(),
-        rs0.getServerName().getStartcode(), now);
+      RegionServerStartupRequest.Builder request = RegionServerStartupRequest.newBuilder();
+      request.setPort(rs0.getServerName().getPort());
+      request.setServerStartCode(rs0.getServerName().getStartcode());
+      request.setServerCurrentTime(now);
+      RegionServerStartupResponse result =
+        master.regionServerStartup(null, request.build());
+      String rshostname = new String();
+      for (NameStringPair e : result.getMapEntriesList()) {
+        if (e.getName().toString().equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
+          rshostname = e.getValue();
+        }
+      }
       // Assert hostname is as expected.
-      String rshostname =
-        mw.get(new Text(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)).toString();
       assertEquals(rs0.getServerName().getHostname(), rshostname);
       // Now master knows there is at least one regionserver checked in and so
       // it'll wait a while to see if more and when none, will assign root and

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java?rev=1333319&r1=1333318&r2=1333319&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java Thu May  3 06:20:26 2012
@@ -34,7 +34,6 @@ import org.apache.hadoop.hbase.client.co
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.ipc.CoprocessorProtocol;
 import org.apache.hadoop.hbase.ipc.HMasterInterface;
-import org.apache.hadoop.hbase.ipc.HMasterRegionInterface;
 import org.apache.hadoop.hbase.ipc.ProtocolSignature;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.JVMClusterUtil;