本文整理了Java中org.apache.hadoop.hbase.client.Admin.listNamespaceDescriptors()
方法的一些代码示例,展示了Admin.listNamespaceDescriptors()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Admin.listNamespaceDescriptors()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Admin
类名称:Admin
方法名:listNamespaceDescriptors
[英]List available namespace descriptors
[中]列出可用的命名空间描述符
代码示例来源:origin: apache/hbase
/**
* Constructor
* @param admin the administrative API
* @throws IOException
*/
public NamespacesModel(Admin admin) throws IOException {
NamespaceDescriptor[] nds = admin.listNamespaceDescriptors();
namespaces = new ArrayList<>(nds.length);
for (NamespaceDescriptor nd : nds) {
namespaces.add(nd.getName());
}
}
代码示例来源:origin: apache/hbase
private boolean doesNamespaceExist(Admin admin, String namespaceName) throws IOException{
NamespaceDescriptor[] nd = admin.listNamespaceDescriptors();
for(int i = 0; i < nd.length; i++){
if(nd[i].getName().equals(namespaceName)){
return true;
}
}
return false;
}
代码示例来源:origin: apache/hbase
private NamespaceDescriptor findNamespace(Admin admin, String namespaceName) throws IOException{
NamespaceDescriptor[] nd = admin.listNamespaceDescriptors();
for(int i = 0; i < nd.length; i++){
if(nd[i].getName().equals(namespaceName)){
return nd[i];
}
}
return null;
}
代码示例来源:origin: apache/hbase
private boolean doesNamespaceExist(Admin admin, String namespaceName) throws IOException {
NamespaceDescriptor[] nd = admin.listNamespaceDescriptors();
for(int i = 0; i < nd.length; i++) {
if(nd[i].getName().equals(namespaceName)) {
return true;
}
}
return false;
}
代码示例来源:origin: apache/hbase
@Override
public List<TNamespaceDescriptor> listNamespaceDescriptors() throws TIOError, TException {
try {
NamespaceDescriptor[] descriptors = connectionCache.getAdmin().listNamespaceDescriptors();
return namespaceDescriptorsFromHBase(descriptors);
} catch (IOException e) {
throw getTIOError(e);
}
}
}
代码示例来源:origin: apache/hbase
public boolean namespaceExists(String ns) throws IOException {
NamespaceDescriptor[] descs = TEST_UTIL.getAdmin().listNamespaceDescriptors();
for (NamespaceDescriptor desc : descs) {
if (ns.equals(desc.getName())) {
return true;
}
}
return false;
}
代码示例来源:origin: apache/hbase
} else if (tableRegex.charAt(0) == '@') { // Namespaces
String namespaceRegex = tableRegex.substring(1);
for (NamespaceDescriptor nsds : admin.listNamespaceDescriptors()) { // Read out all
代码示例来源:origin: apache/hbase
private void verifyNamespaceExists(Admin admin) throws IOException {
String namespaceName = tableName.getNamespaceAsString();
NamespaceDescriptor ns = NamespaceDescriptor.create(namespaceName).build();
NamespaceDescriptor[] list = admin.listNamespaceDescriptors();
boolean exists = false;
for (NamespaceDescriptor nsd : list) {
if (nsd.getName().equals(ns.getName())) {
exists = true;
break;
}
}
if (!exists) {
admin.createNamespace(ns);
}
}
代码示例来源:origin: apache/hbase
public void deleteNamespaceIfNecessary() throws IOException {
for (NamespaceDescriptor desc : TEST_UTIL.getAdmin().listNamespaceDescriptors()) {
if(desc.getName().startsWith(tablePrefix)) {
admin.deleteNamespace(desc.getName());
}
}
}
代码示例来源:origin: apache/hbase
@Test(expected = QuotaExceededException.class)
public void testExceedTableQuotaInNamespace() throws Exception {
String nsp = prefix + "_testExceedTableQuotaInNamespace";
NamespaceDescriptor nspDesc =
NamespaceDescriptor.create(nsp).addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "1")
.build();
ADMIN.createNamespace(nspDesc);
assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
assertEquals(3, ADMIN.listNamespaceDescriptors().length);
HColumnDescriptor fam1 = new HColumnDescriptor("fam1");
HTableDescriptor tableDescOne =
new HTableDescriptor(TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1"));
tableDescOne.addFamily(fam1);
HTableDescriptor tableDescTwo =
new HTableDescriptor(TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table2"));
tableDescTwo.addFamily(fam1);
ADMIN.createTable(tableDescOne);
ADMIN.createTable(tableDescTwo, Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 4);
}
代码示例来源:origin: apache/hbase
@Override
public Object run() throws Exception {
Connection unmanagedConnection =
ConnectionFactory.createConnection(UTIL.getConfiguration());
Admin admin = unmanagedConnection.getAdmin();
try {
return Arrays.asList(admin.listNamespaceDescriptors());
} finally {
admin.close();
unmanagedConnection.close();
}
}
};
代码示例来源:origin: apache/hbase
@Test
public void createRemoveTest() throws Exception {
String nsName = prefix + "_" + name.getMethodName();
LOG.info(name.getMethodName());
//create namespace and verify
admin.createNamespace(NamespaceDescriptor.create(nsName).build());
assertEquals(3, admin.listNamespaceDescriptors().length);
//remove namespace and verify
admin.deleteNamespace(nsName);
assertEquals(2, admin.listNamespaceDescriptors().length);
}
代码示例来源:origin: apache/hbase
@Override
public void cleanUpCluster() throws Exception {
if (!keepObjectsAtTheEnd) {
Admin admin = util.getAdmin();
admin.disableTables("ittable-\\d+");
admin.deleteTables("ittable-\\d+");
NamespaceDescriptor [] nsds = admin.listNamespaceDescriptors();
for(NamespaceDescriptor nsd: nsds) {
if(nsd.getName().matches("itnamespace\\d+")) {
LOG.info("Removing namespace="+nsd.getName());
admin.deleteNamespace(nsd.getName());
}
}
}
enabledTables.clear();
disabledTables.clear();
deletedTables.clear();
namespaceMap.clear();
Connection connection = getConnection();
connection.close();
super.cleanUpCluster();
}
代码示例来源:origin: apache/hbase
@Before
public void beforeMethod() throws IOException {
for (HTableDescriptor desc : admin.listTables(prefix+".*")) {
admin.disableTable(desc.getTableName());
admin.deleteTable(desc.getTableName());
}
for (NamespaceDescriptor ns : admin.listNamespaceDescriptors()) {
if (ns.getName().startsWith(prefix)) {
admin.deleteNamespace(ns.getName());
}
}
}
代码示例来源:origin: apache/hbase
ADMIN.createNamespace(nspDesc);
assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
assertEquals(3, ADMIN.listNamespaceDescriptors().length);
HColumnDescriptor fam1 = new HColumnDescriptor("fam1");
代码示例来源:origin: apache/hbase
@After
public void cleanup() throws Exception, KeeperException {
for (HTableDescriptor table : ADMIN.listTables()) {
ADMIN.disableTable(table.getTableName());
deleteTable(table.getTableName());
}
for (NamespaceDescriptor ns : ADMIN.listNamespaceDescriptors()) {
if (ns.getName().startsWith(prefix)) {
ADMIN.deleteNamespace(ns.getName());
}
}
assertTrue("Quota manager not initialized", UTIL.getHBaseCluster().getMaster()
.getMasterQuotaManager().isQuotaInitialized());
}
代码示例来源:origin: apache/hbase
.addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "2").build();
admin.createNamespace(nspDesc);
assertEquals(3, admin.listNamespaceDescriptors().length);
ColumnFamilyDescriptor fam1 = ColumnFamilyDescriptorBuilder.of("fam1");
TableDescriptor tableDescOne = TableDescriptorBuilder
代码示例来源:origin: apache/hbase
assertEquals(ns.getName(), NamespaceDescriptor.SYSTEM_NAMESPACE.getName());
assertEquals(2, admin.listNamespaceDescriptors().length);
代码示例来源:origin: apache/hbase
UTIL.getMiniHBaseCluster().startMaster();
assertEquals(7, UTIL.getAdmin().listNamespaceDescriptors().length);
for (int i = 0; i < 5; i++) {
NamespaceDescriptor nd = UTIL.getAdmin().getNamespaceDescriptor("Test-NS-" + i);
assertEquals(7, UTIL.getAdmin().listNamespaceDescriptors().length);
代码示例来源:origin: apache/hbase
admin.createNamespace(namespaceDescriptor);
NamespaceDescriptor[] namespaceDescriptors = admin.listNamespaceDescriptors();
boolean found = false;
for (NamespaceDescriptor nd : namespaceDescriptors) {
namespaceDescriptors = admin.listNamespaceDescriptors();
内容来源于网络,如有侵权,请联系作者删除!