本文整理汇总了Java中org.apache.hadoop.hbase.HBaseTestingUtility.createLocalHTU方法的典型用法代码示例。如果您正苦于以下问题:Java HBaseTestingUtility.createLocalHTU方法的具体用法?Java HBaseTestingUtility.createLocalHTU怎么用?Java HBaseTestingUtility.createLocalHTU使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.HBaseTestingUtility
的用法示例。
在下文中一共展示了HBaseTestingUtility.createLocalHTU方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkShouldFlush
import org.apache.hadoop.hbase.HBaseTestingUtility; //导入方法依赖的package包/类
private void checkShouldFlush(Configuration conf, boolean expected) throws Exception {
try {
EnvironmentEdgeForMemstoreTest edge = new EnvironmentEdgeForMemstoreTest();
EnvironmentEdgeManager.injectEdge(edge);
HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf);
HRegion region = hbaseUtility.createTestRegion("foobar", new HColumnDescriptor("foo"));
List<Store> stores = region.getStores();
assertTrue(stores.size() == 1);
Store s = stores.iterator().next();
edge.setCurrentTimeMillis(1234);
s.add(KeyValueTestUtil.create("r", "f", "q", 100, "v"));
edge.setCurrentTimeMillis(1234 + 100);
StringBuffer sb = new StringBuffer();
assertTrue(region.shouldFlush(sb) == false);
edge.setCurrentTimeMillis(1234 + 10000);
assertTrue(region.shouldFlush(sb) == expected);
} finally {
EnvironmentEdgeManager.reset();
}
}
示例2: testShouldFlushMeta
import org.apache.hadoop.hbase.HBaseTestingUtility; //导入方法依赖的package包/类
public void testShouldFlushMeta() throws Exception {
// write an edit in the META and ensure the shouldFlush (that the periodic memstore
// flusher invokes) returns true after SYSTEM_CACHE_FLUSH_INTERVAL (even though
// the MEMSTORE_PERIODIC_FLUSH_INTERVAL is set to a higher value)
Configuration conf = new Configuration();
conf.setInt(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, HRegion.SYSTEM_CACHE_FLUSH_INTERVAL * 10);
HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf);
Path testDir = hbaseUtility.getDataTestDir();
EnvironmentEdgeForMemstoreTest edge = new EnvironmentEdgeForMemstoreTest();
EnvironmentEdgeManager.injectEdge(edge);
edge.setCurrentTimeMillis(1234);
WALFactory wFactory = new WALFactory(conf, null, "1234");
HRegion meta = HRegion.createHRegion(HRegionInfo.FIRST_META_REGIONINFO, testDir,
conf, HTableDescriptor.metaTableDescriptor(conf),
wFactory.getMetaWAL(HRegionInfo.FIRST_META_REGIONINFO.
getEncodedNameAsBytes()));
HRegionInfo hri = new HRegionInfo(TableName.valueOf("testShouldFlushMeta"),
Bytes.toBytes("row_0200"), Bytes.toBytes("row_0300"));
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("testShouldFlushMeta"));
desc.addFamily(new HColumnDescriptor("foo".getBytes()));
HRegion r =
HRegion.createHRegion(hri, testDir, conf, desc,
wFactory.getWAL(hri.getEncodedNameAsBytes()));
HRegion.addRegionToMETA(meta, r);
edge.setCurrentTimeMillis(1234 + 100);
StringBuffer sb = new StringBuffer();
assertTrue(meta.shouldFlush(sb) == false);
edge.setCurrentTimeMillis(edge.currentTime() + HRegion.SYSTEM_CACHE_FLUSH_INTERVAL + 1);
assertTrue(meta.shouldFlush(sb) == true);
}
示例3: setup
import org.apache.hadoop.hbase.HBaseTestingUtility; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {
TEST_UTIL = HBaseTestingUtility.createLocalHTU();
FILESYSTEM = TEST_UTIL.getTestFileSystem();
CONF = TEST_UTIL.getConfiguration();
dir = TEST_UTIL.getDataTestDir("TestHRegion").toString();
method = name.getMethodName();
tableName = Bytes.toBytes(name.getMethodName());
}
示例4: setup
import org.apache.hadoop.hbase.HBaseTestingUtility; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {
TEST_UTIL = HBaseTestingUtility.createLocalHTU();
CONF = TEST_UTIL.getConfiguration();
// Disable block cache.
CONF.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0f);
dir = TEST_UTIL.getDataTestDir("TestHRegion").toString();
tableName = TableName.valueOf(name.getMethodName());
}
示例5: setup
import org.apache.hadoop.hbase.HBaseTestingUtility; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
TEST_UTIL = HBaseTestingUtility.createLocalHTU();
rootDir = TEST_UTIL.getDataTestDir(TABLE_NAME_STR);
fs = TEST_UTIL.getTestFileSystem();
conf = TEST_UTIL.getConfiguration();
SnapshotTestingUtils.SnapshotMock snapshotMock =
new SnapshotTestingUtils.SnapshotMock(conf, fs, rootDir);
SnapshotTestingUtils.SnapshotMock.SnapshotBuilder builder =
snapshotMock.createSnapshotV2("snapshot", TABLE_NAME_STR, 0);
snapshotDir = builder.commit();
snapshotDesc = builder.getSnapshotDescription();
SnapshotDataManifest.Builder dataManifestBuilder =
SnapshotDataManifest.newBuilder();
byte[] startKey = null;
byte[] stopKey = null;
for (int i = 1; i <= TEST_NUM_REGIONS; i++) {
stopKey = Bytes.toBytes(String.format("%016d", i));
HRegionInfo regionInfo = new HRegionInfo(TABLE_NAME, startKey, stopKey, false);
SnapshotRegionManifest.Builder dataRegionManifestBuilder =
SnapshotRegionManifest.newBuilder();
for (HColumnDescriptor hcd: builder.getTableDescriptor().getFamilies()) {
SnapshotRegionManifest.FamilyFiles.Builder family =
SnapshotRegionManifest.FamilyFiles.newBuilder();
family.setFamilyName(ByteStringer.wrap(hcd.getName()));
for (int j = 0; j < 100; ++j) {
SnapshotRegionManifest.StoreFile.Builder sfManifest =
SnapshotRegionManifest.StoreFile.newBuilder();
sfManifest.setName(String.format("%032d", i));
sfManifest.setFileSize((1 + i) * (1 + i) * 1024);
family.addStoreFiles(sfManifest.build());
}
dataRegionManifestBuilder.addFamilyFiles(family.build());
}
dataRegionManifestBuilder.setRegionInfo(HRegionInfo.convert(regionInfo));
dataManifestBuilder.addRegionManifests(dataRegionManifestBuilder.build());
startKey = stopKey;
}
dataManifestBuilder.setTableSchema(builder.getTableDescriptor().convert());
SnapshotDataManifest dataManifest = dataManifestBuilder.build();
writeDataManifest(dataManifest);
}
示例6: setup
import org.apache.hadoop.hbase.HBaseTestingUtility; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {
TEST_UTIL = HBaseTestingUtility.createLocalHTU();
FILESYSTEM = TEST_UTIL.getTestFileSystem();
CONF = TEST_UTIL.getConfiguration();
dir = TEST_UTIL.getDataTestDir("TestHRegionReplayEvents").toString();
method = name.getMethodName();
tableName = Bytes.toBytes(name.getMethodName());
rootDir = new Path(dir + method);
TEST_UTIL.getConfiguration().set(HConstants.HBASE_DIR, rootDir.toString());
method = name.getMethodName();
htd = new HTableDescriptor(TableName.valueOf(method));
for (byte[] family : families) {
htd.addFamily(new HColumnDescriptor(family));
}
time = System.currentTimeMillis();
primaryHri = new HRegionInfo(htd.getTableName(),
HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW,
false, time, 0);
secondaryHri = new HRegionInfo(htd.getTableName(),
HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW,
false, time, 1);
wals = TestHRegion.createWALFactory(CONF, rootDir);
walPrimary = wals.getWAL(primaryHri.getEncodedNameAsBytes());
walSecondary = wals.getWAL(secondaryHri.getEncodedNameAsBytes());
rss = mock(RegionServerServices.class);
when(rss.getServerName()).thenReturn(ServerName.valueOf("foo", 1, 1));
when(rss.getConfiguration()).thenReturn(CONF);
when(rss.getRegionServerAccounting()).thenReturn(new RegionServerAccounting());
primaryRegion = HRegion.createHRegion(primaryHri, rootDir, CONF, htd, walPrimary);
primaryRegion.close();
primaryRegion = HRegion.openHRegion(rootDir, primaryHri, htd, walPrimary, CONF, rss, null);
secondaryRegion = HRegion.openHRegion(secondaryHri, htd, null, CONF, rss, null);
reader = null;
}