Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.ClusterStatus


    if (LOG.isDebugEnabled()) {
      LOG.debug("GET " + uriInfo.getAbsolutePath());
    }
    servlet.getMetrics().incrementRequests(1);
    try {
      ClusterStatus status = servlet.getAdmin().getClusterStatus();
      StorageClusterStatusModel model = new StorageClusterStatusModel();
      model.setRegions(status.getRegionsCount());
      model.setRequests(status.getRequestsCount());
      model.setAverageLoad(status.getAverageLoad());
      for (ServerName info: status.getServers()) {
        ServerLoad load = status.getLoad(info);
        StorageClusterStatusModel.Node node =
          model.addLiveNode(
            info.getHostname() + ":" +
            Integer.toString(info.getPort()),
            info.getStartcode(), load.getUsedHeapMB(),
            load.getMaxHeapMB());
        node.setRequests(load.getNumberOfRequests());
        for (RegionLoad region: load.getRegionsLoad().values()) {
          node.addRegion(region.getName(), region.getStores(),
            region.getStorefiles(), region.getStorefileSizeMB(),
            region.getMemStoreSizeMB(), region.getStorefileIndexSizeMB(),
            region.getReadRequestsCount(), region.getWriteRequestsCount(),
            region.getRootIndexSizeKB(), region.getTotalStaticIndexSizeKB(),
            region.getTotalStaticBloomSizeKB(), region.getTotalCompactingKVs(),
            region.getCurrentCompactedKVs());
        }
      }
      for (ServerName name: status.getDeadServerNames()) {
        model.addDeadNode(name.toString());
      }
      ResponseBuilder response = Response.ok(model);
      response.cacheControl(cacheControl);
      servlet.getMetrics().incrementSucessfulGetRequests(1);
View Full Code Here


   * Creates mock returning ClusterStatus info about given servers.
  */
  private Admin mockAdmin(ServerLoad... servers) throws Exception {
    //get clusterstatus
    Admin mockAdmin = Mockito.mock(Admin.class);
    ClusterStatus clusterStatus = mockCluster(servers);
    when(mockAdmin.getConfiguration()).thenReturn(configuration);
    when(mockAdmin.getClusterStatus()).thenReturn(clusterStatus);
    return mockAdmin;
  }
View Full Code Here

  }

  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;
  }
View Full Code Here

      }));
    }

    doneHalfway.await();

    ClusterStatus status = TEST_UTIL.getHBaseCluster().getClusterStatus();

    // Kill a regionserver
    TEST_UTIL.getHBaseCluster().getRegionServer(0).getRpcServer().stop();
    TEST_UTIL.getHBaseCluster().getRegionServer(0).stop("Testing");
View Full Code Here

    @Override
    protected boolean doAction() throws Exception {
      Admin admin = null;
      try {
        admin = new HBaseAdmin(util.getConfiguration());
        ClusterStatus status = admin.getClusterStatus();
        return status != null;
      } finally {
        if (admin != null) {
          admin.close();
        }
View Full Code Here

  public void perform() throws Exception { }

  /** 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 [] {};
View Full Code Here

    Set<ServerName> deadServers = null;
    if (serverManager != null) {
      deadServers = serverManager.getDeadServers().copyServerNames();
      onlineServers = serverManager.getOnlineServers();
    }
    return new ClusterStatus(VersionInfo.getVersion(), clusterId,
      onlineServers, deadServers, serverName, backupMasters,
      regionsInTransition, coprocessors, balancerOn);
  }
View Full Code Here

    Set<byte[]> tableRegions = new TreeSet<byte[]>(Bytes.BYTES_COMPARATOR);
    for (HRegionLocation regionInfo : tableRegionInfos) {
      tableRegions.add(regionInfo.getRegionInfo().getRegionName());
    }

    ClusterStatus clusterStatus = admin.getClusterStatus();
    Collection<ServerName> servers = clusterStatus.getServers();
    final long megaByte = 1024L * 1024L;

    //iterate all cluster regions, filter regions from our table and compute their size
    for (ServerName serverName: servers) {
      ServerLoad serverLoad = clusterStatus.getLoad(serverName);

      for (RegionLoad regionLoad: serverLoad.getRegionsLoad().values()) {
        byte[] regionId = regionLoad.getName();

        if (tableRegions.contains(regionId)) {
View Full Code Here

  }
  /**
   * 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);
View Full Code Here

    }

    @Override
    public List<String> getExtraInfoLines() {
        try {
            ClusterStatus clusterStatus = hbaseAdmin.getClusterStatus();

            int deadServers = clusterStatus.getDeadServers();
            int liveServers = clusterStatus.getServersSize();
            int regionCount = clusterStatus.getRegionsCount();

            String line = String.format("HBase cluster status: dead servers: %1$d, live servers: %2$d, regions: %3$d",
                    deadServers, liveServers, regionCount);

            return Collections.singletonList(line);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.ClusterStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.