本文整理匯總了Java中org.apache.hadoop.hbase.client.HBaseAdmin.createNamespace方法的典型用法代碼示例。如果您正苦於以下問題:Java HBaseAdmin.createNamespace方法的具體用法?Java HBaseAdmin.createNamespace怎麽用?Java HBaseAdmin.createNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.HBaseAdmin
的用法示例。
在下文中一共展示了HBaseAdmin.createNamespace方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Override
public void createTable(HTableDescriptor tableDescriptor) {
Util.checkNull(tableDescriptor);
try {
HBaseAdmin hbaseAdmin = hbaseDataSource.getHBaseAdmin();
NamespaceDescriptor[] namespaceDescriptors = hbaseAdmin.listNamespaceDescriptors();
String namespace = tableDescriptor.getTableName().getNamespaceAsString();
boolean isExist = false;
for (NamespaceDescriptor nd : namespaceDescriptors) {
if (nd.getName().equals(namespace)) {
isExist = true;
break;
}
}
log.info("namespace " + namespace + " isExist " + isExist);
if (!isExist) {
hbaseAdmin.createNamespace(NamespaceDescriptor.create(namespace).build());
}
hbaseAdmin.createTable(tableDescriptor);
HTableDescriptor newTableDescriptor = hbaseAdmin.getTableDescriptor(tableDescriptor.getName());
log.info("create table " + newTableDescriptor);
} catch (Exception e) {
log.error(e);
throw new SimpleHBaseException(e);
}
}
示例2: setUp
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
testUtil.getConfiguration().setInt("hbase.regionserver.msginterval", 30000);
testUtil.getConfiguration().setBoolean(HConstants.DISTRIBUTED_LOG_REPLAY_KEY, false);
testUtil.startMiniCluster(2);
HBaseAdmin admin = testUtil.getHBaseAdmin();
admin.createNamespace(namespace);
admin.createTable(new HTableDescriptor(tableName).addFamily(new HColumnDescriptor(family)));
testUtil.waitTableAvailable(tableName);
}
示例3: createNamespace
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
protected static void createNamespace(HBaseAdmin admin, String namespaceName) throws IOException {
NamespaceDescriptor nd = NamespaceDescriptor.create(namespaceName).build();
try {
admin.createNamespace(nd);
testNamespaceCreated = true;
} catch (NamespaceExistException ignore) {
}
}
示例4: createTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Override
public void createTable(HTableDescriptor tableDescriptor) {
Util.checkNull(tableDescriptor);
try {
HBaseAdmin hbaseAdmin = hbaseDataSource.getHBaseAdmin();
NamespaceDescriptor[] namespaceDescriptors = hbaseAdmin
.listNamespaceDescriptors();
String namespace = tableDescriptor.getTableName()
.getNamespaceAsString();
boolean isExist = false;
for (NamespaceDescriptor nd : namespaceDescriptors) {
if (nd.getName().equals(namespace)) {
isExist = true;
break;
}
}
log.info("namespace " + namespace + " isExist " + isExist);
if (!isExist) {
hbaseAdmin.createNamespace(NamespaceDescriptor
.create(namespace).build());
}
hbaseAdmin.createTable(tableDescriptor);
HTableDescriptor newTableDescriptor = hbaseAdmin
.getTableDescriptor(tableDescriptor.getName());
log.info("create table " + newTableDescriptor);
} catch (Exception e) {
log.error(e);
throw new SimpleHBaseException(e);
}
}
示例5: testNamespaceOperations
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test
public void testNamespaceOperations() throws Exception {
MiniHBaseCluster cluster = UTIL.getHBaseCluster();
String testNamespace = "observed_ns";
HMaster master = cluster.getMaster();
MasterCoprocessorHost host = master.getCoprocessorHost();
CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
CPMasterObserver.class.getName());
cp.enableBypass(false);
cp.resetStates();
// create a table
HBaseAdmin admin = UTIL.getHBaseAdmin();
admin.createNamespace(NamespaceDescriptor.create(testNamespace).build());
assertTrue("Test namespace should be created", cp.wasCreateNamespaceCalled());
assertNotNull(admin.getNamespaceDescriptor(testNamespace));
// turn off bypass, run the tests again
cp.enableBypass(true);
cp.resetStates();
admin.modifyNamespace(NamespaceDescriptor.create(testNamespace).build());
assertTrue("Test namespace should not have been modified",
cp.preModifyNamespaceCalledOnly());
assertNotNull(admin.getNamespaceDescriptor(testNamespace));
admin.deleteNamespace(testNamespace);
assertTrue("Test namespace should not have been deleted", cp.preDeleteNamespaceCalledOnly());
assertNotNull(admin.getNamespaceDescriptor(testNamespace));
cp.enableBypass(false);
cp.resetStates();
// delete table
admin.modifyNamespace(NamespaceDescriptor.create(testNamespace).build());
assertTrue("Test namespace should have been modified", cp.wasModifyNamespaceCalled());
admin.deleteNamespace(testNamespace);
assertTrue("Test namespace should have been deleted", cp.wasDeleteNamespaceCalled());
cp.enableBypass(true);
cp.resetStates();
admin.createNamespace(NamespaceDescriptor.create(testNamespace).build());
assertTrue("Test namespace should not be created", cp.preCreateNamespaceCalledOnly());
}