Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.ClusterStatus


      LOG.debug("GET " + uriInfo.getAbsolutePath());
    }
    servlet.getMetrics().incrementRequests(1);
    try {
      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
      ClusterStatus status = admin.getClusterStatus();
      StorageClusterStatusModel model = new StorageClusterStatusModel();
      model.setRegions(status.getRegionsCount());
      model.setRequests(status.getRequestsCount());
      model.setAverageLoad(status.getAverageLoad());
      for (HServerInfo info: status.getServerInfo()) {
        HServerLoad load = info.getLoad();
        StorageClusterStatusModel.Node node =
          model.addLiveNode(
            info.getServerAddress().getHostname() + ":" +
            Integer.toString(info.getServerAddress().getPort()),
            info.getStartCode(), load.getUsedHeapMB(),
            load.getMaxHeapMB());
        node.setRequests(load.getNumberOfRequests());
        for (HServerLoad.RegionLoad region: load.getRegionsLoad()) {
          node.addRegion(region.getName(), region.getStores(),
            region.getStorefiles(), region.getStorefileSizeMB(),
            region.getMemStoreSizeMB(), region.getStorefileIndexSizeMB());
        }
      }
      for (String name: status.getDeadServerNames()) {
        model.addDeadNode(name);
      }
      ResponseBuilder response = Response.ok(model);
      response.cacheControl(cacheControl);
      return response.build();
View Full Code Here


    @Override
    protected boolean doAction() throws Exception {
      HBaseAdmin 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

      @Override
      public int compare(ServerName s1, ServerName s2) {
        return s1.getServerName().compareTo(s2.getServerName());
      }});

    return new ClusterStatus(VersionInfo.getVersion(),
      this.fileSystemManager.getClusterId().toString(),
      this.serverManager.getOnlineServers(),
      this.serverManager.getDeadServers().copyServerNames(),
      this.serverName,
      backupMasters,
View Full Code Here

  /**
   * 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 =
View Full Code Here

    Collections.sort(backupMasters, new Comparator<ServerName>() {
      public int compare(ServerName s1, ServerName s2) {
        return s1.getServerName().compareTo(s2.getServerName());
      }});

    return new ClusterStatus(VersionInfo.getVersion(),
      this.fileSystemManager.getClusterId(),
      this.serverManager.getOnlineServers(),
      this.serverManager.getDeadServers(),
      this.serverName,
      backupMasters,
View Full Code Here

    }

    @Override
    public void perform() throws Exception {
      LOG.info("Unbalancing regions");
      ClusterStatus status = this.cluster.getClusterStatus();
      List<ServerName> victimServers = new LinkedList<ServerName>(status.getServers());
      int targetServerCount = (int)Math.ceil(fractionOfServers * victimServers.size());
      List<byte[]> targetServers = new ArrayList<byte[]>(targetServerCount);
      for (int i = 0; i < targetServerCount; ++i) {
        int victimIx = random.nextInt(victimServers.size());
        String serverName = victimServers.remove(victimIx).getServerName();
        targetServers.add(Bytes.toBytes(serverName));
      }

      List<byte[]> victimRegions = new LinkedList<byte[]>();
      for (ServerName server : victimServers) {
        HServerLoad serverLoad = status.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) {
View Full Code Here

    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,
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

   * Creates mock returing ClusterStatus info about given servers.
  */
  private Admin mockAdmin(ServerLoad... servers) throws Exception {
    //get clusterstatus
    Admin mockAdmin = Mockito.mock(HBaseAdmin.class);
    ClusterStatus clusterStatus = mockCluster(servers);
    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

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.