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();
}
}
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";
}
}
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();
}
}
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();
}
}
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;
}
Aggregations