Search in sources :

Example 1 with MasterSwitchType

use of org.apache.hadoop.hbase.client.MasterSwitchType in project hbase by apache.

the class MasterRpcServices method setSplitOrMergeEnabled.

@Override
public SetSplitOrMergeEnabledResponse setSplitOrMergeEnabled(RpcController controller, SetSplitOrMergeEnabledRequest request) throws ServiceException {
    SetSplitOrMergeEnabledResponse.Builder response = SetSplitOrMergeEnabledResponse.newBuilder();
    try {
        server.checkInitialized();
        boolean newValue = request.getEnabled();
        for (MasterProtos.MasterSwitchType masterSwitchType : request.getSwitchTypesList()) {
            MasterSwitchType switchType = convert(masterSwitchType);
            boolean oldValue = server.isSplitOrMergeEnabled(switchType);
            response.addPrevValue(oldValue);
            if (server.cpHost != null) {
                server.cpHost.preSetSplitOrMergeEnabled(newValue, switchType);
            }
            server.getSplitOrMergeTracker().setSplitOrMergeEnabled(newValue, switchType);
            if (server.cpHost != null) {
                server.cpHost.postSetSplitOrMergeEnabled(newValue, switchType);
            }
        }
    } catch (IOException | KeeperException e) {
        throw new ServiceException(e);
    }
    return response.build();
}
Also used : MasterSwitchType(org.apache.hadoop.hbase.client.MasterSwitchType) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) SetSplitOrMergeEnabledResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSplitOrMergeEnabledResponse) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) KeeperException(org.apache.zookeeper.KeeperException) MasterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos)

Example 2 with MasterSwitchType

use of org.apache.hadoop.hbase.client.MasterSwitchType in project hbase by apache.

the class RequestConverter method buildSetSplitOrMergeEnabledRequest.

/**
 * Creates a protocol buffer SetSplitOrMergeEnabledRequest
 *
 * @param enabled switch is enabled or not
 * @param synchronous set switch sync?
 * @param switchTypes see {@link org.apache.hadoop.hbase.client.MasterSwitchType}, it is
 *                    a list.
 * @return a SetSplitOrMergeEnabledRequest
 */
public static SetSplitOrMergeEnabledRequest buildSetSplitOrMergeEnabledRequest(boolean enabled, boolean synchronous, MasterSwitchType... switchTypes) {
    SetSplitOrMergeEnabledRequest.Builder builder = SetSplitOrMergeEnabledRequest.newBuilder();
    builder.setEnabled(enabled);
    builder.setSynchronous(synchronous);
    for (MasterSwitchType switchType : switchTypes) {
        builder.addSwitchTypes(convert(switchType));
    }
    return builder.build();
}
Also used : MasterSwitchType(org.apache.hadoop.hbase.client.MasterSwitchType) SetSplitOrMergeEnabledRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSplitOrMergeEnabledRequest)

Aggregations

MasterSwitchType (org.apache.hadoop.hbase.client.MasterSwitchType)2 IOException (java.io.IOException)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 MasterProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos)1 SetSplitOrMergeEnabledRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSplitOrMergeEnabledRequest)1 SetSplitOrMergeEnabledResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SetSplitOrMergeEnabledResponse)1 ServiceException (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException)1 KeeperException (org.apache.zookeeper.KeeperException)1