Search in sources :

Example 1 with SwitchRpcThrottleResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SwitchRpcThrottleResponse in project hbase by apache.

the class MasterQuotaManager method switchRpcThrottle.

public SwitchRpcThrottleResponse switchRpcThrottle(SwitchRpcThrottleRequest request) throws IOException {
    boolean rpcThrottle = request.getRpcThrottleEnabled();
    if (initialized) {
        masterServices.getMasterCoprocessorHost().preSwitchRpcThrottle(rpcThrottle);
        boolean oldRpcThrottle = rpcThrottleStorage.isRpcThrottleEnabled();
        if (rpcThrottle != oldRpcThrottle) {
            LOG.info("{} switch rpc throttle from {} to {}", masterServices.getClientIdAuditPrefix(), oldRpcThrottle, rpcThrottle);
            ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch();
            SwitchRpcThrottleProcedure procedure = new SwitchRpcThrottleProcedure(rpcThrottleStorage, rpcThrottle, masterServices.getServerName(), latch);
            masterServices.getMasterProcedureExecutor().submitProcedure(procedure);
            latch.await();
        } else {
            LOG.warn("Skip switch rpc throttle to {} because it's the same with old value", rpcThrottle);
        }
        SwitchRpcThrottleResponse response = SwitchRpcThrottleResponse.newBuilder().setPreviousRpcThrottleEnabled(oldRpcThrottle).build();
        masterServices.getMasterCoprocessorHost().postSwitchRpcThrottle(oldRpcThrottle, rpcThrottle);
        return response;
    } else {
        LOG.warn("Skip switch rpc throttle to {} because rpc quota is disabled", rpcThrottle);
        return SwitchRpcThrottleResponse.newBuilder().setPreviousRpcThrottleEnabled(false).build();
    }
}
Also used : SwitchRpcThrottleProcedure(org.apache.hadoop.hbase.master.procedure.SwitchRpcThrottleProcedure) ProcedurePrepareLatch(org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch) SwitchRpcThrottleResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SwitchRpcThrottleResponse)

Aggregations

ProcedurePrepareLatch (org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch)1 SwitchRpcThrottleProcedure (org.apache.hadoop.hbase.master.procedure.SwitchRpcThrottleProcedure)1 SwitchRpcThrottleResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SwitchRpcThrottleResponse)1