hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1356920 [1/5] - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/ main/java/org/apache/hadoop/hbase/client/ main/java/org/apache/hadoop/hbase/io/ main/java/org/apache/hadoop/hbase/ipc/ main/java/org/apache/hadoop/hbase/m...
Date Tue, 03 Jul 2012 20:29:54 GMT
Author: stack
Date: Tue Jul  3 20:29:50 2012
New Revision: 1356920

URL: http://svn.apache.org/viewvc?rev=1356920&view=rev
Log:
HBASE-6039 Remove HMasterInterface and replace with something similar to RegionServerStatusProtocol

Added:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterAdminProtocol.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterMonitorProtocol.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterProtocol.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterAdminKeepAliveConnection.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterMonitorKeepAliveConnection.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/generated/MasterAdminProtos.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/generated/MasterMonitorProtos.java
    hbase/trunk/hbase-server/src/main/protobuf/MasterAdmin.proto
    hbase/trunk/hbase-server/src/main/protobuf/MasterMonitor.proto
Removed:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterKeepAliveConnection.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java
Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/generated/MasterProtos.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/HBasePolicyProvider.java
    hbase/trunk/hbase-server/src/main/protobuf/Master.proto
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java

Added: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterAdminProtocol.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterAdminProtocol.java?rev=1356920&view=auto
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterAdminProtocol.java (added)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterAdminProtocol.java Tue Jul  3 20:29:50 2012
@@ -0,0 +1,306 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.MasterAdminService;
+import org.apache.hadoop.hbase.security.TokenInfo;
+import org.apache.hadoop.hbase.security.KerberosInfo;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AddColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AddColumnResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.CreateTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.CreateTableResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteColumnResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AssignRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AssignRegionResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteTableResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DisableTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DisableTableResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.EnableTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.EnableTableResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyColumnResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyTableResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.MoveRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.MoveRegionResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.OfflineRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.OfflineRegionResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.SetBalancerRunningRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.SetBalancerRunningResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.UnassignRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.UnassignRegionResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.BalanceRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.BalanceResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ShutdownRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ShutdownResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.StopMasterRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.StopMasterResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningResponse;
+
+
+import com.google.protobuf.RpcController;
+import com.google.protobuf.ServiceException;
+
+/**
+ * Protocol that a client uses to communicate with the Master (for admin purposes).
+ */
+@KerberosInfo(
+  serverPrincipal = "hbase.master.kerberos.principal")
+@TokenInfo("HBASE_AUTH_TOKEN")
+@InterfaceAudience.Private
+@InterfaceStability.Evolving
+public interface MasterAdminProtocol extends
+    MasterAdminService.BlockingInterface, MasterProtocol {
+  public static final long VERSION = 1L;
+
+  /* Column-level */
+
+  /**
+   * Adds a column to the specified table
+   * @param controller Unused (set to null).
+   * @param req AddColumnRequest that contains:<br>
+   * - tableName: table to modify<br>
+   * - column: column descriptor
+   * @throws ServiceException
+   */
+  @Override
+  public AddColumnResponse addColumn(RpcController controller, AddColumnRequest req)
+  throws ServiceException;
+
+  /**
+   * Deletes a column from the specified table. Table must be disabled.
+   * @param controller Unused (set to null).
+   * @param req DeleteColumnRequest that contains:<br>
+   * - tableName: table to alter<br>
+   * - columnName: column family to remove
+   * @throws ServiceException
+   */
+  @Override
+  public DeleteColumnResponse deleteColumn(RpcController controller, DeleteColumnRequest req)
+  throws ServiceException;
+
+  /**
+   * Modifies an existing column on the specified table
+   * @param controller Unused (set to null).
+   * @param req ModifyColumnRequest that contains:<br>
+   * - tableName: table name<br>
+   * - descriptor: new column descriptor
+   * @throws IOException e
+   */
+  @Override
+  public ModifyColumnResponse modifyColumn(RpcController controller, ModifyColumnRequest req)
+  throws ServiceException;
+
+  /* Region-level */
+
+  /**
+   * Move a region to a specified destination server.
+   * @param controller Unused (set to null).
+   * @param req The request that contains:<br>
+   * - region: The encoded region name; i.e. the hash that makes
+   * up the region name suffix: e.g. if regionname is
+   * <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
+   * then the encoded region name is: <code>527db22f95c8a9e0116f0cc13c680396</code>.<br>
+   * - destServerName: The servername of the destination regionserver.  If
+   * passed the empty byte array we'll assign to a random server.  A server name
+   * is made of host, port and startcode.  Here is an example:
+   * <code> host187.example.com,60020,1289493121758</code>.
+   * @throws ServiceException that wraps a UnknownRegionException if we can't find a
+   * region named <code>encodedRegionName</code>
+   */
+  @Override
+  public MoveRegionResponse moveRegion(RpcController controller, MoveRegionRequest req)
+  throws ServiceException;
+
+  /**
+   * Assign a region to a server chosen at random.
+   * @param controller Unused (set to null).
+   * @param req contains the region to assign.  Will use existing RegionPlan if one
+   * found.
+   * @throws ServiceException
+   */
+  @Override
+  public AssignRegionResponse assignRegion(RpcController controller, AssignRegionRequest req)
+  throws ServiceException;
+
+  /**
+   * Unassign a region from current hosting regionserver.  Region will then be
+   * assigned to a regionserver chosen at random.  Region could be reassigned
+   * back to the same server.  Use {@link #moveRegion(RpcController,MoveRegionRequest}
+   * if you want to control the region movement.
+   * @param controller Unused (set to null).
+   * @param req The request that contains:<br>
+   * - region: Region to unassign. Will clear any existing RegionPlan
+   * if one found.<br>
+   * - force: If true, force unassign (Will remove region from
+   * regions-in-transition too if present as well as from assigned regions --
+   * radical!.If results in double assignment use hbck -fix to resolve.
+   * @throws ServiceException
+   */
+  @Override
+  public UnassignRegionResponse unassignRegion(RpcController controller, UnassignRegionRequest req)
+  throws ServiceException;
+
+  /**
+   * Offline a region from the assignment manager's in-memory state.  The
+   * region should be in a closed state and there will be no attempt to
+   * automatically reassign the region as in unassign.   This is a special
+   * method, and should only be used by experts or hbck.
+   * @param controller Unused (set to null).
+   * @param request OfflineRegionRequest that contains:<br>
+   * - region: Region to offline.  Will clear any existing RegionPlan
+   * if one found.
+   * @throws ServiceException
+   */
+  @Override
+  public OfflineRegionResponse offlineRegion(RpcController controller, OfflineRegionRequest request)
+  throws ServiceException;
+
+  /* Table-level */
+
+  /**
+   * Creates a new table asynchronously.  If splitKeys are specified, then the
+   * table will be created with an initial set of multiple regions.
+   * If splitKeys is null, the table will be created with a single region.
+   * @param controller Unused (set to null).
+   * @param req CreateTableRequest that contains:<br>
+   * - tablesSchema: table descriptor<br>
+   * - splitKeys
+   * @throws ServiceException
+   */
+  @Override
+  public CreateTableResponse createTable(RpcController controller, CreateTableRequest req)
+  throws ServiceException;
+
+  /**
+   * Deletes a table
+   * @param controller Unused (set to null).
+   * @param req DeleteTableRequest that contains:<br>
+   * - tableName: table to delete
+   * @throws ServiceException
+   */
+  @Override
+  public DeleteTableResponse deleteTable(RpcController controller, DeleteTableRequest req)
+  throws ServiceException;
+
+  /**
+   * Puts the table on-line (only needed if table has been previously taken offline)
+   * @param controller Unused (set to null).
+   * @param req EnableTableRequest that contains:<br>
+   * - tableName: table to enable
+   * @throws ServiceException
+   */
+  @Override
+  public EnableTableResponse enableTable(RpcController controller, EnableTableRequest req)
+  throws ServiceException;
+
+  /**
+   * Take table offline
+   *
+   * @param controller Unused (set to null).
+   * @param req DisableTableRequest that contains:<br>
+   * - tableName: table to take offline
+   * @throws ServiceException
+   */
+  @Override
+  public DisableTableResponse disableTable(RpcController controller, DisableTableRequest req)
+  throws ServiceException;
+
+  /**
+   * Modify a table's metadata
+   *
+   * @param controller Unused (set to null).
+   * @param req ModifyTableRequest that contains:<br>
+   * - tableName: table to modify<br>
+   * - tableSchema: new descriptor for table
+   * @throws ServiceException
+   */
+  @Override
+  public ModifyTableResponse modifyTable(RpcController controller, ModifyTableRequest req)
+  throws ServiceException;
+
+  /* Cluster-level */
+
+  /**
+   * Shutdown an HBase cluster.
+   * @param controller Unused (set to null).
+   * @param request ShutdownRequest
+   * @return ShutdownResponse
+   * @throws ServiceException
+   */
+  @Override
+  public ShutdownResponse shutdown(RpcController controller, ShutdownRequest request)
+  throws ServiceException;
+
+  /**
+   * Stop HBase Master only.
+   * Does not shutdown the cluster.
+   * @param controller Unused (set to null).
+   * @param request StopMasterRequest
+   * @return StopMasterResponse
+   * @throws ServiceException
+   */
+  @Override
+  public StopMasterResponse stopMaster(RpcController controller, StopMasterRequest request)
+  throws ServiceException;
+
+  /**
+   * Run the balancer.  Will run the balancer and if regions to move, it will
+   * go ahead and do the reassignments.  Can NOT run for various reasons.  Check
+   * logs.
+   * @param c Unused (set to null).
+   * @param request BalanceRequest
+   * @return BalanceResponse that contains:<br>
+   * - balancerRan: True if balancer ran and was able to tell the region servers to
+   * unassign all the regions to balance (the re-assignment itself is async),
+   * false otherwise.
+   */
+  @Override
+  public BalanceResponse balance(RpcController c, BalanceRequest request) throws ServiceException;
+
+  /**
+   * Turn the load balancer on or off.
+   * @param controller Unused (set to null).
+   * @param req SetBalancerRunningRequest that contains:<br>
+   * - on: If true, enable balancer. If false, disable balancer.<br>
+   * - synchronous: if true, wait until current balance() call, if outstanding, to return.
+   * @return SetBalancerRunningResponse that contains:<br>
+   * - prevBalanceValue: Previous balancer value
+   * @throws ServiceException
+   */
+  @Override
+  public SetBalancerRunningResponse setBalancerRunning(
+      RpcController controller, SetBalancerRunningRequest req) throws ServiceException;
+
+    /**
+   * @param c Unused (set to null).
+   * @param req IsMasterRunningRequest
+   * @return IsMasterRunningRequest that contains:<br>
+   * isMasterRunning: true if master is available
+   * @throws ServiceException
+   */
+  @Override
+  public IsMasterRunningResponse isMasterRunning(RpcController c, IsMasterRunningRequest req)
+  throws ServiceException;
+}

Added: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterMonitorProtocol.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterMonitorProtocol.java?rev=1356920&view=auto
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterMonitorProtocol.java (added)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterMonitorProtocol.java Tue Jul  3 20:29:50 2012
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.MasterMonitorService;
+import org.apache.hadoop.hbase.security.TokenInfo;
+import org.apache.hadoop.hbase.security.KerberosInfo;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetSchemaAlterStatusRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetSchemaAlterStatusResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetTableDescriptorsRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetTableDescriptorsResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetClusterStatusRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetClusterStatusResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningResponse;
+
+import com.google.protobuf.RpcController;
+import com.google.protobuf.ServiceException;
+
+/**
+ * Protocol that a client uses to communicate with the Master (for monitoring purposes).
+ */
+@KerberosInfo(
+  serverPrincipal = "hbase.master.kerberos.principal")
+@TokenInfo("HBASE_AUTH_TOKEN")
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
+public interface MasterMonitorProtocol extends
+    MasterMonitorService.BlockingInterface, MasterProtocol {
+  public static final long VERSION = 1L;
+
+  /**
+   * Used by the client to get the number of regions that have received the
+   * updated schema
+   *
+   * @param controller Unused (set to null).
+   * @param req GetSchemaAlterStatusRequest that contains:<br>
+   * - tableName
+   * @return GetSchemaAlterStatusResponse indicating the number of regions updated.
+   *         yetToUpdateRegions is the regions that are yet to be updated totalRegions
+   *         is the total number of regions of the table
+   * @throws ServiceException
+   */
+  @Override
+  public GetSchemaAlterStatusResponse getSchemaAlterStatus(
+    RpcController controller, GetSchemaAlterStatusRequest req) throws ServiceException;
+
+  /**
+   * Get list of TableDescriptors for requested tables.
+   * @param controller Unused (set to null).
+   * @param req GetTableDescriptorsRequest that contains:<br>
+   * - tableNames: requested tables, or if empty, all are requested
+   * @return GetTableDescriptorsResponse
+   * @throws ServiceException
+   */
+  @Override
+  public GetTableDescriptorsResponse getTableDescriptors(
+      RpcController controller, GetTableDescriptorsRequest req) throws ServiceException;
+
+  /**
+   * Return cluster status.
+   * @param controller Unused (set to null).
+   * @param req GetClusterStatusRequest
+   * @return status object
+   * @throws ServiceException
+   */
+  @Override
+  public GetClusterStatusResponse getClusterStatus(RpcController controller, GetClusterStatusRequest req)
+  throws ServiceException;
+
+  /**
+   * @param c Unused (set to null).
+   * @param req IsMasterRunningRequest
+   * @return IsMasterRunningRequest that contains:<br>
+   * isMasterRunning: true if master is available
+   * @throws ServiceException
+   */
+  @Override
+  public IsMasterRunningResponse isMasterRunning(RpcController c, IsMasterRunningRequest req)
+  throws ServiceException;
+}

Added: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterProtocol.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterProtocol.java?rev=1356920&view=auto
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterProtocol.java (added)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/MasterProtocol.java Tue Jul  3 20:29:50 2012
@@ -0,0 +1,44 @@
+/**
+ * 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.
+ */
+
+// Functions implemented by all the master protocols (e.g. MasterAdminProtocol,
+// MasterMonitorProtocol).  Currently, this is only isMasterRunning, which is used,
+// on proxy creation, to check if the master has been stopped.  If it has,
+// a MasterNotRunningException is thrown back to the client, and the client retries.
+
+package org.apache.hadoop.hbase;
+
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MasterService;
+import org.apache.hadoop.hbase.ipc.VersionedProtocol;
+import com.google.protobuf.RpcController;
+import com.google.protobuf.ServiceException;
+
+public interface MasterProtocol extends VersionedProtocol, MasterService.BlockingInterface {
+
+  /**
+   * @param c Unused (set to null).
+   * @param req IsMasterRunningRequest
+   * @return IsMasterRunningRequest that contains:<br>
+   * isMasterRunning: true if master is available
+   * @throws ServiceException
+   */
+  public IsMasterRunningResponse isMasterRunning(RpcController c, IsMasterRunningRequest req)
+  throws ServiceException;
+}
\ No newline at end of file

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1356920&r1=1356919&r2=1356920&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Tue Jul  3 20:29:50 2012
@@ -58,7 +58,6 @@ import org.apache.hadoop.hbase.client.Ad
 import org.apache.hadoop.hbase.client.ClientProtocol;
 import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor;
 import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase;
-import org.apache.hadoop.hbase.ipc.HMasterInterface;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.protobuf.RequestConverter;
 import org.apache.hadoop.hbase.protobuf.ResponseConverter;
@@ -75,25 +74,27 @@ import org.apache.hadoop.hbase.protobuf.
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableSchema;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DisableTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetClusterStatusRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ShutdownRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.StopMasterRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AddColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.CreateTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DisableTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.EnableTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetSchemaAlterStatusRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetSchemaAlterStatusResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetTableDescriptorsRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetTableDescriptorsResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AssignRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetClusterStatusRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.MoveRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.SetBalancerRunningRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.UnassignRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ShutdownRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.StopMasterRequest;
+import org.apache.hadoop.hbase.client.MasterAdminKeepAliveConnection;
+import org.apache.hadoop.hbase.client.MasterMonitorKeepAliveConnection;
 import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException;
 import org.apache.hadoop.hbase.util.Addressing;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -210,22 +211,6 @@ public class HBaseAdmin implements Abort
     return connection;
   }
 
-  /**
-   * Get a connection to the currently set master.
-   * @return proxy connection to master server for this instance
-   * @throws MasterNotRunningException if the master is not running
-   * @throws ZooKeeperConnectionException if unable to connect to zookeeper
-   * @deprecated  Master is an implementation detail for HBaseAdmin.
-   * Deprecated in HBase 0.94
-   */
-  @Deprecated
-  public HMasterInterface getMaster()
-  throws MasterNotRunningException, ZooKeeperConnectionException {
-    // We take a shared master, but we will never release it,
-    //  so we will have the same behavior as before.
-    return this.connection.getKeepAliveMaster();
-  }
-
   /** @return - true if the master server is running. Throws an exception
    *  otherwise.
    * @throws ZooKeeperConnectionException
@@ -505,11 +490,11 @@ public class HBaseAdmin implements Abort
       }
     }
 
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
         CreateTableRequest request = RequestConverter.buildCreateTableRequest(desc, splitKeys);
-        master.createTable(null, request);
+        masterAdmin.createTable(null, request);
         return null;
       }
     });
@@ -538,11 +523,11 @@ public class HBaseAdmin implements Abort
     HRegionLocation firstMetaServer = getFirstMetaServerForTable(tableName);
     boolean tableExists = true;
 
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
         DeleteTableRequest req = RequestConverter.buildDeleteTableRequest(tableName);
-        master.deleteTable(null,req);
+        masterAdmin.deleteTable(null,req);
         return null;
       }
     });
@@ -571,7 +556,7 @@ public class HBaseAdmin implements Abort
         if (values == null || values.length == 0) {
           tableExists = false;
           GetTableDescriptorsResponse htds;
-          MasterKeepAliveConnection master = connection.getKeepAliveMaster();
+          MasterMonitorKeepAliveConnection master = connection.getKeepAliveMasterMonitor();
           try {
             GetTableDescriptorsRequest req =
               RequestConverter.buildGetTableDescriptorsRequest(null);
@@ -726,12 +711,12 @@ public class HBaseAdmin implements Abort
   public void enableTableAsync(final byte [] tableName)
   throws IOException {
     HTableDescriptor.isLegalTableName(tableName);
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
         LOG.info("Started enable of " + Bytes.toString(tableName));
         EnableTableRequest req = RequestConverter.buildEnableTableRequest(tableName);
-        master.enableTable(null,req);
+        masterAdmin.enableTable(null,req);
         return null;
       }
     });
@@ -797,12 +782,12 @@ public class HBaseAdmin implements Abort
    */
   public void disableTableAsync(final byte [] tableName) throws IOException {
     HTableDescriptor.isLegalTableName(tableName);
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
         LOG.info("Started disable of " + Bytes.toString(tableName));
         DisableTableRequest req = RequestConverter.buildDisableTableRequest(tableName);
-        master.disableTable(null,req);
+        masterAdmin.disableTable(null,req);
         return null;
       }
     });
@@ -968,12 +953,12 @@ public class HBaseAdmin implements Abort
   public Pair<Integer, Integer> getAlterStatus(final byte[] tableName)
   throws IOException {
     HTableDescriptor.isLegalTableName(tableName);
-    return execute(new MasterCallable<Pair<Integer, Integer>>() {
+    return execute(new MasterMonitorCallable<Pair<Integer, Integer>>() {
       @Override
       public Pair<Integer, Integer> call() throws ServiceException {
         GetSchemaAlterStatusRequest req =
           RequestConverter.buildGetSchemaAlterStatusRequest(tableName);
-        GetSchemaAlterStatusResponse ret = master.getSchemaAlterStatus(null,req);
+        GetSchemaAlterStatusResponse ret = masterMonitor.getSchemaAlterStatus(null,req);
         Pair<Integer,Integer> pair =
           new Pair<Integer,Integer>(
             new Integer(ret.getYetToUpdateRegions()),new Integer(ret.getTotalRegions()));
@@ -1005,11 +990,11 @@ public class HBaseAdmin implements Abort
    */
   public void addColumn(final byte [] tableName, final HColumnDescriptor column)
   throws IOException {
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
         AddColumnRequest req = RequestConverter.buildAddColumnRequest(tableName, column);
-        master.addColumn(null,req);
+        masterAdmin.addColumn(null,req);
         return null;
       }
     });
@@ -1038,11 +1023,11 @@ public class HBaseAdmin implements Abort
    */
   public void deleteColumn(final byte [] tableName, final byte [] columnName)
   throws IOException {
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
         DeleteColumnRequest req = RequestConverter.buildDeleteColumnRequest(tableName, columnName);
-        master.deleteColumn(null,req);
+        masterAdmin.deleteColumn(null,req);
         return null;
       }
     });
@@ -1073,11 +1058,11 @@ public class HBaseAdmin implements Abort
    */
   public void modifyColumn(final byte [] tableName, final HColumnDescriptor descriptor)
   throws IOException {
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
         ModifyColumnRequest req = RequestConverter.buildModifyColumnRequest(tableName, descriptor);
-        master.modifyColumn(null,req);
+        masterAdmin.modifyColumn(null,req);
         return null;
       }
     });
@@ -1392,7 +1377,7 @@ public class HBaseAdmin implements Abort
    */
   public void move(final byte [] encodedRegionName, final byte [] destServerName)
   throws UnknownRegionException, MasterNotRunningException, ZooKeeperConnectionException {
-    MasterKeepAliveConnection master = connection.getKeepAliveMaster();
+    MasterAdminKeepAliveConnection master = connection.getKeepAliveMasterAdmin();
     try {
       MoveRegionRequest request = RequestConverter.buildMoveRegionRequest(encodedRegionName, destServerName);
       master.moveRegion(null,request);
@@ -1419,11 +1404,11 @@ public class HBaseAdmin implements Abort
    */
   public void assign(final byte[] regionName) throws MasterNotRunningException,
       ZooKeeperConnectionException, IOException {
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
         AssignRegionRequest request = RequestConverter.buildAssignRegionRequest(regionName);
-        master.assignRegion(null,request);
+        masterAdmin.assignRegion(null,request);
         return null;
       }
     });
@@ -1445,12 +1430,12 @@ public class HBaseAdmin implements Abort
    */
   public void unassign(final byte [] regionName, final boolean force)
   throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
         UnassignRegionRequest request =
           RequestConverter.buildUnassignRegionRequest(regionName, force);
-        master.unassignRegion(null,request);
+        masterAdmin.unassignRegion(null,request);
         return null;
       }
     });
@@ -1461,7 +1446,7 @@ public class HBaseAdmin implements Abort
    */
   public void offline(final byte [] regionName)
   throws IOException {
-    MasterKeepAliveConnection master = connection.getKeepAliveMaster();
+    MasterAdminKeepAliveConnection master = connection.getKeepAliveMasterAdmin();
     try {
       master.offlineRegion(null,RequestConverter.buildOfflineRegionRequest(regionName));
     } catch (ServiceException se) {
@@ -1479,7 +1464,7 @@ public class HBaseAdmin implements Abort
    */
   public boolean setBalancerRunning(final boolean on, final boolean synchronous)
   throws MasterNotRunningException, ZooKeeperConnectionException {
-    MasterKeepAliveConnection master = connection.getKeepAliveMaster();
+    MasterAdminKeepAliveConnection master = connection.getKeepAliveMasterAdmin();
     try {
       SetBalancerRunningRequest req =
         RequestConverter.buildSetBalancerRunningRequest(on, synchronous);
@@ -1509,7 +1494,7 @@ public class HBaseAdmin implements Abort
    */
   public boolean balancer()
   throws MasterNotRunningException, ZooKeeperConnectionException, ServiceException {
-    MasterKeepAliveConnection master = connection.getKeepAliveMaster();
+    MasterAdminKeepAliveConnection master = connection.getKeepAliveMasterAdmin();
     try {
       return master.balance(null,RequestConverter.buildBalanceRequest()).getBalancerRan();
     } finally {
@@ -1611,11 +1596,11 @@ public class HBaseAdmin implements Abort
    */
   public void modifyTable(final byte [] tableName, final HTableDescriptor htd)
   throws IOException {
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
         ModifyTableRequest request = RequestConverter.buildModifyTableRequest(tableName, htd);
-        master.modifyTable(null, request);
+        masterAdmin.modifyTable(null, request);
         return null;
       }
     });
@@ -1662,10 +1647,10 @@ public class HBaseAdmin implements Abort
    * @throws IOException if a remote or network exception occurs
    */
   public synchronized void shutdown() throws IOException {
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
-        master.shutdown(null,ShutdownRequest.newBuilder().build());
+        masterAdmin.shutdown(null,ShutdownRequest.newBuilder().build());
         return null;
       }
     });
@@ -1678,10 +1663,10 @@ public class HBaseAdmin implements Abort
    * @throws IOException if a remote or network exception occurs
    */
   public synchronized void stopMaster() throws IOException {
-    execute(new MasterCallable<Void>() {
+    execute(new MasterAdminCallable<Void>() {
       @Override
       public Void call() throws ServiceException {
-        master.stopMaster(null,StopMasterRequest.newBuilder().build());
+        masterAdmin.stopMaster(null,StopMasterRequest.newBuilder().build());
         return null;
       }
     });
@@ -1713,11 +1698,11 @@ public class HBaseAdmin implements Abort
    * @throws IOException if a remote or network exception occurs
    */
   public ClusterStatus getClusterStatus() throws IOException {
-    return execute(new MasterCallable<ClusterStatus>() {
+    return execute(new MasterMonitorCallable<ClusterStatus>() {
       @Override
       public ClusterStatus call() throws ServiceException {
         GetClusterStatusRequest req = RequestConverter.buildGetClusterStatusRequest();
-        return ClusterStatus.convert(master.getClusterStatus(null,req).getClusterStatus());
+        return ClusterStatus.convert(masterMonitor.getClusterStatus(null,req).getClusterStatus());
       }
     });
   }
@@ -1779,9 +1764,9 @@ public class HBaseAdmin implements Abort
       }
 
       // Check Master, same logic.
-      MasterKeepAliveConnection master = null;
+      MasterAdminKeepAliveConnection master = null;
       try {
-        master = connection.getKeepAliveMaster();
+        master = connection.getKeepAliveMasterAdmin();
         master.isMasterRunning(null,RequestConverter.buildIsMasterRunningRequest());
       } finally {
         if (master != null) {
@@ -1966,19 +1951,51 @@ public class HBaseAdmin implements Abort
   }
 
   /**
-   * @see {@link #execute}
+   * @see {@link #execute(MasterAdminCallable<V>)}
+   */
+  private abstract static class MasterAdminCallable<V> implements Callable<V>{
+    protected MasterAdminKeepAliveConnection masterAdmin;
+  }
+
+  /**
+   * @see {@link #execute(MasterMonitorCallable<V>)}
+   */
+  private abstract static class MasterMonitorCallable<V> implements Callable<V> {
+    protected MasterMonitorKeepAliveConnection masterMonitor;
+  }
+
+  /**
+   * This method allows to execute a function requiring a connection to
+   * master without having to manage the connection creation/close.
+   * Create a {@link MasterAdminCallable} to use it.
    */
-  private abstract static class MasterCallable<V> implements Callable<V>{
-    protected MasterKeepAliveConnection master;
+  private <V> V execute(MasterAdminCallable<V> function) throws IOException {
+    function.masterAdmin = connection.getKeepAliveMasterAdmin();
+    try {
+      return executeCallable(function);
+    } finally {
+      function.masterAdmin.close();
+    }
   }
 
   /**
    * This method allows to execute a function requiring a connection to
    * master without having to manage the connection creation/close.
-   * Create a {@link MasterCallable} to use it.
+   * Create a {@link MasterAdminCallable} to use it.
+   */
+  private <V> V execute(MasterMonitorCallable<V> function) throws IOException {
+    function.masterMonitor = connection.getKeepAliveMasterMonitor();
+    try {
+      return executeCallable(function);
+    } finally {
+      function.masterMonitor.close();
+    }
+  }
+
+  /**
+   * Helper function called by other execute functions.
    */
-  private <V> V execute(MasterCallable<V> function) throws IOException {
-    function.master = connection.getKeepAliveMaster();
+  private <V> V executeCallable(Callable<V> function) throws IOException {
     try {
       return function.call();
     } catch (RemoteException re) {
@@ -1990,8 +2007,6 @@ public class HBaseAdmin implements Abort
     } catch (Exception e) {
       // This should not happen...
       throw new IOException("Unexpected exception when calling master", e);
-    } finally {
-      function.master.close();
     }
   }
 }

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnection.java?rev=1356920&r1=1356919&r2=1356920&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnection.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnection.java Tue Jul  3 20:29:50 2012
@@ -40,7 +40,6 @@ import org.apache.hadoop.hbase.client.Ad
 import org.apache.hadoop.hbase.client.ClientProtocol;
 import org.apache.hadoop.hbase.client.coprocessor.Batch;
 import org.apache.hadoop.hbase.ipc.CoprocessorProtocol;
-import org.apache.hadoop.hbase.ipc.HMasterInterface;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 
 /**
@@ -79,20 +78,6 @@ public interface HConnection extends Abo
   @Deprecated
   public ZooKeeperWatcher getZooKeeperWatcher() throws IOException;
 
-  /**
-   * @return proxy connection to master server for this instance
-   * @throws MasterNotRunningException if the master is not running
-   * @throws ZooKeeperConnectionException if unable to connect to zookeeper
-   * @deprecated Removed because it was a mistake exposing master in this
-   * interface (master is an implementation detail). Master functions are
-   * available from HConnection or HBaseAdmin, without having to use
-   * directly the master.
-   * Deprecated in HBase 0.94
-   */
-  @Deprecated
-  public HMasterInterface getMaster()
-    throws MasterNotRunningException, ZooKeeperConnectionException;
-
   /** @return - true if the master server is running */
   public boolean isMasterRunning()
   throws MasterNotRunningException, ZooKeeperConnectionException;

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1356920&r1=1356919&r2=1356920&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Tue Jul  3 20:29:50 2012
@@ -65,13 +65,17 @@ import org.apache.hadoop.hbase.client.co
 import org.apache.hadoop.hbase.ipc.CoprocessorProtocol;
 import org.apache.hadoop.hbase.ipc.ExecRPCInvoker;
 import org.apache.hadoop.hbase.ipc.HBaseRPC;
-import org.apache.hadoop.hbase.ipc.HMasterInterface;
+import org.apache.hadoop.hbase.MasterProtocol;
+import org.apache.hadoop.hbase.MasterMonitorProtocol;
+import org.apache.hadoop.hbase.MasterAdminProtocol;
+import org.apache.hadoop.hbase.client.MasterAdminKeepAliveConnection;
+import org.apache.hadoop.hbase.client.MasterMonitorKeepAliveConnection;
 import org.apache.hadoop.hbase.ipc.VersionedProtocol;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.protobuf.RequestConverter;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableSchema;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetTableDescriptorsRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetTableDescriptorsResponse;
 import org.apache.hadoop.hbase.security.User;
 import org.apache.hadoop.hbase.util.*;
 import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
@@ -523,7 +527,6 @@ public class HConnectionManager {
     private final Object masterAndZKLock = new Object();
 
     private long keepZooKeeperWatcherAliveUntil = Long.MAX_VALUE;
-    private long keepMasterAliveUntil = Long.MAX_VALUE;
     private final DelayedClosing delayedClosing =
       DelayedClosing.createAndStart(this);
 
@@ -657,12 +660,26 @@ public class HConnectionManager {
       return this.conf;
     }
 
+    private static class MasterProtocolState {
+      public MasterProtocol protocol;
+      public int userCount;
+      public long keepAliveUntil = Long.MAX_VALUE;
+      public final Class<? extends MasterProtocol> protocolClass;
+      public long version;
+
+      public MasterProtocolState (
+          final Class<? extends MasterProtocol> protocolClass, long version) {
+        this.protocolClass = protocolClass;
+        this.version = version;
+      }
+    }
 
     /**
      * Create a new Master proxy. Try once only.
      */
-    private HMasterInterface createMasterInterface()
-      throws IOException, KeeperException, ServiceException {
+    private MasterProtocol createMasterInterface(
+        MasterProtocolState masterProtocolState)
+        throws IOException, KeeperException, ServiceException {
 
       ZooKeeperKeepAliveConnection zkw;
       try {
@@ -685,9 +702,10 @@ public class HConnectionManager {
 
         InetSocketAddress isa =
           new InetSocketAddress(sn.getHostname(), sn.getPort());
-        HMasterInterface tryMaster = (HMasterInterface) HBaseRPC.getProxy(
-          HMasterInterface.class, HMasterInterface.VERSION, isa, this.conf,
-          this.rpcTimeout);
+        MasterProtocol tryMaster = (MasterProtocol) HBaseRPC.getProxy(
+          masterProtocolState.protocolClass,
+          masterProtocolState.version,
+          isa, this.conf,this.rpcTimeout);
 
         if (tryMaster.isMasterRunning(
             null, RequestConverter.buildIsMasterRunningRequest()).getIsMasterRunning()) {
@@ -703,50 +721,24 @@ public class HConnectionManager {
       }
     }
 
-
-    /**
-     * Get a connection to master. This connection will be reset if master dies.
-     * Don't close it, it will be closed with the connection.
-     * @deprecated This function is deprecated because it creates a never ending
-     * connection to master and  hence wastes resources.
-     * In the hbase.client package, use {@link #getKeepAliveMaster()} instead.
-     *
-     * Internally, we're using the shared master as there is no reason to create
-     *  a new connection. However, in this case, we will never close the shared
-     *  master.
-     */
-    @Override
-    @Deprecated
-    public HMasterInterface getMaster() throws
-      MasterNotRunningException, ZooKeeperConnectionException {
-      synchronized (this.masterAndZKLock) {
-        canCloseMaster = false;
-        try {
-          return getKeepAliveMaster();
-        } catch (MasterNotRunningException e) {
-          throw e;
-        }
-      }
-    }
-
     /**
      * Create a master, retries if necessary.
      */
-    private HMasterInterface createMasterWithRetries()
-      throws MasterNotRunningException {
+    private MasterProtocol createMasterWithRetries(
+      MasterProtocolState masterProtocolState) throws MasterNotRunningException {
 
       // The lock must be at the beginning to prevent multiple master creation
       //  (and leaks) in a multithread context
       synchronized (this.masterAndZKLock) {
         Exception exceptionCaught = null;
-        HMasterInterface master = null;
+        MasterProtocol master = null;
         int tries = 0;
         while (
           !this.closed && master == null
           ) {
           tries++;
           try {
-            master = createMasterInterface();
+            master = createMasterInterface(masterProtocolState);
           } catch (IOException e) {
             exceptionCaught = e;
           } catch (KeeperException e) {
@@ -818,7 +810,7 @@ public class HConnectionManager {
       // When getting the master proxy connection, we check it's running,
       // so if there is no exception, it means we've been able to get a
       // connection on a running master
-      getKeepAliveMaster().close();
+      getKeepAliveMasterMonitor().close();
       return true;
     }
 
@@ -1471,7 +1463,7 @@ public class HConnectionManager {
     /**
      * Creates a Chore thread to check the connections to master & zookeeper
      *  and close them when they reach their closing time (
-     *  {@link #keepMasterAliveUntil} and
+     *  {@link #MasterProtocolState.keepAliveUntil} and
      *  {@link #keepZooKeeperWatcherAliveUntil}). Keep alive time is
      *  managed by the release functions and the variable {@link #keepAlive}
      */
@@ -1499,6 +1491,13 @@ public class HConnectionManager {
         return new DelayedClosing(hci, stoppable);
       }
 
+      protected void closeMasterProtocol(MasterProtocolState protocolState) {
+        if (System.currentTimeMillis() > protocolState.keepAliveUntil) {
+          hci.closeMasterProtocol(protocolState);
+          protocolState.keepAliveUntil = Long.MAX_VALUE;
+        }
+      }
+
       @Override
       protected void chore() {
         synchronized (hci.masterAndZKLock) {
@@ -1510,12 +1509,8 @@ public class HConnectionManager {
               hci.keepZooKeeperWatcherAliveUntil = Long.MAX_VALUE;
             }
           }
-          if (hci.canCloseMaster) {
-            if (System.currentTimeMillis() > hci.keepMasterAliveUntil) {
-              hci.closeMaster();
-              hci.keepMasterAliveUntil = Long.MAX_VALUE;
-            }
-          }
+          closeMasterProtocol(hci.masterAdminProtocol);
+          closeMasterProtocol(hci.masterMonitorProtocol);
         }
       }
 
@@ -1543,14 +1538,14 @@ public class HConnectionManager {
       }
     }
 
-    private static class MasterHandler implements InvocationHandler {
+    private static class MasterProtocolHandler implements InvocationHandler {
       private HConnectionImplementation connection;
-      private HMasterInterface master;
+      private MasterProtocolState protocolStateTracker;
 
-      protected MasterHandler(HConnectionImplementation connection,
-                                    HMasterInterface master) {
+      protected MasterProtocolHandler(HConnectionImplementation connection,
+                                    MasterProtocolState protocolStateTracker) {
         this.connection = connection;
-        this.master = master;
+        this.protocolStateTracker = protocolStateTracker;
       }
 
       @Override
@@ -1558,11 +1553,11 @@ public class HConnectionManager {
         throws Throwable {
         if (method.getName().equals("close") &&
               method.getParameterTypes().length == 0) {
-          release(connection, master);
+          release(connection, protocolStateTracker);
           return null;
         } else {
           try {
-            return method.invoke(master, args);
+            return method.invoke(protocolStateTracker.protocol, args);
           }catch  (InvocationTargetException e){
             // We will have this for all the exception, checked on not, sent
             //  by any layer, including the functional exception
@@ -1581,20 +1576,15 @@ public class HConnectionManager {
 
       private void release(
         HConnectionImplementation connection,
-        org.apache.hadoop.hbase.ipc.HMasterInterface target) {
+        MasterProtocolState target) {
         connection.releaseMaster(target);
       }
     }
 
-    private HMasterInterface keepAliveMaster;
-    private int keepAliveMasterUserCount;
-
-    // The old interface {@link #getMaster} allows to get a master that's never
-    //  closed. So if someone uses this interface, we never close the shared
-    //  master whatever the user count...
-    // When closing the connection, we close the master as well, as in the
-    //  previous implementation.
-    private boolean canCloseMaster = true;
+    MasterProtocolState masterAdminProtocol =
+      new MasterProtocolState(MasterAdminProtocol.class, MasterAdminProtocol.VERSION);
+    MasterProtocolState masterMonitorProtocol =
+      new MasterProtocolState(MasterMonitorProtocol.class, MasterMonitorProtocol.VERSION);
 
     /**
      * This function allows HBaseAdmin and potentially others
@@ -1603,33 +1593,58 @@ public class HConnectionManager {
      * @return The shared instance. Never returns null.
      * @throws MasterNotRunningException
      */
-    MasterKeepAliveConnection getKeepAliveMaster()
-      throws MasterNotRunningException {
+    private Object getKeepAliveMasterProtocol(
+        MasterProtocolState protocolState, Class connectionClass)
+        throws MasterNotRunningException {
       synchronized (masterAndZKLock) {
-        if (!isKeepAliveMasterConnectedAndRunning()) {
-          if (keepAliveMaster != null) {
-            HBaseRPC.stopProxy(keepAliveMaster);
-          }
-          keepAliveMaster = null;
-          keepAliveMaster = createMasterWithRetries();
-        }
-        keepAliveMasterUserCount++;
-        keepMasterAliveUntil = Long.MAX_VALUE;
-
-        return (MasterKeepAliveConnection) Proxy.newProxyInstance(
-          MasterKeepAliveConnection.class.getClassLoader(),
-          new Class[]{MasterKeepAliveConnection.class},
-          new MasterHandler(this, keepAliveMaster)
+        if (!isKeepAliveMasterConnectedAndRunning(protocolState)) {
+          if (protocolState.protocol != null) {
+            HBaseRPC.stopProxy(protocolState.protocol);
+          }
+          protocolState.protocol = null;
+          protocolState.protocol = createMasterWithRetries(protocolState);
+        }
+        protocolState.userCount++;
+        protocolState.keepAliveUntil = Long.MAX_VALUE;
+
+        return Proxy.newProxyInstance(
+          connectionClass.getClassLoader(),
+          new Class[]{connectionClass},
+          new MasterProtocolHandler(this, protocolState)
         );
       }
     }
 
-    private boolean isKeepAliveMasterConnectedAndRunning(){
-      if (keepAliveMaster == null){
+    /**
+     * This function allows HBaseAdmin and potentially others
+     * to get a shared MasterAdminProtocol connection.
+     *
+     * @return The shared instance. Never returns null.
+     * @throws MasterNotRunningException
+     */
+    MasterAdminKeepAliveConnection getKeepAliveMasterAdmin() throws MasterNotRunningException {
+      return (MasterAdminKeepAliveConnection)
+        getKeepAliveMasterProtocol(masterAdminProtocol, MasterAdminKeepAliveConnection.class);
+    }
+
+    /**
+     * This function allows HBaseAdminProtocol and potentially others
+     * to get a shared MasterMonitor connection.
+     *
+     * @return The shared instance. Never returns null.
+     * @throws MasterNotRunningException
+     */
+    MasterMonitorKeepAliveConnection getKeepAliveMasterMonitor() throws MasterNotRunningException {
+      return (MasterMonitorKeepAliveConnection)
+        getKeepAliveMasterProtocol(masterMonitorProtocol, MasterMonitorKeepAliveConnection.class);
+    }
+
+    private boolean isKeepAliveMasterConnectedAndRunning(MasterProtocolState protocolState){
+      if (protocolState.protocol == null){
         return false;
       }
       try {
-         return keepAliveMaster.isMasterRunning(
+         return protocolState.protocol.isMasterRunning(
            null, RequestConverter.buildIsMasterRunningRequest()).getIsMasterRunning();
       }catch (UndeclaredThrowableException e){
         // It's somehow messy, but we can receive exceptions such as
@@ -1644,35 +1659,39 @@ public class HConnectionManager {
       }
     }
 
-   private void releaseMaster(HMasterInterface master) {
-      if (master == null){
+   private void releaseMaster(MasterProtocolState protocolState) {
+      if (protocolState.protocol == null){
         return;
       }
       synchronized (masterAndZKLock) {
-        --keepAliveMasterUserCount;
-        if (keepAliveMasterUserCount <= 0) {
-          keepMasterAliveUntil =
+        --protocolState.userCount;
+        if (protocolState.userCount <= 0) {
+          protocolState.keepAliveUntil =
             System.currentTimeMillis() + keepAlive;
         }
       }
     }
 
+    private void closeMasterProtocol(MasterProtocolState protocolState) {
+      if (protocolState.protocol != null){
+        LOG.info("Closing master protocol: " + protocolState.protocolClass.getName());
+        HBaseRPC.stopProxy(protocolState.protocol);
+        protocolState.protocol = null;
+      }
+      protocolState.userCount = 0;
+    }
+
     /**
      * Immediate close of the shared master. Can be by the delayed close or
      *  when closing the connection itself.
      */
     private void closeMaster() {
       synchronized (masterAndZKLock) {
-        if (keepAliveMaster != null ){
-          LOG.info("Closing master connection");
-          HBaseRPC.stopProxy(keepAliveMaster);
-          keepAliveMaster = null;
-        }
-        keepAliveMasterUserCount = 0;
+        closeMasterProtocol(masterAdminProtocol);
+        closeMasterProtocol(masterMonitorProtocol);
       }
     }
 
-
     @Override
     public <T> T getRegionServerWithRetries(ServerCallable<T> callable)
     throws IOException, RuntimeException {
@@ -2357,7 +2376,7 @@ public class HConnectionManager {
 
     @Override
     public HTableDescriptor[] listTables() throws IOException {
-      MasterKeepAliveConnection master = getKeepAliveMaster();
+      MasterMonitorKeepAliveConnection master = getKeepAliveMasterMonitor();
       try {
         GetTableDescriptorsRequest req =
           RequestConverter.buildGetTableDescriptorsRequest(null);
@@ -2372,7 +2391,7 @@ public class HConnectionManager {
     @Override
     public HTableDescriptor[] getHTableDescriptors(List<String> tableNames) throws IOException {
       if (tableNames == null || tableNames.isEmpty()) return new HTableDescriptor[0];
-      MasterKeepAliveConnection master = getKeepAliveMaster();
+      MasterMonitorKeepAliveConnection master = getKeepAliveMasterMonitor();
       try {
         GetTableDescriptorsRequest req =
           RequestConverter.buildGetTableDescriptorsRequest(tableNames);
@@ -2401,7 +2420,7 @@ public class HConnectionManager {
       if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
         return HTableDescriptor.META_TABLEDESC;
       }
-      MasterKeepAliveConnection master = getKeepAliveMaster();
+      MasterMonitorKeepAliveConnection master = getKeepAliveMasterMonitor();
       GetTableDescriptorsResponse htds;
       try {
         GetTableDescriptorsRequest req =
@@ -2441,3 +2460,4 @@ public class HConnectionManager {
     log.debug("Set serverside HConnection retries=" + retries);
   }
 }
+

Added: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterAdminKeepAliveConnection.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterAdminKeepAliveConnection.java?rev=1356920&view=auto
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterAdminKeepAliveConnection.java (added)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterAdminKeepAliveConnection.java Tue Jul  3 20:29:50 2012
@@ -0,0 +1,44 @@
+/**
+ * Copyright 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.MasterAdminProtocol;
+
+import java.io.Closeable;
+
+/**
+ * A KeepAlive connection is not physically closed immediately after the close,
+ *  but rather kept alive for a few minutes. It makes sense only if it's shared.
+ *
+ * This interface is used by a dynamic proxy. It allows to have a #close
+ *  function in a master client.
+ *
+ * This class is intended to be used internally by HBase classes that need to
+ * speak the MasterAdminProtocol; but not by * final user code. Hence it's
+ * package protected.
+ */
+interface MasterAdminKeepAliveConnection extends MasterAdminProtocol, Closeable {
+
+  @Override
+  public void close();
+}
+

Added: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterMonitorKeepAliveConnection.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterMonitorKeepAliveConnection.java?rev=1356920&view=auto
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterMonitorKeepAliveConnection.java (added)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/MasterMonitorKeepAliveConnection.java Tue Jul  3 20:29:50 2012
@@ -0,0 +1,44 @@
+/**
+ * Copyright 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.MasterMonitorProtocol;
+
+import java.io.Closeable;
+
+/**
+ * A KeepAlive connection is not physically closed immediately after the close,
+ *  but rather kept alive for a few minutes. It makes sense only if it's shared.
+ *
+ * This interface is used by a dynamic proxy. It allows to have a #close
+ *  function in a master client.
+ *
+ * This class is intended to be used internally by HBase classes that need to
+ * speak the MasterMonitorProtocol; but not by final user code. Hence it's
+ * package protected.
+ */
+interface MasterMonitorKeepAliveConnection extends MasterMonitorProtocol, Closeable {
+
+  @Override
+  public void close();
+}
+

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java?rev=1356920&r1=1356919&r2=1356920&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java Tue Jul  3 20:29:50 2012
@@ -122,7 +122,7 @@ public class HbaseObjectWritable impleme
 
   // Here we maintain two static maps of classes to code and vice versa.
   // Add new classes+codes as wanted or figure way to auto-generate these
-  // maps from the HMasterInterface.
+  // maps.
   static final Map<Integer, Class<?>> CODE_TO_CLASS =
     new HashMap<Integer, Class<?>>();
   static final Map<Class<?>, Integer> CLASS_TO_CODE =

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java?rev=1356920&r1=1356919&r2=1356920&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java Tue Jul  3 20:29:50 2012
@@ -25,6 +25,8 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.client.AdminProtocol;
 import org.apache.hadoop.hbase.client.ClientProtocol;
+import org.apache.hadoop.hbase.MasterMonitorProtocol;
+import org.apache.hadoop.hbase.MasterAdminProtocol;
 import org.apache.hadoop.hbase.ipc.VersionedProtocol;
 import org.apache.hadoop.metrics.MetricsContext;
 import org.apache.hadoop.metrics.MetricsRecord;
@@ -66,7 +68,8 @@ public class HBaseRpcMetrics implements 
 
     context.registerUpdater(this);
 
-    initMethods(HMasterInterface.class);
+    initMethods(MasterMonitorProtocol.class);
+    initMethods(MasterAdminProtocol.class);
     initMethods(RegionServerStatusProtocol.class);
     initMethods(ClientProtocol.class);
     initMethods(AdminProtocol.class);

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java?rev=1356920&r1=1356919&r2=1356920&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java Tue Jul  3 20:29:50 2012
@@ -34,6 +34,8 @@ import org.apache.hadoop.conf.Configurab
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.client.AdminProtocol;
 import org.apache.hadoop.hbase.client.ClientProtocol;
+import org.apache.hadoop.hbase.MasterMonitorProtocol;
+import org.apache.hadoop.hbase.MasterAdminProtocol;
 import org.apache.hadoop.hbase.io.HbaseObjectWritable;
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService;
@@ -65,6 +67,8 @@ public class Invocation extends Versione
       Long.valueOf(AdminProtocol.VERSION));
     PROTOCOL_VERSION.put(RegionServerStatusService.BlockingInterface.class,
       Long.valueOf(RegionServerStatusProtocol.VERSION));
+    PROTOCOL_VERSION.put(MasterMonitorProtocol.class,Long.valueOf(MasterMonitorProtocol.VERSION));
+    PROTOCOL_VERSION.put(MasterAdminProtocol.class,Long.valueOf(MasterAdminProtocol.VERSION));
   }
 
   // For protobuf protocols, which use ServiceException, instead of IOException
@@ -75,7 +79,8 @@ public class Invocation extends Versione
     PROTOBUF_PROTOCOLS.add(ClientProtocol.class);
     PROTOBUF_PROTOCOLS.add(AdminProtocol.class);
     PROTOBUF_PROTOCOLS.add(RegionServerStatusProtocol.class);
-    PROTOBUF_PROTOCOLS.add(HMasterInterface.class);
+    PROTOBUF_PROTOCOLS.add(MasterMonitorProtocol.class);
+    PROTOBUF_PROTOCOLS.add(MasterAdminProtocol.class);
   }
 
   private static byte RPC_VERSION = 1;

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1356920&r1=1356919&r2=1356920&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Tue Jul  3 20:29:50 2012
@@ -76,7 +76,8 @@ import org.apache.hadoop.hbase.executor.
 import org.apache.hadoop.hbase.executor.ExecutorService.ExecutorType;
 import org.apache.hadoop.hbase.ipc.HBaseRPC;
 import org.apache.hadoop.hbase.ipc.HBaseServer;
-import org.apache.hadoop.hbase.ipc.HMasterInterface;
+import org.apache.hadoop.hbase.MasterMonitorProtocol;
+import org.apache.hadoop.hbase.MasterAdminProtocol;
 import org.apache.hadoop.hbase.RegionServerStatusProtocol;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.protobuf.RequestConverter;
@@ -124,52 +125,52 @@ import org.apache.hadoop.hbase.protobuf.
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
 import com.google.protobuf.RpcController;
 
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DisableTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DisableTableResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.OfflineRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.OfflineRegionResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AddColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AddColumnResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AssignRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AssignRegionResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.CreateTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.CreateTableResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteColumnResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteTableResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DisableTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DisableTableResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.EnableTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.EnableTableResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetSchemaAlterStatusRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetSchemaAlterStatusResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetTableDescriptorsRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetTableDescriptorsResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyColumnResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyTableResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.MoveRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.MoveRegionResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.OfflineRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.OfflineRegionResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.UnassignRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.UnassignRegionResponse;
 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerReportRequest;
 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerReportResponse;
 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorRequest;
 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.ReportRSFatalErrorResponse;
 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerStartupRequest;
 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerStartupResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.BalanceRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.BalanceResponse;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ShutdownRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ShutdownResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.StopMasterRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.StopMasterResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetClusterStatusRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetClusterStatusResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.SetBalancerRunningRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.SetBalancerRunningResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ShutdownRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ShutdownResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.StopMasterRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.StopMasterResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetClusterStatusRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetClusterStatusResponse;
 import com.google.protobuf.ServiceException;
 
 /**
@@ -185,13 +186,14 @@ import com.google.protobuf.ServiceExcept
  *
  * <p>You can also shutdown just this master.  Call {@link #stopMaster()}.
  *
- * @see HMasterInterface
- * @see MasterRegionInterface
+ * @see MasterMonitorProtocol
+ * @see MasterAdminProtocol
+ * @see RegionServerStatusProtocol
  * @see Watcher
  */
 @InterfaceAudience.Private
 public class HMaster extends HasThread
-implements HMasterInterface, RegionServerStatusProtocol, MasterServices,
+implements MasterMonitorProtocol, MasterAdminProtocol, RegionServerStatusProtocol, MasterServices,
 Server {
   private static final Log LOG = LogFactory.getLog(HMaster.class.getName());
 
@@ -315,7 +317,8 @@ Server {
     int numHandlers = conf.getInt("hbase.master.handler.count",
       conf.getInt("hbase.regionserver.handler.count", 25));
     this.rpcServer = HBaseRPC.getServer(this,
-      new Class<?>[]{HMasterInterface.class, RegionServerStatusProtocol.class},
+      new Class<?>[]{MasterMonitorProtocol.class,
+        MasterAdminProtocol.class, RegionServerStatusProtocol.class},
         initialIsa.getHostName(), // BindAddress is IP we got for this server.
         initialIsa.getPort(),
         numHandlers,
@@ -893,8 +896,10 @@ Server {
   public ProtocolSignature getProtocolSignature(
       String protocol, long version, int clientMethodsHashCode)
   throws IOException {
-    if (HMasterInterface.class.getName().equals(protocol)) {
-      return new ProtocolSignature(HMasterInterface.VERSION, null);
+    if (MasterMonitorProtocol.class.getName().equals(protocol)) {
+      return new ProtocolSignature(MasterMonitorProtocol.VERSION, null);
+    } else if (MasterAdminProtocol.class.getName().equals(protocol)) {
+      return new ProtocolSignature(MasterAdminProtocol.VERSION, null);
     } else if (RegionServerStatusProtocol.class.getName().equals(protocol)) {
       return new ProtocolSignature(RegionServerStatusProtocol.VERSION, null);
     }
@@ -902,8 +907,10 @@ Server {
   }
 
   public long getProtocolVersion(String protocol, long clientVersion) {
-    if (HMasterInterface.class.getName().equals(protocol)) {
-      return HMasterInterface.VERSION;
+    if (MasterMonitorProtocol.class.getName().equals(protocol)) {
+      return MasterMonitorProtocol.VERSION;
+    } else if (MasterAdminProtocol.class.getName().equals(protocol)) {
+      return MasterAdminProtocol.VERSION;
     } else if (RegionServerStatusProtocol.class.getName().equals(protocol)) {
       return RegionServerStatusProtocol.VERSION;
     }

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java?rev=1356920&r1=1356919&r2=1356920&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java Tue Jul  3 20:29:50 2012
@@ -106,8 +106,8 @@ import org.apache.hadoop.hbase.protobuf.
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionInfo;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionLoad;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableSchema;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.CreateTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetTableDescriptorsResponse;
 import org.apache.hadoop.hbase.regionserver.wal.HLog;
 import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java?rev=1356920&r1=1356919&r2=1356920&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/RequestConverter.java Tue Jul  3 20:29:50 2012
@@ -80,24 +80,24 @@ import org.apache.hadoop.hbase.protobuf.
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.UnlockRowRequest;
 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.MasterProtos.AddColumnRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DisableTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.OfflineRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AddColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AssignRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.CreateTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DisableTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.EnableTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetSchemaAlterStatusRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetTableDescriptorsRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyColumnRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.ModifyTableRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.MoveRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.OfflineRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.UnassignRegionRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.BalanceRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetClusterStatusRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.SetBalancerRunningRequest;
+import org.apache.hadoop.hbase.protobuf.generated.MasterMonitorProtos.GetClusterStatusRequest;
 import org.apache.hadoop.hbase.regionserver.wal.HLog;
 import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;



Mime
View raw message