当前位置: 首页>>代码示例>>Java>>正文


Java SnapshotTestingUtils.waitForTableToBeOnline方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils.waitForTableToBeOnline方法的典型用法代码示例。如果您正苦于以下问题:Java SnapshotTestingUtils.waitForTableToBeOnline方法的具体用法?Java SnapshotTestingUtils.waitForTableToBeOnline怎么用?Java SnapshotTestingUtils.waitForTableToBeOnline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils的用法示例。


在下文中一共展示了SnapshotTestingUtils.waitForTableToBeOnline方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMobTable

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
private void createMobTable(final HBaseTestingUtility util, final TableName tableName,
  final byte[][] splitKeys, int regionReplication, final byte[]... families) throws IOException,
  InterruptedException {
  HTableDescriptor htd = new HTableDescriptor(tableName);
  htd.setRegionReplication(regionReplication);
  htd.addCoprocessor(DelayFlushCoprocessor.class.getName());
  for (byte[] family : families) {
    HColumnDescriptor hcd = new HColumnDescriptor(family);
    hcd.setMobEnabled(true);
    hcd.setMobThreshold(0L);
    htd.addFamily(hcd);
  }
  util.getAdmin().createTable(htd, splitKeys);
  SnapshotTestingUtils.waitForTableToBeOnline(util, tableName);
  assertEquals((splitKeys.length + 1) * regionReplication,
    util.getAdmin().getTableRegions(tableName).size());
}
 
开发者ID:apache,项目名称:hbase,代码行数:18,代码来源:TestMobCloneSnapshotFromClient.java

示例2: waitRegionsAfterMerge

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
private void waitRegionsAfterMerge(final long numRegionsAfterMerge)
    throws IOException, InterruptedException {
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // Verify that there's one region less
  long startTime = System.currentTimeMillis();
  while (admin.getTableRegions(TABLE_NAME).size() != numRegionsAfterMerge) {
    // This may be flaky... if after 15sec the merge is not complete give up
    // it will fail in the assertEquals(numRegionsAfterMerge).
    if ((System.currentTimeMillis() - startTime) > 15000)
      break;
    Thread.sleep(100);
  }
  SnapshotTestingUtils.waitForTableToBeOnline(UTIL, TABLE_NAME);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:15,代码来源:TestFlushSnapshotFromClient.java

示例3: testSnapshotStateAfterMerge

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testSnapshotStateAfterMerge() throws Exception {
  int numRows = DEFAULT_NUM_ROWS;
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);
  // load the table so we have some data
  SnapshotTestingUtils.loadData(UTIL, TABLE_NAME, numRows, TEST_FAM);

  // Take a snapshot
  String snapshotBeforeMergeName = "snapshotBeforeMerge";
  admin.snapshot(snapshotBeforeMergeName, STRING_TABLE_NAME, SnapshotDescription.Type.FLUSH);

  // Clone the table
  String cloneBeforeMergeName = "cloneBeforeMerge";
  admin.cloneSnapshot(snapshotBeforeMergeName, cloneBeforeMergeName);
  SnapshotTestingUtils.waitForTableToBeOnline(UTIL, TableName.valueOf(cloneBeforeMergeName));

  // Merge two regions
  List<HRegionInfo> regions = admin.getTableRegions(TABLE_NAME);
  Collections.sort(regions, new Comparator<HRegionInfo>() {
    public int compare(HRegionInfo r1, HRegionInfo r2) {
      return Bytes.compareTo(r1.getStartKey(), r2.getStartKey());
    }
  });

  int numRegions = admin.getTableRegions(TABLE_NAME).size();
  int numRegionsAfterMerge = numRegions - 2;
  admin.mergeRegions(regions.get(1).getEncodedNameAsBytes(),
      regions.get(2).getEncodedNameAsBytes(), true);
  admin.mergeRegions(regions.get(5).getEncodedNameAsBytes(),
      regions.get(6).getEncodedNameAsBytes(), true);

  // Verify that there's one region less
  waitRegionsAfterMerge(numRegionsAfterMerge);
  assertEquals(numRegionsAfterMerge, admin.getTableRegions(TABLE_NAME).size());

  // Clone the table
  String cloneAfterMergeName = "cloneAfterMerge";
  admin.cloneSnapshot(snapshotBeforeMergeName, cloneAfterMergeName);
  SnapshotTestingUtils.waitForTableToBeOnline(UTIL, TableName.valueOf(cloneAfterMergeName));

  SnapshotTestingUtils.verifyRowCount(UTIL, TABLE_NAME, numRows);
  SnapshotTestingUtils.verifyRowCount(UTIL, TableName.valueOf(cloneBeforeMergeName), numRows);
  SnapshotTestingUtils.verifyRowCount(UTIL, TableName.valueOf(cloneAfterMergeName), numRows);

  // test that we can delete the snapshot
  UTIL.deleteTable(cloneAfterMergeName);
  UTIL.deleteTable(cloneBeforeMergeName);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:51,代码来源:TestFlushSnapshotFromClient.java

示例4: testTakeSnapshotAfterMerge

import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testTakeSnapshotAfterMerge() throws Exception {
  int numRows = DEFAULT_NUM_ROWS;
  HBaseAdmin admin = UTIL.getHBaseAdmin();
  // make sure we don't fail on listing snapshots
  SnapshotTestingUtils.assertNoSnapshots(admin);
  // load the table so we have some data
  SnapshotTestingUtils.loadData(UTIL, TABLE_NAME, numRows, TEST_FAM);

  // Merge two regions
  List<HRegionInfo> regions = admin.getTableRegions(TABLE_NAME);
  Collections.sort(regions, new Comparator<HRegionInfo>() {
    public int compare(HRegionInfo r1, HRegionInfo r2) {
      return Bytes.compareTo(r1.getStartKey(), r2.getStartKey());
    }
  });

  int numRegions = admin.getTableRegions(TABLE_NAME).size();
  int numRegionsAfterMerge = numRegions - 2;
  admin.mergeRegions(regions.get(1).getEncodedNameAsBytes(),
      regions.get(2).getEncodedNameAsBytes(), true);
  admin.mergeRegions(regions.get(5).getEncodedNameAsBytes(),
      regions.get(6).getEncodedNameAsBytes(), true);

  waitRegionsAfterMerge(numRegionsAfterMerge);
  assertEquals(numRegionsAfterMerge, admin.getTableRegions(TABLE_NAME).size());

  // Take a snapshot
  String snapshotName = "snapshotAfterMerge";
  SnapshotTestingUtils.snapshot(admin, snapshotName, STRING_TABLE_NAME,
    SnapshotDescription.Type.FLUSH, 3);

  // Clone the table
  String cloneName = "cloneMerge";
  admin.cloneSnapshot(snapshotName, cloneName);
  SnapshotTestingUtils.waitForTableToBeOnline(UTIL, TableName.valueOf(cloneName));

  SnapshotTestingUtils.verifyRowCount(UTIL, TABLE_NAME, numRows);
  SnapshotTestingUtils.verifyRowCount(UTIL, TableName.valueOf(cloneName), numRows);

  // test that we can delete the snapshot
  UTIL.deleteTable(cloneName);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:44,代码来源:TestFlushSnapshotFromClient.java


注:本文中的org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils.waitForTableToBeOnline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。