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

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

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

Admin.deleteColumnFamily介绍

[英]Delete a column family from a table. Synchronous operation. Use #deleteColumnFamily(TableName,byte[]) instead because it returns a Future from which you can learn whether success or failure.
[中]从表中删除列族。同步操作。改用#deleteColumnFamily(TableName,byte[]),因为它返回一个未来,您可以从中了解成功还是失败。

代码示例

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

@Override
public void deleteColumnFamily(TTableName tableName, ByteBuffer column)
  throws TIOError, TException {
 try {
  TableName table = tableNameFromThrift(tableName);
  connectionCache.getAdmin().deleteColumnFamily(table, column.array());
 } catch (IOException e) {
  throw getTIOError(e);
 }
}

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

@Test
public void testDeleteColumn() throws IOException {
 Admin admin = TEST_UTIL.getAdmin();
 // Create a table with two families
 HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
 baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
 baseHtd.addFamily(new HColumnDescriptor(FAMILY_1));
 admin.createTable(baseHtd);
 admin.disableTable(TABLE_NAME);
 try {
  // Verify the table descriptor
  verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1);
  // Modify the table removing one family and verify the descriptor
  admin.deleteColumnFamily(TABLE_NAME, FAMILY_1);
  verifyTableDescriptor(TABLE_NAME, FAMILY_0);
 } finally {
  admin.deleteTable(TABLE_NAME);
 }
}

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

@Test
public void testDeleteSameColumnFamilyTwice() throws IOException {
 Admin admin = TEST_UTIL.getAdmin();
 // Create a table with two families
 HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
 baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
 baseHtd.addFamily(new HColumnDescriptor(FAMILY_1));
 admin.createTable(baseHtd);
 admin.disableTable(TABLE_NAME);
 try {
  // Verify the table descriptor
  verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1);
  // Modify the table removing one family and verify the descriptor
  admin.deleteColumnFamily(TABLE_NAME, FAMILY_1);
  verifyTableDescriptor(TABLE_NAME, FAMILY_0);
  try {
   // Delete again - expect failure
   admin.deleteColumnFamily(TABLE_NAME, FAMILY_1);
   Assert.fail("Delete a non-exist column family should fail");
  } catch (Exception e) {
   // Expected.
  }
 } finally {
  admin.deleteTable(TABLE_NAME);
 }
}

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

@Test
public void testDeleteLastColumnFamily() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
 while (!this.admin.isTableEnabled(TableName.valueOf(name.getMethodName()))) {
  Thread.sleep(10);
 }
 // test for enabled table
 try {
  this.admin.deleteColumnFamily(tableName, HConstants.CATALOG_FAMILY);
  fail("Should have failed to delete the only column family of a table");
 } catch (InvalidFamilyOperationException ex) {
  // expected
 }
 // test for disabled table
 this.admin.disableTable(tableName);
 try {
  this.admin.deleteColumnFamily(tableName, HConstants.CATALOG_FAMILY);
  fail("Should have failed to delete the only column family of a table");
 } catch (InvalidFamilyOperationException ex) {
  // expected
 }
 this.admin.deleteTable(tableName);
}

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

admin.disableTable(TABLENAME);
admin.deleteColumnFamily(TABLENAME, Bytes.toBytes(cfToDelete));
 admin.deleteColumnFamily(TABLENAME, Bytes.toBytes(cfToDelete));
 Assert.fail("Delete a non-exist column family should fail");
} catch (InvalidFamilyOperationException e) {

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

@Test
public void testEnableDisableAddColumnDeleteColumn() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
 while (!this.admin.isTableEnabled(TableName.valueOf(name.getMethodName()))) {
  Thread.sleep(10);
 }
 this.admin.disableTable(tableName);
 try {
  TEST_UTIL.getConnection().getTable(tableName);
 } catch (org.apache.hadoop.hbase.DoNotRetryIOException e) {
  //expected
 }
 this.admin.addColumnFamily(tableName, new HColumnDescriptor("col2"));
 this.admin.enableTable(tableName);
 try {
  this.admin.deleteColumnFamily(tableName, Bytes.toBytes("col2"));
 } catch (TableNotDisabledException e) {
  LOG.info(e.toString(), e);
 }
 this.admin.disableTable(tableName);
 this.admin.deleteTable(tableName);
}

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

@Test
public void disableNotFullReplication() throws Exception {
 HTableDescriptor table = new HTableDescriptor(admin2.getTableDescriptor(tableName));
 HColumnDescriptor f = new HColumnDescriptor("notReplicatedFamily");
 table.addFamily(f);
 admin1.disableTable(tableName);
 admin1.modifyTable(tableName, table);
 admin1.enableTable(tableName);
 admin1.disableTableReplication(tableName);
 table = admin1.getTableDescriptor(tableName);
 for (HColumnDescriptor fam : table.getColumnFamilies()) {
  assertEquals(HConstants.REPLICATION_SCOPE_LOCAL, fam.getScope());
 }
 admin1.deleteColumnFamily(table.getTableName(), f.getName());
}

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

admin.deleteColumnFamily(TABLENAME, Bytes.toBytes("cf2"));

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

admin.deleteColumnFamily(tableName, cfd.getName());

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

admin.deleteColumnFamily(LABELS_TABLE_NAME, VisibilityConstants.LABELS_TABLE_FAMILY);
 fail("Lables table should not get altered by user.");
} catch (Exception e) {

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

@Test
public void testEnableReplicationWhenTableDescriptorIsNotSameInClusters() throws Exception {
 HTableDescriptor table = new HTableDescriptor(admin2.getTableDescriptor(tableName));
 HColumnDescriptor f = new HColumnDescriptor("newFamily");
 table.addFamily(f);
 admin2.disableTable(tableName);
 admin2.modifyTable(tableName, table);
 admin2.enableTable(tableName);
 try {
  admin1.enableTableReplication(tableName);
  fail("Exception should be thrown if table descriptors in the clusters are not same.");
 } catch (RuntimeException ignored) {
 }
 admin1.disableTable(tableName);
 admin1.modifyTable(tableName, table);
 admin1.enableTable(tableName);
 admin1.enableTableReplication(tableName);
 table = admin1.getTableDescriptor(tableName);
 for (HColumnDescriptor fam : table.getColumnFamilies()) {
  assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope());
 }
 admin1.deleteColumnFamily(tableName, f.getName());
 admin2.deleteColumnFamily(tableName, f.getName());
}

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

this.admin.deleteColumnFamily(nonexistentTable, nonexistentColumn);
} catch (IOException e) {
 exception = e;
 exception = null;
 try {
  this.admin.deleteColumnFamily(htd.getTableName(), nonexistentHcd.getName());
 } catch (IOException e) {
  exception = e;

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

UTIL.getAdmin().deleteColumnFamily(tableName, TEST_FAM);

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

admin.addColumnFamily(snapshotTableName, columnFamilyDescriptor3);
admin.addColumnFamily(snapshotTableName, columnFamilyDescriptor4);
admin.deleteColumnFamily(snapshotTableName, CF2);

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

@Test
public void testMobFamilyDelete() throws Exception {
 final TableName tableName = TableName.valueOf(name.getMethodName());
 HTableDescriptor htd = createTableDescriptor(tableName, true);
 HColumnDescriptor hcd = htd.getFamily(FAMILY);
 htd.addFamily(new HColumnDescriptor(Bytes.toBytes("family2")));
 Table table = createTableWithOneFile(htd);
 try {
  // the mob file exists
  Assert.assertEquals(1, countMobFiles(tableName, hcd.getNameAsString()));
  Assert.assertEquals(0, countArchiveMobFiles(tableName, hcd.getNameAsString()));
  String fileName = assertHasOneMobRow(table, tableName, hcd.getNameAsString());
  Assert.assertFalse(mobArchiveExist(tableName, hcd.getNameAsString(), fileName));
  Assert.assertTrue(mobTableDirExist(tableName));
  TEST_UTIL.getAdmin().deleteColumnFamily(tableName, FAMILY);
  Assert.assertEquals(0, countMobFiles(tableName, hcd.getNameAsString()));
  Assert.assertEquals(1, countArchiveMobFiles(tableName, hcd.getNameAsString()));
  Assert.assertTrue(mobArchiveExist(tableName, hcd.getNameAsString(), fileName));
  Assert.assertFalse(mobColumnFamilyDirExist(tableName, hcd.getNameAsString()));
 } finally {
  table.close();
  TEST_UTIL.deleteTable(tableName);
 }
}

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

this.admin.deleteColumnFamily(tableName, xtracol.getName());
modifiedHtd = this.admin.getTableDescriptor(tableName);
hcd = modifiedHtd.getFamily(xtracol.getName());

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

admin.deleteColumnFamily(TableName.valueOf(physicalTableName), Bytes.toBytes(cf));

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

assertTrue(columnFamilyADescriptor1Returned.isInMemory() == true);
admin.deleteColumnFamily(tableDescriptor.getTableName(), FAMILYA);
tableDescriptorReturned = admin.getDescriptor(tableDescriptor.getTableName());
assertTrue(tableDescriptorReturned.getColumnFamilies().length == 3);

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testDeleteColumn() throws IOException {
 Admin admin = TEST_UTIL.getAdmin();
 // Create a table with two families
 HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
 baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
 baseHtd.addFamily(new HColumnDescriptor(FAMILY_1));
 admin.createTable(baseHtd);
 admin.disableTable(TABLE_NAME);
 try {
  // Verify the table descriptor
  verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1);
  // Modify the table removing one family and verify the descriptor
  admin.deleteColumnFamily(TABLE_NAME, FAMILY_1);
  verifyTableDescriptor(TABLE_NAME, FAMILY_0);
 } finally {
  admin.deleteTable(TABLE_NAME);
 }
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void disableNotFullReplication() throws Exception {
 HTableDescriptor table = new HTableDescriptor(admin2.getTableDescriptor(tableName));
 HColumnDescriptor f = new HColumnDescriptor("notReplicatedFamily");
 table.addFamily(f);
 admin1.disableTable(tableName);
 admin1.modifyTable(tableName, table);
 admin1.enableTable(tableName);
 admin1.disableTableReplication(tableName);
 table = admin1.getTableDescriptor(tableName);
 for (HColumnDescriptor fam : table.getColumnFamilies()) {
  assertEquals(HConstants.REPLICATION_SCOPE_LOCAL, fam.getScope());
 }
 admin1.deleteColumnFamily(table.getTableName(), f.getName());
}

相关文章

Admin类方法