Search in sources :

Example 1 with ClusterStatus

use of org.apache.hadoop.hbase.ClusterStatus in project hbase by apache.

the class RegionSplitter method getRegionServerCount.

/**
   * Alternative getCurrentNrHRS which is no longer available.
   * @param connection
   * @return Rough count of regionservers out on cluster.
   * @throws IOException 
   */
private static int getRegionServerCount(final Connection connection) throws IOException {
    try (Admin admin = connection.getAdmin()) {
        ClusterStatus status = admin.getClusterStatus();
        Collection<ServerName> servers = status.getServers();
        return servers == null || servers.isEmpty() ? 0 : servers.size();
    }
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) Admin(org.apache.hadoop.hbase.client.Admin) ClusterStatus(org.apache.hadoop.hbase.ClusterStatus)

Example 2 with ClusterStatus

use of org.apache.hadoop.hbase.ClusterStatus in project cdap by caskdata.

the class HBaseInfo method collect.

@Override
public synchronized void collect() throws IOException {
    try (HBaseAdmin admin = new HBaseAdmin(conf)) {
        ClusterStatus clusterStatus = admin.getClusterStatus();
        ServerName master = clusterStatus.getMaster();
        String protocol = conf.getBoolean("hbase.ssl.enabled", false) && conf.get("hbase.http.policy").equals("HTTPS_ONLY") ? "https" : "http";
        webUrl = String.format("%s://%s:%s", protocol, master.getHostname(), conf.get("hbase.master.info.port"));
        logsUrl = webUrl + "/logs";
    }
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) ServerName(org.apache.hadoop.hbase.ServerName) ClusterStatus(org.apache.hadoop.hbase.ClusterStatus)

Example 3 with ClusterStatus

use of org.apache.hadoop.hbase.ClusterStatus in project cdap by caskdata.

the class HBaseLoad method collect.

@Override
public void collect() throws IOException {
    try (HBaseAdmin admin = new HBaseAdmin(conf)) {
        ClusterStatus clusterStatus = admin.getClusterStatus();
        regions = clusterStatus.getRegionsCount();
        regionsInTransition = clusterStatus.getRegionsInTransition().size();
        averageLoad = clusterStatus.getAverageLoad();
        requests = clusterStatus.getRequestsCount();
    }
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) ClusterStatus(org.apache.hadoop.hbase.ClusterStatus)

Example 4 with ClusterStatus

use of org.apache.hadoop.hbase.ClusterStatus in project cdap by caskdata.

the class HBaseNodes method collect.

@Override
public synchronized void collect() throws IOException {
    try (HBaseAdmin admin = new HBaseAdmin(conf)) {
        ClusterStatus clusterStatus = admin.getClusterStatus();
        // 1 master + number of backup masters
        masters = 1 + clusterStatus.getBackupMastersSize();
        regionServers = clusterStatus.getServersSize();
        deadRegionServers = clusterStatus.getDeadServers();
    }
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) ClusterStatus(org.apache.hadoop.hbase.ClusterStatus)

Example 5 with ClusterStatus

use of org.apache.hadoop.hbase.ClusterStatus in project beam by apache.

the class HBaseUtils method estimateSizeBytes.

/**
 * Estimates the size in bytes that a scan will cover for a given table based on HBase store file
 * information. The size can vary between calls because the data can be compressed based on the
 * HBase configuration.
 */
static long estimateSizeBytes(Connection connection, String tableId, ByteKeyRange range) throws Exception {
    // This code is based on RegionSizeCalculator in hbase-server
    long estimatedSizeBytes = 0L;
    List<HRegionLocation> regionLocations = getRegionLocations(connection, tableId, range);
    // builds set of regions who are part of the table scan
    Set<byte[]> tableRegions = new TreeSet<>(Bytes.BYTES_COMPARATOR);
    for (HRegionLocation regionLocation : regionLocations) {
        tableRegions.add(regionLocation.getRegionInfo().getRegionName());
    }
    // calculate estimated size for the regions
    Admin admin = connection.getAdmin();
    ClusterStatus clusterStatus = admin.getClusterStatus();
    Collection<ServerName> servers = clusterStatus.getServers();
    for (ServerName serverName : servers) {
        ServerLoad serverLoad = clusterStatus.getLoad(serverName);
        for (RegionLoad regionLoad : serverLoad.getRegionsLoad().values()) {
            byte[] regionId = regionLoad.getName();
            if (tableRegions.contains(regionId)) {
                long regionSizeBytes = regionLoad.getStorefileSizeMB() * 1_048_576L;
                estimatedSizeBytes += regionSizeBytes;
            }
        }
    }
    return estimatedSizeBytes;
}
Also used : ServerLoad(org.apache.hadoop.hbase.ServerLoad) HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) RegionLoad(org.apache.hadoop.hbase.RegionLoad) TreeSet(java.util.TreeSet) ServerName(org.apache.hadoop.hbase.ServerName) Admin(org.apache.hadoop.hbase.client.Admin) ClusterStatus(org.apache.hadoop.hbase.ClusterStatus)

Aggregations

ClusterStatus (org.apache.hadoop.hbase.ClusterStatus)12 ServerName (org.apache.hadoop.hbase.ServerName)9 ServerLoad (org.apache.hadoop.hbase.ServerLoad)4 Admin (org.apache.hadoop.hbase.client.Admin)3 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)3 RegionLoad (org.apache.hadoop.hbase.RegionLoad)2 RegionState (org.apache.hadoop.hbase.master.RegionState)2 ByteString (org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString)2 LiveServerInfo (org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.LiveServerInfo)2 RegionInTransition (org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionInTransition)2 TableId (co.cask.cdap.data2.util.TableId)1 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 ClusterId (org.apache.hadoop.hbase.ClusterId)1 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 TableName (org.apache.hadoop.hbase.TableName)1 TableNotFoundException (org.apache.hadoop.hbase.TableNotFoundException)1