if (numCpu == ResourceCalculatorPlugin.UNAVAILABLE) {
numCpu = 1;
}
LOG.info("Will report " + numCpu + " CPUs");
int totalMemoryMB = (int) (resourceCalculatorPlugin.getPhysicalMemorySize() / 1024D / 1024);
ComputeSpecs total = new ComputeSpecs((short)numCpu);
total.setNetworkMBps((short)100);
total.setMemoryMB(totalMemoryMB);
total.setDiskGB(
(int)(getDiskSpace(false) / 1024D / 1024 / 1024));
String appInfo = null;
if (getLocalHostAddress() != null) {
appInfo = getLocalHostAddress() + ":" + actionServerAddr.getPort();
}
else {
appInfo = getLocalHostname() + ":" + actionServerAddr.getPort();
}
Map<ResourceType, String> resourceInfos =
new EnumMap<ResourceType, String>(ResourceType.class);
resourceInfos.put(ResourceType.MAP, appInfo);
resourceInfos.put(ResourceType.REDUCE, appInfo);
resourceInfos.put(ResourceType.JOBTRACKER, appInfo);
while (running && !shuttingDown) {
try {
long now = System.currentTimeMillis();
Thread.sleep(heartbeatCMInterval);
float cpuUsage = resourceCalculatorPlugin.getCpuUsage();
if (cpuUsage == ResourceCalculatorPlugin.UNAVAILABLE) {
cpuUsage = 0;
}
ComputeSpecs free = new ComputeSpecs((short)(numCpu * cpuUsage / 100D));
// TODO find free network.
free.setNetworkMBps((short)100);
int availableMemoryMB =
(int)(resourceCalculatorPlugin.
getAvailablePhysicalMemorySize() / 1024D / 1024);
free.setMemoryMB(availableMemoryMB);
long freeDiskSpace = getDiskSpace(true);
long freeLogDiskSpace = getLogDiskFreeSpace();
free.setDiskGB((int)(
Math.min(freeDiskSpace, freeLogDiskSpace) / 1024D / 1024 / 1024));
// TT puts it's MR specific host:port tuple here
ClusterNodeInfo node = new ClusterNodeInfo
(this.getName(), clusterManagerCallbackServerAddr, total);
node.setFree(free);