本文整理匯總了Java中org.apache.hadoop.hbase.client.HBaseAdmin.close方法的典型用法代碼示例。如果您正苦於以下問題:Java HBaseAdmin.close方法的具體用法?Java HBaseAdmin.close怎麽用?Java HBaseAdmin.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.HBaseAdmin
的用法示例。
在下文中一共展示了HBaseAdmin.close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupBeforeClass
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@BeforeClass
public static void setupBeforeClass() throws Exception {
// set configure to indicate which cp should be loaded
Configuration conf = util.getConfiguration();
conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
org.apache.hadoop.hbase.coprocessor.ColumnAggregationEndpoint.class.getName(),
ProtobufCoprocessorService.class.getName());
conf.setStrings(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
ProtobufCoprocessorService.class.getName());
util.startMiniCluster(2);
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor desc = new HTableDescriptor(TEST_TABLE);
desc.addFamily(new HColumnDescriptor(TEST_FAMILY));
admin.createTable(desc, new byte[][]{ROWS[rowSeperator1], ROWS[rowSeperator2]});
util.waitUntilAllRegionsAssigned(TEST_TABLE);
admin.close();
HTable table = new HTable(conf, TEST_TABLE);
for (int i = 0; i < ROWSIZE; i++) {
Put put = new Put(ROWS[i]);
put.add(TEST_FAMILY, TEST_QUALIFIER, Bytes.toBytes(i));
table.put(put);
}
table.close();
}
示例2: 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;
}
示例3: prepareForLoadTest
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
protected void prepareForLoadTest() throws IOException {
LOG.info("Starting load test: dataBlockEncoding=" + dataBlockEncoding +
", isMultiPut=" + isMultiPut);
numKeys = numKeys();
HBaseAdmin admin = new HBaseAdmin(conf);
while (admin.getClusterStatus().getServers().size() < NUM_RS) {
LOG.info("Sleeping until " + NUM_RS + " RSs are online");
Threads.sleepWithoutInterrupt(1000);
}
admin.close();
HTableDescriptor htd = new HTableDescriptor(TABLE);
HColumnDescriptor hcd = new HColumnDescriptor(CF)
.setCompressionType(compression)
.setDataBlockEncoding(dataBlockEncoding);
createPreSplitLoadTestTable(htd, hcd);
LoadTestDataGenerator dataGen = new MultiThreadedAction.DefaultDataGenerator(CF);
writerThreads = prepareWriterThreads(dataGen, conf, TABLE);
readerThreads = prepareReaderThreads(dataGen, conf, TABLE, 100);
}
示例4: connect
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Override
public void connect() throws IOException
{
super.connect();
HTableDescriptor tdesc = table.getTableDescriptor();
if (!tdesc.hasFamily(columnFamilyBytes)) {
HBaseAdmin admin = new HBaseAdmin(table.getConfiguration());
admin.disableTable(table.getTableName());
try {
HColumnDescriptor cdesc = new HColumnDescriptor(columnFamilyBytes);
admin.addColumn(table.getTableName(), cdesc);
} finally {
admin.enableTable(table.getTableName());
admin.close();
}
}
}
示例5: getTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* Gets a handle of a specific table.
* @param tableName of the table to be accessed.
* @return HTable of the table found.
*/
@Override
public HTable getTable(String tableName) {
logger.debug("NATIVE Begin of getTable for " + tableName);
HTable table = tableNameHandleMap.get(tableName);
if (table != null) {
logger.debug("NATIVE Found a cached handle for table " + tableName);
return table;
}
try {
logger.debug("NATIVE Looking for a handle of table: " + tableName);
HBaseAdmin admin = new HBaseAdmin(this.getHbcfg());
HTableDescriptor[] resources = admin.listTables(tableName);
Preconditions.checkElementIndex(0, resources.length, "no table " + tableName + " found");
admin.close();
table = new HTable(this.getHbcfg(), tableName);
} catch (IOException e) {
logger.error("NATIVE Error while trying to obtain table: " + tableName);
logger.error(e.getMessage());
};
tableNameHandleMap.put(tableName, table);
logger.debug("NATIVE Cached a handle of table: " + tableName);
return table;
}
示例6: createTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public Boolean createTable(String tableName, String familyName) throws Exception {
HBaseAdmin admin = new HBaseAdmin(conn);
if (admin.tableExists(tableName)) {
LOGGER.warn(">>>> Table {} exists!", tableName);
admin.close();
return false;
}
HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf(tableName));
tableDesc.addFamily(new HColumnDescriptor(familyName));
admin.createTable(tableDesc);
LOGGER.info(">>>> Table {} create success!", tableName);
admin.close();
return true;
}
示例7: testTableDeletion
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test
public void testTableDeletion() throws Exception {
User TABLE_ADMIN = User.createUserForTesting(conf, "TestUser", new String[0]);
// Grant TABLE ADMIN privs
grantOnTable(TEST_UTIL, TABLE_ADMIN.getShortName(),
TEST_TABLE.getTableName(), null, null,
Permission.Action.ADMIN);
AccessTestAction deleteTableAction = new AccessTestAction() {
@Override
public Object run() throws Exception {
HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
try {
admin.disableTable(TEST_TABLE.getTableName());
admin.deleteTable(TEST_TABLE.getTableName());
} finally {
admin.close();
}
return null;
}
};
verifyDenied(deleteTableAction, USER_RW, USER_RO, USER_NONE);
verifyAllowed(deleteTableAction, TABLE_ADMIN);
}
示例8: deleteTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* @param tableName
* @return
*/
public boolean deleteTable(String tableName) throws IOException {
HBaseAdmin admin = new HBaseAdmin(getConnPool().getConn());
if (admin.tableExists(tableName)) {
try {
if (admin.isTableEnabled(tableName)) {
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;
}
示例9: createTableIfMissing
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private void createTableIfMissing() throws IOException {
try {
HTableDescriptor ihtd = new HTableDescriptor(TableName.valueOf(TABLE_NAME));
for (byte[] family : FAMILIES) {
ihtd.addFamily(new HColumnDescriptor(family));
}
IndexSpecification iSpec = new IndexSpecification("ScanIndex");
iSpec.addIndexColumn(new HColumnDescriptor(Bytes.toString(FAMILY_A)),
Bytes.toString(QUALIFIER_NAME) + "1", ValueType.String, 10);
TableIndices indices = new TableIndices();
indices.addIndex(iSpec);
HBaseAdmin admin = new IndexAdmin(util.getConfiguration());
admin.createTable(ihtd);
admin.close();
} catch (TableExistsException tee) {
}
}
示例10: createTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public Boolean createTable(String tableName, String familyName) throws Exception {
HBaseAdmin admin = new HBaseAdmin(hconn);
if (admin.tableExists(tableName)) {
LOGGER.warn(">>>> Table {} exists!", tableName);
admin.close();
return false;
}
HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf(tableName));
tableDesc.addFamily(new HColumnDescriptor(familyName));
admin.createTable(tableDesc);
LOGGER.info(">>>> Table {} create success!", tableName);
admin.close();
return true;
}
示例11: RegionSizeCalculator
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
* Computes size of each region for table and given column families.
*
* @deprecated Use {@link #RegionSizeCalculator(RegionLocator, Admin)} instead.
*/
@Deprecated
public RegionSizeCalculator(HTable table) throws IOException {
HBaseAdmin admin = new HBaseAdmin(table.getConfiguration());
try {
init(table.getRegionLocator(), admin);
} finally {
admin.close();
}
}
示例12: createTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private void createTable(Configuration conf, String tableName) throws IOException {
HBaseAdmin admin = new HBaseAdmin(conf);
if (admin.tableExists(tableName)) {
admin.close();
return;
}
HTableDescriptor table = new HTableDescriptor(tableName);
table.addFamily(new HColumnDescriptor("info"));
admin.createTable(table);
admin.close();
}
示例13: LoadHFile2HBase
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private void LoadHFile2HBase(Configuration conf,String tableName,String hfile) throws Exception{
conf.set("hbase.metrics.showTableName", "false");
LoadIncrementalHFiles loader = new LoadIncrementalHFiles(conf);
HBaseAdmin admin = new HBaseAdmin(conf);
HTable table = new HTable(conf, tableName);
loader.doBulkLoad(new Path(hfile), table);
table.flushCommits();
table.close();
admin.close();
}
示例14: enableOmidCompaction
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public static void enableOmidCompaction(Configuration conf,
TableName table, byte[] columnFamily) throws IOException {
HBaseAdmin admin = new HBaseAdmin(conf);
try {
HTableDescriptor desc = admin.getTableDescriptor(table);
HColumnDescriptor cfDesc = desc.getFamily(columnFamily);
cfDesc.setValue(OmidCompactor.OMID_COMPACTABLE_CF_FLAG,
Boolean.TRUE.toString());
admin.modifyColumn(table, cfDesc);
} finally {
admin.close();
}
}
示例15: disableOmidCompaction
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public static void disableOmidCompaction(Configuration conf,
TableName table, byte[] columnFamily) throws IOException {
HBaseAdmin admin = new HBaseAdmin(conf);
try {
HTableDescriptor desc = admin.getTableDescriptor(table);
HColumnDescriptor cfDesc = desc.getFamily(columnFamily);
cfDesc.setValue(OmidCompactor.OMID_COMPACTABLE_CF_FLAG,
Boolean.FALSE.toString());
admin.modifyColumn(table, cfDesc);
} finally {
admin.close();
}
}