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


Java Store.triggerMajorCompaction方法代码示例

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


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

示例1: testReplayEditsAfterRegionMovedWithMultiCF

import org.apache.hadoop.hbase.regionserver.Store; //导入方法依赖的package包/类
/**
 * 
 * @throws Exception
 */
@Test
public void testReplayEditsAfterRegionMovedWithMultiCF() throws Exception {
  final byte[] tableName = Bytes
      .toBytes("testReplayEditsAfterRegionMovedWithMultiCF");
  byte[] family1 = Bytes.toBytes("cf1");
  byte[] family2 = Bytes.toBytes("cf2");
  byte[] qualifier = Bytes.toBytes("q");
  byte[] value = Bytes.toBytes("testV");
  byte[][] familys = { family1, family2 };
  TEST_UTIL.createTable(tableName, familys);
  HTable htable = new HTable(TEST_UTIL.getConfiguration(), tableName);
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(family1, qualifier, value);
  htable.put(put);
  ResultScanner resultScanner = htable.getScanner(new Scan());
  int count = 0;
  while (resultScanner.next() != null) {
    count++;
  }
  resultScanner.close();
  assertEquals(1, count);

  MiniHBaseCluster hbaseCluster = TEST_UTIL.getMiniHBaseCluster();
  List<HRegion> regions = hbaseCluster.getRegions(tableName);
  assertEquals(1, regions.size());

  // move region to another regionserver
  HRegion destRegion = regions.get(0);
  int originServerNum = hbaseCluster
      .getServerWith(destRegion.getRegionName());
  assertTrue("Please start more than 1 regionserver", hbaseCluster
      .getRegionServerThreads().size() > 1);
  int destServerNum = 0;
  while (destServerNum == originServerNum) {
    destServerNum++;
  }
  HRegionServer originServer = hbaseCluster.getRegionServer(originServerNum);
  HRegionServer destServer = hbaseCluster.getRegionServer(destServerNum);
  // move region to destination regionserver
  moveRegionAndWait(destRegion, destServer);

  // delete the row
  Delete del = new Delete(Bytes.toBytes("r1"));
  htable.delete(del);
  resultScanner = htable.getScanner(new Scan());
  count = 0;
  while (resultScanner.next() != null) {
    count++;
  }
  resultScanner.close();
  assertEquals(0, count);

  // flush region and make major compaction
  destServer.getOnlineRegion(destRegion.getRegionName()).flushcache();
  // wait to complete major compaction
  for (Store store : destServer.getOnlineRegion(destRegion.getRegionName())
      .getStores().values()) {
    store.triggerMajorCompaction();
  }
  destServer.getOnlineRegion(destRegion.getRegionName()).compactStores();

  // move region to origin regionserver
  moveRegionAndWait(destRegion, originServer);
  // abort the origin regionserver
  originServer.abort("testing");

  // see what we get
  Result result = htable.get(new Get(Bytes.toBytes("r1")));
  if (result != null) {
    assertTrue("Row is deleted, but we get" + result.toString(),
        (result == null) || result.isEmpty());
  }
  resultScanner.close();
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:79,代码来源:TestWALReplay.java

示例2: testReplayEditsAfterRegionMovedWithMultiCF

import org.apache.hadoop.hbase.regionserver.Store; //导入方法依赖的package包/类
/**
 *
 * @throws Exception
 */
@Test
public void testReplayEditsAfterRegionMovedWithMultiCF() throws Exception {
  final TableName tableName =
      TableName.valueOf("testReplayEditsAfterRegionMovedWithMultiCF");
  byte[] family1 = Bytes.toBytes("cf1");
  byte[] family2 = Bytes.toBytes("cf2");
  byte[] qualifier = Bytes.toBytes("q");
  byte[] value = Bytes.toBytes("testV");
  byte[][] familys = { family1, family2 };
  TEST_UTIL.createTable(tableName, familys);
  Table htable = new HTable(TEST_UTIL.getConfiguration(), tableName);
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(family1, qualifier, value);
  htable.put(put);
  ResultScanner resultScanner = htable.getScanner(new Scan());
  int count = 0;
  while (resultScanner.next() != null) {
    count++;
  }
  resultScanner.close();
  assertEquals(1, count);

  MiniHBaseCluster hbaseCluster = TEST_UTIL.getMiniHBaseCluster();
  List<HRegion> regions = hbaseCluster.getRegions(tableName);
  assertEquals(1, regions.size());

  // move region to another regionserver
  HRegion destRegion = regions.get(0);
  int originServerNum = hbaseCluster
      .getServerWith(destRegion.getRegionName());
  assertTrue("Please start more than 1 regionserver", hbaseCluster
      .getRegionServerThreads().size() > 1);
  int destServerNum = 0;
  while (destServerNum == originServerNum) {
    destServerNum++;
  }
  HRegionServer originServer = hbaseCluster.getRegionServer(originServerNum);
  HRegionServer destServer = hbaseCluster.getRegionServer(destServerNum);
  // move region to destination regionserver
  moveRegionAndWait(destRegion, destServer);

  // delete the row
  Delete del = new Delete(Bytes.toBytes("r1"));
  htable.delete(del);
  resultScanner = htable.getScanner(new Scan());
  count = 0;
  while (resultScanner.next() != null) {
    count++;
  }
  resultScanner.close();
  assertEquals(0, count);

  // flush region and make major compaction
  destServer.getOnlineRegion(destRegion.getRegionName()).flushcache();
  // wait to complete major compaction
  for (Store store : destServer.getOnlineRegion(destRegion.getRegionName())
      .getStores().values()) {
    store.triggerMajorCompaction();
  }
  destServer.getOnlineRegion(destRegion.getRegionName()).compactStores();

  // move region to origin regionserver
  moveRegionAndWait(destRegion, originServer);
  // abort the origin regionserver
  originServer.abort("testing");

  // see what we get
  Result result = htable.get(new Get(Bytes.toBytes("r1")));
  if (result != null) {
    assertTrue("Row is deleted, but we get" + result.toString(),
        (result == null) || result.isEmpty());
  }
  resultScanner.close();
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:79,代码来源:TestWALReplay.java

示例3: testReplayEditsAfterRegionMovedWithMultiCF

import org.apache.hadoop.hbase.regionserver.Store; //导入方法依赖的package包/类
/**
 * 
 * @throws Exception
 */
@Test
public void testReplayEditsAfterRegionMovedWithMultiCF() throws Exception {
  final TableName tableName =
      TableName.valueOf("testReplayEditsAfterRegionMovedWithMultiCF");
  byte[] family1 = Bytes.toBytes("cf1");
  byte[] family2 = Bytes.toBytes("cf2");
  byte[] qualifier = Bytes.toBytes("q");
  byte[] value = Bytes.toBytes("testV");
  byte[][] familys = { family1, family2 };
  TEST_UTIL.createTable(tableName, familys);
  HTable htable = new HTable(TEST_UTIL.getConfiguration(), tableName);
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(family1, qualifier, value);
  htable.put(put);
  ResultScanner resultScanner = htable.getScanner(new Scan());
  int count = 0;
  while (resultScanner.next() != null) {
    count++;
  }
  resultScanner.close();
  assertEquals(1, count);

  MiniHBaseCluster hbaseCluster = TEST_UTIL.getMiniHBaseCluster();
  List<HRegion> regions = hbaseCluster.getRegions(tableName);
  assertEquals(1, regions.size());

  // move region to another regionserver
  HRegion destRegion = regions.get(0);
  int originServerNum = hbaseCluster
      .getServerWith(destRegion.getRegionName());
  assertTrue("Please start more than 1 regionserver", hbaseCluster
      .getRegionServerThreads().size() > 1);
  int destServerNum = 0;
  while (destServerNum == originServerNum) {
    destServerNum++;
  }
  HRegionServer originServer = hbaseCluster.getRegionServer(originServerNum);
  HRegionServer destServer = hbaseCluster.getRegionServer(destServerNum);
  // move region to destination regionserver
  moveRegionAndWait(destRegion, destServer);

  // delete the row
  Delete del = new Delete(Bytes.toBytes("r1"));
  htable.delete(del);
  resultScanner = htable.getScanner(new Scan());
  count = 0;
  while (resultScanner.next() != null) {
    count++;
  }
  resultScanner.close();
  assertEquals(0, count);

  // flush region and make major compaction
  destServer.getOnlineRegion(destRegion.getRegionName()).flushcache();
  // wait to complete major compaction
  for (Store store : destServer.getOnlineRegion(destRegion.getRegionName())
      .getStores().values()) {
    store.triggerMajorCompaction();
  }
  destServer.getOnlineRegion(destRegion.getRegionName()).compactStores();

  // move region to origin regionserver
  moveRegionAndWait(destRegion, originServer);
  // abort the origin regionserver
  originServer.abort("testing");

  // see what we get
  Result result = htable.get(new Get(Bytes.toBytes("r1")));
  if (result != null) {
    assertTrue("Row is deleted, but we get" + result.toString(),
        (result == null) || result.isEmpty());
  }
  resultScanner.close();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:79,代码来源:TestWALReplay.java


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