Java Code Examples for org.apache.hadoop.yarn.client.api.YarnClient#getNodeReports()
The following examples show how to use
org.apache.hadoop.yarn.client.api.YarnClient#getNodeReports() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractYarnClusterDescriptor.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private ClusterResourceDescription getCurrentFreeClusterResources(YarnClient yarnClient) throws YarnException, IOException { List<NodeReport> nodes = yarnClient.getNodeReports(NodeState.RUNNING); int totalFreeMemory = 0; int containerLimit = 0; int[] nodeManagersFree = new int[nodes.size()]; for (int i = 0; i < nodes.size(); i++) { NodeReport rep = nodes.get(i); int free = rep.getCapability().getMemory() - (rep.getUsed() != null ? rep.getUsed().getMemory() : 0); nodeManagersFree[i] = free; totalFreeMemory += free; if (free > containerLimit) { containerLimit = free; } } return new ClusterResourceDescription(totalFreeMemory, containerLimit, nodeManagersFree); }
Example 2
Source File: AbstractYarnClusterDescriptor.java From flink with Apache License 2.0 | 6 votes |
private ClusterResourceDescription getCurrentFreeClusterResources(YarnClient yarnClient) throws YarnException, IOException { List<NodeReport> nodes = yarnClient.getNodeReports(NodeState.RUNNING); int totalFreeMemory = 0; int containerLimit = 0; int[] nodeManagersFree = new int[nodes.size()]; for (int i = 0; i < nodes.size(); i++) { NodeReport rep = nodes.get(i); int free = rep.getCapability().getMemory() - (rep.getUsed() != null ? rep.getUsed().getMemory() : 0); nodeManagersFree[i] = free; totalFreeMemory += free; if (free > containerLimit) { containerLimit = free; } } return new ClusterResourceDescription(totalFreeMemory, containerLimit, nodeManagersFree); }
Example 3
Source File: YarnClusterDescriptor.java From flink with Apache License 2.0 | 6 votes |
private ClusterResourceDescription getCurrentFreeClusterResources(YarnClient yarnClient) throws YarnException, IOException { List<NodeReport> nodes = yarnClient.getNodeReports(NodeState.RUNNING); int totalFreeMemory = 0; int containerLimit = 0; int[] nodeManagersFree = new int[nodes.size()]; for (int i = 0; i < nodes.size(); i++) { NodeReport rep = nodes.get(i); int free = rep.getCapability().getMemory() - (rep.getUsed() != null ? rep.getUsed().getMemory() : 0); nodeManagersFree[i] = free; totalFreeMemory += free; if (free > containerLimit) { containerLimit = free; } } return new ClusterResourceDescription(totalFreeMemory, containerLimit, nodeManagersFree); }
Example 4
Source File: Hadoop21YarnAppClient.java From twill with Apache License 2.0 | 5 votes |
@Override public List<NodeReport> getNodeReports() throws Exception { YarnClient yarnClient = createYarnClient(); try { return yarnClient.getNodeReports(); } finally { yarnClient.stop(); } }
Example 5
Source File: SolrClient.java From yarn-proto with Apache License 2.0 | 5 votes |
protected void logYarnDiagnostics(YarnClient yarnClient) throws IOException, YarnException { YarnClusterMetrics clusterMetrics = yarnClient.getYarnClusterMetrics(); log.info("Got Cluster metric info from ASM" + ", numNodeManagers=" + clusterMetrics.getNumNodeManagers()); List<NodeReport> clusterNodeReports = yarnClient.getNodeReports(); log.info("Got Cluster node info from ASM"); for (NodeReport node : clusterNodeReports) { log.info("Got node report from ASM for" + ", nodeId=" + node.getNodeId() + ", nodeAddress" + node.getHttpAddress() + ", nodeRackName" + node.getRackName() + ", nodeNumContainers" + node.getNumContainers()); } QueueInfo queueInfo = yarnClient.getQueueInfo("default"); log.info("Queue info" + ", queueName=" + queueInfo.getQueueName() + ", queueCurrentCapacity=" + queueInfo.getCurrentCapacity() + ", queueMaxCapacity=" + queueInfo.getMaximumCapacity() + ", queueApplicationCount=" + queueInfo.getApplications().size() + ", queueChildQueueCount=" + queueInfo.getChildQueues().size()); List<QueueUserACLInfo> listAclInfo = yarnClient.getQueueAclsInfo(); for (QueueUserACLInfo aclInfo : listAclInfo) { for (QueueACL userAcl : aclInfo.getUserAcls()) { log.info("User ACL Info for Queue" + ", queueName=" + aclInfo.getQueueName() + ", userAcl=" + userAcl.name()); } } }
Example 6
Source File: Client.java From stratosphere with Apache License 2.0 | 5 votes |
private void showClusterMetrics(YarnClient yarnClient) throws YarnException, IOException { YarnClusterMetrics metrics = yarnClient.getYarnClusterMetrics(); System.out.println("NodeManagers in Cluster " + metrics.getNumNodeManagers()); List<NodeReport> nodes = yarnClient.getNodeReports(); 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(); 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); }