本文整理汇总了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();
}
示例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();
}
示例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();
}