org.apache.hadoop.hbase.client.Admin.createNamespace()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(228)

本文整理了Java中org.apache.hadoop.hbase.client.Admin.createNamespace()方法的一些代码示例,展示了Admin.createNamespace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Admin.createNamespace()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Admin
类名称:Admin
方法名:createNamespace

Admin.createNamespace介绍

[英]Create a new namespace
[中]创建一个新的命名空间

代码示例

代码示例来源:origin: apache/hbase

@Override
public void createNamespace(TNamespaceDescriptor namespaceDesc) throws TIOError, TException {
 try {
  NamespaceDescriptor descriptor = namespaceDescriptorFromThrift(namespaceDesc);
  connectionCache.getAdmin().createNamespace(descriptor);
 } catch (IOException e) {
  throw getTIOError(e);
 }
}

代码示例来源:origin: apache/hbase

public static void createNamespace(HBaseTestingUtility testUtil, NamespaceDescriptor nsDesc)
  throws Exception {
 testUtil.getAdmin().createNamespace(nsDesc);
}

代码示例来源: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

private void createNamespaceViaAdmin(Admin admin, String name) throws IOException {
 NamespaceDescriptor.Builder builder = NamespaceDescriptor.create(name);
 NamespaceDescriptor nsd = builder.build();
 admin.createNamespace(nsd);
}

代码示例来源:origin: apache/hbase

@Override
 public Void call() throws Exception {
  admin.createNamespace(NamespaceDescriptor.create(prefix + "ns1").build());
  return null;
 }
}, NamespaceExistException.class);

代码示例来源:origin: apache/hbase

NamespaceDescriptor createNamespace() throws Exception {
 NamespaceDescriptor nd = NamespaceDescriptor.create("ns" + counter.getAndIncrement()).build();
 testUtil.getAdmin().createNamespace(nd);
 return nd;
}

代码示例来源:origin: apache/hbase

protected static void setupNamespace() throws Exception {
 util.getAdmin().createNamespace(NamespaceDescriptor.create(NAMESPACE).build());
}

代码示例来源:origin: apache/hbase

@Test
 public void testCloneSnapshotCrossNamespace() throws IOException, InterruptedException {
  String nsName = getValidMethodName() + "_ns_" + System.currentTimeMillis();
  admin.createNamespace(NamespaceDescriptor.create(nsName).build());
  final TableName clonedTableName =
   TableName.valueOf(nsName, getValidMethodName() + "-" + System.currentTimeMillis());
  testCloneSnapshot(clonedTableName, snapshotName0, snapshot0Rows);
  testCloneSnapshot(clonedTableName, snapshotName1, snapshot1Rows);
  testCloneSnapshot(clonedTableName, emptySnapshot, 0);
 }
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setupCluster() throws Exception {
 setupConf(UTIL.getConfiguration());
 UTIL.startMiniCluster(1);
 masterServices = UTIL.getMiniHBaseCluster().getMaster();
 UTIL.getAdmin().createNamespace(NamespaceDescriptor.create(namespace).build());
 UTIL.createTable(tableName, new byte[][]{"fam".getBytes()}, new byte[][] {"1".getBytes()});
 List<HRegionInfo> regions = UTIL.getAdmin().getTableRegions(tableName);
 assert regions.size() > 0;
 tableRegions = new HRegionInfo[regions.size()];
 regions.toArray(tableRegions);
}

代码示例来源:origin: apache/hbase

@Test(expected = QuotaExceededException.class)
public void testCloneSnapshotQuotaExceed() throws Exception {
 String nsp = prefix + "_testTableQuotaExceedWithCloneSnapshot";
 NamespaceDescriptor nspDesc =
   NamespaceDescriptor.create(nsp).addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "1")
     .build();
 ADMIN.createNamespace(nspDesc);
 assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
 TableName tableName = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1");
 TableName cloneTableName = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table2");
 HColumnDescriptor fam1 = new HColumnDescriptor("fam1");
 HTableDescriptor tableDescOne = new HTableDescriptor(tableName);
 tableDescOne.addFamily(fam1);
 ADMIN.createTable(tableDescOne);
 String snapshot = "snapshot_testTableQuotaExceedWithCloneSnapshot";
 ADMIN.snapshot(snapshot, tableName);
 ADMIN.cloneSnapshot(snapshot, cloneTableName);
 ADMIN.deleteSnapshot(snapshot);
}

代码示例来源:origin: apache/hbase

@BeforeClass
public static void setupCluster() throws Exception {
 setupConf(UTIL.getConfiguration());
 UTIL.startMiniCluster(1);
 UTIL.getAdmin().createNamespace(NamespaceDescriptor.create(namespace).build());
 UTIL.createTable(tableName1,
   new byte[][]{ Bytes.toBytes("fam")}, new byte[][] {Bytes.toBytes("1")});
 UTIL.createTable(tableName2,
   new byte[][]{Bytes.toBytes("fam")}, new byte[][] {Bytes.toBytes("1")});
 masterRpcService = UTIL.getHBaseCluster().getMaster().getMasterRpcServices();
 procExec = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor();
 tableRegions1 = UTIL.getAdmin().getRegions(tableName1);
 tableRegions2 = UTIL.getAdmin().getRegions(tableName2);
 assert tableRegions1.size() > 0;
 assert tableRegions2.size() > 0;
}

代码示例来源:origin: apache/hbase

@Before
public void setUp() throws Exception {
 testUtil.getConfiguration().setInt("hbase.regionserver.msginterval", 30000);
 testUtil.startMiniCluster(2);
 Admin admin = testUtil.getAdmin();
 admin.createNamespace(namespace);
 admin.createTable(TableDescriptorBuilder.newBuilder(tableName)
   .setColumnFamily(ColumnFamilyDescriptorBuilder.of(family)).build());
 testUtil.waitTableAvailable(tableName);
}

代码示例来源:origin: apache/hbase

@Test
 public void testDeleteRow() throws IOException {
  Admin admin = TEST_UTIL.getAdmin();
  admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
  Table table
      = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);

  table.put(new Put(HelloHBase.MY_ROW_ID).
      addColumn(HelloHBase.MY_COLUMN_FAMILY_NAME,
          HelloHBase.MY_FIRST_COLUMN_QUALIFIER,
          Bytes.toBytes("xyz")));
  HelloHBase.deleteRow(table);
  Result row = table.get(new Get(HelloHBase.MY_ROW_ID));
  assertEquals("#deleteRow failed to delete row.", true, row.isEmpty());

  TEST_UTIL.deleteTable(HelloHBase.MY_TABLE_NAME);
  admin.deleteNamespace(HelloHBase.MY_NAMESPACE_NAME);
 }
}

代码示例来源:origin: apache/hbase

@Test
 public void testDeleteRow() throws IOException {
  Admin admin = TEST_UTIL.getAdmin();
  admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
  Table table
      = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);

  table.put(new Put(HelloHBase.MY_ROW_ID).
      addColumn(HelloHBase.MY_COLUMN_FAMILY_NAME,
          HelloHBase.MY_FIRST_COLUMN_QUALIFIER,
          Bytes.toBytes("xyz")));
  HelloHBase.deleteRow(table);
  Result row = table.get(new Get(HelloHBase.MY_ROW_ID));
  assertEquals("#deleteRow failed to delete row.", true, row.isEmpty());

  TEST_UTIL.deleteTable(HelloHBase.MY_TABLE_NAME);
  admin.deleteNamespace(HelloHBase.MY_NAMESPACE_NAME);
 }
}

代码示例来源: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

@Test
public void testPutRowToTable() throws IOException {
 Admin admin = TEST_UTIL.getAdmin();
 admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
 Table table
     = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
 HelloHBase.putRowToTable(table);
 Result row = table.get(new Get(HelloHBase.MY_ROW_ID));
 assertEquals("#putRowToTable failed to store row.", false, row.isEmpty());
 TEST_UTIL.deleteTable(HelloHBase.MY_TABLE_NAME);
 admin.deleteNamespace(HelloHBase.MY_NAMESPACE_NAME);
}

代码示例来源:origin: apache/hbase

@Test
public void testPutRowToTable() throws IOException {
 Admin admin = TEST_UTIL.getAdmin();
 admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
 Table table
     = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
 HelloHBase.putRowToTable(table);
 Result row = table.get(new Get(HelloHBase.MY_ROW_ID));
 assertEquals("#putRowToTable failed to store row.", false, row.isEmpty());
 TEST_UTIL.deleteTable(HelloHBase.MY_TABLE_NAME);
 admin.deleteNamespace(HelloHBase.MY_NAMESPACE_NAME);
}

代码示例来源:origin: apache/hbase

@Test
public void testNamespaceExists() throws Exception {
 final String NONEXISTENT_NAMESPACE = "xyzpdq_nonexistent";
 final String EXISTING_NAMESPACE = "pdqxyz_myExistingNamespace";
 boolean exists;
 Admin admin = TEST_UTIL.getAdmin();
 exists = HelloHBase.namespaceExists(admin, NONEXISTENT_NAMESPACE);
 assertEquals("#namespaceExists failed: found nonexistent namespace.",
     false, exists);
 admin.createNamespace(NamespaceDescriptor.create(EXISTING_NAMESPACE).build());
 exists = HelloHBase.namespaceExists(admin, EXISTING_NAMESPACE);
 assertEquals("#namespaceExists failed: did NOT find existing namespace.",
     true, exists);
 admin.deleteNamespace(EXISTING_NAMESPACE);
}

代码示例来源:origin: apache/hbase

@Test
public void testNamespaceExists() throws Exception {
 final String NONEXISTENT_NAMESPACE = "xyzpdq_nonexistent";
 final String EXISTING_NAMESPACE = "pdqxyz_myExistingNamespace";
 boolean exists;
 Admin admin = TEST_UTIL.getAdmin();
 exists = HelloHBase.namespaceExists(admin, NONEXISTENT_NAMESPACE);
 assertEquals("#namespaceExists failed: found nonexistent namespace.",
     false, exists);
 admin.createNamespace(NamespaceDescriptor.create(EXISTING_NAMESPACE).build());
 exists = HelloHBase.namespaceExists(admin, EXISTING_NAMESPACE);
 assertEquals("#namespaceExists failed: did NOT find existing namespace.",
     true, exists);
 admin.deleteNamespace(EXISTING_NAMESPACE);
}

代码示例来源:origin: apache/hbase

@Test
public void testNamespaceOperations() throws Exception {
 MiniHBaseCluster cluster = UTIL.getHBaseCluster();
 String testNamespace = "observed_ns";
 HMaster master = cluster.getMaster();
 MasterCoprocessorHost host = master.getMasterCoprocessorHost();
 CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class);
 // create a table
 Admin admin = UTIL.getAdmin();
 admin.createNamespace(NamespaceDescriptor.create(testNamespace).build());
 assertTrue("Test namespace should be created", cp.wasCreateNamespaceCalled());
 assertNotNull(admin.getNamespaceDescriptor(testNamespace));
 assertTrue("Test namespace descriptor should have been called",
   cp.wasGetNamespaceDescriptorCalled());
 // This test used to do a bunch w/ bypass but bypass of these table and namespace stuff has
 // been removed so the testing code was removed.
}

相关文章

Admin类方法