本文整理匯總了Java中org.apache.hadoop.hbase.client.HBaseAdmin.getTableDescriptor方法的典型用法代碼示例。如果您正苦於以下問題:Java HBaseAdmin.getTableDescriptor方法的具體用法?Java HBaseAdmin.getTableDescriptor怎麽用?Java HBaseAdmin.getTableDescriptor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.HBaseAdmin
的用法示例。
在下文中一共展示了HBaseAdmin.getTableDescriptor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateTableAttribute
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
/**
@param rawAttributeName is the attribute name viewed by applications, it allows multiple values. For example, secondaryIndex in secondaryIndex$1 and coprocessor in corpcessor$2
@param indexOfAttribute is of the same raw attribute name, for example 2 in secondary$2
*/
static void updateTableAttribute(Configuration conf, byte[] tableName, String rawAttributeName, int indexOfAttribute, boolean ifUpdateorRemove, String value) throws IOException{
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor desc = admin.getTableDescriptor(tableName);
admin.disableTable(tableName);
// System.out.println("TTDEBUG: disable table " + Bytes.toString(tableName));
String coprocessorKey = rawAttributeName + indexOfAttribute;
if(!ifUpdateorRemove) {
desc.remove(Bytes.toBytes(coprocessorKey));
} else {
desc.setValue(coprocessorKey, value);
}
admin.modifyTable(tableName, desc);
// System.out.println("TTDEBUG: modify table " + Bytes.toString(tableName));
admin.enableTable(tableName);
// System.out.println("TTDEBUG: enable table " + Bytes.toString(tableName));
HTableDescriptor descNew = admin.getTableDescriptor(tableName);
//modify table is asynchronous, has to loop over to check
while (!desc.equals(descNew)){
System.err.println("TTDEBUG: waiting for descriptor to change: from " + descNew + " to " + desc);
try {Thread.sleep(500);} catch(InterruptedException ex) {}
descNew = admin.getTableDescriptor(tableName);
}
}
示例2: verifyHColumnDescriptor
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private void verifyHColumnDescriptor(int expected, final TableName tableName,
final byte[]... families) throws IOException {
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
// Verify descriptor from master
HTableDescriptor htd = admin.getTableDescriptor(tableName);
HColumnDescriptor[] hcds = htd.getColumnFamilies();
verifyHColumnDescriptor(expected, hcds, tableName, families);
// Verify descriptor from HDFS
MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem();
Path tableDir = FSUtils.getTableDir(mfs.getRootDir(), tableName);
htd = FSTableDescriptors.getTableDescriptorFromFs(mfs.getFileSystem(), tableDir);
hcds = htd.getColumnFamilies();
verifyHColumnDescriptor(expected, hcds, tableName, families);
}
示例3: createIndexTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
public static void createIndexTable(String userTable, Configuration conf,
Map<String, List<String>> indexColumnFamily) throws IOException, InterruptedException,
ClassNotFoundException {
HBaseAdmin hbaseAdmin = new IndexAdmin(conf);
try {
HTableDescriptor tableDescriptor = hbaseAdmin.getTableDescriptor(Bytes.toBytes(userTable));
String input = conf.get(TABLE_INPUT_COLS);
HTableDescriptor ihtd = parse(userTable, tableDescriptor, input, indexColumnFamily);
// disable the table
hbaseAdmin.disableTable(userTable);
// This will create the index table. Also modifies the existing table htable descriptor.
hbaseAdmin.modifyTable(Bytes.toBytes(userTable), ihtd);
hbaseAdmin.enableTable(Bytes.toBytes(userTable));
} finally {
if (hbaseAdmin != null) {
hbaseAdmin.close();
}
}
}
示例4: ensureTableExists
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private HTableDescriptor ensureTableExists(String tableName, String initialCFName, int ttlInSeconds) throws BackendException {
HBaseAdmin adm = null;
HTableDescriptor desc;
try { // Create our table, if necessary
adm = getAdminInterface();
/*
* Some HBase versions/impls respond badly to attempts to create a
* table without at least one CF. See #661. Creating a CF along with
* the table avoids HBase carping.
*/
if (adm.tableExists(tableName)) {
desc = adm.getTableDescriptor(tableName.getBytes());
} else {
desc = createTable(tableName, initialCFName, ttlInSeconds, adm);
}
} catch (IOException e) {
throw new TemporaryBackendException(e);
} finally {
IOUtils.closeQuietly(adm);
}
return desc;
}
示例5: 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();
}
}
示例6: 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();
}
}
示例7: verifyTableDescriptor
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private void verifyTableDescriptor(final byte[] tableName, final byte[]... families)
throws IOException {
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
// Verify descriptor from master
HTableDescriptor htd = admin.getTableDescriptor(tableName);
verifyTableDescriptor(htd, tableName, families);
// Verify descriptor from HDFS
MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem();
Path tableDir = HTableDescriptor.getTableDir(mfs.getRootDir(), tableName);
htd = FSTableDescriptors.getTableDescriptor(mfs.getFileSystem(), tableDir);
verifyTableDescriptor(htd, tableName, families);
}
示例8: modifyTableSync
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private void modifyTableSync(HBaseAdmin admin, byte[] tableName, HTableDescriptor htd)
throws IOException {
admin.modifyTable(tableName, htd);
//wait until modify table finishes
for (int t = 0; t < 100; t++) { //10 sec timeout
HTableDescriptor td = admin.getTableDescriptor(htd.getName());
if (td.equals(htd)) {
break;
}
Threads.sleep(100);
}
}
示例9: createTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Override
public void createTable(HBaseTableSchema hbaseTableSchema) {
Util.checkNull(hbaseTableSchema);
HTableDescriptor tableDescriptor = new HTableDescriptor(hbaseTableSchema.getTableName());
try {
HBaseAdmin hbaseAdmin = hbaseDataSource.getHBaseAdmin();
NamespaceDescriptor[] namespaceDescriptors = hbaseAdmin.listNamespaceDescriptors();
String namespace = tableDescriptor.getTableName().getNamespaceAsString();
boolean isExist = false;
for (NamespaceDescriptor nd : namespaceDescriptors) {
if (nd.getName().equals(namespace)) {
isExist = true;
break;
}
}
log.info("namespace " + namespace + " isExist " + isExist);
if (!isExist) {
hbaseAdmin.createNamespace(NamespaceDescriptor.create(namespace).build());
}
if(null != hbaseTableSchema.getDefaultFamily())
tableDescriptor.addFamily(new HColumnDescriptor(hbaseTableSchema.getDefaultFamily()));
hbaseAdmin.createTable(tableDescriptor);
HTableDescriptor newTableDescriptor = hbaseAdmin.getTableDescriptor(tableDescriptor.getName());
log.info("create table " + newTableDescriptor);
} catch (Exception e) {
log.error(e);
throw new SimpleHBaseException(e);
}
}
示例10: updateCoprocessor
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private static void updateCoprocessor(Configuration conf, byte[] dataTableName) throws IOException{
HBaseAdmin admin = new HBaseAdmin(conf);
HTableDescriptor desc = admin.getTableDescriptor(dataTableName);
admin.disableTable(dataTableName);
System.out.println("TTDEBUG: disable data table");
if(INDEX_CP_CLASS.contains("null")) {
desc.remove(Bytes.toBytes(INDEX_CP_NAME));
} else {
desc.setValue(INDEX_CP_NAME, INDEX_CP_PATH + "|" + INDEX_CP_CLASS + "|1001|arg1=1,arg2=2");
}
HColumnDescriptor descIndexCF = desc.getFamily(Bytes.toBytes("cf"));//TOREMOVE don't use cf,
//KEEP_DELETED_CELLS => 'true'
descIndexCF.setKeepDeletedCells(true);
descIndexCF.setTimeToLive(HConstants.FOREVER);
descIndexCF.setMaxVersions(Integer.MAX_VALUE);
admin.modifyTable(dataTableName, desc);
System.out.println("TTDEBUG: modify data table");
admin.enableTable(dataTableName);
System.out.println("TTDEBUG: enable data table");
HTableDescriptor descNew = admin.getTableDescriptor(dataTableName);
//modify table is asynchronous, has to loop over to check
while (!desc.equals(descNew)){
System.out.println("TTDEBUG: waiting for descriptor to change: from " + descNew + " to " + desc);
try {Thread.sleep(500);} catch(InterruptedException ex) {}
descNew = admin.getTableDescriptor(dataTableName);
}
}
示例11: verifyTableDescriptor
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private void verifyTableDescriptor(final TableName tableName,
final byte[]... families) throws IOException {
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
// Verify descriptor from master
HTableDescriptor htd = admin.getTableDescriptor(tableName);
verifyTableDescriptor(htd, tableName, families);
// Verify descriptor from HDFS
MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem();
Path tableDir = FSUtils.getTableDir(mfs.getRootDir(), tableName);
htd = FSTableDescriptors.getTableDescriptorFromFs(mfs.getFileSystem(), tableDir);
verifyTableDescriptor(htd, tableName, families);
}
示例12: modifyTableSync
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
private void modifyTableSync(HBaseAdmin admin, TableName tableName, HTableDescriptor htd)
throws IOException {
admin.modifyTable(tableName, htd);
//wait until modify table finishes
for (int t = 0; t < 100; t++) { //10 sec timeout
HTableDescriptor td = admin.getTableDescriptor(htd.getTableName());
if (td.equals(htd)) {
break;
}
Threads.sleep(100);
}
}
示例13: createTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void createTable(HBaseTableSchema hbaseTableSchema) {
Util.checkNull(hbaseTableSchema);
HTableDescriptor tableDescriptor = new HTableDescriptor(hbaseTableSchema.getTableName());
try {
HBaseAdmin hbaseAdmin = hbaseDataSource.getHBaseAdmin();
NamespaceDescriptor[] namespaceDescriptors = hbaseAdmin.listNamespaceDescriptors();
String namespace = tableDescriptor.getTableName().getNamespaceAsString();
boolean isExist = false;
for (NamespaceDescriptor nd : namespaceDescriptors) {
if (nd.getName().equals(namespace)) {
isExist = true;
break;
}
}
log.info("namespace " + namespace + " isExist " + isExist);
if (!isExist) {
hbaseAdmin.createNamespace(NamespaceDescriptor.create(namespace).build());
}
if(null != hbaseTableSchema.getDefaultFamily())
tableDescriptor.addFamily(new HColumnDescriptor(hbaseTableSchema.getDefaultFamily()));
hbaseAdmin.createTable(tableDescriptor);
HTableDescriptor newTableDescriptor = hbaseAdmin.getTableDescriptor(tableDescriptor.getName());
log.info("create table " + newTableDescriptor);
} catch (Exception e) {
log.error(e);
throw new SimpleHBaseException(e);
}
}
示例14: perform
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Override
public void perform() throws Exception {
Random random = new Random();
HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
HBaseAdmin admin = util.getHBaseAdmin();
LOG.info("Performing action: Change bloom filter on all columns of table "
+ tableName);
HTableDescriptor tableDescriptor = admin.getTableDescriptor(Bytes
.toBytes(tableName));
HColumnDescriptor[] columnDescriptors = tableDescriptor.getColumnFamilies();
if (columnDescriptors == null || columnDescriptors.length == 0) {
return;
}
final BloomType[] bloomArray = BloomType.values();
final int bloomArraySize = bloomArray.length;
for (HColumnDescriptor descriptor : columnDescriptors) {
int bloomFilterIndex = random.nextInt(bloomArraySize);
LOG.debug("Performing action: About to set bloom filter type to "
+ bloomArray[bloomFilterIndex] + " on column "
+ descriptor.getNameAsString() + " of table " + tableName);
descriptor.setBloomFilterType(bloomArray[bloomFilterIndex]);
LOG.debug("Performing action: Just set bloom filter type to "
+ bloomArray[bloomFilterIndex] + " on column "
+ descriptor.getNameAsString() + " of table " + tableName);
}
admin.modifyTable(tableName, tableDescriptor);
}
示例15: getTable
import org.apache.hadoop.hbase.client.HBaseAdmin; //導入方法依賴的package包/類
@Test
public void getTable() throws Exception {
String TABLE_NAME = "TEST_BENCHMARK";
//
Configuration configuration = createConfiguration();
HBaseAdmin hbaseAdmin = createHBaseAdmin(configuration);
HTableDescriptor htd = hbaseAdmin.getTableDescriptor(Bytes
.toBytes(TABLE_NAME));// TableNotFoundException
//
System.out.println(htd);
assertNotNull(htd);
}