use of org.apache.hadoop.yarn.client.api.YarnClient in project cdap by caskdata.
the class YarnNodes method collect.
@Override
public synchronized void collect() throws Exception {
reset();
List<NodeReport> nodeReports;
YarnClient yarnClient = createYARNClient();
try {
nodeReports = yarnClient.getNodeReports();
} finally {
yarnClient.stop();
}
for (NodeReport nodeReport : nodeReports) {
switch(nodeReport.getNodeState()) {
case RUNNING:
healthyNodes++;
healthyContainers += nodeReport.getNumContainers();
break;
case UNHEALTHY:
case DECOMMISSIONED:
case LOST:
unusableNodes++;
unusableContainers += nodeReport.getNumContainers();
break;
case NEW:
case REBOOTED:
newNodes++;
newContainers += nodeReport.getNumContainers();
break;
}
}
}
use of org.apache.hadoop.yarn.client.api.YarnClient in project cdap by caskdata.
the class YarnQueues method collect.
@Override
public synchronized void collect() throws Exception {
reset();
List<QueueInfo> queues;
YarnClient yarnClient = createYARNClient();
try {
queues = yarnClient.getAllQueues();
} finally {
yarnClient.stop();
}
for (QueueInfo queue : queues) {
switch(queue.getQueueState()) {
case RUNNING:
running++;
break;
case STOPPED:
stopped++;
break;
}
}
}
use of org.apache.hadoop.yarn.client.api.YarnClient in project cdap by caskdata.
the class YarnResources method collect.
@Override
public synchronized void collect() throws Exception {
reset();
List<NodeReport> nodeReports;
YarnClient yarnClient = createYARNClient();
try {
nodeReports = yarnClient.getNodeReports();
} finally {
yarnClient.stop();
}
for (NodeReport nodeReport : nodeReports) {
NodeId nodeId = nodeReport.getNodeId();
LOG.debug("Got report for node {}", nodeId);
if (!nodeReport.getNodeState().isUnusable()) {
Resource nodeCapability = nodeReport.getCapability();
Resource nodeUsed = nodeReport.getUsed();
// some versions of hadoop return null, others do not
if (nodeCapability != null) {
LOG.debug("node {} resource capability: memory = {}, vcores = {}", nodeId, nodeCapability.getMemory(), nodeCapability.getVirtualCores());
totalMemory += nodeCapability.getMemory();
totalVCores += nodeCapability.getVirtualCores();
}
if (nodeUsed != null) {
LOG.debug("node {} resources used: memory = {}, vcores = {}", nodeId, nodeUsed.getMemory(), nodeUsed.getVirtualCores());
usedMemory += nodeUsed.getMemory();
usedVCores += nodeUsed.getVirtualCores();
}
}
}
}
Aggregations