Search in sources :

Example 26 with QueueInfo

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;
}
Also used : QueueInfo(org.apache.hadoop.yarn.api.records.QueueInfo) ArrayList(java.util.ArrayList)

Example 27 with QueueInfo

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;
}
Also used : QueueInfo(org.apache.hadoop.yarn.api.records.QueueInfo) ArrayList(java.util.ArrayList)

Example 28 with QueueInfo

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;
}
Also used : QueueInfo(org.apache.hadoop.yarn.api.records.QueueInfo) QueueStatistics(org.apache.hadoop.yarn.api.records.QueueStatistics) ParseException(org.apache.commons.cli.ParseException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ConnectException(java.net.ConnectException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException)

Example 29 with QueueInfo

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());
}
Also used : QueueInfo(org.apache.hadoop.yarn.api.records.QueueInfo) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HashSet(java.util.HashSet) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 30 with QueueInfo

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;
        }
    }
}
Also used : QueueInfo(org.apache.hadoop.yarn.api.records.QueueInfo) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient)

Aggregations

QueueInfo (org.apache.hadoop.yarn.api.records.QueueInfo)33 Test (org.junit.Test)11 Resource (org.apache.hadoop.yarn.api.records.Resource)9 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)7 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)5 NodeReport (org.apache.hadoop.yarn.api.records.NodeReport)5 YarnClusterMetrics (org.apache.hadoop.yarn.api.records.YarnClusterMetrics)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 PrintWriter (java.io.PrintWriter)4 GetNewApplicationResponse (org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse)4 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)4 Priority (org.apache.hadoop.yarn.api.records.Priority)4 YarnClientApplication (org.apache.hadoop.yarn.client.api.YarnClientApplication)4 ByteBuffer (java.nio.ByteBuffer)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 Path (org.apache.hadoop.fs.Path)3 DataOutputBuffer (org.apache.hadoop.io.DataOutputBuffer)3