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


Java ProtobufUtil.getOnlineRegions方法代码示例

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


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

示例1: testCloseRegionIfInvalidRegionNameIsPassed

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion1");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(TABLENAME));
  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion1")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName("sample", rs.getServerName()
            .getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:TestAdmin2.java

示例2: testCloseRegionWhenServerNameIsNull

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testCloseRegionWhenServerNameIsNull() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion3");
  createTableWithDefaultConf(TABLENAME);

  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(TABLENAME));

  try {
    List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
    for (HRegionInfo regionInfo : onlineRegions) {
      if (!regionInfo.isMetaTable()) {
        if (regionInfo.getRegionNameAsString()
            .contains("TestHBACloseRegion3")) {
          admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(),
              null);
        }
      }
    }
    fail("The test should throw exception if the servername passed is null.");
  } catch (IllegalArgumentException e) {
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestAdmin2.java

示例3: testCloseRegionWhenServerNameIsEmpty

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testCloseRegionWhenServerNameIsEmpty() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegionWhenServerNameIsEmpty");
  createTableWithDefaultConf(TABLENAME);

  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(TABLENAME));

  try {
    List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
    for (HRegionInfo regionInfo : onlineRegions) {
      if (!regionInfo.isMetaTable()) {
        if (regionInfo.getRegionNameAsString()
            .contains("TestHBACloseRegionWhenServerNameIsEmpty")) {
          admin.closeRegionWithEncodedRegionName(regionInfo.getEncodedName(),
              " ");
        }
      }
    }
    fail("The test should throw exception if the servername passed is empty.");
  } catch (IllegalArgumentException e) {
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestAdmin2.java

示例4: testCloseRegionWhenEncodedRegionNameIsNotGiven

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Test (timeout=300000)
public void testCloseRegionWhenEncodedRegionNameIsNotGiven() throws Exception {
  byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion4");
  createTableWithDefaultConf(TABLENAME);

  HRegionInfo info = null;
  HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TableName.valueOf(TABLENAME));

  List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  for (HRegionInfo regionInfo : onlineRegions) {
    if (!regionInfo.isMetaTable()) {
      if (regionInfo.getRegionNameAsString().contains("TestHBACloseRegion4")) {
        info = regionInfo;
        try {
          admin.closeRegionWithEncodedRegionName(regionInfo
            .getRegionNameAsString(), rs.getServerName().getServerName());
        } catch (NotServingRegionException nsre) {
          // expected, ignore it.
        }
      }
    }
  }
  onlineRegions = ProtobufUtil.getOnlineRegions(rs.getRSRpcServices());
  assertTrue("The region should be present in online regions list.",
      onlineRegions.contains(info));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:TestAdmin2.java

示例5: getDeployedHRIs

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
/**
 * Get region info from local cluster.
 */
Map<ServerName, List<String>> getDeployedHRIs(final HBaseAdmin admin) throws IOException {
  ClusterStatus status = admin.getClusterStatus();
  Collection<ServerName> regionServers = status.getServers();
  Map<ServerName, List<String>> mm =
      new HashMap<ServerName, List<String>>();
  for (ServerName hsi : regionServers) {
    AdminProtos.AdminService.BlockingInterface server = ((HConnection) connection).getAdmin(hsi);

    // list all online regions from this region server
    List<HRegionInfo> regions = ProtobufUtil.getOnlineRegions(server);
    List<String> regionNames = new ArrayList<String>();
    for (HRegionInfo hri : regions) {
      regionNames.add(hri.getRegionNameAsString());
    }
    mm.put(hsi, regionNames);
  }
  return mm;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:TestHBaseFsck.java

示例6: call

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
@Override
public synchronized Void call() throws IOException {
  errors.progress();
  try {
    BlockingInterface server = connection.getAdmin(rsinfo);

    // list all online regions from this region server
    List<HRegionInfo> regions = ProtobufUtil.getOnlineRegions(server);
    regions = filterRegions(regions);

    if (details) {
      errors.detail("RegionServer: " + rsinfo.getServerName() +
                       " number of regions: " + regions.size());
      for (HRegionInfo rinfo: regions) {
        errors.detail("  " + rinfo.getRegionNameAsString() +
                         " id: " + rinfo.getRegionId() +
                         " encoded_name: " + rinfo.getEncodedName() +
                         " start: " + Bytes.toStringBinary(rinfo.getStartKey()) +
                         " end: " + Bytes.toStringBinary(rinfo.getEndKey()));
      }
    }

    // check to see if the existence of this region matches the region in META
    for (HRegionInfo r:regions) {
      HbckInfo hbi = hbck.getOrCreateInfo(r.getEncodedName());
      hbi.addServer(r, rsinfo);
    }
  } catch (IOException e) {          // unable to connect to the region server.
    errors.reportError(ERROR_CODE.RS_CONNECT_FAILURE, "RegionServer: " + rsinfo.getServerName() +
      " Unable to fetch region information. " + e);
    throw e;
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:35,代码来源:HBaseFsck.java

示例7: getDoubleAssignedRegions

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
private NavigableSet<String> getDoubleAssignedRegions(
    MiniHBaseCluster cluster) throws IOException {
  NavigableSet<String> online = new TreeSet<String>();
  NavigableSet<String> doubled = new TreeSet<String>();
  for (RegionServerThread rst : cluster.getLiveRegionServerThreads()) {
    for (HRegionInfo region : ProtobufUtil.getOnlineRegions(
        rst.getRegionServer().getRSRpcServices())) {
      if(!online.add(region.getRegionNameAsString())) {
        doubled.add(region.getRegionNameAsString());
      }
    }
  }
  return doubled;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:TestRollingRestart.java

示例8: verifyRegionLocation

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
/**
 * Verify regions are on the expected region server
 */
private void verifyRegionLocation(HRegionServer hrs, List<HRegionInfo> regions)
    throws IOException {
  List<HRegionInfo> tmpOnlineRegions =
    ProtobufUtil.getOnlineRegions(hrs.getRSRpcServices());
  Iterator<HRegionInfo> itr = regions.iterator();
  while (itr.hasNext()) {
    HRegionInfo tmp = itr.next();
    if (!tmpOnlineRegions.contains(tmp)) {
      itr.remove();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:TestMasterFailover.java

示例9: verifyMethodResult

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
private void verifyMethodResult(Class<?> c, String methodName[], TableName tableName,
                                Object value[]) throws IOException {
  try {
    for (JVMClusterUtil.RegionServerThread t : cluster.getRegionServerThreads()) {
      if (!t.isAlive() || t.getRegionServer().isAborted() || t.getRegionServer().isStopping()){
        continue;
      }
      for (HRegionInfo r : ProtobufUtil.getOnlineRegions(t.getRegionServer().getRSRpcServices())) {
        if (!r.getTable().equals(tableName)) {
          continue;
        }
        RegionCoprocessorHost cph = t.getRegionServer().getOnlineRegion(r.getRegionName()).
            getCoprocessorHost();

        Coprocessor cp = cph.findCoprocessor(c.getName());
        assertNotNull(cp);
        for (int i = 0; i < methodName.length; ++i) {
          Method m = c.getMethod(methodName[i]);
          Object o = m.invoke(cp);
          assertTrue("Result of " + c.getName() + "." + methodName[i]
              + " is expected to be " + value[i].toString()
              + ", while we get " + o.toString(), o.equals(value[i]));
        }
      }
    }
  } catch (Exception e) {
    throw new IOException(e.toString());
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:TestRegionObserverInterface.java

示例10: printOutRegions

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
private void printOutRegions(final HRegionServer hrs, final String prefix)
    throws IOException {
  List<HRegionInfo> regions = ProtobufUtil.getOnlineRegions(hrs.getRSRpcServices());
  for (HRegionInfo region: regions) {
    LOG.info(prefix + region.getRegionNameAsString());
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:TestSplitTransactionOnCluster.java

示例11: getOnlineRegions

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
/**
 * Get all the online regions on a region server.
 */
@Override
public List<HRegionInfo> getOnlineRegions(final ServerName sn) throws IOException {
  AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
  PayloadCarryingRpcController controller = rpcControllerFactory.newController();
  return ProtobufUtil.getOnlineRegions(controller, admin);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:HBaseAdmin.java

示例12: assertRegionsAreBalanced

import org.apache.hadoop.hbase.protobuf.ProtobufUtil; //导入方法依赖的package包/类
/**
 * Determine if regions are balanced. Figure out the total, divide by the
 * number of online servers, then test if each server is +/- 1 of average
 * rounded up.
 */
private void assertRegionsAreBalanced() throws IOException {
  // TODO: Fix this test.  Old balancer used to run with 'slop'.  New
  // balancer does not.
  boolean success = false;
  float slop = (float)UTIL.getConfiguration().getFloat("hbase.regions.slop", 0.1f);
  if (slop <= 0) slop = 1;

  for (int i = 0; i < 5; i++) {
    success = true;
    // make sure all the regions are reassigned before we test balance
    waitForAllRegionsAssigned();

    long regionCount = UTIL.getMiniHBaseCluster().countServedRegions();
    List<HRegionServer> servers = getOnlineRegionServers();
    double avg = UTIL.getHBaseCluster().getMaster().getAverageLoad();
    int avgLoadPlusSlop = (int)Math.ceil(avg * (1 + slop));
    int avgLoadMinusSlop = (int)Math.floor(avg * (1 - slop)) - 1;
    LOG.debug("There are " + servers.size() + " servers and " + regionCount
      + " regions. Load Average: " + avg + " low border: " + avgLoadMinusSlop
      + ", up border: " + avgLoadPlusSlop + "; attempt: " + i);

    for (HRegionServer server : servers) {
      int serverLoad =
        ProtobufUtil.getOnlineRegions(server.getRSRpcServices()).size();
      LOG.debug(server.getServerName() + " Avg: " + avg + " actual: " + serverLoad);
      if (!(avg > 2.0 && serverLoad <= avgLoadPlusSlop
          && serverLoad >= avgLoadMinusSlop)) {
        for (HRegionInfo hri :
            ProtobufUtil.getOnlineRegions(server.getRSRpcServices())) {
          if (hri.isMetaRegion()) serverLoad--;
          // LOG.debug(hri.getRegionNameAsString());
        }
        if (!(serverLoad <= avgLoadPlusSlop && serverLoad >= avgLoadMinusSlop)) {
          LOG.debug(server.getServerName() + " Isn't balanced!!! Avg: " + avg +
              " actual: " + serverLoad + " slop: " + slop);
          success = false;
          break;
        }
      }
    }

    if (!success) {
      // one or more servers are not balanced. sleep a little to give it a
      // chance to catch up. then, go back to the retry loop.
      try {
        Thread.sleep(10000);
      } catch (InterruptedException e) {}

      UTIL.getHBaseCluster().getMaster().balance();
      continue;
    }

    // if we get here, all servers were balanced, so we should just return.
    return;
  }
  // if we get here, we tried 5 times and never got to short circuit out of
  // the retry loop, so this is a failure.
  fail("After 5 attempts, region assignments were not balanced.");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:65,代码来源:TestRegionRebalancing.java


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