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


Java Admin.majorCompact方法代碼示例

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


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

示例1: main

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
public static void main(String[] argc) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  conf.addResource(new Path("file:///", System.getProperty("oozie.action.conf.xml")));

  if (System.getenv("HADOOP_TOKEN_FILE_LOCATION") != null) {
    conf.set("mapreduce.job.credentials.binary",
             System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
  }

  Connection connection = ConnectionFactory.createConnection(conf);
  Admin admin = connection.getAdmin();

  System.out.println("Compacting table " + argc[0]);
  TableName tableName = TableName.valueOf(argc[0]);
  admin.majorCompact(tableName);
  while (admin.getCompactionState(tableName).toString() == "MAJOR") {
    TimeUnit.SECONDS.sleep(10);
    System.out.println("Compacting table " + argc[0]);
  }
  System.out.println("Done compacting table " + argc[0]);
}
 
開發者ID:cbaenziger,項目名稱:Oozie_MajorCompaction_Example,代碼行數:22,代碼來源:MajorCompaction.java

示例2: perform

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

  LOG.info("Performing action: Compact table " + tableName + ", major=" + major);
  try {
    if (major) {
      admin.majorCompact(tableName);
    } else {
      admin.compact(tableName);
    }
  } catch (Exception ex) {
    LOG.warn("Compaction failed, might be caused by other chaos: " + ex.getMessage());
  }
  if (sleepTime > 0) {
    Thread.sleep(sleepTime);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:21,代碼來源:CompactTableAction.java

示例3: testAssignmentListener

import org.apache.hadoop.hbase.client.Admin; //導入方法依賴的package包/類
@Test(timeout=60000)
public void testAssignmentListener() throws IOException, InterruptedException {
  AssignmentManager am = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager();
  Admin admin = TEST_UTIL.getHBaseAdmin();

  DummyAssignmentListener listener = new DummyAssignmentListener();
  am.registerListener(listener);
  try {
    final String TABLE_NAME_STR = "testtb";
    final TableName TABLE_NAME = TableName.valueOf(TABLE_NAME_STR);
    final byte[] FAMILY = Bytes.toBytes("cf");

    // Create a new table, with a single region
    LOG.info("Create Table");
    TEST_UTIL.createTable(TABLE_NAME, FAMILY);
    listener.awaitModifications(1);
    assertEquals(1, listener.getLoadCount());
    assertEquals(0, listener.getCloseCount());

    // Add some data
    Table table = new HTable(TEST_UTIL.getConfiguration(), TABLE_NAME);
    try {
      for (int i = 0; i < 10; ++i) {
        byte[] key = Bytes.toBytes("row-" + i);
        Put put = new Put(key);
        put.add(FAMILY, null, key);
        table.put(put);
      }
    } finally {
      table.close();
    }

    // Split the table in two
    LOG.info("Split Table");
    listener.reset();
    admin.split(TABLE_NAME, Bytes.toBytes("row-3"));
    listener.awaitModifications(3);
    assertEquals(2, listener.getLoadCount());     // daughters added
    assertEquals(1, listener.getCloseCount());    // parent removed

    // Wait for the Regions to be mergeable
    MiniHBaseCluster miniCluster = TEST_UTIL.getMiniHBaseCluster();
    int mergeable = 0;
    while (mergeable < 2) {
      Thread.sleep(100);
      admin.majorCompact(TABLE_NAME);
      mergeable = 0;
      for (JVMClusterUtil.RegionServerThread regionThread: miniCluster.getRegionServerThreads()) {
        for (Region region: regionThread.getRegionServer().getOnlineRegions(TABLE_NAME)) {
          mergeable += ((HRegion)region).isMergeable() ? 1 : 0;
        }
      }
    }

    // Merge the two regions
    LOG.info("Merge Regions");
    listener.reset();
    List<HRegionInfo> regions = admin.getTableRegions(TABLE_NAME);
    assertEquals(2, regions.size());
    admin.mergeRegions(regions.get(0).getEncodedNameAsBytes(),
      regions.get(1).getEncodedNameAsBytes(), true);
    listener.awaitModifications(3);
    assertEquals(1, admin.getTableRegions(TABLE_NAME).size());
    assertEquals(1, listener.getLoadCount());     // new merged region added
    assertEquals(2, listener.getCloseCount());    // daughters removed

    // Delete the table
    LOG.info("Drop Table");
    listener.reset();
    TEST_UTIL.deleteTable(TABLE_NAME);
    listener.awaitModifications(1);
    assertEquals(0, listener.getLoadCount());
    assertEquals(1, listener.getCloseCount());
  } finally {
    am.unregisterListener(listener);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:78,代碼來源:TestAssignmentListener.java


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