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


Java Admin.enableTable方法代碼示例

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


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

示例1: enableTable

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
/**
 * 激活表
 *
 * @param tableName
 */
public void enableTable(String tableName) {
    HBaseConfiguration hBaseConfiguration = new HBaseConfiguration();
    Admin admin = hBaseConfiguration.admin();
    TableName tn = TableName.valueOf(tableName);
    try {
        if (admin.tableExists(tn)) {
            admin.enableTable(tn);
        } else {
            log.info("表名【" + tableName + "】不存在");
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        hBaseConfiguration.close();
    }
}
 
開發者ID:mumuhadoop,項目名稱:mumu-hbase,代碼行數:22,代碼來源:HBaseTableOperation.java

示例2: 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

示例3: setUp

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Before
@Override
public void setUp() throws Exception {
  // Initialize the cluster. This invokes LoadTestTool -init_only, which
  // will create the test table, appropriately pre-split
  super.setUp();

  if (!initialized) {
    return;
  }

  // Update the test table schema so HFiles from this point will be written with
  // encryption features enabled.
  final Admin admin = util.getHBaseAdmin();
  HTableDescriptor tableDescriptor =
      new HTableDescriptor(admin.getTableDescriptor(getTablename()));
  for (HColumnDescriptor columnDescriptor: tableDescriptor.getColumnFamilies()) {
    columnDescriptor.setEncryptionType("AES");
    LOG.info("Updating CF schema for " + getTablename() + "." +
      columnDescriptor.getNameAsString());
    admin.disableTable(getTablename());
    admin.modifyColumn(getTablename(), columnDescriptor);
    admin.enableTable(getTablename());
    util.waitFor(30000, 1000, true, new Predicate<IOException>() {
      @Override
      public boolean evaluate() throws IOException {
        return admin.isTableAvailable(getTablename());
      }
    });
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:32,代碼來源:IntegrationTestIngestWithEncryption.java

示例4: 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

示例5: testForCheckingIfEnableAndDisableWorksFineAfterSwitch

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Test
public void testForCheckingIfEnableAndDisableWorksFineAfterSwitch()
    throws Exception {
  final int NUM_MASTERS = 2;
  final int NUM_RS = 1;
  final int NUM_REGIONS_TO_CREATE = 4;

  // Start the cluster
  log("Starting cluster");
  Configuration conf = HBaseConfiguration.create();
  HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
  TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
  MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
  log("Waiting for active/ready master");
  cluster.waitForActiveAndReadyMaster();
  ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "testmasterRestart", null);
  HMaster master = cluster.getMaster();

  // Create a table with regions
  TableName table = TableName.valueOf("tableRestart");
  byte[] family = Bytes.toBytes("family");
  log("Creating table with " + NUM_REGIONS_TO_CREATE + " regions");
  HTable ht = TEST_UTIL.createMultiRegionTable(table, family, NUM_REGIONS_TO_CREATE);
  int numRegions = -1;
  try (RegionLocator r = ht.getRegionLocator()) {
    numRegions = r.getStartKeys().length;
  }
  numRegions += 1; // catalogs
  log("Waiting for no more RIT\n");
  blockUntilNoRIT(zkw, master);
  log("Disabling table\n");
  TEST_UTIL.getHBaseAdmin().disableTable(table);

  NavigableSet<String> regions = HBaseTestingUtility.getAllOnlineRegions(cluster);
  assertEquals(
      "The number of regions for the table tableRestart should be 0 and only"
          + "the catalog and namespace tables should be present.", 2, regions.size());

  List<MasterThread> masterThreads = cluster.getMasterThreads();
  MasterThread activeMaster = null;
  if (masterThreads.get(0).getMaster().isActiveMaster()) {
    activeMaster = masterThreads.get(0);
  } else {
    activeMaster = masterThreads.get(1);
  }
  activeMaster.getMaster().stop(
      "stopping the active master so that the backup can become active");
  cluster.hbaseCluster.waitOnMaster(activeMaster);
  cluster.waitForActiveAndReadyMaster();

  assertTrue("The table should not be in enabled state", cluster.getMaster()
      .getAssignmentManager().getTableStateManager().isTableState(
      TableName.valueOf("tableRestart"), ZooKeeperProtos.Table.State.DISABLED,
      ZooKeeperProtos.Table.State.DISABLING));
  log("Enabling table\n");
  // Need a new Admin, the previous one is on the old master
  Admin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
  admin.enableTable(table);
  admin.close();
  log("Waiting for no more RIT\n");
  blockUntilNoRIT(zkw, master);
  log("Verifying there are " + numRegions + " assigned on cluster\n");
  regions = HBaseTestingUtility.getAllOnlineRegions(cluster);
  assertEquals("The assigned regions were not onlined after master"
      + " switch except for the catalog and namespace tables.",
        6, regions.size());
  assertTrue("The table should be in enabled state", cluster.getMaster()
      .getAssignmentManager().getTableStateManager()
      .isTableState(TableName.valueOf("tableRestart"), ZooKeeperProtos.Table.State.ENABLED));
  ht.close();
  TEST_UTIL.shutdownMiniCluster();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:73,代碼來源:TestMasterRestartAfterDisablingTable.java

示例6: 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

示例7: testMetaRebuild

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Test(timeout = 120000)
public void testMetaRebuild() throws Exception {
  wipeOutMeta();

  // is meta really messed up?
  assertEquals(1, scanMeta());
  assertErrors(doFsck(conf, false),
      new ERROR_CODE[] {
          ERROR_CODE.NOT_IN_META_OR_DEPLOYED,
          ERROR_CODE.NOT_IN_META_OR_DEPLOYED,
          ERROR_CODE.NOT_IN_META_OR_DEPLOYED,
          ERROR_CODE.NOT_IN_META_OR_DEPLOYED});
  // Note, would like to check # of tables, but this takes a while to time
  // out.

  // shutdown the minicluster
  TEST_UTIL.shutdownMiniHBaseCluster();
  TEST_UTIL.shutdownMiniZKCluster();

  // rebuild meta table from scratch
  HBaseFsck fsck = new HBaseFsck(conf);
  assertTrue(fsck.rebuildMeta(false));

  // bring up the minicluster
  TEST_UTIL.startMiniZKCluster();
  TEST_UTIL.restartHBaseCluster(3);
  try (Connection connection = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration())) {
    Admin admin = connection.getAdmin();
    admin.enableTable(table);
    LOG.info("Waiting for no more RIT");
    TEST_UTIL.waitUntilNoRegionsInTransition(60000);
    LOG.info("No more RIT in ZK, now doing final test verification");

    // everything is good again.
    assertEquals(5, scanMeta());
    HTableDescriptor[] htbls = admin.listTables();
    LOG.info("Tables present after restart: " + Arrays.toString(htbls));
    assertEquals(1, htbls.length);
  }

  assertErrors(doFsck(conf, false), new ERROR_CODE[] {});
  LOG.info("Table " + table + " has " + tableRowCount(conf, table) + " entries.");
  assertEquals(16, tableRowCount(conf, table));
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:45,代碼來源:TestOfflineMetaRebuildBase.java


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