Search in sources :

Example 1 with ProcedurePrepareLatch

use of org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch in project hbase by apache.

the class HMaster method modifyNamespace.

/**
 * Modify an existing Namespace.
 * @param nonceGroup Identifier for the source of the request, a client or process.
 * @param nonce A unique identifier for this operation from the client or process identified by
 * <code>nonceGroup</code> (the source must ensure each operation gets a unique id).
 * @return procedure id
 */
long modifyNamespace(final NamespaceDescriptor newNsDescriptor, final long nonceGroup, final long nonce) throws IOException {
    checkInitialized();
    TableName.isLegalNamespaceName(Bytes.toBytes(newNsDescriptor.getName()));
    return MasterProcedureUtil.submitProcedure(new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {

        @Override
        protected void run() throws IOException {
            NamespaceDescriptor oldNsDescriptor = getNamespace(newNsDescriptor.getName());
            getMaster().getMasterCoprocessorHost().preModifyNamespace(oldNsDescriptor, newNsDescriptor);
            // We need to wait for the procedure to potentially fail due to "prepare" sanity
            // checks. This will block only the beginning of the procedure. See HBASE-19953.
            ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch();
            LOG.info(getClientIdAuditPrefix() + " modify " + newNsDescriptor);
            // Execute the operation synchronously - wait for the operation to complete before
            // continuing.
            setProcId(getClusterSchema().modifyNamespace(newNsDescriptor, getNonceKey(), latch));
            latch.await();
            getMaster().getMasterCoprocessorHost().postModifyNamespace(oldNsDescriptor, newNsDescriptor);
        }

        @Override
        protected String getDescription() {
            return "ModifyNamespaceProcedure";
        }
    });
}
Also used : NamespaceDescriptor(org.apache.hadoop.hbase.NamespaceDescriptor) ProcedurePrepareLatch(org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) InterruptedIOException(java.io.InterruptedIOException) NonceProcedureRunnable(org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil.NonceProcedureRunnable) MasterProcedureUtil(org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil)

Example 2 with ProcedurePrepareLatch

use of org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch 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)

Example 3 with ProcedurePrepareLatch

use of org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch in project hbase by apache.

the class HMaster method createTable.

@Override
public long createTable(final TableDescriptor tableDescriptor, final byte[][] splitKeys, final long nonceGroup, final long nonce) throws IOException {
    checkInitialized();
    TableDescriptor desc = getMasterCoprocessorHost().preCreateTableRegionsInfos(tableDescriptor);
    if (desc == null) {
        throw new IOException("Creation for " + tableDescriptor + " is canceled by CP");
    }
    String namespace = desc.getTableName().getNamespaceAsString();
    this.clusterSchemaService.getNamespace(namespace);
    RegionInfo[] newRegions = ModifyRegionUtils.createRegionInfos(desc, splitKeys);
    TableDescriptorChecker.sanityCheck(conf, desc);
    return MasterProcedureUtil.submitProcedure(new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {

        @Override
        protected void run() throws IOException {
            getMaster().getMasterCoprocessorHost().preCreateTable(desc, newRegions);
            LOG.info(getClientIdAuditPrefix() + " create " + desc);
            // TODO: We can handle/merge duplicate requests, and differentiate the case of
            // TableExistsException by saying if the schema is the same or not.
            // 
            // We need to wait for the procedure to potentially fail due to "prepare" sanity
            // checks. This will block only the beginning of the procedure. See HBASE-19953.
            ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch();
            submitProcedure(new CreateTableProcedure(procedureExecutor.getEnvironment(), desc, newRegions, latch));
            latch.await();
            getMaster().getMasterCoprocessorHost().postCreateTable(desc, newRegions);
        }

        @Override
        protected String getDescription() {
            return "CreateTableProcedure";
        }
    });
}
Also used : ProcedurePrepareLatch(org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) InterruptedIOException(java.io.InterruptedIOException) NonceProcedureRunnable(org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil.NonceProcedureRunnable) MasterProcedureUtil(org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil) CreateTableProcedure(org.apache.hadoop.hbase.master.procedure.CreateTableProcedure) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Example 4 with ProcedurePrepareLatch

use of org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch in project hbase by apache.

the class HMaster method createNamespace.

/**
 * Create a new Namespace.
 * @param namespaceDescriptor descriptor for new Namespace
 * @param nonceGroup Identifier for the source of the request, a client or process.
 * @param nonce A unique identifier for this operation from the client or process identified by
 * <code>nonceGroup</code> (the source must ensure each operation gets a unique id).
 * @return procedure id
 */
long createNamespace(final NamespaceDescriptor namespaceDescriptor, final long nonceGroup, final long nonce) throws IOException {
    checkInitialized();
    TableName.isLegalNamespaceName(Bytes.toBytes(namespaceDescriptor.getName()));
    return MasterProcedureUtil.submitProcedure(new MasterProcedureUtil.NonceProcedureRunnable(this, nonceGroup, nonce) {

        @Override
        protected void run() throws IOException {
            getMaster().getMasterCoprocessorHost().preCreateNamespace(namespaceDescriptor);
            // We need to wait for the procedure to potentially fail due to "prepare" sanity
            // checks. This will block only the beginning of the procedure. See HBASE-19953.
            ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch();
            LOG.info(getClientIdAuditPrefix() + " creating " + namespaceDescriptor);
            // Execute the operation synchronously - wait for the operation to complete before
            // continuing.
            setProcId(getClusterSchema().createNamespace(namespaceDescriptor, getNonceKey(), latch));
            latch.await();
            getMaster().getMasterCoprocessorHost().postCreateNamespace(namespaceDescriptor);
        }

        @Override
        protected String getDescription() {
            return "CreateNamespaceProcedure";
        }
    });
}
Also used : ProcedurePrepareLatch(org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) InterruptedIOException(java.io.InterruptedIOException) NonceProcedureRunnable(org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil.NonceProcedureRunnable) MasterProcedureUtil(org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil)

Aggregations

ProcedurePrepareLatch (org.apache.hadoop.hbase.master.procedure.ProcedurePrepareLatch)4 IOException (java.io.IOException)3 InterruptedIOException (java.io.InterruptedIOException)3 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)3 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)3 MasterProcedureUtil (org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil)3 NonceProcedureRunnable (org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil.NonceProcedureRunnable)3 NamespaceDescriptor (org.apache.hadoop.hbase.NamespaceDescriptor)1 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)1 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)1 CreateTableProcedure (org.apache.hadoop.hbase.master.procedure.CreateTableProcedure)1 SwitchRpcThrottleProcedure (org.apache.hadoop.hbase.master.procedure.SwitchRpcThrottleProcedure)1 SwitchRpcThrottleResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.SwitchRpcThrottleResponse)1