Example usage for org.apache.hadoop.yarn.api.records NodeReport getHealthReport

List of usage examples for org.apache.hadoop.yarn.api.records NodeReport getHealthReport

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.api.records NodeReport getHealthReport.

Prototype

@Public
@Stable
public abstract String getHealthReport();

Source Link

Document

Get the diagnostic health report of the node.

Usage

From source file:eu.stratosphere.yarn.Client.java

License:Apache License

private void showClusterMetrics(YarnClient yarnClient) throws YarnException, IOException {
    YarnClusterMetrics metrics = yarnClient.getYarnClusterMetrics();
    System.out.println("NodeManagers in the Cluster " + metrics.getNumNodeManagers());
    List<NodeReport> nodes = yarnClient.getNodeReports(NodeState.RUNNING);
    final String format = "|%-16s |%-16s %n";
    System.out.printf("|Property         |Value          %n");
    System.out.println("+---------------------------------------+");
    int totalMemory = 0;
    int totalCores = 0;
    for (NodeReport rep : nodes) {
        final Resource res = rep.getCapability();
        totalMemory += res.getMemory();//from ww w.  jav a2  s .  c  o m
        totalCores += res.getVirtualCores();
        System.out.format(format, "NodeID", rep.getNodeId());
        System.out.format(format, "Memory", res.getMemory() + " MB");
        System.out.format(format, "vCores", res.getVirtualCores());
        System.out.format(format, "HealthReport", rep.getHealthReport());
        System.out.format(format, "Containers", rep.getNumContainers());
        System.out.println("+---------------------------------------+");
    }
    System.out.println("Summary: totalMemory " + totalMemory + " totalCores " + totalCores);
    List<QueueInfo> qInfo = yarnClient.getAllQueues();
    for (QueueInfo q : qInfo) {
        System.out.println("Queue: " + q.getQueueName() + ", Current Capacity: " + q.getCurrentCapacity()
                + " Max Capacity: " + q.getMaximumCapacity() + " Applications: " + q.getApplications().size());
    }
    yarnClient.stop();
    System.exit(0);
}

From source file:io.hops.hopsworks.common.jobs.flink.AbstractYarnClusterDescriptor.java

License:Apache License

@Override
public String getClusterDescription() {

    try {/* w  w  w.j a v a2s.  c  o m*/
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintStream ps = new PrintStream(baos);

        YarnClient yarnClient = getYarnClient();
        YarnClusterMetrics metrics = yarnClient.getYarnClusterMetrics();

        ps.append("NodeManagers in the ClusterClient " + metrics.getNumNodeManagers());
        List<NodeReport> nodes = yarnClient.getNodeReports(NodeState.RUNNING);
        final String format = "|%-16s |%-16s %n";
        ps.printf("|Property         |Value          %n");
        ps.println("+---------------------------------------+");
        int totalMemory = 0;
        int totalCores = 0;
        for (NodeReport rep : nodes) {
            final Resource res = rep.getCapability();
            totalMemory += res.getMemory();
            totalCores += res.getVirtualCores();
            ps.format(format, "NodeID", rep.getNodeId());
            ps.format(format, "Memory", res.getMemory() + " MB");
            ps.format(format, "vCores", res.getVirtualCores());
            ps.format(format, "HealthReport", rep.getHealthReport());
            ps.format(format, "Containers", rep.getNumContainers());
            ps.println("+---------------------------------------+");
        }
        ps.println("Summary: totalMemory " + totalMemory + " totalCores " + totalCores);
        List<QueueInfo> qInfo = yarnClient.getAllQueues();
        for (QueueInfo q : qInfo) {
            ps.println("Queue: " + q.getQueueName() + ", Current Capacity: " + q.getCurrentCapacity()
                    + " Max Capacity: " + q.getMaximumCapacity() + " Applications: "
                    + q.getApplications().size());
        }
        yarnClient.stop();
        return baos.toString();
    } catch (Exception e) {
        throw new RuntimeException("Couldn't get cluster description", e);
    }
}

From source file:org.apache.flink.yarn.FlinkYarnClient.java

License:Apache License

public String getClusterDescription() throws Exception {

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);

    YarnClusterMetrics metrics = yarnClient.getYarnClusterMetrics();

    ps.append("NodeManagers in the Cluster " + metrics.getNumNodeManagers());
    List<NodeReport> nodes = yarnClient.getNodeReports(NodeState.RUNNING);
    final String format = "|%-16s |%-16s %n";
    ps.printf("|Property         |Value          %n");
    ps.println("+---------------------------------------+");
    int totalMemory = 0;
    int totalCores = 0;
    for (NodeReport rep : nodes) {
        final Resource res = rep.getCapability();
        totalMemory += res.getMemory();//from   w ww . j a v  a  2  s  .c om
        totalCores += res.getVirtualCores();
        ps.format(format, "NodeID", rep.getNodeId());
        ps.format(format, "Memory", res.getMemory() + " MB");
        ps.format(format, "vCores", res.getVirtualCores());
        ps.format(format, "HealthReport", rep.getHealthReport());
        ps.format(format, "Containers", rep.getNumContainers());
        ps.println("+---------------------------------------+");
    }
    ps.println("Summary: totalMemory " + totalMemory + " totalCores " + totalCores);
    List<QueueInfo> qInfo = yarnClient.getAllQueues();
    for (QueueInfo q : qInfo) {
        ps.println("Queue: " + q.getQueueName() + ", Current Capacity: " + q.getCurrentCapacity()
                + " Max Capacity: " + q.getMaximumCapacity() + " Applications: " + q.getApplications().size());
    }
    yarnClient.stop();
    return baos.toString();
}

From source file:org.apache.flink.yarn.FlinkYarnClientBase.java

License:Apache License

@Override
public String getClusterDescription() throws Exception {

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);

    YarnClusterMetrics metrics = yarnClient.getYarnClusterMetrics();

    ps.append("NodeManagers in the Cluster " + metrics.getNumNodeManagers());
    List<NodeReport> nodes = yarnClient.getNodeReports(NodeState.RUNNING);
    final String format = "|%-16s |%-16s %n";
    ps.printf("|Property         |Value          %n");
    ps.println("+---------------------------------------+");
    int totalMemory = 0;
    int totalCores = 0;
    for (NodeReport rep : nodes) {
        final Resource res = rep.getCapability();
        totalMemory += res.getMemory();/*w  ww  .ja  va2 s .co m*/
        totalCores += res.getVirtualCores();
        ps.format(format, "NodeID", rep.getNodeId());
        ps.format(format, "Memory", res.getMemory() + " MB");
        ps.format(format, "vCores", res.getVirtualCores());
        ps.format(format, "HealthReport", rep.getHealthReport());
        ps.format(format, "Containers", rep.getNumContainers());
        ps.println("+---------------------------------------+");
    }
    ps.println("Summary: totalMemory " + totalMemory + " totalCores " + totalCores);
    List<QueueInfo> qInfo = yarnClient.getAllQueues();
    for (QueueInfo q : qInfo) {
        ps.println("Queue: " + q.getQueueName() + ", Current Capacity: " + q.getCurrentCapacity()
                + " Max Capacity: " + q.getMaximumCapacity() + " Applications: " + q.getApplications().size());
    }
    yarnClient.stop();
    return baos.toString();
}

From source file:uk.ac.gla.terrier.probos.controller.ControllerServer.java

License:Open Source License

@Override
public PBSNodeStatus[] getNodesStatus() throws Exception {

    //first use the container reports of all running jobs to get a picture of the hosts in use
    //for each job
    TIntObjectHashMap<List<ContainerId>> job2con = getAllActiveContainers();
    final Map<String, TIntArrayList> node2job = new HashMap<String, TIntArrayList>();
    job2con.forEachEntry(new TIntObjectProcedure<List<ContainerId>>() {
        @Override/*from   w  w w  .  j a  va2s .  c  om*/
        public boolean execute(int jobId, List<ContainerId> containerList) {
            for (ContainerId cid : containerList) {
                try {
                    ContainerReport cr = yClient.getContainerReport(cid);
                    String hostname = cr.getAssignedNode().getHost();

                    TIntArrayList jobs = node2job.get(hostname);
                    if (jobs == null)
                        node2job.put(hostname, jobs = new TIntArrayList());
                    jobs.add(jobId);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            return true;
        }
    });

    List<NodeReport> nodeReports = yClient.getNodeReports();

    PBSNodeStatus[] rtr = new PBSNodeStatus[nodeReports.size()];
    for (int i = 0; i < rtr.length; i++) {
        final NodeReport node = nodeReports.get(i);
        String hostname = node.getNodeId().getHost();
        String yarnState = node.getNodeState().toString();

        String rack = node.getRackName();
        String tracker = node.getHttpAddress();
        int numContainers = node.getNumContainers();
        int numProcs = node.getCapability().getVirtualCores();
        TIntArrayList jobList = node2job.get(hostname);
        int[] jobs;
        if (jobList == null)
            jobs = new int[0];
        else
            jobs = jobList.toArray();

        String state = "free";
        if (numContainers >= numProcs)
            state = "busy";

        StringBuilder status = new StringBuilder();
        status.append("capacity=" + node.getCapability().toString());
        status.append(",used=" + node.getUsed().toString());

        rtr[i] = new PBSNodeStatus(hostname, state, status.toString(), jobs, tracker, node.getHealthReport(),
                rack, yarnState, numProcs, node.getNodeLabels());
    }
    return rtr;
}