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


Java SplitTransaction.prepare方法代码示例

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


在下文中一共展示了SplitTransaction.prepare方法的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;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:TestCoprocessorInterface.java

示例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;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:34,代码来源:TestCoprocessorInterface.java

示例3: testCleanUpDaughtersNotInMetaAfterFailedSplit

import org.apache.hadoop.hbase.regionserver.SplitTransaction; //导入方法依赖的package包/类
@Test (timeout=180000)
public void testCleanUpDaughtersNotInMetaAfterFailedSplit() throws Exception {
  TableName table = TableName.valueOf("testCleanUpDaughtersNotInMetaAfterFailedSplit");
  MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
  try {
    HTableDescriptor desc = new HTableDescriptor(table);
    desc.addFamily(new HColumnDescriptor(Bytes.toBytes("f")));
    admin.createTable(desc);
    tbl = new HTable(cluster.getConfiguration(), desc.getTableName());
    for (int i = 0; i < 5; i++) {
      Put p1 = new Put(("r" + i).getBytes());
      p1.add(Bytes.toBytes("f"), "q1".getBytes(), "v".getBytes());
      tbl.put(p1);
    }
    admin.flush(desc.getTableName());
    List<HRegion> regions = cluster.getRegions(desc.getTableName());
    int serverWith = cluster.getServerWith(regions.get(0).getRegionName());
    HRegionServer regionServer = cluster.getRegionServer(serverWith);
    cluster.getServerWith(regions.get(0).getRegionName());
    SplitTransaction st = new SplitTransaction(regions.get(0), Bytes.toBytes("r3"));
    st.prepare();
    st.stepsBeforePONR(regionServer, regionServer, false);
    AssignmentManager am = cluster.getMaster().getAssignmentManager();
    Map<String, RegionState> regionsInTransition = am.getRegionStates().getRegionsInTransition();
    for (RegionState state : regionsInTransition.values()) {
      am.regionOffline(state.getRegion());
    }
    ZKAssign.deleteNodeFailSilent(regionServer.getZooKeeper(), regions.get(0).getRegionInfo());
    Map<HRegionInfo, ServerName> regionsMap = new HashMap<HRegionInfo, ServerName>();
    regionsMap.put(regions.get(0).getRegionInfo(), regionServer.getServerName());
    am.assign(regionsMap);
    am.waitForAssignment(regions.get(0).getRegionInfo());
    HBaseFsck hbck = doFsck(conf, false);
    assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.NOT_IN_META_OR_DEPLOYED,
        ERROR_CODE.NOT_IN_META_OR_DEPLOYED });
    // holes are separate from overlap groups
    assertEquals(0, hbck.getOverlapGroups(table).size());

    // fix hole
    assertErrors(
      doFsck(
        conf, false, true, false, false, false, false, false, false, false, false, false, null),
      new ERROR_CODE[] { ERROR_CODE.NOT_IN_META_OR_DEPLOYED,
        ERROR_CODE.NOT_IN_META_OR_DEPLOYED });

    // check that hole fixed
    assertNoErrors(doFsck(conf, false));
    assertEquals(5, countRows());
  } finally {
    if (tbl != null) {
      tbl.close();
      tbl = null;
    }
    cleanupTable(table);
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:57,代码来源:TestHBaseFsck.java

示例4: 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);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:42,代码来源:TestIndexRegionObserver.java


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