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


Java Admin.disableTable方法代碼示例

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


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

示例1: deleteTable

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
/**
 * 刪除表
 *
 * @param tableName
 */
public void deleteTable(String tableName) {
    HBaseConfiguration hBaseConfiguration = new HBaseConfiguration();
    Admin admin = hBaseConfiguration.admin();
    TableName tn = TableName.valueOf(tableName);
    try {
        if (admin.tableExists(tn)) {
            admin.disableTable(tn);//先禁用表 才能刪除
            admin.deleteTable(tn);
        } else {
            log.info("表名【" + tableName + "】不存在");
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        hBaseConfiguration.close();
    }
}
 
開發者ID:mumuhadoop,項目名稱:mumu-hbase,代碼行數:23,代碼來源:HBaseTableOperation.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: testDeleteColumn

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Test
public void testDeleteColumn() throws IOException {
  Admin admin = TEST_UTIL.getHBaseAdmin();
  // Create a table with two families
  HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
  baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
  baseHtd.addFamily(new HColumnDescriptor(FAMILY_1));
  admin.createTable(baseHtd);
  admin.disableTable(TABLE_NAME);
  try {
    // Verify the table descriptor
    verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1);

    // Modify the table removing one family and verify the descriptor
    admin.deleteColumn(TABLE_NAME, FAMILY_1);
    verifyTableDescriptor(TABLE_NAME, FAMILY_0);
  } finally {
    admin.deleteTable(TABLE_NAME);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:21,代碼來源:TestTableDescriptorModification.java

示例4: testCreateTableWithDefaultFromConf

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Test
public void testCreateTableWithDefaultFromConf() throws Exception {
  TEST_UTIL.shutdownMiniCluster();
  TEST_UTIL.getConfiguration().setInt("hbase.column.max.version", 3);
  TEST_UTIL.startMiniCluster(1);

  Admin admin = TEST_UTIL.getHBaseAdmin();
  // Create a table with one family
  HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
  HColumnDescriptor hcd = new HColumnDescriptor(FAMILY);
  hcd.setMaxVersions(TEST_UTIL.getConfiguration().getInt("hbase.column.max.version", 1));
  baseHtd.addFamily(hcd);
  admin.createTable(baseHtd);
  admin.disableTable(TABLE_NAME);
  try {
    // Verify the column descriptor
    verifyHColumnDescriptor(3, TABLE_NAME, FAMILY);
  } finally {
    admin.deleteTable(TABLE_NAME);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:22,代碼來源:TestHColumnDescriptorDefaultVersions.java

示例5: setUp

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
  LOG.info(String.format("Initializing cluster with %d region servers.",
    REGION_SERVER_COUNT));
  util.initializeCluster(REGION_SERVER_COUNT);
  LOG.info("Cluster initialized");

  Admin admin = util.getHBaseAdmin();
  if (admin.tableExists(TABLE_NAME)) {
    LOG.info(String.format("Deleting existing table %s.", TABLE_NAME));
    if (admin.isTableEnabled(TABLE_NAME)) admin.disableTable(TABLE_NAME);
    admin.deleteTable(TABLE_NAME);
    LOG.info(String.format("Existing table %s deleted.", TABLE_NAME));
  }
  LOG.info("Cluster ready");
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:IntegrationTestManyRegions.java

示例6: generateHBaseDatasetNullStr

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
public static void generateHBaseDatasetNullStr(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor("f"));
  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);

  Put p = new Put("a1".getBytes());
  p.addColumn("f".getBytes(), "c1".getBytes(), "".getBytes());
  p.addColumn("f".getBytes(), "c2".getBytes(), "".getBytes());
  p.addColumn("f".getBytes(), "c3".getBytes(), "5".getBytes());
  p.addColumn("f".getBytes(), "c4".getBytes(), "".getBytes());
  table.mutate(p);

  table.close();
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:26,代碼來源:TestTableGenerator.java

示例7: deleteTable

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
public static void deleteTable(HBaseTestingUtility testUtil, Admin admin, TableName tableName)
    throws Exception {
  // NOTE: We need a latch because admin is not sync,
  // so the postOp coprocessor method may be called after the admin operation returned.
  MasterSyncObserver observer = (MasterSyncObserver)testUtil.getHBaseCluster().getMaster()
    .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class.getName());
  observer.tableDeletionLatch = new CountDownLatch(1);
  try {
    admin.disableTable(tableName);
  } catch (TableNotEnabledException e) {
    LOG.debug("Table: " + tableName + " already disabled, so just deleting it.");
  }
  admin.deleteTable(tableName);
  observer.tableDeletionLatch.await();
  observer.tableDeletionLatch = null;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:SecureTestUtil.java

示例8: testAddColumn

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

示例9: setUp

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
  Admin admin = util.getHBaseAdmin();
  if (admin.tableExists(tableName)) {
    if (admin.isTableEnabled(tableName)) {
      admin.disableTable(tableName);
    }
    admin.deleteTable(tableName);
  }
  util.createTable(tableName, new byte[][] {dummy, test});
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:12,代碼來源:TestRegionObserverBypass.java

示例10: testTableExists

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Test public void testTableExists() throws IOException {
  final TableName name =
      TableName.valueOf("testTableExists");
  assertFalse(MetaTableAccessor.tableExists(connection, name));
  UTIL.createTable(name, HConstants.CATALOG_FAMILY);
  assertTrue(MetaTableAccessor.tableExists(connection, name));
  Admin admin = UTIL.getHBaseAdmin();
  admin.disableTable(name);
  admin.deleteTable(name);
  assertFalse(MetaTableAccessor.tableExists(connection, name));
  assertTrue(MetaTableAccessor.tableExists(connection,
    TableName.META_TABLE_NAME));
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:14,代碼來源:TestMetaTableAccessor.java

示例11: generateHBaseDatasetFloatOB

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
public static void generateHBaseDatasetFloatOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);

  for (float i = (float)0.5; i <= 100.00; i += 0.75) {
    byte[] bytes = new byte[5];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
    OrderedBytes.encodeFloat32(br, i,Order.ASCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %03f", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:31,代碼來源:TestTableGenerator.java

示例12: generateHBaseDatasetBigIntOB

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
public static void generateHBaseDatasetBigIntOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);
  long startTime = (long)1438034423 * 1000;
  for (long i = startTime; i <= startTime + 100; i ++) {
    byte[] bytes = new byte[9];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 9);
    OrderedBytes.encodeInt64(br, i, Order.ASCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:31,代碼來源:TestTableGenerator.java

示例13: generateHBaseDatasetIntOB

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
public static void generateHBaseDatasetIntOB(Connection conn, Admin admin, TableName tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  BufferedMutator table = conn.getBufferedMutator(tableName);

  for (int i = -49; i <= 100; i ++) {
    byte[] bytes = new byte[5];
    PositionedByteRange br = new SimplePositionedMutableByteRange(bytes, 0, 5);
    OrderedBytes.encodeInt32(br, i, Order.ASCENDING);
    Put p = new Put(bytes);
    p.addColumn(FAMILY_F, COLUMN_C, String.format("value %d", i).getBytes());
    table.mutate(p);
  }

  table.close();

  admin.flush(tableName);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:31,代碼來源:TestTableGenerator.java

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

示例15: destroy

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
private static void destroy(Admin admin, TableName tableName) throws IOException {
  try {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  } catch (TableNotFoundException tnfe) {
    /* Ignore */
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:9,代碼來源:TestSCVFWithMiniCluster.java


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