Java Code Examples for org.apache.hadoop.yarn.client.api.YarnClient#close()

The following examples show how to use org.apache.hadoop.yarn.client.api.YarnClient#close() . 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: LogsCLI.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private int verifyApplicationState(ApplicationId appId) throws IOException,
    YarnException {
  YarnClient yarnClient = createYarnClient();

  try {
    ApplicationReport appReport = yarnClient.getApplicationReport(appId);
    switch (appReport.getYarnApplicationState()) {
    case NEW:
    case NEW_SAVING:
    case SUBMITTED:
      return -1;
    case ACCEPTED:
    case RUNNING:
    case FAILED:
    case FINISHED:
    case KILLED:
    default:
      break;

    }
  } finally {
    yarnClient.close();
  }
  return 0;
}
 
Example 2
Source File: TestYarnClient.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test (timeout = 10000)
public void testGetLabelsToNodes() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  // Get labels to nodes mapping
  Map<String, Set<NodeId>> expectedLabelsToNodes =
      ((MockYarnClient)client).getLabelsToNodesMap();
  Map<String, Set<NodeId>> labelsToNodes = client.getLabelsToNodes();
  Assert.assertEquals(labelsToNodes, expectedLabelsToNodes);
  Assert.assertEquals(labelsToNodes.size(), 3);

  // Get labels to nodes for selected labels
  Set<String> setLabels = new HashSet<String>(Arrays.asList("x", "z"));
  expectedLabelsToNodes =
      ((MockYarnClient)client).getLabelsToNodesMap(setLabels);
  labelsToNodes = client.getLabelsToNodes(setLabels);
  Assert.assertEquals(labelsToNodes, expectedLabelsToNodes);
  Assert.assertEquals(labelsToNodes.size(), 2);

  client.stop();
  client.close();
}
 
Example 3
Source File: LogsCLI.java    From big-c with Apache License 2.0 6 votes vote down vote up
private int verifyApplicationState(ApplicationId appId) throws IOException,
    YarnException {
  YarnClient yarnClient = createYarnClient();

  try {
    ApplicationReport appReport = yarnClient.getApplicationReport(appId);
    switch (appReport.getYarnApplicationState()) {
    case NEW:
    case NEW_SAVING:
    case SUBMITTED:
      return -1;
    case ACCEPTED:
    case RUNNING:
    case FAILED:
    case FINISHED:
    case KILLED:
    default:
      break;

    }
  } finally {
    yarnClient.close();
  }
  return 0;
}
 
Example 4
Source File: TestYarnClient.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test (timeout = 10000)
public void testGetLabelsToNodes() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  // Get labels to nodes mapping
  Map<String, Set<NodeId>> expectedLabelsToNodes =
      ((MockYarnClient)client).getLabelsToNodesMap();
  Map<String, Set<NodeId>> labelsToNodes = client.getLabelsToNodes();
  Assert.assertEquals(labelsToNodes, expectedLabelsToNodes);
  Assert.assertEquals(labelsToNodes.size(), 3);

  // Get labels to nodes for selected labels
  Set<String> setLabels = new HashSet<String>(Arrays.asList("x", "z"));
  expectedLabelsToNodes =
      ((MockYarnClient)client).getLabelsToNodesMap(setLabels);
  labelsToNodes = client.getLabelsToNodes(setLabels);
  Assert.assertEquals(labelsToNodes, expectedLabelsToNodes);
  Assert.assertEquals(labelsToNodes.size(), 2);

  client.stop();
  client.close();
}