當前位置: 首頁>>代碼示例>>Java>>正文


Java YarnClient.start方法代碼示例

本文整理匯總了Java中org.apache.hadoop.yarn.client.api.YarnClient.start方法的典型用法代碼示例。如果您正苦於以下問題:Java YarnClient.start方法的具體用法?Java YarnClient.start怎麽用?Java YarnClient.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.yarn.client.api.YarnClient的用法示例。


在下文中一共展示了YarnClient.start方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: killApplication

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
public static void killApplication(String applicationId) throws Exception {
  try {
    YarnClient yarnClient = YarnClient.createYarnClient();
    yarnClient.init(conf);
    yarnClient.start();
    LOGGER.logInfo("[yarn application -kill %s]", applicationId);
    yarnClient.killApplication(ConverterUtils.toApplicationId(applicationId));
    yarnClient.stop();
  } catch (ApplicationNotFoundException ignored) {
  } catch (Exception e) {
    if (e.getMessage().toLowerCase().contains("invalid applicationid")) {
      // ignored
    } else {
      throw e;
    }
  }
}
 
開發者ID:Microsoft,項目名稱:pai,代碼行數:18,代碼來源:HadoopUtils.java

示例2: verifyClientConnection

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
private void verifyClientConnection() {
  int numRetries = 3;
  while(numRetries-- > 0) {
    Configuration conf = new YarnConfiguration(this.conf);
    YarnClient client = YarnClient.createYarnClient();
    client.init(conf);
    client.start();
    try {
      client.getApplications();
      return;
    } catch (Exception e) {
      LOG.error(e);
    } finally {
      client.stop();
    }
  }
  fail("Client couldn't connect to the Active RM");
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:TestRMFailover.java

示例3: testKillApplication

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
@Test
public void testKillApplication() throws Exception {
  MockRM rm = new MockRM();
  rm.start();
  RMApp app = rm.submitApp(2000);

  Configuration conf = new Configuration();
  @SuppressWarnings("resource")
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  client.killApplication(app.getApplicationId());
  verify(((MockYarnClient) client).getRMClient(), times(2))
    .forceKillApplication(any(KillApplicationRequest.class));
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:TestYarnClient.java

示例4: testGetApplicationAttempts

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
@Test(timeout = 10000)
public void testGetApplicationAttempts() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  List<ApplicationAttemptReport> reports = client
      .getApplicationAttempts(applicationId);
  Assert.assertNotNull(reports);
  Assert.assertEquals(reports.get(0).getApplicationAttemptId(),
      ApplicationAttemptId.newInstance(applicationId, 1));
  Assert.assertEquals(reports.get(1).getApplicationAttemptId(),
      ApplicationAttemptId.newInstance(applicationId, 2));
  client.stop();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:18,代碼來源:TestYarnClient.java

示例5: testGetApplicationAttempt

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports = ((MockYarnClient) client)
      .getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      applicationId, 1);
  ApplicationAttemptReport report = client
      .getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
      expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:TestYarnClient.java

示例6: testGetLabelsToNodes

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
@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();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:TestYarnClient.java

示例7: testGetLabelsToNodes

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
@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<NodeLabel, Set<NodeId>> expectedLabelsToNodes =
      ((MockYarnClient)client).getLabelsToNodesMap();
  Map<NodeLabel, 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();
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:26,代碼來源:TestYarnClient.java

示例8: testSignalContainer

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
@Test
public void testSignalContainer() throws Exception {
  Configuration conf = new Configuration();
  @SuppressWarnings("resource")
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();
  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      applicationId, 1);
  ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
  SignalContainerCommand command = SignalContainerCommand.OUTPUT_THREAD_DUMP;
  client.signalContainer(containerId, command);
  final ArgumentCaptor<SignalContainerRequest> signalReqCaptor =
      ArgumentCaptor.forClass(SignalContainerRequest.class);
  verify(((MockYarnClient) client).getRMClient())
      .signalContainer(signalReqCaptor.capture());
  SignalContainerRequest request = signalReqCaptor.getValue();
  Assert.assertEquals(containerId, request.getContainerId());
  Assert.assertEquals(command, request.getCommand());
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:22,代碼來源:TestYarnClient.java

示例9: getLiveContainerIdsFromRM

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
public static HashSet<String> getLiveContainerIdsFromRM(String attemptId, String amContainerId) throws Exception {
  HashSet<String> containerIds = new HashSet<>();

  YarnClient yarnClient = YarnClient.createYarnClient();
  yarnClient.init(conf);
  yarnClient.start();
  List<ContainerReport> containerReports = yarnClient.getContainers(ConverterUtils.toApplicationAttemptId(attemptId));
  yarnClient.stop();

  // Since we at least has AM container, so we check whether the containerReports is reliable
  if (containerReports == null) {
    throw new Exception(
        String.format("Container reports of attempt %s is empty , but AM container exists",
            attemptId));
  }

  for (ContainerReport containerReport : containerReports) {
    if (containerReport.getContainerState() == ContainerState.COMPLETE) {
      continue;
    }
    containerIds.add(containerReport.getContainerId().toString());
  }

  if (!containerIds.contains(amContainerId)) {
    throw new Exception(
        String.format("Container reports of attempt %s does not contain AM container %s",
            attemptId, amContainerId));
  }
  containerIds.remove(amContainerId);

  return containerIds;
}
 
開發者ID:Microsoft,項目名稱:pai,代碼行數:33,代碼來源:HadoopUtils.java

示例10: Client

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
Client(Configuration conf, YarnClient yarnClient) {
  super("Client");
  this.conf = conf;
  this.yarnClient = yarnClient;
  yarnClient.init(conf);
  yarnClient.start();
  LOG.info("Starting YarnClient...");
}
 
開發者ID:Intel-bigdata,項目名稱:TensorFlowOnYARN,代碼行數:9,代碼來源:Client.java

示例11: createYarnClient

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
@VisibleForTesting
protected YarnClient createYarnClient() {
  YarnClient yarnClient = YarnClient.createYarnClient();
  yarnClient.init(getConf());
  yarnClient.start();
  return yarnClient;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:8,代碼來源:LogsCLI.java

示例12: createAndStartYarnClient

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
protected YarnClient createAndStartYarnClient(Configuration conf) {
  Configuration configuration = new YarnConfiguration(conf);
  YarnClient client = YarnClient.createYarnClient();
  client.init(configuration);
  client.start();
  return client;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:8,代碼來源:ProtocolHATestBase.java

示例13: testClientStop

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
@Test
public void testClientStop() {
  Configuration conf = new Configuration();
  ResourceManager rm = new ResourceManager();
  rm.init(conf);
  rm.start();

  YarnClient client = YarnClient.createYarnClient();
  client.init(conf);
  client.start();
  client.stop();
  rm.stop();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:14,代碼來源:TestYarnClient.java

示例14: testGetContainers

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
@Test(timeout = 10000)
public void testGetContainers() throws YarnException, IOException {
  Configuration conf = new Configuration();
  conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED,
      true);
  
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      applicationId, 1);
  List<ContainerReport> reports = client.getContainers(appAttemptId);
  Assert.assertNotNull(reports);
  Assert.assertEquals(reports.get(0).getContainerId(),
      (ContainerId.newContainerId(appAttemptId, 1)));
  Assert.assertEquals(reports.get(1).getContainerId(),
      (ContainerId.newContainerId(appAttemptId, 2)));
  Assert.assertEquals(reports.get(2).getContainerId(),
      (ContainerId.newContainerId(appAttemptId, 3)));
  
  //First2 containers should come from RM with updated state information and 
  // 3rd container is not there in RM and should
  Assert.assertEquals(ContainerState.RUNNING,
      (reports.get(0).getContainerState()));
  Assert.assertEquals(ContainerState.RUNNING,
      (reports.get(1).getContainerState()));
  Assert.assertEquals(ContainerState.COMPLETE,
      (reports.get(2).getContainerState()));
  client.stop();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:33,代碼來源:TestYarnClient.java

示例15: testGetContainerReport

import org.apache.hadoop.yarn.client.api.YarnClient; //導入方法依賴的package包/類
@Test(timeout = 10000)
public void testGetContainerReport() throws YarnException, IOException {
  Configuration conf = new Configuration();
  conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED,
      true);
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports = ((MockYarnClient) client)
      .getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      applicationId, 1);
  ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
  ContainerReport report = client.getContainerReport(containerId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getContainerId().toString(),
      (ContainerId.newContainerId(expectedReports.get(0)
          .getCurrentApplicationAttemptId(), 1)).toString());
  containerId = ContainerId.newContainerId(appAttemptId, 3);
  report = client.getContainerReport(containerId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getContainerId().toString(),
      (ContainerId.newContainerId(expectedReports.get(0)
          .getCurrentApplicationAttemptId(), 3)).toString());
  client.stop();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:30,代碼來源:TestYarnClient.java


注:本文中的org.apache.hadoop.yarn.client.api.YarnClient.start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。