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


Java ClusterStatus类代码示例

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


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

示例1: getDeployedHRIs

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

示例2: mockCluster

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
private ClusterStatus mockCluster(ServerLoad[] servers) {
  List<ServerName> serverNames = new ArrayList<ServerName>();

  ClusterStatus clusterStatus = Mockito.mock(ClusterStatus.class);
  when(clusterStatus.getServers()).thenReturn(serverNames);

  int serverCounter = 0;
  for (ServerLoad server : servers) {
    ServerName serverName = mock(ServerName.class);
    when(serverName.getServerName()).thenReturn("server" + (serverCounter++));
    serverNames.add(serverName);
    when(clusterStatus.getLoad(serverName)).thenReturn(server);
  }

  return clusterStatus;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestRegionSizeCalculator.java

示例3: getCurrentServers

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
/** Returns current region servers - active master */
protected ServerName[] getCurrentServers() throws IOException {
  ClusterStatus clusterStatus = cluster.getClusterStatus();
  Collection<ServerName> regionServers = clusterStatus.getServers();
  int count = regionServers == null ? 0 : regionServers.size();
  if (count <= 0) {
    return new ServerName [] {};
  }
  ServerName master = clusterStatus.getMaster();
  if (master == null || !regionServers.contains(master)) {
    return regionServers.toArray(new ServerName[count]);
  }
  if (count == 1) {
    return new ServerName [] {};
  }
  ArrayList<ServerName> tmp = new ArrayList<ServerName>(count);
  tmp.addAll(regionServers);
  tmp.remove(master);
  return tmp.toArray(new ServerName[count-1]);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:Action.java

示例4: perform

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
@Override
public void perform() throws Exception {
  LOG.info("Performing action: Restart region server holding META");
  ServerName server = cluster.getServerHoldingMeta();
  if (server == null) {
    LOG.warn("No server is holding hbase:meta right now.");
    return;
  }
  ClusterStatus clusterStatus = cluster.getClusterStatus();
  if (server.equals(clusterStatus.getMaster())) {
    // Master holds the meta, so restart the master.
    restartMaster(server, sleepTime);
  } else {
    restartRs(server, sleepTime);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:RestartRsHoldingMetaAction.java

示例5: getDeployedHRIs

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
/**
 * Get region info from local cluster.
 */
Map<ServerName, List<String>> getDeployedHRIs(HBaseAdmin admin)
  throws IOException {
  ClusterStatus status = admin.getMaster().getClusterStatus();
  Collection<ServerName> regionServers = status.getServers();
  Map<ServerName, List<String>> mm =
      new HashMap<ServerName, List<String>>();
  HConnection connection = admin.getConnection();
  for (ServerName hsi : regionServers) {
    HRegionInterface server =
      connection.getHRegionConnection(hsi.getHostname(), hsi.getPort());

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

示例6: getDeployedHRIs

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的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>>();
  HConnection connection = admin.getConnection();
  for (ServerName hsi : regionServers) {
    AdminProtos.AdminService.BlockingInterface server = 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:tenggyut,项目名称:HIndex,代码行数:24,代码来源:TestHBaseFsck.java

示例7: unbalanceRegions

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
protected void unbalanceRegions(ClusterStatus clusterStatus,
    List<ServerName> fromServers, List<ServerName> toServers,
    double fractionOfRegions) throws Exception {
  List<byte[]> victimRegions = new LinkedList<byte[]>();
  for (ServerName server : fromServers) {
    ServerLoad serverLoad = clusterStatus.getLoad(server);
    // Ugh.
    List<byte[]> regions = new LinkedList<byte[]>(serverLoad.getRegionsLoad().keySet());
    int victimRegionCount = (int)Math.ceil(fractionOfRegions * regions.size());
    LOG.debug("Removing " + victimRegionCount + " regions from " + server.getServerName());
    for (int i = 0; i < victimRegionCount; ++i) {
      int victimIx = RandomUtils.nextInt(regions.size());
      String regionId = HRegionInfo.encodeRegionName(regions.remove(victimIx));
      victimRegions.add(Bytes.toBytes(regionId));
    }
  }

  LOG.info("Moving " + victimRegions.size() + " regions from " + fromServers.size()
      + " servers to " + toServers.size() + " different servers");
  HBaseAdmin admin = this.context.getHBaseIntegrationTestingUtility().getHBaseAdmin();
  for (byte[] victimRegion : victimRegions) {
    int targetIx = RandomUtils.nextInt(toServers.size());
    admin.move(victimRegion, Bytes.toBytes(toServers.get(targetIx).getServerName()));
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:26,代码来源:Action.java

示例8: perform

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
@Override
public void perform() throws Exception {
  ClusterStatus status = this.cluster.getClusterStatus();
  List<ServerName> victimServers = new LinkedList<ServerName>(status.getServers());
  int liveCount = (int)Math.ceil(FRC_SERVERS_THAT_HOARD_AND_LIVE * victimServers.size());
  int deadCount = (int)Math.ceil(FRC_SERVERS_THAT_HOARD_AND_DIE * victimServers.size());
  Assert.assertTrue((liveCount + deadCount) < victimServers.size());
  List<ServerName> targetServers = new ArrayList<ServerName>(liveCount);
  for (int i = 0; i < liveCount + deadCount; ++i) {
    int victimIx = RandomUtils.nextInt(victimServers.size());
    targetServers.add(victimServers.remove(victimIx));
  }
  unbalanceRegions(status, victimServers, targetServers, HOARD_FRC_OF_REGIONS);
  Thread.sleep(WAIT_FOR_UNBALANCE_MS);
  for (int i = 0; i < liveCount; ++i) {
    killRs(targetServers.get(i));
  }
  Thread.sleep(WAIT_FOR_KILLS_MS);
  forceBalancer();
  Thread.sleep(WAIT_AFTER_BALANCE_MS);
  for (int i = 0; i < liveCount; ++i) {
    startRs(targetServers.get(i));
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:25,代码来源:UnbalanceKillAndRebalanceAction.java

示例9: getClusterStatus

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
/**
 * @return cluster status
 */
public ClusterStatus getClusterStatus() {
  // Build Set of backup masters from ZK nodes
  List<String> backupMasterStrings;
  try {
    backupMasterStrings = ZKUtil.listChildrenNoWatch(this.zooKeeper,
                            this.zooKeeper.backupMasterAddressesZNode);
  } catch (KeeperException e) {
    LOG.warn(this.zooKeeper.prefix("Unable to list backup servers"), e);
    backupMasterStrings = new ArrayList<String>(0);
  }
  List<ServerName> backupMasters = new ArrayList<ServerName>(
                                        backupMasterStrings.size());
  for (String s: backupMasterStrings) {
    backupMasters.add(new ServerName(s));
  }

  return new ClusterStatus(VersionInfo.getVersion(),
    this.fileSystemManager.getClusterId(),
    this.serverManager.getOnlineServers(),
    this.serverManager.getDeadServers(),
    this.serverName,
    backupMasters,
    this.assignmentManager.getRegionsInTransition(),
    this.getCoprocessors());
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:29,代码来源:HMaster.java

示例10: testClusterStatus

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
@Test
public void testClusterStatus() throws Exception {

  ClusterStatus status = TEST_UTIL.getHBaseClusterInterface()
      .getClusterStatus();
  StorageClusterStatusModel returnedStatus = remoteAdmin.getClusterStatus();
  assertEquals(
      "Region count from cluster status and returned status did not match up. ",
      status.getRegionsCount(), returnedStatus.getRegions());
  assertEquals(
      "Dead server count from cluster status and returned status did not match up. ",
      status.getDeadServers(), returnedStatus.getDeadNodes().size());
  assertEquals(
      "Number of requests from cluster status and returned status did not match up. ",
      status.getRequestsCount(), returnedStatus.getRequests());
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:17,代码来源:TestRemoteAdmin.java

示例11: getDeployedHRIs

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的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>>();
  HConnection connection = admin.getConnection();
  for (ServerName hsi : regionServers) {
    AdminProtocol server =
      connection.getAdmin(hsi.getHostname(), hsi.getPort());

    // 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:daidong,项目名称:DominoHBase,代码行数:25,代码来源:TestHBaseFsck.java

示例12: unbalanceRegions

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
protected void unbalanceRegions(ClusterStatus clusterStatus,
    List<ServerName> fromServers, List<ServerName> toServers,
    double fractionOfRegions) throws Exception {
  List<byte[]> victimRegions = new LinkedList<byte[]>();
  for (ServerName server : fromServers) {
    ServerLoad serverLoad = clusterStatus.getLoad(server);
    // Ugh.
    List<byte[]> regions = new LinkedList<byte[]>(serverLoad.getRegionsLoad().keySet());
    int victimRegionCount = (int)Math.ceil(fractionOfRegions * regions.size());
    LOG.debug("Removing " + victimRegionCount + " regions from " + server.getServerName());
    for (int i = 0; i < victimRegionCount; ++i) {
      int victimIx = random.nextInt(regions.size());
      String regionId = HRegionInfo.encodeRegionName(regions.remove(victimIx));
      victimRegions.add(Bytes.toBytes(regionId));
    }
  }

  LOG.info("Moving " + victimRegions.size() + " regions from " + fromServers.size()
      + " servers to " + toServers.size() + " different servers");
  HBaseAdmin admin = this.context.getHaseIntegrationTestingUtility().getHBaseAdmin();
  for (byte[] victimRegion : victimRegions) {
    int targetIx = random.nextInt(toServers.size());
    admin.move(victimRegion, Bytes.toBytes(toServers.get(targetIx).getServerName()));
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:26,代码来源:ChaosMonkey.java

示例13: setClusterStatus

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
public void setClusterStatus(ClusterStatus status) {
  long currentTime = EnvironmentEdgeManager.currentTime();
  this.status = status;
  if (currentTime > lastFullRefresh + (CACHE_TIME / 2)) {
    // Only count the refresh if it includes user tables ( eg more than meta and namespace ).
    lastFullRefresh = scheduleFullRefresh()?currentTime:lastFullRefresh;
  }

}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:10,代码来源:RegionLocationFinder.java

示例14: setClusterStatus

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
@Override
public synchronized void setClusterStatus(ClusterStatus st) {
  super.setClusterStatus(st);
  updateRegionLoad();
  for(CostFromRegionLoadFunction cost : regionLoadFunctions) {
    cost.setClusterStatus(st);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:StochasticLoadBalancer.java

示例15: chore

import org.apache.hadoop.hbase.ClusterStatus; //导入依赖的package包/类
@Override
protected void chore() {
  if (!connected) {
    return;
  }

  List<ServerName> sns = generateDeadServersListToSend();
  if (sns.isEmpty()) {
    // Nothing to send. Done.
    return;
  }

  final long curTime = EnvironmentEdgeManager.currentTime();
  if (lastMessageTime > curTime - messagePeriod) {
    // We already sent something less than 10 second ago. Done.
    return;
  }

  // Ok, we're going to send something then.
  lastMessageTime = curTime;

  // We're reusing an existing protobuf message, but we don't send everything.
  // This could be extended in the future, for example if we want to send stuff like the
  //  hbase:meta server name.
  ClusterStatus cs = new ClusterStatus(VersionInfo.getVersion(),
      master.getMasterFileSystem().getClusterId().toString(),
      null,
      sns,
      master.getServerName(),
      null,
      null,
      null,
      null);


  publisher.publish(cs);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:38,代码来源:ClusterStatusPublisher.java


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