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

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

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

Admin.getTableDescriptor介绍

[英]Method for getting the tableDescriptor
[中]获取tableDescriptor的方法

代码示例

代码示例来源:origin: thinkaurelius/titan

@Override
public HTableDescriptor getTableDescriptor(String tableString) throws TableNotFoundException, IOException
{
  return adm.getTableDescriptor(TableName.valueOf(tableString));
}

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

public void check(List<String> segFullNameList) {
  issueExistHTables = Lists.newArrayList();
  inconsistentHTables = Lists.newArrayList();
  for (String segFullName : segFullNameList) {
    String[] sepNameList = segFullName.split(",");
    try {
      HTableDescriptor hTableDescriptor = hbaseAdmin.getTableDescriptor(TableName.valueOf(sepNameList[0]));
      String host = hTableDescriptor.getValue(IRealizationConstants.HTableTag);
      if (!dstCfg.getMetadataUrlPrefix().equalsIgnoreCase(host)) {
        inconsistentHTables.add(segFullName);
      }
    } catch (IOException e) {
      issueExistHTables.add(segFullName);
      continue;
    }
  }
}

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

private void updateHtable(String tableName) throws IOException {
  HTableDescriptor desc = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName));
  if (oldHostValue.equals(desc.getValue(IRealizationConstants.HTableTag))) {
    desc.setValue(IRealizationConstants.HTableTag, kylinConfig.getMetadataUrlPrefix());
    hbaseAdmin.disableTable(TableName.valueOf(tableName));
    hbaseAdmin.modifyTable(TableName.valueOf(tableName), desc);
    hbaseAdmin.enableTable(TableName.valueOf(tableName));
    updatedResources.add(tableName);
  }
}

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

@Override
protected String createMetaStoreUUID() throws IOException {
  try (final Admin hbaseAdmin = HBaseConnection.get(metadataUrl).getAdmin()) {
    final String metaStoreName = metadataUrl.getIdentifier();
    final HTableDescriptor desc = hbaseAdmin.getTableDescriptor(TableName.valueOf(metaStoreName));
    String uuid = desc.getValue(HBaseConnection.HTABLE_UUID_TAG);
    if (uuid != null)
      return uuid;
    return UUID.randomUUID().toString();
  } catch (Exception e) {
    return null;
  }
}

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

@Override
public void call(Admin admin) throws Exception {
 admin.getTableDescriptor(TableName.valueOf(name.getMethodName()));
}
@Override

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

protected HColumnDescriptor getColumnDesc(Admin admin)
  throws TableNotFoundException, IOException {
 return admin.getTableDescriptor(TABLE).getFamily(CF);
}

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

/**
 * Allows to set HTableDescriptor
 *
 * @param connection with a server
 * @param tableName the name of table
 */
protected void setTableDesc(Connection connection, String tableName) {
 try {
  tableDesc = connection.getAdmin().getTableDescriptor(TableName.valueOf(tableName));
 } catch (IOException e) {
  throw UserException.dataReadError()
    .message("Failure while loading table %s in database %s.", tableName, getStorageEngineName())
    .addContext("Message: ", e.getMessage())
    .build(logger);
 }
}

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

@Override
 public Object run() throws Exception {
  try (Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
    Admin admin = conn.getAdmin()) {
   return admin.getTableDescriptor(TEST_TABLE);
  }
 }
};

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

/**
 * Set the number of Region replicas.
 */
public static void setReplicas(Admin admin, TableName table, int replicaCount)
  throws IOException, InterruptedException {
 admin.disableTable(table);
 HTableDescriptor desc = new HTableDescriptor(admin.getTableDescriptor(table));
 desc.setRegionReplication(replicaCount);
 admin.modifyTable(desc.getTableName(), desc);
 admin.enableTable(table);
}

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

private void modifyTableSync(Admin 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);
 }
}

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

@Test
public void testMetaHTDReplicaCount() throws Exception {
 assertTrue(TEST_UTIL.getAdmin().getTableDescriptor(TableName.META_TABLE_NAME)
   .getRegionReplication() == 3);
}

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

private void undeployRegions(HbckInfo hi) throws IOException, InterruptedException {
 undeployRegionsForHbi(hi);
 // undeploy replicas of the region (but only if the method is invoked for the primary)
 if (hi.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID) {
  return;
 }
 int numReplicas = admin.getTableDescriptor(hi.getTableName()).getRegionReplication();
 for (int i = 1; i < numReplicas; i++) {
  if (hi.getPrimaryHRIForDeployedReplica() == null) continue;
  RegionInfo hri = RegionReplicaUtil.getRegionInfoForReplica(
    hi.getPrimaryHRIForDeployedReplica(), i);
  HbckInfo h = regionInfoMap.get(hri.getEncodedName());
  if (h != null) {
   undeployRegionsForHbi(h);
   //set skip checks; we undeployed it, and we don't want to evaluate this anymore
   //in consistency checks
   h.setSkipChecks(true);
  }
 }
}

代码示例来源: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/kylin

private void alter() throws IOException {
  Connection conn = HBaseConnection.get(KylinConfig.getInstanceFromEnv().getStorageUrl());
  Admin hbaseAdmin = null;
  try {
    hbaseAdmin = conn.getAdmin();
    HTableDescriptor table = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName));
    hbaseAdmin.disableTable(table.getTableName());
    table.setValue(metadataKey, metadataValue);
    hbaseAdmin.modifyTable(table.getTableName(), table);
    hbaseAdmin.enableTable(table.getTableName());
  } finally {
    if (hbaseAdmin != null) {
      hbaseAdmin.close();
    }
  }
}

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

@Test
public void testDisableAndEnableReplication() throws Exception {
 admin1.disableTableReplication(tableName);
 HTableDescriptor table = admin1.getTableDescriptor(tableName);
 for (HColumnDescriptor fam : table.getColumnFamilies()) {
  assertEquals(HConstants.REPLICATION_SCOPE_LOCAL, fam.getScope());
 }
 admin1.enableTableReplication(tableName);
 table = admin1.getTableDescriptor(tableName);
 for (HColumnDescriptor fam : table.getColumnFamilies()) {
  assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope());
 }
}

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

@Test
public void createDoubleTest() throws IOException, InterruptedException {
 String nsName = prefix + "_" + name.getMethodName();
 LOG.info(name.getMethodName());
 final TableName tableName = TableName.valueOf(name.getMethodName());
 final TableName tableNameFoo = TableName.valueOf(nsName + ":" + name.getMethodName());
 //create namespace and verify
 admin.createNamespace(NamespaceDescriptor.create(nsName).build());
 TEST_UTIL.createTable(tableName, Bytes.toBytes(nsName));
 TEST_UTIL.createTable(tableNameFoo,Bytes.toBytes(nsName));
 assertEquals(2, admin.listTables().length);
 assertNotNull(admin
   .getTableDescriptor(tableName));
 assertNotNull(admin
   .getTableDescriptor(tableNameFoo));
 //remove namespace and verify
 admin.disableTable(tableName);
 admin.deleteTable(tableName);
 assertEquals(1, admin.listTables().length);
}

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

@Test
public void testEnableReplicationWhenReplicationNotEnabled() throws Exception {
 HTableDescriptor table = new HTableDescriptor(admin1.getTableDescriptor(tableName));
 for (HColumnDescriptor fam : table.getColumnFamilies()) {
  fam.setScope(HConstants.REPLICATION_SCOPE_LOCAL);
 }
 admin1.disableTable(tableName);
 admin1.modifyTable(tableName, table);
 admin1.enableTable(tableName);
 admin2.disableTable(tableName);
 admin2.modifyTable(tableName, table);
 admin2.enableTable(tableName);
 admin1.enableTableReplication(tableName);
 table = admin1.getTableDescriptor(tableName);
 for (HColumnDescriptor fam : table.getColumnFamilies()) {
  assertEquals(HConstants.REPLICATION_SCOPE_GLOBAL, fam.getScope());
 }
}

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

@Override
protected void initTable() throws IOException {
 super.initTable();
 TableName tableName = getTablename();
 try (Connection connection = ConnectionFactory.createConnection();
    Admin admin = connection.getAdmin()) {
  HTableDescriptor tableDesc = admin.getTableDescriptor(tableName);
  LOG.info("Disabling table " + getTablename());
  admin.disableTable(tableName);
  ColumnFamilyDescriptor mobColumn = tableDesc.getColumnFamily(mobColumnFamily);
  ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(mobColumn)
   .setMobEnabled(true)
   .setMobThreshold((long) threshold)
   .build();
  admin.modifyColumnFamily(tableName, cfd);
  LOG.info("Enabling table " + getTablename());
  admin.enableTable(tableName);
 }
}

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

private void validateSnapshotRestore() throws IOException {
  try {
   UTIL.getAdmin().enableTable(snapshotTableName);

   HTableDescriptor currentHTD = UTIL.getAdmin().getTableDescriptor(snapshotTableName);
   assertTrue(currentHTD.hasFamily(CF1));
   assertTrue(currentHTD.hasFamily(CF2));
   assertFalse(currentHTD.hasFamily(CF3));
   assertFalse(currentHTD.hasFamily(CF4));
   assertEquals(currentHTD.getFamiliesKeys().size(), snapshotHTD.getFamiliesKeys().size());
   SnapshotTestingUtils.verifyRowCount(UTIL, snapshotTableName, rowCountCF1 + rowCountCF2);
  } finally {
   UTIL.getAdmin().disableTable(snapshotTableName);
  }
 }
}

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

private void verifyTableDescriptor(final TableName tableName,
                  final byte[]... families) throws IOException {
 Admin admin = TEST_UTIL.getAdmin();
 // 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);
 TableDescriptor td =
   FSTableDescriptors.getTableDescriptorFromFs(mfs.getFileSystem(), tableDir);
 verifyTableDescriptor(td, tableName, families);
}

相关文章

Admin类方法