本文整理匯總了Java中org.apache.hadoop.hbase.client.HBaseAdmin.isTableDisabled方法的典型用法代碼示例。如果您正苦於以下問題:Java HBaseAdmin.isTableDisabled方法的具體用法?Java HBaseAdmin.isTableDisabled怎麽用?Java HBaseAdmin.isTableDisabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.HBaseAdmin
的用法示例。
在下文中一共展示了HBaseAdmin.isTableDisabled方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@BeforeMethod
public void setUp() throws Exception {
HBaseAdmin admin = testutil.getHBaseAdmin();
if (!admin.tableExists(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME)) {
HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);
HColumnDescriptor datafam = new HColumnDescriptor(DEFAULT_TIMESTAMP_STORAGE_CF_NAME);
datafam.setMaxVersions(Integer.MAX_VALUE);
desc.addFamily(datafam);
admin.createTable(desc);
}
if (admin.isTableDisabled(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME)) {
admin.enableTable(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME);
}
HTableDescriptor[] tables = admin.listTables();
for (HTableDescriptor t : tables) {
LOG.info(t.getNameAsString());
}
}
示例2: deleteTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* delete table in preparation for next test
*
* @param tablename
* @throws IOException
*/
void deleteTable(String tablename) throws IOException {
HBaseAdmin admin = new HBaseAdmin(conf);
admin.getConnection().clearRegionCache();
byte[] tbytes = Bytes.toBytes(tablename);
if (admin.isTableEnabled(tbytes)) {
admin.disableTableAsync(tbytes);
}
while (!admin.isTableDisabled(tbytes)) {
try {
Thread.sleep(250);
} catch (InterruptedException e) {
e.printStackTrace();
fail("Interrupted when trying to disable table " + tablename);
}
}
admin.deleteTable(tbytes);
}
示例3: 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());
}
示例4: deleteTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* delete table in preparation for next test
*
* @param tablename
* @throws IOException
*/
void deleteTable(TableName tablename) throws IOException {
HBaseAdmin admin = new HBaseAdmin(conf);
admin.getConnection().clearRegionCache();
if (admin.isTableEnabled(tablename)) {
admin.disableTableAsync(tablename);
}
long totalWait = 0;
long maxWait = 30*1000;
long sleepTime = 250;
while (!admin.isTableDisabled(tablename)) {
try {
Thread.sleep(sleepTime);
totalWait += sleepTime;
if (totalWait >= maxWait) {
fail("Waited too long for table to be disabled + " + tablename);
}
} catch (InterruptedException e) {
e.printStackTrace();
fail("Interrupted when trying to disable table " + tablename);
}
}
admin.deleteTable(tablename);
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: deleteTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
void deleteTable(HBaseAdmin admin, TableName tableName) throws IOException {
if (admin.tableExists(tableName)) {
if (admin.isTableDisabled(tableName)) {
admin.deleteTable(tableName);
} else {
admin.disableTable(tableName);
admin.deleteTable(tableName);
}
}
}
示例8: setUp
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@BeforeMethod
public void setUp() throws Exception {
HBaseAdmin admin = testutil.getHBaseAdmin();
if (!admin.tableExists(TEST_TABLE)) {
HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);
HColumnDescriptor datafam = new HColumnDescriptor(commitTableFamily);
datafam.setMaxVersions(Integer.MAX_VALUE);
desc.addFamily(datafam);
HColumnDescriptor lowWatermarkFam = new HColumnDescriptor(lowWatermarkFamily);
lowWatermarkFam.setMaxVersions(Integer.MAX_VALUE);
desc.addFamily(lowWatermarkFam);
desc.addCoprocessor("org.apache.hadoop.hbase.coprocessor.AggregateImplementation");
admin.createTable(desc);
}
if (admin.isTableDisabled(TEST_TABLE)) {
admin.enableTable(TEST_TABLE);
}
HTableDescriptor[] tables = admin.listTables();
for (HTableDescriptor t : tables) {
LOG.info(t.getNameAsString());
}
}
示例9: merge
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* Scans the table and merges two adjacent regions if they are small. This
* only happens when a lot of rows are deleted.
*
* When merging the META region, the HBase instance must be offline.
* When merging a normal table, the HBase instance must be online, but the
* table must be disabled.
*
* @param conf - configuration object for HBase
* @param fs - FileSystem where regions reside
* @param tableName - Table to be compacted
* @param testMasterRunning True if we are to verify master is down before
* running merge
* @throws IOException
*/
public static void merge(Configuration conf, FileSystem fs,
final byte [] tableName, final boolean testMasterRunning)
throws IOException {
boolean masterIsRunning = false;
if (testMasterRunning) {
masterIsRunning = HConnectionManager
.execute(new HConnectable<Boolean>(conf) {
@Override
public Boolean connect(HConnection connection) throws IOException {
return connection.isMasterRunning();
}
});
}
if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
if (masterIsRunning) {
throw new IllegalStateException(
"Can not compact META table if instance is on-line");
}
new OfflineMerger(conf, fs).process();
} else {
if(!masterIsRunning) {
throw new IllegalStateException(
"HBase instance must be running to merge a normal table");
}
HBaseAdmin admin = new HBaseAdmin(conf);
if (!admin.isTableDisabled(tableName)) {
throw new TableNotDisabledException(tableName);
}
new OnlineMerger(conf, fs, tableName).process();
}
}
示例10: merge
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* Scans the table and merges two adjacent regions if they are small. This
* only happens when a lot of rows are deleted.
*
* When merging the hbase:meta region, the HBase instance must be offline.
* When merging a normal table, the HBase instance must be online, but the
* table must be disabled.
*
* @param conf - configuration object for HBase
* @param fs - FileSystem where regions reside
* @param tableName - Table to be compacted
* @param testMasterRunning True if we are to verify master is down before
* running merge
* @throws IOException
*/
public static void merge(Configuration conf, FileSystem fs,
final TableName tableName, final boolean testMasterRunning)
throws IOException {
boolean masterIsRunning = false;
if (testMasterRunning) {
masterIsRunning = HConnectionManager
.execute(new HConnectable<Boolean>(conf) {
@Override
public Boolean connect(HConnection connection) throws IOException {
return connection.isMasterRunning();
}
});
}
if (tableName.equals(TableName.META_TABLE_NAME)) {
if (masterIsRunning) {
throw new IllegalStateException(
"Can not compact hbase:meta table if instance is on-line");
}
// TODO reenable new OfflineMerger(conf, fs).process();
} else {
if(!masterIsRunning) {
throw new IllegalStateException(
"HBase instance must be running to merge a normal table");
}
HBaseAdmin admin = new HBaseAdmin(conf);
if (!admin.isTableDisabled(tableName)) {
throw new TableNotDisabledException(tableName);
}
new OnlineMerger(conf, fs, tableName).process();
}
}
示例11: runTestMultiTableConflict
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test(timeOut = 10_000)
public void runTestMultiTableConflict(ITestContext context) throws Exception {
TransactionManager tm = newTransactionManager(context);
TTable tt = new TTable(hbaseConf, TEST_TABLE);
String table2 = TEST_TABLE + 2;
TableName table2Name = TableName.valueOf(table2);
HBaseAdmin admin = new HBaseAdmin(hbaseConf);
if (!admin.tableExists(table2)) {
HTableDescriptor desc = new HTableDescriptor(table2Name);
HColumnDescriptor datafam = new HColumnDescriptor(TEST_FAMILY);
datafam.setMaxVersions(Integer.MAX_VALUE);
desc.addFamily(datafam);
admin.createTable(desc);
}
if (admin.isTableDisabled(table2)) {
admin.enableTable(table2);
}
admin.close();
TTable tt2 = new TTable(hbaseConf, table2);
Transaction t1 = tm.begin();
LOG.info("Transaction created " + t1);
Transaction t2 = tm.begin();
LOG.info("Transaction created" + t2);
byte[] row = Bytes.toBytes("test-simple");
byte[] row2 = Bytes.toBytes("test-simple2");
byte[] fam = Bytes.toBytes(TEST_FAMILY);
byte[] col = Bytes.toBytes("testdata");
byte[] data1 = Bytes.toBytes("testWrite-1");
byte[] data2 = Bytes.toBytes("testWrite-2");
Put p = new Put(row);
p.add(fam, col, data1);
tt.put(t1, p);
tt2.put(t1, p);
Put p2 = new Put(row);
p2.add(fam, col, data2);
tt.put(t2, p2);
p2 = new Put(row2);
p2.add(fam, col, data2);
tt2.put(t2, p2);
tm.commit(t2);
boolean aborted = false;
try {
tm.commit(t1);
fail("Transaction commited successfully");
} catch (RollbackException e) {
aborted = true;
}
assertTrue(aborted, "Transaction didn't raise exception");
ResultScanner rs = tt2.getHTable().getScanner(fam, col);
int count = 0;
Result r;
while ((r = rs.next()) != null) {
count += r.size();
}
assertEquals(count, 1, "Should have cell");
}
示例12: addColumnFamily
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test
public void addColumnFamily() throws Exception {
String TABLE_NAME = "TEST_BENCHMARK";
//
Configuration configuration = createConfiguration();
HBaseAdmin hbaseAdmin = createHBaseAdmin(configuration);
//
// 新增column時,須將table disable
if (hbaseAdmin.isTableEnabled(TABLE_NAME)) {
hbaseAdmin.disableTable(TABLE_NAME);
}
//
String COLUMN_FAMILY = "seq";
HColumnDescriptor hcd = new HColumnDescriptor(COLUMN_FAMILY);
// hcd.setBloomFilterType(BloomType.ROWCOL);
hcd.setBlockCacheEnabled(true);
// hcd.setCompressionType(Algorithm.SNAPPY);
hcd.setInMemory(true);
hcd.setMaxVersions(1);
hcd.setMinVersions(0);
hcd.setTimeToLive(432000);// 秒為單位
hbaseAdmin.addColumn(TABLE_NAME, hcd);// TableNotDisabledException,
System.out.println("add column family [" + COLUMN_FAMILY + "]");
//
COLUMN_FAMILY = "id";
hcd = new HColumnDescriptor(COLUMN_FAMILY);
// hcd.setBloomFilterType(BloomType.ROWCOL);
hcd.setBlockCacheEnabled(true);
// hcd.setCompressionType(Algorithm.SNAPPY);
hcd.setInMemory(true);
hcd.setMaxVersions(1);
hcd.setMinVersions(0);
hcd.setTimeToLive(432000);// 秒為單位,5d
hbaseAdmin.addColumn(TABLE_NAME, hcd);// TableNotDisabledException,
System.out.println("add column family [" + COLUMN_FAMILY + "]");
//
COLUMN_FAMILY = "info";
hcd = new HColumnDescriptor(COLUMN_FAMILY);
// hcd.setBloomFilterType(BloomType.ROWCOL);
hcd.setBlockCacheEnabled(true);
// hcd.setCompressionType(Algorithm.SNAPPY);
hcd.setInMemory(true);
hcd.setMaxVersions(1);
hcd.setMinVersions(0);
hcd.setTimeToLive(432000);// 秒為單位
hbaseAdmin.addColumn(TABLE_NAME, hcd);// TableNotDisabledException
System.out.println("add column family [" + COLUMN_FAMILY + "]");
// 新增column後,再將table enable
if (hbaseAdmin.isTableDisabled(TABLE_NAME)) {
hbaseAdmin.enableTable(TABLE_NAME);
}
}