Java Code Examples for org.apache.hadoop.hbase.TableName#isLegalNamespaceName()
The following examples show how to use
org.apache.hadoop.hbase.TableName#isLegalNamespaceName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HMaster.java From hbase with Apache License 2.0 | 5 votes |
/** * 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"; } }); }
Example 2
Source File: HMaster.java From hbase with Apache License 2.0 | 5 votes |
/** * 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"; } }); }