use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.Coprocessor.Builder in project hbase by apache.
the class HRegionServer method buildServerLoad.
ClusterStatusProtos.ServerLoad buildServerLoad(long reportStartTime, long reportEndTime) throws IOException {
// We're getting the MetricsRegionServerWrapper here because the wrapper computes requests
// per second, and other metrics As long as metrics are part of ServerLoad it's best to use
// the wrapper to compute those numbers in one place.
// In the long term most of these should be moved off of ServerLoad and the heart beat.
// Instead they should be stored in an HBase table so that external visibility into HBase is
// improved; Additionally the load balancer will be able to take advantage of a more complete
// history.
MetricsRegionServerWrapper regionServerWrapper = metricsRegionServer.getRegionServerWrapper();
Collection<Region> regions = getOnlineRegionsLocalContext();
long usedMemory = -1L;
long maxMemory = -1L;
final MemoryUsage usage = MemorySizeUtil.safeGetHeapMemoryUsage();
if (usage != null) {
usedMemory = usage.getUsed();
maxMemory = usage.getMax();
}
ClusterStatusProtos.ServerLoad.Builder serverLoad = ClusterStatusProtos.ServerLoad.newBuilder();
serverLoad.setNumberOfRequests((int) regionServerWrapper.getRequestsPerSecond());
serverLoad.setTotalNumberOfRequests((int) regionServerWrapper.getTotalRequestCount());
serverLoad.setUsedHeapMB((int) (usedMemory / 1024 / 1024));
serverLoad.setMaxHeapMB((int) (maxMemory / 1024 / 1024));
Set<String> coprocessors = getWAL(null).getCoprocessorHost().getCoprocessors();
Builder coprocessorBuilder = Coprocessor.newBuilder();
for (String coprocessor : coprocessors) {
serverLoad.addCoprocessors(coprocessorBuilder.setName(coprocessor).build());
}
RegionLoad.Builder regionLoadBldr = RegionLoad.newBuilder();
RegionSpecifier.Builder regionSpecifier = RegionSpecifier.newBuilder();
for (Region region : regions) {
if (region.getCoprocessorHost() != null) {
Set<String> regionCoprocessors = region.getCoprocessorHost().getCoprocessors();
Iterator<String> iterator = regionCoprocessors.iterator();
while (iterator.hasNext()) {
serverLoad.addCoprocessors(coprocessorBuilder.setName(iterator.next()).build());
}
}
serverLoad.addRegionLoads(createRegionLoad(region, regionLoadBldr, regionSpecifier));
for (String coprocessor : getWAL(region.getRegionInfo()).getCoprocessorHost().getCoprocessors()) {
serverLoad.addCoprocessors(coprocessorBuilder.setName(coprocessor).build());
}
}
serverLoad.setReportStartTime(reportStartTime);
serverLoad.setReportEndTime(reportEndTime);
if (this.infoServer != null) {
serverLoad.setInfoServerPort(this.infoServer.getPort());
} else {
serverLoad.setInfoServerPort(-1);
}
// for the replicationLoad purpose. Only need to get from one service
// either source or sink will get the same info
ReplicationSourceService rsources = getReplicationSourceService();
if (rsources != null) {
// always refresh first to get the latest value
ReplicationLoad rLoad = rsources.refreshAndGetReplicationLoad();
if (rLoad != null) {
serverLoad.setReplLoadSink(rLoad.getReplicationLoadSink());
for (ClusterStatusProtos.ReplicationLoadSource rLS : rLoad.getReplicationLoadSourceList()) {
serverLoad.addReplLoadSource(rLS);
}
}
}
return serverLoad.build();
}
Aggregations