HBASE-6039 Remove HMasterInterface and replace with something similar to RegionServerStatusProtocol
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1356920 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
02cd5297ee
commit
f2f468cc65
|
@ -1,6 +1,4 @@
|
|||
/**
|
||||
* Copyright 2010 The Apache Software Foundation
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -17,140 +15,66 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.ipc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
package org.apache.hadoop.hbase;
|
||||
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.ClusterStatus;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
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.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.AssignRegionRequest;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionResponse;
|
||||
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.SetBalancerRunningRequest;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningResponse;
|
||||
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.MasterProtos.BalanceRequest;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.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.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.UnknownRegionException;
|
||||
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.util.Pair;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Clients interact with the HMasterInterface to gain access to meta-level
|
||||
* HBase functionality, like finding an HRegionServer and creating/destroying
|
||||
* tables.
|
||||
*
|
||||
* <p>NOTE: if you change the interface, you must change the RPC version
|
||||
* number in HBaseRPCProtocolVersion
|
||||
*
|
||||
* Protocol that a client uses to communicate with the Master (for admin purposes).
|
||||
*/
|
||||
@KerberosInfo(
|
||||
serverPrincipal = "hbase.master.kerberos.principal")
|
||||
serverPrincipal = "hbase.master.kerberos.principal")
|
||||
@TokenInfo("HBASE_AUTH_TOKEN")
|
||||
@InterfaceAudience.Public
|
||||
@InterfaceAudience.Private
|
||||
@InterfaceStability.Evolving
|
||||
public interface HMasterInterface extends VersionedProtocol {
|
||||
/**
|
||||
* This Interfaces' version. Version changes when the Interface changes.
|
||||
*/
|
||||
// All HBase Interfaces used derive from HBaseRPCProtocolVersion. It
|
||||
// maintained a single global version number on all HBase Interfaces. This
|
||||
// meant all HBase RPC was broke though only one of the three RPC Interfaces
|
||||
// had changed. This has since been undone.
|
||||
// 29: 4/3/2010 - changed ClusterStatus serialization
|
||||
// 30: 3/20/2012 - HBASE-5589: Added offline method
|
||||
// 31: 5/8/2012 - HBASE-5445: Converted to PB-based calls
|
||||
public static final long VERSION = 31L;
|
||||
public interface MasterAdminProtocol extends
|
||||
MasterAdminService.BlockingInterface, MasterProtocol {
|
||||
public static final long VERSION = 1L;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
// Admin tools would use these cmds
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public DeleteTableResponse deleteTable(RpcController controller, DeleteTableRequest req)
|
||||
throws ServiceException;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public GetSchemaAlterStatusResponse getSchemaAlterStatus(
|
||||
RpcController controller, GetSchemaAlterStatusRequest req) throws ServiceException;
|
||||
/* Column-level */
|
||||
|
||||
/**
|
||||
* Adds a column to the specified table
|
||||
|
@ -160,9 +84,22 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||
* - 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).
|
||||
|
@ -171,136 +108,31 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||
* - descriptor: new column descriptor
|
||||
* @throws IOException e
|
||||
*/
|
||||
@Override
|
||||
public ModifyColumnResponse modifyColumn(RpcController controller, ModifyColumnRequest req)
|
||||
throws ServiceException;
|
||||
|
||||
/* Region-level */
|
||||
|
||||
/**
|
||||
* Deletes a column from the specified table. Table must be disabled.
|
||||
* Move a region to a specified destination server.
|
||||
* @param controller Unused (set to null).
|
||||
* @param req DeleteColumnRequest that contains:<br>
|
||||
* - tableName: table to alter<br>
|
||||
* - columnName: column family to remove
|
||||
* @throws ServiceException
|
||||
* @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>
|
||||
*/
|
||||
public DeleteColumnResponse deleteColumn(RpcController controller, DeleteColumnRequest req)
|
||||
@Override
|
||||
public MoveRegionResponse moveRegion(RpcController controller, MoveRegionRequest 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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public ModifyTableResponse modifyTable(RpcController controller, ModifyTableRequest req)
|
||||
throws ServiceException;
|
||||
|
||||
/**
|
||||
* Shutdown an HBase cluster.
|
||||
* @param controller Unused (set to null).
|
||||
* @param request ShutdownRequest
|
||||
* @return ShutdownResponse
|
||||
* @throws ServiceException
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public StopMasterResponse stopMaster(RpcController controller, StopMasterRequest request)
|
||||
throws ServiceException;
|
||||
|
||||
/**
|
||||
* Return cluster status.
|
||||
* @param controller Unused (set to null).
|
||||
* @param req GetClusterStatusRequest
|
||||
* @return status object
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public GetClusterStatusResponse getClusterStatus(RpcController controller, GetClusterStatusRequest 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
|
||||
*/
|
||||
public OfflineRegionResponse offlineRegion(RpcController controller, OfflineRegionRequest 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.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public SetBalancerRunningResponse setBalancerRunning(
|
||||
RpcController controller, SetBalancerRunningRequest 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
|
||||
*/
|
||||
public GetTableDescriptorsResponse getTableDescriptors(
|
||||
RpcController controller, GetTableDescriptorsRequest req) throws ServiceException;
|
||||
|
||||
/**
|
||||
* Assign a region to a server chosen at random.
|
||||
* @param controller Unused (set to null).
|
||||
|
@ -308,6 +140,7 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||
* found.
|
||||
* @throws ServiceException
|
||||
*/
|
||||
@Override
|
||||
public AssignRegionResponse assignRegion(RpcController controller, AssignRegionRequest req)
|
||||
throws ServiceException;
|
||||
|
||||
|
@ -325,24 +158,149 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||
* radical!.If results in double assignment use hbck -fix to resolve.
|
||||
* @throws ServiceException
|
||||
*/
|
||||
@Override
|
||||
public UnassignRegionResponse unassignRegion(RpcController controller, UnassignRegionRequest req)
|
||||
throws ServiceException;
|
||||
|
||||
/**
|
||||
* Move a region to a specified destination server.
|
||||
* 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 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>
|
||||
* @param request OfflineRegionRequest that contains:<br>
|
||||
* - region: Region to offline. Will clear any existing RegionPlan
|
||||
* if one found.
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public MoveRegionResponse moveRegion(RpcController controller, MoveRegionRequest req)
|
||||
@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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -58,7 +58,6 @@ import org.apache.hadoop.hbase.client.AdminProtocol;
|
|||
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.generated.AdminProtos.StopServerRequest;
|
|||
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 Abortable, Closeable {
|
|||
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 Abortable, Closeable {
|
|||
}
|
||||
}
|
||||
|
||||
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 Abortable, Closeable {
|
|||
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 Abortable, Closeable {
|
|||
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 Abortable, Closeable {
|
|||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
*/
|
||||
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 Abortable, Closeable {
|
|||
* @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 Abortable, Closeable {
|
|||
* @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 Abortable, Closeable {
|
|||
* @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 Abortable, Closeable {
|
|||
}
|
||||
|
||||
// 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 Abortable, Closeable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see {@link #execute}
|
||||
* @see {@link #execute(MasterAdminCallable<V>)}
|
||||
*/
|
||||
private abstract static class MasterCallable<V> implements Callable<V>{
|
||||
protected MasterKeepAliveConnection master;
|
||||
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 MasterCallable} to use it.
|
||||
* Create a {@link MasterAdminCallable} to use it.
|
||||
*/
|
||||
private <V> V execute(MasterCallable<V> function) throws IOException {
|
||||
function.master = connection.getKeepAliveMaster();
|
||||
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 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 executeCallable(Callable<V> function) throws IOException {
|
||||
try {
|
||||
return function.call();
|
||||
} catch (RemoteException re) {
|
||||
|
@ -1990,8 +2007,6 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||
} catch (Exception e) {
|
||||
// This should not happen...
|
||||
throw new IOException("Unexpected exception when calling master", e);
|
||||
} finally {
|
||||
function.master.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.apache.hadoop.hbase.client.AdminProtocol;
|
|||
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 Abortable, Closeable {
|
|||
@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;
|
||||
|
|
|
@ -65,13 +65,17 @@ import org.apache.hadoop.hbase.client.coprocessor.Batch;
|
|||
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);
|
||||
if (!isKeepAliveMasterConnectedAndRunning(protocolState)) {
|
||||
if (protocolState.protocol != null) {
|
||||
HBaseRPC.stopProxy(protocolState.protocol);
|
||||
}
|
||||
keepAliveMaster = null;
|
||||
keepAliveMaster = createMasterWithRetries();
|
||||
protocolState.protocol = null;
|
||||
protocolState.protocol = createMasterWithRetries(protocolState);
|
||||
}
|
||||
keepAliveMasterUserCount++;
|
||||
keepMasterAliveUntil = Long.MAX_VALUE;
|
||||
protocolState.userCount++;
|
||||
protocolState.keepAliveUntil = Long.MAX_VALUE;
|
||||
|
||||
return (MasterKeepAliveConnection) Proxy.newProxyInstance(
|
||||
MasterKeepAliveConnection.class.getClassLoader(),
|
||||
new Class[]{MasterKeepAliveConnection.class},
|
||||
new MasterHandler(this, keepAliveMaster)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright 2012 The Apache Software Foundation
|
||||
* Copyright The Apache Software Foundation
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
|
@ -21,7 +21,7 @@
|
|||
package org.apache.hadoop.hbase.client;
|
||||
|
||||
|
||||
import org.apache.hadoop.hbase.ipc.HMasterInterface;
|
||||
import org.apache.hadoop.hbase.MasterAdminProtocol;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
|
@ -32,10 +32,11 @@ import java.io.Closeable;
|
|||
* 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; but not by
|
||||
* final user code. Hence it's package protected.
|
||||
* 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 MasterKeepAliveConnection extends HMasterInterface, Closeable {
|
||||
interface MasterAdminKeepAliveConnection extends MasterAdminProtocol, Closeable {
|
||||
|
||||
@Override
|
||||
public void close();
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ public class HbaseObjectWritable implements Writable, WritableWithSize, Configur
|
|||
|
||||
// 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 =
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.apache.commons.logging.LogFactory;
|
|||
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 Updater {
|
|||
|
||||
context.registerUpdater(this);
|
||||
|
||||
initMethods(HMasterInterface.class);
|
||||
initMethods(MasterMonitorProtocol.class);
|
||||
initMethods(MasterAdminProtocol.class);
|
||||
initMethods(RegionServerStatusProtocol.class);
|
||||
initMethods(ClientProtocol.class);
|
||||
initMethods(AdminProtocol.class);
|
||||
|
|
|
@ -34,6 +34,8 @@ import org.apache.hadoop.conf.Configurable;
|
|||
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 VersionedWritable implements Configurable {
|
|||
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 VersionedWritable implements Configurable {
|
|||
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;
|
||||
|
|
|
@ -76,7 +76,8 @@ import org.apache.hadoop.hbase.executor.ExecutorService;
|
|||
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.generated.HBaseProtos.RegionSpecifier.Re
|
|||
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.ServiceException;
|
|||
*
|
||||
* <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;
|
||||
}
|
||||
|
|
|
@ -106,8 +106,8 @@ import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
|
|||
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;
|
||||
|
|
|
@ -80,24 +80,24 @@ import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
|
|||
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;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -20,7 +20,8 @@ package org.apache.hadoop.hbase.security;
|
|||
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.ipc.HMasterInterface;
|
||||
import org.apache.hadoop.hbase.MasterMonitorProtocol;
|
||||
import org.apache.hadoop.hbase.MasterAdminProtocol;
|
||||
import org.apache.hadoop.hbase.RegionServerStatusProtocol;
|
||||
import org.apache.hadoop.security.authorize.PolicyProvider;
|
||||
import org.apache.hadoop.security.authorize.Service;
|
||||
|
@ -34,7 +35,8 @@ public class HBasePolicyProvider extends PolicyProvider {
|
|||
protected static Service[] services = {
|
||||
new Service("security.client.protocol.acl", ClientProtocol.class),
|
||||
new Service("security.client.protocol.acl", AdminProtocol.class),
|
||||
new Service("security.admin.protocol.acl", HMasterInterface.class),
|
||||
new Service("security.admin.protocol.acl", MasterMonitorProtocol.class),
|
||||
new Service("security.admin.protocol.acl", MasterAdminProtocol.class),
|
||||
new Service("security.masterregion.protocol.acl", RegionServerStatusProtocol.class)
|
||||
};
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// This file contains protocol buffers that are used for MasterProtocol.
|
||||
// This file contains protocol buffers that are used for protocols implemented by the master.
|
||||
|
||||
option java_package = "org.apache.hadoop.hbase.protobuf.generated";
|
||||
option java_outer_classname = "MasterProtos";
|
||||
|
@ -24,108 +24,6 @@ option java_generic_services = true;
|
|||
option java_generate_equals_and_hash = true;
|
||||
option optimize_for = SPEED;
|
||||
|
||||
import "hbase.proto";
|
||||
import "ClusterStatus.proto";
|
||||
|
||||
/* Column-level protobufs */
|
||||
|
||||
message AddColumnRequest {
|
||||
required bytes tableName = 1;
|
||||
required ColumnFamilySchema columnFamilies = 2;
|
||||
}
|
||||
|
||||
message AddColumnResponse {
|
||||
}
|
||||
|
||||
message DeleteColumnRequest {
|
||||
required bytes tableName = 1;
|
||||
required bytes columnName = 2;
|
||||
}
|
||||
|
||||
message DeleteColumnResponse {
|
||||
}
|
||||
|
||||
message ModifyColumnRequest {
|
||||
required bytes tableName = 1;
|
||||
required ColumnFamilySchema columnFamilies = 2;
|
||||
}
|
||||
|
||||
message ModifyColumnResponse {
|
||||
}
|
||||
|
||||
/* Region-level Protos */
|
||||
|
||||
message MoveRegionRequest {
|
||||
required RegionSpecifier region = 1;
|
||||
optional ServerName destServerName = 2;
|
||||
}
|
||||
|
||||
message MoveRegionResponse {
|
||||
}
|
||||
|
||||
message AssignRegionRequest {
|
||||
required RegionSpecifier region = 1;
|
||||
}
|
||||
|
||||
message AssignRegionResponse {
|
||||
}
|
||||
|
||||
message UnassignRegionRequest {
|
||||
required RegionSpecifier region = 1;
|
||||
optional bool force = 2 [default = false];
|
||||
}
|
||||
|
||||
message UnassignRegionResponse {
|
||||
}
|
||||
|
||||
message OfflineRegionRequest {
|
||||
required RegionSpecifier region = 1;
|
||||
}
|
||||
|
||||
message OfflineRegionResponse {
|
||||
}
|
||||
|
||||
/* Table-level protobufs */
|
||||
|
||||
message CreateTableRequest {
|
||||
required TableSchema tableSchema = 1;
|
||||
repeated bytes splitKeys = 2;
|
||||
}
|
||||
|
||||
message CreateTableResponse {
|
||||
}
|
||||
|
||||
message DeleteTableRequest {
|
||||
required bytes tableName = 1;
|
||||
}
|
||||
|
||||
message DeleteTableResponse {
|
||||
}
|
||||
|
||||
message EnableTableRequest {
|
||||
required bytes tableName = 1;
|
||||
}
|
||||
|
||||
message EnableTableResponse {
|
||||
}
|
||||
|
||||
message DisableTableRequest {
|
||||
required bytes tableName = 1;
|
||||
}
|
||||
|
||||
message DisableTableResponse {
|
||||
}
|
||||
|
||||
message ModifyTableRequest {
|
||||
required bytes tableName = 1;
|
||||
required TableSchema tableSchema = 2;
|
||||
}
|
||||
|
||||
message ModifyTableResponse {
|
||||
}
|
||||
|
||||
/* Cluster-level protobufs */
|
||||
|
||||
message IsMasterRunningRequest {
|
||||
}
|
||||
|
||||
|
@ -133,153 +31,8 @@ message IsMasterRunningResponse {
|
|||
required bool isMasterRunning = 1;
|
||||
}
|
||||
|
||||
message ShutdownRequest {
|
||||
}
|
||||
|
||||
message ShutdownResponse {
|
||||
}
|
||||
|
||||
message StopMasterRequest {
|
||||
}
|
||||
|
||||
message StopMasterResponse {
|
||||
}
|
||||
|
||||
message BalanceRequest {
|
||||
}
|
||||
|
||||
message BalanceResponse {
|
||||
required bool balancerRan = 1;
|
||||
}
|
||||
|
||||
message SetBalancerRunningRequest {
|
||||
required bool on = 1;
|
||||
optional bool synchronous = 2;
|
||||
}
|
||||
|
||||
message SetBalancerRunningResponse {
|
||||
optional bool prevBalanceValue = 1;
|
||||
}
|
||||
|
||||
message GetSchemaAlterStatusRequest {
|
||||
required bytes tableName = 1;
|
||||
}
|
||||
|
||||
message GetSchemaAlterStatusResponse {
|
||||
optional uint32 yetToUpdateRegions = 1;
|
||||
optional uint32 totalRegions = 2;
|
||||
}
|
||||
|
||||
message GetTableDescriptorsRequest {
|
||||
repeated string tableNames = 1;
|
||||
}
|
||||
|
||||
message GetTableDescriptorsResponse {
|
||||
repeated TableSchema tableSchema = 1;
|
||||
}
|
||||
|
||||
message GetClusterStatusRequest {
|
||||
}
|
||||
|
||||
message GetClusterStatusResponse {
|
||||
required ClusterStatus clusterStatus = 1;
|
||||
}
|
||||
|
||||
service MasterService {
|
||||
/** Adds a column to the specified table. */
|
||||
rpc addColumn(AddColumnRequest)
|
||||
returns(AddColumnResponse);
|
||||
|
||||
/** Deletes a column from the specified table. Table must be disabled. */
|
||||
rpc deleteColumn(DeleteColumnRequest)
|
||||
returns(DeleteColumnResponse);
|
||||
|
||||
/** Modifies an existing column on the specified table. */
|
||||
rpc modifyColumn(ModifyColumnRequest)
|
||||
returns(ModifyColumnResponse);
|
||||
|
||||
/** Move the region region to the destination server. */
|
||||
rpc moveRegion(MoveRegionRequest)
|
||||
returns(MoveRegionResponse);
|
||||
|
||||
/** Assign a region to a server chosen at random. */
|
||||
rpc assignRegion(AssignRegionRequest)
|
||||
returns(AssignRegionResponse);
|
||||
|
||||
/**
|
||||
* 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 moveRegion if you want
|
||||
* to control the region movement.
|
||||
*/
|
||||
rpc unassignRegion(UnassignRegionRequest)
|
||||
returns(UnassignRegionResponse);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
rpc offlineRegion(OfflineRegionRequest)
|
||||
returns(OfflineRegionResponse);
|
||||
|
||||
/** Deletes a table */
|
||||
rpc deleteTable(DeleteTableRequest)
|
||||
returns(DeleteTableResponse);
|
||||
|
||||
/** Puts the table on-line (only needed if table has been previously taken offline) */
|
||||
rpc enableTable(EnableTableRequest)
|
||||
returns(EnableTableResponse);
|
||||
|
||||
/** Take table offline */
|
||||
rpc disableTable(DisableTableRequest)
|
||||
returns(DisableTableResponse);
|
||||
|
||||
/** Modify a table's metadata */
|
||||
rpc modifyTable(ModifyTableRequest)
|
||||
returns(ModifyTableResponse);
|
||||
|
||||
/** Creates a new table asynchronously */
|
||||
rpc createTable(CreateTableRequest)
|
||||
returns(CreateTableResponse);
|
||||
|
||||
/** return true if master is available */
|
||||
rpc isMasterRunning(IsMasterRunningRequest)
|
||||
returns(IsMasterRunningResponse);
|
||||
|
||||
/** Shutdown an HBase cluster. */
|
||||
rpc shutdown(ShutdownRequest)
|
||||
returns(ShutdownResponse);
|
||||
|
||||
/** Stop HBase Master only. Does not shutdown the cluster. */
|
||||
rpc stopMaster(StopMasterRequest)
|
||||
returns(StopMasterResponse);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
rpc balance(BalanceRequest)
|
||||
returns(BalanceResponse);
|
||||
|
||||
/**
|
||||
* Turn the load balancer on or off.
|
||||
* If synchronous is true, it waits until current balance() call, if outstanding, to return.
|
||||
*/
|
||||
rpc setBalancerRunning(SetBalancerRunningRequest)
|
||||
returns(SetBalancerRunningResponse);
|
||||
|
||||
/** Used by the client to get the number of regions that have received the updated schema */
|
||||
rpc getSchemaAlterStatus(GetSchemaAlterStatusRequest)
|
||||
returns(GetSchemaAlterStatusResponse);
|
||||
|
||||
/** Get list of TableDescriptors for requested tables. */
|
||||
rpc getTableDescriptors(GetTableDescriptorsRequest)
|
||||
returns(GetTableDescriptorsResponse);
|
||||
|
||||
/** Return cluster status. */
|
||||
rpc getClusterStatus(GetClusterStatusRequest)
|
||||
returns(GetClusterStatusResponse);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,239 @@
|
|||
/**
|
||||
* 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 MasterAdminProtocol.
|
||||
|
||||
option java_package = "org.apache.hadoop.hbase.protobuf.generated";
|
||||
option java_outer_classname = "MasterAdminProtos";
|
||||
option java_generic_services = true;
|
||||
option java_generate_equals_and_hash = true;
|
||||
option optimize_for = SPEED;
|
||||
|
||||
import "hbase.proto";
|
||||
|
||||
/* Column-level protobufs */
|
||||
|
||||
message AddColumnRequest {
|
||||
required bytes tableName = 1;
|
||||
required ColumnFamilySchema columnFamilies = 2;
|
||||
}
|
||||
|
||||
message AddColumnResponse {
|
||||
}
|
||||
|
||||
message DeleteColumnRequest {
|
||||
required bytes tableName = 1;
|
||||
required bytes columnName = 2;
|
||||
}
|
||||
|
||||
message DeleteColumnResponse {
|
||||
}
|
||||
|
||||
message ModifyColumnRequest {
|
||||
required bytes tableName = 1;
|
||||
required ColumnFamilySchema columnFamilies = 2;
|
||||
}
|
||||
|
||||
message ModifyColumnResponse {
|
||||
}
|
||||
|
||||
/* Region-level Protos */
|
||||
|
||||
message MoveRegionRequest {
|
||||
required RegionSpecifier region = 1;
|
||||
optional ServerName destServerName = 2;
|
||||
}
|
||||
|
||||
message MoveRegionResponse {
|
||||
}
|
||||
|
||||
message AssignRegionRequest {
|
||||
required RegionSpecifier region = 1;
|
||||
}
|
||||
|
||||
message AssignRegionResponse {
|
||||
}
|
||||
|
||||
message UnassignRegionRequest {
|
||||
required RegionSpecifier region = 1;
|
||||
optional bool force = 2 [default = false];
|
||||
}
|
||||
|
||||
message UnassignRegionResponse {
|
||||
}
|
||||
|
||||
message OfflineRegionRequest {
|
||||
required RegionSpecifier region = 1;
|
||||
}
|
||||
|
||||
message OfflineRegionResponse {
|
||||
}
|
||||
|
||||
/* Table-level protobufs */
|
||||
|
||||
message CreateTableRequest {
|
||||
required TableSchema tableSchema = 1;
|
||||
repeated bytes splitKeys = 2;
|
||||
}
|
||||
|
||||
message CreateTableResponse {
|
||||
}
|
||||
|
||||
message DeleteTableRequest {
|
||||
required bytes tableName = 1;
|
||||
}
|
||||
|
||||
message DeleteTableResponse {
|
||||
}
|
||||
|
||||
message EnableTableRequest {
|
||||
required bytes tableName = 1;
|
||||
}
|
||||
|
||||
message EnableTableResponse {
|
||||
}
|
||||
|
||||
message DisableTableRequest {
|
||||
required bytes tableName = 1;
|
||||
}
|
||||
|
||||
message DisableTableResponse {
|
||||
}
|
||||
|
||||
message ModifyTableRequest {
|
||||
required bytes tableName = 1;
|
||||
required TableSchema tableSchema = 2;
|
||||
}
|
||||
|
||||
message ModifyTableResponse {
|
||||
}
|
||||
|
||||
/* Cluster-level protobufs */
|
||||
|
||||
|
||||
message ShutdownRequest {
|
||||
}
|
||||
|
||||
message ShutdownResponse {
|
||||
}
|
||||
|
||||
message StopMasterRequest {
|
||||
}
|
||||
|
||||
message StopMasterResponse {
|
||||
}
|
||||
|
||||
message BalanceRequest {
|
||||
}
|
||||
|
||||
message BalanceResponse {
|
||||
required bool balancerRan = 1;
|
||||
}
|
||||
|
||||
message SetBalancerRunningRequest {
|
||||
required bool on = 1;
|
||||
optional bool synchronous = 2;
|
||||
}
|
||||
|
||||
message SetBalancerRunningResponse {
|
||||
optional bool prevBalanceValue = 1;
|
||||
}
|
||||
|
||||
service MasterAdminService {
|
||||
/** Adds a column to the specified table. */
|
||||
rpc addColumn(AddColumnRequest)
|
||||
returns(AddColumnResponse);
|
||||
|
||||
/** Deletes a column from the specified table. Table must be disabled. */
|
||||
rpc deleteColumn(DeleteColumnRequest)
|
||||
returns(DeleteColumnResponse);
|
||||
|
||||
/** Modifies an existing column on the specified table. */
|
||||
rpc modifyColumn(ModifyColumnRequest)
|
||||
returns(ModifyColumnResponse);
|
||||
|
||||
/** Move the region region to the destination server. */
|
||||
rpc moveRegion(MoveRegionRequest)
|
||||
returns(MoveRegionResponse);
|
||||
|
||||
/** Assign a region to a server chosen at random. */
|
||||
rpc assignRegion(AssignRegionRequest)
|
||||
returns(AssignRegionResponse);
|
||||
|
||||
/**
|
||||
* 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 moveRegion if you want
|
||||
* to control the region movement.
|
||||
*/
|
||||
rpc unassignRegion(UnassignRegionRequest)
|
||||
returns(UnassignRegionResponse);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
rpc offlineRegion(OfflineRegionRequest)
|
||||
returns(OfflineRegionResponse);
|
||||
|
||||
/** Deletes a table */
|
||||
rpc deleteTable(DeleteTableRequest)
|
||||
returns(DeleteTableResponse);
|
||||
|
||||
/** Puts the table on-line (only needed if table has been previously taken offline) */
|
||||
rpc enableTable(EnableTableRequest)
|
||||
returns(EnableTableResponse);
|
||||
|
||||
/** Take table offline */
|
||||
rpc disableTable(DisableTableRequest)
|
||||
returns(DisableTableResponse);
|
||||
|
||||
/** Modify a table's metadata */
|
||||
rpc modifyTable(ModifyTableRequest)
|
||||
returns(ModifyTableResponse);
|
||||
|
||||
/** Creates a new table asynchronously */
|
||||
rpc createTable(CreateTableRequest)
|
||||
returns(CreateTableResponse);
|
||||
|
||||
/** Shutdown an HBase cluster. */
|
||||
rpc shutdown(ShutdownRequest)
|
||||
returns(ShutdownResponse);
|
||||
|
||||
/** Stop HBase Master only. Does not shutdown the cluster. */
|
||||
rpc stopMaster(StopMasterRequest)
|
||||
returns(StopMasterResponse);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
rpc balance(BalanceRequest)
|
||||
returns(BalanceResponse);
|
||||
|
||||
/**
|
||||
* Turn the load balancer on or off.
|
||||
* If synchronous is true, it waits until current balance() call, if outstanding, to return.
|
||||
*/
|
||||
rpc setBalancerRunning(SetBalancerRunningRequest)
|
||||
returns(SetBalancerRunningResponse);
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* 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 MasterMonitorProtocol.
|
||||
|
||||
option java_package = "org.apache.hadoop.hbase.protobuf.generated";
|
||||
option java_outer_classname = "MasterMonitorProtos";
|
||||
option java_generic_services = true;
|
||||
option java_generate_equals_and_hash = true;
|
||||
option optimize_for = SPEED;
|
||||
|
||||
import "hbase.proto";
|
||||
import "ClusterStatus.proto";
|
||||
|
||||
message GetSchemaAlterStatusRequest {
|
||||
required bytes tableName = 1;
|
||||
}
|
||||
|
||||
message GetSchemaAlterStatusResponse {
|
||||
optional uint32 yetToUpdateRegions = 1;
|
||||
optional uint32 totalRegions = 2;
|
||||
}
|
||||
|
||||
message GetTableDescriptorsRequest {
|
||||
repeated string tableNames = 1;
|
||||
}
|
||||
|
||||
message GetTableDescriptorsResponse {
|
||||
repeated TableSchema tableSchema = 1;
|
||||
}
|
||||
|
||||
message GetClusterStatusRequest {
|
||||
}
|
||||
|
||||
message GetClusterStatusResponse {
|
||||
required ClusterStatus clusterStatus = 1;
|
||||
}
|
||||
|
||||
service MasterMonitorService {
|
||||
/** Used by the client to get the number of regions that have received the updated schema */
|
||||
rpc getSchemaAlterStatus(GetSchemaAlterStatusRequest)
|
||||
returns(GetSchemaAlterStatusResponse);
|
||||
|
||||
/** Get list of TableDescriptors for requested tables. */
|
||||
rpc getTableDescriptors(GetTableDescriptorsRequest)
|
||||
returns(GetTableDescriptorsResponse);
|
||||
|
||||
/** Return cluster status. */
|
||||
rpc getClusterStatus(GetClusterStatusRequest)
|
||||
returns(GetClusterStatusResponse);
|
||||
}
|
|
@ -28,7 +28,7 @@ import java.net.InetSocketAddress;
|
|||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.*;
|
||||
import org.apache.hadoop.hbase.ipc.HBaseRPC;
|
||||
import org.apache.hadoop.hbase.ipc.HMasterInterface;
|
||||
import org.apache.hadoop.hbase.MasterMonitorProtocol;
|
||||
import org.apache.hadoop.hbase.protobuf.RequestConverter;
|
||||
import org.apache.hadoop.ipc.RemoteException;
|
||||
import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
|
||||
|
@ -50,8 +50,8 @@ public class TestHMasterRPCException {
|
|||
ServerName sm = hm.getServerName();
|
||||
InetSocketAddress isa = new InetSocketAddress(sm.getHostname(), sm.getPort());
|
||||
try {
|
||||
HMasterInterface inf = (HMasterInterface) HBaseRPC.getProxy(
|
||||
HMasterInterface.class, HMasterInterface.VERSION, isa, conf, 100);
|
||||
MasterMonitorProtocol inf = (MasterMonitorProtocol) HBaseRPC.getProxy(
|
||||
MasterMonitorProtocol.class, MasterMonitorProtocol.VERSION, isa, conf, 100);
|
||||
fail();
|
||||
} catch (ServerNotRunningYetException ex) {
|
||||
assertTrue(ex.getMessage().startsWith(
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.apache.hadoop.hbase.client.Row;
|
|||
import org.apache.hadoop.hbase.client.coprocessor.Batch;
|
||||
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.ProtocolSignature;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.JVMClusterUtil;
|
||||
|
|
Loading…
Reference in New Issue