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


Java AssignmentManager.unassign方法代码示例

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


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

示例1: postMove

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
@Override
public void postMove(ObserverContext<MasterCoprocessorEnvironment> ctx, HRegionInfo regionInfo,
    ServerName srcServer, ServerName destServer) throws IOException {
  LOG.info("Entering into postMove " + regionInfo.getRegionNameAsString() + '.');
  if (!IndexUtils.isIndexTable(regionInfo.getTable().getNameAsString())) {
    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);
    try {
      am.waitOnRegionToClearRegionsInTransition(regionInfo, timeout);
      destServer = am.getRegionStates().getRegionServerOfRegion(regionInfo);
      am.getBalancer().regionOnline(regionInfo, destServer);
    } catch (InterruptedException e) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Interrupted while region in assignment.");
      }
    }
    TableName indexTableName =
        TableName.valueOf(IndexUtils.getIndexTableName(regionInfo.getTable().getNameAsString()));
    List<HRegionInfo> tableRegions = am.getRegionStates().getRegionsOfTable(indexTableName);
    for (HRegionInfo indexRegionInfo : tableRegions) {
      if (0 == Bytes.compareTo(indexRegionInfo.getStartKey(), regionInfo.getStartKey())) {
        LOG.info("Assigning region " + indexRegionInfo.getRegionNameAsString() + "from "
            + srcServer + " to server " + destServer + '.');
        am.getBalancer().regionOnline(indexRegionInfo, destServer);
        am.addPlan(indexRegionInfo.getEncodedName(), new RegionPlan(indexRegionInfo, null,
            destServer));
        am.unassign(indexRegionInfo);
      }
    }
  }
  LOG.info("Exiting from postMove " + regionInfo.getRegionNameAsString() + '.');
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:37,代码来源:IndexMasterObserver.java

示例2: 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

示例3: 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

示例4: 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

示例5: postMove

import org.apache.hadoop.hbase.master.AssignmentManager; //导入方法依赖的package包/类
@Override
public void postMove(ObserverContext<MasterCoprocessorEnvironment> ctx, HRegionInfo regionInfo,
    ServerName srcServer, ServerName destServer) throws IOException {
  LOG.info("Entering into postMove " + 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);
      destServer = am.getRegionServerOfRegion(regionInfo);
      am.putRegionPlan(regionInfo, destServer);
    } catch (InterruptedException e) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Interrupted while region in assignment.");
      }
    }
    String indexTableName = IndexUtils.getIndexTableName(regionInfo.getTableNameAsString());
    List<HRegionInfo> tableRegions = am.getRegionsOfTable(Bytes.toBytes(indexTableName));
    for (HRegionInfo indexRegionInfo : tableRegions) {
      if (0 == Bytes.compareTo(indexRegionInfo.getStartKey(), regionInfo.getStartKey())) {
        LOG.info("Assigning region " + indexRegionInfo.getRegionNameAsString() + "from "
            + srcServer + " to server " + destServer + '.');
        am.putRegionPlan(indexRegionInfo, destServer);
        am.addPlan(indexRegionInfo.getEncodedName(), new RegionPlan(indexRegionInfo, null,
            destServer));
        am.unassign(indexRegionInfo);
        /*
         * ((HMaster) master).move(indexRegionInfo.getEncodedNameAsBytes(),
         * Bytes.toBytes(destServer.getServerName()));
         */
      }
    }
  }
  LOG.info("Exiting from postMove " + regionInfo.getRegionNameAsString() + '.');
}
 
开发者ID:Huawei-Hadoop,项目名称:hindex,代码行数:43,代码来源:IndexMasterObserver.java


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