本文整理汇总了Java中org.apache.hadoop.hbase.regionserver.SplitTransaction.execute方法的典型用法代码示例。如果您正苦于以下问题:Java SplitTransaction.execute方法的具体用法?Java SplitTransaction.execute怎么用?Java SplitTransaction.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.regionserver.SplitTransaction
的用法示例。
在下文中一共展示了SplitTransaction.execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: split
import org.apache.hadoop.hbase.regionserver.SplitTransaction; //导入方法依赖的package包/类
private Region [] split(final Region r, final byte [] splitRow) throws IOException {
Region[] regions = new Region[2];
SplitTransaction st = new SplitTransactionFactory(TEST_UTIL.getConfiguration())
.create(r, splitRow);
int i = 0;
if (!st.prepare()) {
// test fails.
assertTrue(false);
}
try {
Server mockServer = Mockito.mock(Server.class);
when(mockServer.getConfiguration()).thenReturn(TEST_UTIL.getConfiguration());
PairOfSameType<Region> daughters = st.execute(mockServer, null);
for (Region each_daughter: daughters) {
regions[i] = each_daughter;
i++;
}
} catch (IOException ioe) {
LOG.info("Split transaction of " + r.getRegionInfo().getRegionNameAsString() +
" failed:" + ioe.getMessage());
assertTrue(false);
} catch (RuntimeException e) {
LOG.info("Failed rollback of failed split of " +
r.getRegionInfo().getRegionNameAsString() + e.getMessage());
}
assertTrue(i == 2);
return regions;
}
示例2: split
import org.apache.hadoop.hbase.regionserver.SplitTransaction; //导入方法依赖的package包/类
private HRegion [] split(final HRegion r, final byte [] splitRow)
throws IOException {
HRegion[] regions = new HRegion[2];
SplitTransaction st = new SplitTransaction(r, splitRow);
int i = 0;
if (!st.prepare()) {
// test fails.
assertTrue(false);
}
try {
Server mockServer = Mockito.mock(Server.class);
when(mockServer.getConfiguration()).thenReturn(
TEST_UTIL.getConfiguration());
PairOfSameType<HRegion> daughters = st.execute(mockServer, null);
for (HRegion each_daughter: daughters) {
regions[i] = each_daughter;
i++;
}
} catch (IOException ioe) {
LOG.info("Split transaction of " + r.getRegionNameAsString() +
" failed:" + ioe.getMessage());
assertTrue(false);
} catch (RuntimeException e) {
LOG.info("Failed rollback of failed split of " +
r.getRegionNameAsString() + e.getMessage());
}
assertTrue(i == 2);
return regions;
}
示例3: testIndexManagerWithFailedSplitTransaction
import org.apache.hadoop.hbase.regionserver.SplitTransaction; //导入方法依赖的package包/类
@Test(timeout = 180000)
public void testIndexManagerWithFailedSplitTransaction() throws Exception {
Configuration conf = UTIL.getConfiguration();
conf.setBoolean("hbase.use.secondary.index", true);
String userTableName = "testIndexManagerWithFailedSplitTransaction";
HTableDescriptor ihtd = new HTableDescriptor(TableName.valueOf(userTableName));
HColumnDescriptor hcd = new HColumnDescriptor("col1");
ihtd.addFamily(hcd);
IndexSpecification iSpec = new IndexSpecification("Index1");
iSpec.addIndexColumn(hcd, "ql", ValueType.String, 10);
TableIndices indices = new TableIndices();
indices.addIndex(iSpec);
ihtd.setValue(Constants.INDEX_SPEC_KEY, indices.toByteArray());
admin.createTable(ihtd);
IndexManager manager = IndexManager.getInstance();
int count = manager.getTableRegionCount(userTableName);
Assert.assertEquals(1, count);
HTable table = new HTable(conf, userTableName);
Put p = null;
for (int i = 0; i < 10; i++) {
p = new Put(Bytes.toBytes("row" + i));
p.add(Bytes.toBytes("col1"), Bytes.toBytes("ql"), Bytes.toBytes("test_val"));
table.put(p);
}
List<HRegion> regions = UTIL.getMiniHBaseCluster().getRegions(Bytes.toBytes(userTableName));
HRegionServer rs = UTIL.getMiniHBaseCluster().getRegionServer(0);
SplitTransaction st = null;
st = new MockedSplitTransaction(regions.get(0), "row5".getBytes());
try {
st.prepare();
st.execute(rs, rs);
} catch (IOException e) {
st.rollback(rs, rs);
}
count = manager.getTableRegionCount(userTableName);
Assert.assertEquals(1, count);
}
示例4: testIndexManagerWithFailedSplitTransaction
import org.apache.hadoop.hbase.regionserver.SplitTransaction; //导入方法依赖的package包/类
@Test(timeout = 180000)
public void testIndexManagerWithFailedSplitTransaction() throws Exception {
HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
Configuration conf = admin.getConfiguration();
conf.setBoolean("hbase.use.secondary.index", true);
ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(UTIL);
String userTableName = "testIndexManagerWithFailedSplitTransaction";
IndexedHTableDescriptor ihtd = new IndexedHTableDescriptor(userTableName);
HColumnDescriptor hcd = new HColumnDescriptor("col1");
ihtd.addFamily(hcd);
IndexSpecification iSpec = new IndexSpecification("Index1");
iSpec.addIndexColumn(hcd, "ql", ValueType.String, 10);
ihtd.addIndex(iSpec);
admin.createTable(ihtd);
ZKAssign.blockUntilNoRIT(zkw);
IndexManager manager = IndexManager.getInstance();
int count = manager.getTableRegionCount(userTableName);
Assert.assertEquals(1, count);
HTable table = new HTable(conf, userTableName);
Put p = null;
for (int i = 0; i < 10; i++) {
p = new Put(Bytes.toBytes("row" + i));
p.add(Bytes.toBytes("col1"), Bytes.toBytes("ql"), Bytes.toBytes("test_val"));
table.put(p);
}
List<HRegion> regions = UTIL.getMiniHBaseCluster().getRegions(Bytes.toBytes(userTableName));
HRegionServer rs = UTIL.getMiniHBaseCluster().getRegionServer(0);
SplitTransaction st = null;
st = new MockedSplitTransaction(regions.get(0), null) {
@Override
protected void splitStoreFiles(final Path splitdir, final List<StoreFile> hstoreFilesToSplit)
throws IOException {
throw new IOException();
}
};
try {
st.execute(rs, rs);
} catch (IOException e) {
st.rollback(rs, rs);
}
count = manager.getTableRegionCount(userTableName);
Assert.assertEquals(1, count);
}