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


Java AssignmentManager.assign方法代码示例

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


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

示例1: fixupDaughter

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
/**
 * Check individual daughter is up in .META.; fixup if its not.
 * @param result The contents of the parent row in .META.
 * @param qualifier Which daughter to check for.
 * @return 1 if the daughter is missing and fixed. Otherwise 0
 * @throws IOException
 */
static int fixupDaughter(final Result result, final byte [] qualifier,
    final AssignmentManager assignmentManager,
    final CatalogTracker catalogTracker)
throws IOException {
  HRegionInfo daughter =
    MetaReader.parseHRegionInfoFromCatalogResult(result, qualifier);
  if (daughter == null) return 0;
  if (isDaughterMissing(catalogTracker, daughter)) {
    LOG.info("Fixup; missing daughter " + daughter.getRegionNameAsString());
    MetaEditor.addDaughter(catalogTracker, daughter, null);

    // TODO: Log WARN if the regiondir does not exist in the fs.  If its not
    // there then something wonky about the split -- things will keep going
    // but could be missing references to parent region.

    // And assign it.
    assignmentManager.assign(daughter, true);
    return 1;
  } else {
    LOG.debug("Daughter " + daughter.getRegionNameAsString() + " present");
  }
  return 0;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:31,代码来源:ServerShutdownHandler.java

示例2: fixupDaughter

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
/**
 * Check individual daughter is up in .META.; fixup if its not.
 * @param result The contents of the parent row in .META. - not used
 * @param daughter Which daughter to check for.
 * @return 1 if the daughter is missing and fixed. Otherwise 0
 * @throws IOException
 */
static int fixupDaughter(final Result result, HRegionInfo daughter,
    final AssignmentManager assignmentManager,
    final CatalogTracker catalogTracker)
throws IOException {
  if (daughter == null) return 0;
  if (isDaughterMissing(catalogTracker, daughter)) {
    LOG.info("Fixup; missing daughter " + daughter.getRegionNameAsString());
    MetaEditor.addDaughter(catalogTracker, daughter, null);

    // TODO: Log WARN if the regiondir does not exist in the fs.  If its not
    // there then something wonky about the split -- things will keep going
    // but could be missing references to parent region.

    // And assign it.
    assignmentManager.assign(daughter, true, true);
    return 1;
  } else {
    LOG.debug("Daughter " + daughter.getRegionNameAsString() + " present");
  }
  return 0;
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:29,代码来源:ServerShutdownHandler.java

示例3: assign

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
private boolean assign(final MasterProcedureEnv env, final List<HRegionInfo> hris)
throws InterruptedIOException {
  AssignmentManager am = env.getMasterServices().getAssignmentManager();
  try {
    am.assign(hris);
  } catch (InterruptedException ie) {
    LOG.error("Caught " + ie + " during round-robin assignment");
    throw (InterruptedIOException)new InterruptedIOException().initCause(ie);
  } catch (IOException ioe) {
    LOG.info("Caught " + ioe + " during region assignment, will retry");
    return false;
  }
  return true;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:ServerCrashProcedure.java

示例4: assignRegions

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
/**
 * Triggers a bulk assignment of the specified regions
 *
 * @param assignmentManager the Assignment Manger
 * @param regionInfos the list of regions to assign
 * @throws IOException if an error occurred during the assignment
 */
public static void assignRegions(final AssignmentManager assignmentManager,
    final List<HRegionInfo> regionInfos) throws IOException {
  try {
    assignmentManager.getRegionStates().createRegionStates(regionInfos);
    assignmentManager.assign(regionInfos);
  } catch (InterruptedException e) {
    LOG.error("Caught " + e + " during round-robin assignment");
    InterruptedIOException ie = new InterruptedIOException(e.getMessage());
    ie.initCause(e);
    throw ie;
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:ModifyRegionUtils.java

示例5: postAssign

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
@Override
public void postAssign(ObserverContext<MasterCoprocessorEnvironment> ctx, HRegionInfo regionInfo)
    throws IOException {
  LOG.info("Entering into postAssign of region " + regionInfo.getRegionNameAsString() + '.');

  if (!IndexUtils.isIndexTable(regionInfo.getTable().getName())) {
    MasterServices master = ctx.getEnvironment().getMasterServices();
    LoadBalancer balancer = master.getAssignmentManager().getBalancer();
    AssignmentManager am = master.getAssignmentManager();
    RegionStates regionStates = am.getRegionStates();
    // waiting until user region is removed from transition.
    long timeout =
        master.getConfiguration()
            .getLong("hbase.bulk.assignment.waiton.empty.rit", 5 * 60 * 1000);
    try {
      am.waitOnRegionToClearRegionsInTransition(regionInfo, timeout);
    } catch (InterruptedException e) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Interrupted while region in assignment.");
      }
    }
    ServerName sn = regionStates.getRegionServerOfRegion(regionInfo);
    TableName indexTableName =
        TableName.valueOf(IndexUtils.getIndexTableName(regionInfo.getTableName()));
    List<HRegionInfo> tableRegions = regionStates.getRegionsOfTable(indexTableName);
    for (HRegionInfo hRegionInfo : tableRegions) {
      if (0 == Bytes.compareTo(hRegionInfo.getStartKey(), regionInfo.getStartKey())) {
        am.addPlan(hRegionInfo.getEncodedName(), new RegionPlan(hRegionInfo, null, sn));
        LOG.info("Assigning region " + hRegionInfo.getRegionNameAsString() + " to server " + sn
            + '.');
        balancer.regionOnline(hRegionInfo, sn);
        am.assign(hRegionInfo, true, false);
        break;
      }
    }
  }
  LOG.info("Exiting from postAssign " + regionInfo.getRegionNameAsString() + '.');
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:39,代码来源:IndexMasterObserver.java

示例6: postAssign

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
@Override
public void postAssign(ObserverContext<MasterCoprocessorEnvironment> ctx, HRegionInfo regionInfo)
    throws IOException {
  LOG.info("Entering into postAssign of region " + regionInfo.getRegionNameAsString() + '.');

  if (false == regionInfo.getTableNameAsString().endsWith(Constants.INDEX_TABLE_SUFFIX)) {
    MasterServices master = ctx.getEnvironment().getMasterServices();
    AssignmentManager am = master.getAssignmentManager();
    // waiting until user region is removed from transition.
    long timeout =
        master.getConfiguration()
            .getLong("hbase.bulk.assignment.waiton.empty.rit", 5 * 60 * 1000);
    Set<HRegionInfo> regionSet = new HashSet<HRegionInfo>(1);
    regionSet.add(regionInfo);
    try {
      am.waitUntilNoRegionsInTransition(timeout, regionSet);
      am.waitForAssignment(regionInfo, timeout);
    } catch (InterruptedException e) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Interrupted while region in assignment.");
      }
    }
    ServerName sn = am.getRegionServerOfRegion(regionInfo);
    String indexTableName = IndexUtils.getIndexTableName(regionInfo.getTableNameAsString());
    List<HRegionInfo> tableRegions = am.getRegionsOfTable(Bytes.toBytes(indexTableName));
    for (HRegionInfo hRegionInfo : tableRegions) {
      if (0 == Bytes.compareTo(hRegionInfo.getStartKey(), regionInfo.getStartKey())) {
        am.addPlan(hRegionInfo.getEncodedName(), new RegionPlan(hRegionInfo, null, sn));
        LOG.info("Assigning region " + hRegionInfo.getRegionNameAsString() + " to server " + sn
            + '.');
        am.assign(hRegionInfo, true, false, false);
      }
    }
  }
  LOG.info("Exiting from postAssign " + regionInfo.getRegionNameAsString() + '.');
}
 
开发者ID:Huawei-Hadoop,项目名称:hindex,代码行数:37,代码来源:IndexMasterObserver.java

示例7: testCleanUpDaughtersNotInMetaAfterFailedSplit

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的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")));
    createTable(TEST_UTIL, desc, null);
    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).getRegionInfo().getRegionName());
    HRegionServer regionServer = cluster.getRegionServer(serverWith);
    cluster.getServerWith(regions.get(0).getRegionInfo().getRegionName());
    SplitTransactionImpl st = new SplitTransactionImpl(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:fengchen8086,项目名称:ditb,代码行数:57,代码来源:TestHBaseFsck.java

示例8: testWholesomeMerge

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
@Test
public void testWholesomeMerge() throws Exception {
  LOG.info("Starting testWholesomeMerge");
  final TableName tableName =
      TableName.valueOf("testWholesomeMerge");

  // Create table and load data.
  Table table = createTableAndLoadData(master, tableName);
  // Merge 1st and 2nd region
  mergeRegionsAndVerifyRegionNum(master, tableName, 0, 1,
      INITIAL_REGION_NUM - 1);

  // Merge 2nd and 3th region
  PairOfSameType<HRegionInfo> mergedRegions =
    mergeRegionsAndVerifyRegionNum(master, tableName, 1, 2,
      INITIAL_REGION_NUM - 2);

  verifyRowCount(table, ROWSIZE);

  // Randomly choose one of the two merged regions
  HRegionInfo hri = RandomUtils.nextBoolean() ?
    mergedRegions.getFirst() : mergedRegions.getSecond();
  MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
  AssignmentManager am = cluster.getMaster().getAssignmentManager();
  RegionStates regionStates = am.getRegionStates();
  long start = EnvironmentEdgeManager.currentTime();
  while (!regionStates.isRegionInState(hri, State.MERGED)) {
    assertFalse("Timed out in waiting one merged region to be in state MERGED",
      EnvironmentEdgeManager.currentTime() - start > 60000);
    Thread.sleep(500);
  }

  // We should not be able to assign it again
  am.assign(hri, true, true);
  assertFalse("Merged region can't be assigned",
    regionStates.isRegionInTransition(hri));
  assertTrue(regionStates.isRegionInState(hri, State.MERGED));

  // We should not be able to unassign it either
  am.unassign(hri, true, null);
  assertFalse("Merged region can't be unassigned",
    regionStates.isRegionInTransition(hri));
  assertTrue(regionStates.isRegionInState(hri, State.MERGED));

  table.close();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:47,代码来源:TestRegionMergeTransactionOnCluster.java

示例9: testCleanUpDaughtersNotInMetaAfterFailedSplit

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的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

示例10: testWholesomeMerge

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
@Test
public void testWholesomeMerge() throws Exception {
  LOG.info("Starting testWholesomeMerge");
  final TableName tableName =
      TableName.valueOf("testWholesomeMerge");

  // Create table and load data.
  HTable table = createTableAndLoadData(master, tableName);
  // Merge 1st and 2nd region
  mergeRegionsAndVerifyRegionNum(master, tableName, 0, 1,
      INITIAL_REGION_NUM - 1);

  // Merge 2nd and 3th region
  PairOfSameType<HRegionInfo> mergedRegions =
    mergeRegionsAndVerifyRegionNum(master, tableName, 1, 2,
      INITIAL_REGION_NUM - 2);

  verifyRowCount(table, ROWSIZE);

  // Randomly choose one of the two merged regions
  HRegionInfo hri = RandomUtils.nextBoolean() ?
    mergedRegions.getFirst() : mergedRegions.getSecond();
  MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
  AssignmentManager am = cluster.getMaster().getAssignmentManager();
  RegionStates regionStates = am.getRegionStates();
  long start = EnvironmentEdgeManager.currentTimeMillis();
  while (!regionStates.isRegionInState(hri, State.MERGED)) {
    assertFalse("Timed out in waiting one merged region to be in state MERGED",
      EnvironmentEdgeManager.currentTimeMillis() - start > 60000);
    Thread.sleep(500);
  }

  // We should not be able to assign it again
  am.assign(hri, true, true);
  assertFalse("Merged region can't be assigned",
    regionStates.isRegionInTransition(hri));
  assertTrue(regionStates.isRegionInState(hri, State.MERGED));

  // We should not be able to unassign it either
  am.unassign(hri, true, null);
  assertFalse("Merged region can't be unassigned",
    regionStates.isRegionInTransition(hri));
  assertTrue(regionStates.isRegionInState(hri, State.MERGED));

  table.close();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:47,代码来源:TestRegionMergeTransactionOnCluster.java

示例11: testSplitRegionNotAssignable

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
/**
 * After a region is split, it should not be able to assign again
 */
@Test
public void testSplitRegionNotAssignable() throws Exception {
  final TableName tableName =
      TableName.valueOf("testSplitRegionWithNoStoreFiles");
  // Create table then get the single region for our new table.
  HTable t = createTableAndWait(tableName.getName(), CF);
  try {
    List<HRegion> regions = cluster.getRegions(tableName);
    int regionServerIndex = cluster.getServerWith(regions.get(0).getRegionName());
    HRegionServer regionServer = cluster.getRegionServer(regionServerIndex);
    insertData(tableName.getName(), admin, t);
    // Turn off balancer so it doesn't cut in and mess up our placements.
    admin.setBalancerRunning(false, true);
    // Turn off the meta scanner so it don't remove parent on us.
    cluster.getMaster().setCatalogJanitorEnabled(false);
    final HRegion region = findSplittableRegion(regions);
    assertTrue("not able to find a splittable region", region != null);

    // Now split.
    SplitTransaction st = new MockedSplitTransaction(region, Bytes.toBytes("row2"));
    try {
      st.prepare();
      st.execute(regionServer, regionServer);
    } catch (IOException e) {
      fail("Split execution should have succeeded with no exceptions thrown");
    }

    List<HRegion> daughters = cluster.getRegions(tableName);
    assertTrue(daughters.size() == regions.size() + 1);

    HRegionInfo hri = region.getRegionInfo(); // split parent
    AssignmentManager am = cluster.getMaster().getAssignmentManager();
    RegionStates regionStates = am.getRegionStates();
    long start = EnvironmentEdgeManager.currentTimeMillis();
    while (!regionStates.isRegionInState(hri, State.SPLIT)) {
      assertFalse("Timed out in waiting split parent to be in state SPLIT",
        EnvironmentEdgeManager.currentTimeMillis() - start > 60000);
      Thread.sleep(500);
    }

    // We should not be able to assign it again
    am.assign(hri, true, true);
    assertFalse("Split region can't be assigned",
      regionStates.isRegionInTransition(hri));
    assertTrue(regionStates.isRegionInState(hri, State.SPLIT));

    // We should not be able to unassign it either
    am.unassign(hri, true, null);
    assertFalse("Split region can't be unassigned",
      regionStates.isRegionInTransition(hri));
    assertTrue(regionStates.isRegionInState(hri, State.SPLIT));
  } finally {
    admin.setBalancerRunning(true, false);
    cluster.getMaster().setCatalogJanitorEnabled(true);
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:60,代码来源:TestSplitTransactionOnCluster.java


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