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";
}
});
}
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();
}
}
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";
}
});
}
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";
}
});
}
Aggregations