use of org.apache.hadoop.yarn.api.records.QueueInfo in project hadoop by apache.
the class YarnClientImpl method getChildQueueInfos.
@Override
public List<QueueInfo> getChildQueueInfos(String parent) throws YarnException, IOException {
List<QueueInfo> queues = new ArrayList<QueueInfo>();
QueueInfo parentQueue = rmClient.getQueueInfo(getQueueInfoRequest(parent, false, true, false)).getQueueInfo();
getChildQueues(parentQueue, queues, true);
return queues;
}
use of org.apache.hadoop.yarn.api.records.QueueInfo in project hadoop by apache.
the class YarnClientImpl method getAllQueues.
@Override
public List<QueueInfo> getAllQueues() throws YarnException, IOException {
List<QueueInfo> queues = new ArrayList<QueueInfo>();
QueueInfo rootQueue = rmClient.getQueueInfo(getQueueInfoRequest(ROOT, false, true, true)).getQueueInfo();
getChildQueues(rootQueue, queues, true);
return queues;
}
use of org.apache.hadoop.yarn.api.records.QueueInfo in project hadoop by apache.
the class TopCLI method getQueueMetrics.
protected QueueMetrics getQueueMetrics() {
QueueMetrics queueMetrics = new QueueMetrics();
List<QueueInfo> queuesInfo;
if (queues.isEmpty()) {
try {
queuesInfo = client.getRootQueueInfos();
} catch (Exception ie) {
LOG.error("Unable to get queue information", ie);
return queueMetrics;
}
} else {
queuesInfo = new ArrayList<>();
for (String queueName : queues) {
try {
QueueInfo qInfo = client.getQueueInfo(queueName);
queuesInfo.add(qInfo);
} catch (Exception ie) {
LOG.error("Unable to get queue information", ie);
return queueMetrics;
}
}
}
for (QueueInfo childInfo : queuesInfo) {
QueueStatistics stats = childInfo.getQueueStatistics();
if (stats != null) {
queueMetrics.appsSubmitted += stats.getNumAppsSubmitted();
queueMetrics.appsRunning += stats.getNumAppsRunning();
queueMetrics.appsPending += stats.getNumAppsPending();
queueMetrics.appsCompleted += stats.getNumAppsCompleted();
queueMetrics.appsKilled += stats.getNumAppsKilled();
queueMetrics.appsFailed += stats.getNumAppsFailed();
queueMetrics.activeUsers += stats.getNumActiveUsers();
queueMetrics.availableMemoryGB += stats.getAvailableMemoryMB();
queueMetrics.allocatedMemoryGB += stats.getAllocatedMemoryMB();
queueMetrics.pendingMemoryGB += stats.getPendingMemoryMB();
queueMetrics.reservedMemoryGB += stats.getReservedMemoryMB();
queueMetrics.availableVCores += stats.getAvailableVCores();
queueMetrics.allocatedVCores += stats.getAllocatedVCores();
queueMetrics.pendingVCores += stats.getPendingVCores();
queueMetrics.reservedVCores += stats.getReservedVCores();
queueMetrics.allocatedContainers += stats.getAllocatedContainers();
queueMetrics.pendingContainers += stats.getPendingContainers();
queueMetrics.reservedContainers += stats.getReservedContainers();
}
}
queueMetrics.availableMemoryGB = queueMetrics.availableMemoryGB / 1024;
queueMetrics.allocatedMemoryGB = queueMetrics.allocatedMemoryGB / 1024;
queueMetrics.pendingMemoryGB = queueMetrics.pendingMemoryGB / 1024;
queueMetrics.reservedMemoryGB = queueMetrics.reservedMemoryGB / 1024;
return queueMetrics;
}
use of org.apache.hadoop.yarn.api.records.QueueInfo in project hadoop by apache.
the class TestYarnCLI method testGetQueueInfo.
@Test
public void testGetQueueInfo() throws Exception {
QueueCLI cli = createAndGetQueueCLI();
Set<String> nodeLabels = new HashSet<String>();
nodeLabels.add("GPU");
nodeLabels.add("JDK_7");
QueueInfo queueInfo = QueueInfo.newInstance("queueA", 0.4f, 0.8f, 0.5f, null, null, QueueState.RUNNING, nodeLabels, "GPU", null, false);
when(client.getQueueInfo(any(String.class))).thenReturn(queueInfo);
int result = cli.run(new String[] { "-status", "queueA" });
assertEquals(0, result);
verify(client).getQueueInfo("queueA");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(baos);
pw.println("Queue Information : ");
pw.println("Queue Name : " + "queueA");
pw.println("\tState : " + "RUNNING");
pw.println("\tCapacity : " + "40.0%");
pw.println("\tCurrent Capacity : " + "50.0%");
pw.println("\tMaximum Capacity : " + "80.0%");
pw.println("\tDefault Node Label expression : " + "GPU");
pw.println("\tAccessible Node Labels : " + "JDK_7,GPU");
pw.println("\tPreemption : " + "enabled");
pw.close();
String queueInfoStr = baos.toString("UTF-8");
Assert.assertEquals(queueInfoStr, sysOutStream.toString());
}
use of org.apache.hadoop.yarn.api.records.QueueInfo 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;
}
}
}
Aggregations