當前位置: 首頁>>代碼示例>>Java>>正文


Java Admin.modifyTable方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.client.Admin.modifyTable方法的典型用法代碼示例。如果您正苦於以下問題:Java Admin.modifyTable方法的具體用法?Java Admin.modifyTable怎麽用?Java Admin.modifyTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.client.Admin的用法示例。


在下文中一共展示了Admin.modifyTable方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: modifyTableSync

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
/**
 * Modify a table, synchronous. Waiting logic similar to that of {@code admin.rb#alter_status}.
 */
@SuppressWarnings("serial")
public static void modifyTableSync(Admin admin, HTableDescriptor desc)
    throws IOException, InterruptedException {
  admin.modifyTable(desc.getTableName(), desc);
  Pair<Integer, Integer> status = new Pair<Integer, Integer>() {{
    setFirst(0);
    setSecond(0);
  }};
  int i = 0;
  do {
    status = admin.getAlterStatus(desc.getTableName());
    if (status.getSecond() != 0) {
      LOG.debug(status.getSecond() - status.getFirst() + "/" + status.getSecond()
        + " regions updated.");
      Thread.sleep(1 * 1000l);
    } else {
      LOG.debug("All regions updated.");
      break;
    }
  } while (status.getFirst() != 0 && i++ < 500);
  if (status.getFirst() != 0) {
    throw new IOException("Failed to update all regions even after 500 seconds.");
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:HBaseTestingUtility.java

示例2: testModifyTable

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Test
public void testModifyTable() throws IOException {
  Admin admin = TEST_UTIL.getHBaseAdmin();
  // Create a table with one family
  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 adding another family and verify the descriptor
    HTableDescriptor modifiedHtd = new HTableDescriptor(TABLE_NAME);
    modifiedHtd.addFamily(new HColumnDescriptor(FAMILY_0));
    modifiedHtd.addFamily(new HColumnDescriptor(FAMILY_1));
    admin.modifyTable(TABLE_NAME, modifiedHtd);
    verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1);
  } finally {
    admin.deleteTable(TABLE_NAME);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:23,代碼來源:TestTableDescriptorModification.java

示例3: setReplicas

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
/**
 * Set the number of Region replicas.
 */
public static void setReplicas(Admin admin, TableName table, int replicaCount)
    throws IOException, InterruptedException {
  admin.disableTable(table);
  HTableDescriptor desc = admin.getTableDescriptor(table);
  desc.setRegionReplication(replicaCount);
  admin.modifyTable(desc.getTableName(), desc);
  admin.enableTable(table);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:12,代碼來源:HBaseTestingUtility.java

示例4: modifyTableSync

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
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);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:13,代碼來源:TestMasterObserver.java

示例5: perform

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Override
public void perform() throws Exception {
  HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
  Admin admin = util.getHBaseAdmin();

  LOG.info("Performing action: Change split policy of table " + tableName);
  HTableDescriptor tableDescriptor = admin.getTableDescriptor(tableName);
  String chosenPolicy = possiblePolicies[random.nextInt(possiblePolicies.length)];
  tableDescriptor.setRegionSplitPolicyClassName(chosenPolicy);
  LOG.info("Changing "  + tableName + " split policy to " + chosenPolicy);
  admin.modifyTable(tableName, tableDescriptor);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:13,代碼來源:ChangeSplitPolicyAction.java

示例6: perform

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Override
public void perform() throws Exception {
  Random random = new Random();
  HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
  Admin admin = util.getHBaseAdmin();

  LOG.info("Performing action: Change bloom filter on all columns of table "
      + tableName);
  HTableDescriptor tableDescriptor = admin.getTableDescriptor(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);
  }

  // Don't try the modify if we're stopping
  if (context.isStopping()) {
    return;
  }
  admin.modifyTable(tableName, tableDescriptor);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:36,代碼來源:ChangeBloomFilterAction.java

示例7: setTableRep

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
/**
 * Set the table's replication switch if the table's replication switch is already not set.
 * @param tableName name of the table
 * @param isRepEnabled is replication switch enable or disable
 * @throws IOException if a remote or network exception occurs
 */
private void setTableRep(final TableName tableName, boolean isRepEnabled) throws IOException {
  Admin admin = null;
  try {
    admin = this.connection.getAdmin();
    HTableDescriptor htd = admin.getTableDescriptor(tableName);
    if (isTableRepEnabled(htd) ^ isRepEnabled) {
      boolean isOnlineSchemaUpdateEnabled =
          this.connection.getConfiguration()
              .getBoolean("hbase.online.schema.update.enable", true);
      if (!isOnlineSchemaUpdateEnabled) {
        admin.disableTable(tableName);
      }
      for (HColumnDescriptor hcd : htd.getFamilies()) {
        hcd.setScope(isRepEnabled ? HConstants.REPLICATION_SCOPE_GLOBAL
            : HConstants.REPLICATION_SCOPE_LOCAL);
      }
      admin.modifyTable(tableName, htd);
      if (!isOnlineSchemaUpdateEnabled) {
        admin.enableTable(tableName);
      }
    }
  } finally {
    if (admin != null) {
      try {
        admin.close();
      } catch (IOException e) {
        LOG.warn("Failed to close admin connection.");
        LOG.debug("Details on failure to close admin connection.", e);
      }
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:39,代碼來源:ReplicationAdmin.java

示例8: updateTable

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
private static void updateTable(HTableDescriptor desc) throws Exception {
  Admin admin = TEST_UTIL.getHBaseAdmin();
  admin.disableTable(desc.getTableName());
  admin.modifyTable(desc.getTableName(), desc);
  admin.enableTable(desc.getTableName());
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:7,代碼來源:TestCoprocessorTableEndpoint.java

示例9: perform

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Override
public void perform() throws Exception {
  HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
  Admin admin = util.getHBaseAdmin();
  HTableDescriptor htd = admin.getTableDescriptor(tableName);

  // Try and get the current value.
  long currentValue = htd.getMaxFileSize();

  // If the current value is not set use the default for the cluster.
  // If configs are really weird this might not work.
  // That's ok. We're trying to cause chaos.
  if (currentValue <= 0) {
    currentValue =
        context.getHBaseCluster().getConf().getLong(HConstants.HREGION_MAX_FILESIZE,
            HConstants.DEFAULT_MAX_FILE_SIZE);
  }

  // Decrease by 10% at a time.
  long newValue = (long) (currentValue * 0.9);

  // We don't want to go too far below 1gb.
  // So go to about 1gb +/- 512 on each side.
  newValue = Math.max(minFileSize, newValue) - (512 - random.nextInt(1024));

  // Change the table descriptor.
  htd.setMaxFileSize(newValue);

  // Don't try the modify if we're stopping
  if (context.isStopping()) {
    return;
  }

  // modify the table.
  admin.modifyTable(tableName, htd);

  // Sleep some time.
  if (sleepTime > 0) {
    Thread.sleep(sleepTime);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:42,代碼來源:DecreaseMaxHFileSizeAction.java


注:本文中的org.apache.hadoop.hbase.client.Admin.modifyTable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。