本文整理匯總了Java中org.apache.hadoop.hbase.client.HBaseAdmin.deleteTable方法的典型用法代碼示例。如果您正苦於以下問題:Java HBaseAdmin.deleteTable方法的具體用法?Java HBaseAdmin.deleteTable怎麽用?Java HBaseAdmin.deleteTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.HBaseAdmin
的用法示例。
在下文中一共展示了HBaseAdmin.deleteTable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deleteTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public static void deleteTable(HBaseTestingUtility testUtil, HBaseAdmin admin,
TableName tableName)
throws Exception {
// NOTE: We need a latch because admin is not sync,
// so the postOp coprocessor method may be called after the admin operation returned.
MasterSyncObserver observer = (MasterSyncObserver)testUtil.getHBaseCluster().getMaster()
.getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class.getName());
observer.tableDeletionLatch = new CountDownLatch(1);
try {
admin.disableTable(tableName);
} catch (Exception e) {
LOG.debug("Table: " + tableName + " already disabled, so just deleting it.");
}
admin.deleteTable(tableName);
observer.tableDeletionLatch.await();
observer.tableDeletionLatch = null;
}
示例2: prepareData
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private Store prepareData() throws IOException {
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTable table = TEST_UTIL.createTable(tableName, family);
Random rand = new Random();
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
byte[] value = new byte[128 * 1024];
rand.nextBytes(value);
table.put(new Put(Bytes.toBytes(i * 10 + j)).add(family, qualifier, value));
}
admin.flush(tableName);
}
return getStoreWithName(tableName);
}
示例3: delete
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public static boolean delete(String tablename) throws IOException{
HBaseAdmin admin=new HBaseAdmin(cfg);
if(admin.tableExists(tablename)){
try
{
admin.disableTable(tablename);
admin.deleteTable(tablename);
}catch(Exception ex){
ex.printStackTrace();
return false;
}
}
return true;
}
示例4: setUp
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
LOG.info(String.format("Initializing cluster with %d region servers.",
REGION_SERVER_COUNT));
util.initializeCluster(REGION_SERVER_COUNT);
LOG.info("Cluster initialized");
HBaseAdmin admin = util.getHBaseAdmin();
if (admin.tableExists(TABLE_NAME)) {
LOG.info(String.format("Deleting existing table %s.", TABLE_NAME));
if (admin.isTableEnabled(TABLE_NAME)) admin.disableTable(TABLE_NAME);
admin.deleteTable(TABLE_NAME);
LOG.info(String.format("Existing table %s deleted.", TABLE_NAME));
}
LOG.info("Cluster ready");
}
示例5: testAddColumn
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test
public void testAddColumn() throws IOException {
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
// Create a table with two families
HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
admin.createTable(baseHtd);
admin.disableTable(TABLE_NAME);
try {
// Verify the table descriptor
verifyTableDescriptor(TABLE_NAME, FAMILY_0);
// Modify the table removing one family and verify the descriptor
admin.addColumn(TABLE_NAME, new HColumnDescriptor(FAMILY_1));
verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1);
} finally {
admin.deleteTable(TABLE_NAME);
}
}
示例6: deleteTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* @param tableName
* @return
*/
public boolean deleteTable(String tableName) throws IOException {
HBaseAdmin admin = new HBaseAdmin(conn);
if (admin.tableExists(tableName)) {
try {
admin.disableTable(tableName);
admin.deleteTable(tableName);
LOGGER.info(">>>> Table {} delete success!", tableName);
} catch (Exception ex) {
LOGGER.error("delete table error:", ex);
return false;
}
} else {
LOGGER.warn(">>>> Table {} delete but not exist.", tableName);
}
admin.close();
return true;
}
示例7: deleteTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private void deleteTable(HBaseAdmin admin, HTableDescriptor htd)
throws IOException, InterruptedException {
// Use disableTestAsync because disable can take a long time to complete
System.out.print("Disabling table " + htd.getNameAsString() +" ");
admin.disableTableAsync(htd.getName());
long start = System.currentTimeMillis();
// NOTE tables can be both admin.isTableEnabled=false and
// isTableDisabled=false, when disabling must use isTableDisabled!
while (!admin.isTableDisabled(htd.getName())) {
System.out.print(".");
Thread.sleep(1000);
}
long delta = System.currentTimeMillis() - start;
System.out.println(" " + delta +" ms");
System.out.println("Deleting table " + htd.getNameAsString() +" ");
admin.deleteTable(htd.getName());
}
示例8: testDeleteColumn
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test
public void testDeleteColumn() throws IOException {
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
// 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.deleteColumn(TABLE_NAME, FAMILY_1);
verifyTableDescriptor(TABLE_NAME, FAMILY_0);
} finally {
admin.deleteTable(TABLE_NAME);
}
}
示例9: deleteTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Override
public void deleteTable(String tableName) {
Util.checkEmptyString(tableName);
try {
HBaseAdmin hbaseAdmin = hbaseDataSource.getHBaseAdmin();
// delete table if table exist.
if (hbaseAdmin.tableExists(tableName)) {
// disable table before delete it.
if (!hbaseAdmin.isTableDisabled(tableName)) {
hbaseAdmin.disableTable(tableName);
}
hbaseAdmin.deleteTable(tableName);
}
} catch (Exception e) {
log.error(e);
throw new SimpleHBaseException(e);
}
}
示例10: testCreateTableWithSetVersion
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test
public void testCreateTableWithSetVersion() throws Exception {
TEST_UTIL.shutdownMiniCluster();
TEST_UTIL.getConfiguration().setInt("hbase.column.max.version", 3);
TEST_UTIL.startMiniCluster(1);
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
// Create a table with one family
HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
HColumnDescriptor hcd =
new HColumnDescriptor(FAMILY, 5, HColumnDescriptor.DEFAULT_COMPRESSION,
HColumnDescriptor.DEFAULT_IN_MEMORY, HColumnDescriptor.DEFAULT_BLOCKCACHE,
HColumnDescriptor.DEFAULT_TTL, HColumnDescriptor.DEFAULT_BLOOMFILTER);
baseHtd.addFamily(hcd);
admin.createTable(baseHtd);
admin.disableTable(TABLE_NAME);
try {
// Verify the column descriptor
verifyHColumnDescriptor(5, TABLE_NAME, FAMILY);
} finally {
admin.deleteTable(TABLE_NAME);
}
}
示例11: deleteTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Override
public void deleteTable(String tableName) {
Util.checkEmptyString(tableName);
try {
HBaseAdmin hbaseAdmin = hbaseDataSource.getHBaseAdmin();
// delete table if table exist.
if (hbaseAdmin.tableExists(tableName)) {
// disable table before delete it.
if (!hbaseAdmin.isTableDisabled(tableName)) {
hbaseAdmin.disableTable(tableName);
}
hbaseAdmin.deleteTable(tableName);
}
} catch (Exception e) {
log.error(e);
throw new SimpleHBaseException(e);
}
}
示例12: generateHBaseDatasetCompositeKeyDate
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public static void generateHBaseDatasetCompositeKeyDate(HBaseAdmin admin, String tableName, int numberRegions) throws Exception {
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILY_F));
if (numberRegions > 1) {
admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
} else {
admin.createTable(desc);
}
HTable table = new HTable(admin.getConfiguration(), tableName);
Date startDate = new Date(1408924800000L);
long startTime = startDate.getTime();
long MILLISECONDS_IN_A_DAY = (long)1000 * 60 * 60 * 24;
long MILLISECONDS_IN_A_YEAR = MILLISECONDS_IN_A_DAY * 365;
long endTime = startTime + MILLISECONDS_IN_A_YEAR;
long interval = MILLISECONDS_IN_A_DAY / 3;
for (long ts = startTime, counter = 0; ts < endTime; ts += interval, counter ++) {
byte[] rowKey = ByteBuffer.allocate(16) .putLong(ts).array();
for(int i = 0; i < 8; ++i) {
rowKey[8 + i] = (byte)(counter >> (56 - (i * 8)));
}
Put p = new Put(rowKey);
p.add(FAMILY_F, COLUMN_C, "dummy".getBytes());
table.put(p);
}
table.flushCommits();
table.close();
}
示例13: generateHBaseDatasetCompositeKeyInt
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public static void generateHBaseDatasetCompositeKeyInt(HBaseAdmin admin, String tableName, int numberRegions) throws Exception {
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILY_F));
if (numberRegions > 1) {
admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
} else {
admin.createTable(desc);
}
HTable table = new HTable(admin.getConfiguration(), tableName);
int startVal = 0;
int stopVal = 1000;
int interval = 47;
long counter = 0;
for (int i = startVal; i < stopVal; i += interval, counter ++) {
byte[] rowKey = ByteBuffer.allocate(12).putInt(i).array();
for(int j = 0; j < 8; ++j) {
rowKey[4 + j] = (byte)(counter >> (56 - (j * 8)));
}
Put p = new Put(rowKey);
p.add(FAMILY_F, COLUMN_C, "dummy".getBytes());
table.put(p);
}
table.flushCommits();
table.close();
}
示例14: generateHBaseDatasetDoubleOB
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public static void generateHBaseDatasetDoubleOB(HBaseAdmin admin, String tableName, int numberRegions) throws Exception {
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILY_F));
if (numberRegions > 1) {
admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
} else {
admin.createTable(desc);
}
HTable table = new HTable(admin.getConfiguration(), tableName);
for (double i = 0.5; i <= 100.00; i += 0.75) {
byte[] bytes = new byte[9];
org.apache.hadoop.hbase.util.PositionedByteRange br =
new org.apache.hadoop.hbase.util.SimplePositionedByteRange(bytes, 0, 9);
org.apache.hadoop.hbase.util.OrderedBytes.encodeFloat64(br, i,
org.apache.hadoop.hbase.util.Order.ASCENDING);
Put p = new Put(bytes);
p.add(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
table.put(p);
}
table.flushCommits();
table.close();
admin.flush(tableName);
}
示例15: generateHBaseDatasetFloatOB
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public static void generateHBaseDatasetFloatOB(HBaseAdmin admin, String tableName, int numberRegions) throws Exception {
if (admin.tableExists(tableName)) {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILY_F));
if (numberRegions > 1) {
admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
} else {
admin.createTable(desc);
}
HTable table = new HTable(admin.getConfiguration(), tableName);
for (float i = (float)0.5; i <= 100.00; i += 0.75) {
byte[] bytes = new byte[5];
org.apache.hadoop.hbase.util.PositionedByteRange br =
new org.apache.hadoop.hbase.util.SimplePositionedByteRange(bytes, 0, 5);
org.apache.hadoop.hbase.util.OrderedBytes.encodeFloat32(br, i,
org.apache.hadoop.hbase.util.Order.ASCENDING);
Put p = new Put(bytes);
p.add(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
table.put(p);
}
table.flushCommits();
table.close();
admin.flush(tableName);
}