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


Java ApplicationId.toString方法代碼示例

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


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

示例1: run

import org.apache.hadoop.yarn.api.records.ApplicationId; //導入方法依賴的package包/類
public boolean run() throws Exception {
  YarnClientApplication app = createApplication();
  ApplicationId appId = app.getNewApplicationResponse().getApplicationId();

  // Copy the application jar to the filesystem
  FileSystem fs = FileSystem.get(conf);
  String appIdStr = appId.toString();
  Path dstJarPath = Utils.copyLocalFileToDfs(fs, appIdStr, new Path(tfJar), Constants.TF_JAR_NAME);
  Path dstLibPath = Utils.copyLocalFileToDfs(fs, appIdStr, new Path(tfLib),
      Constants.TF_LIB_NAME);
  Map<String, Path> files = new HashMap<>();
  files.put(Constants.TF_JAR_NAME, dstJarPath);
  Map<String, LocalResource> localResources = Utils.makeLocalResources(fs, files);
  Map<String, String> javaEnv = Utils.setJavaEnv(conf);
  String command = makeAppMasterCommand(dstLibPath.toString(), dstJarPath.toString());
  LOG.info("Make ApplicationMaster command: " + command);
  ContainerLaunchContext launchContext = ContainerLaunchContext.newInstance(
      localResources, javaEnv, Lists.newArrayList(command), null, null, null);
  Resource resource = Resource.newInstance(amMemory, amVCores);
  submitApplication(app, appName, launchContext, resource, amQueue);
  return awaitApplication(appId);
}
 
開發者ID:Intel-bigdata,項目名稱:TensorFlowOnYARN,代碼行數:23,代碼來源:LaunchCluster.java

示例2: getHistoryFileReader

import org.apache.hadoop.yarn.api.records.ApplicationId; //導入方法依賴的package包/類
private HistoryFileReader getHistoryFileReader(ApplicationId appId)
    throws IOException {
  Path applicationHistoryFile = new Path(rootDirPath, appId.toString());
  if (!fs.exists(applicationHistoryFile)) {
    throw new IOException("History file for application " + appId
        + " is not found");
  }
  // The history file is still under writing
  if (outstandingWriters.containsKey(appId)) {
    throw new IOException("History file for application " + appId
        + " is under writing");
  }
  return new HistoryFileReader(applicationHistoryFile);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:15,代碼來源:FileSystemApplicationHistoryStore.java

示例3: toString

import org.apache.hadoop.yarn.api.records.ApplicationId; //導入方法依賴的package包/類
public static String toString(ApplicationId appId) {
  return appId.toString();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:4,代碼來源:ConverterUtils.java

示例4: testContainerLogs

import org.apache.hadoop.yarn.api.records.ApplicationId; //導入方法依賴的package包/類
@Test
public void testContainerLogs() throws IOException {
  WebResource r = resource();
  final ContainerId containerId = BuilderUtils.newContainerId(0, 0, 0, 0);
  final String containerIdStr = BuilderUtils.newContainerId(0, 0, 0, 0)
      .toString();
  final ApplicationAttemptId appAttemptId = containerId.getApplicationAttemptId();
  final ApplicationId appId = appAttemptId.getApplicationId();
  final String appIdStr = appId.toString();
  final String filename = "logfile1";
  final String logMessage = "log message\n";
  nmContext.getApplications().put(appId, new ApplicationImpl(null, "user",
      appId, null, nmContext));
  
  MockContainer container = new MockContainer(appAttemptId,
      new AsyncDispatcher(), new Configuration(), "user", appId, 1);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(containerId, container);
  
  // write out log file
  Path path = dirsHandler.getLogPathForWrite(
      ContainerLaunch.getRelativeContainerLogDir(
          appIdStr, containerIdStr) + "/" + filename, false);
  
  File logFile = new File(path.toUri().getPath());
  logFile.deleteOnExit();
  assertTrue("Failed to create log dir", logFile.getParentFile().mkdirs());
  PrintWriter pw = new PrintWriter(logFile);
  pw.print(logMessage);
  pw.close();

  // ask for it
  ClientResponse response = r.path("ws").path("v1").path("node")
      .path("containerlogs").path(containerIdStr).path(filename)
      .accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
  String responseText = response.getEntity(String.class);
  assertEquals(logMessage, responseText);
  
  // ask for file that doesn't exist
  response = r.path("ws").path("v1").path("node")
      .path("containerlogs").path(containerIdStr).path("uhhh")
      .accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
  Assert.assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus());
  responseText = response.getEntity(String.class);
  assertTrue(responseText.contains("Cannot find this log on the local disk."));
  
  // After container is completed, it is removed from nmContext
  nmContext.getContainers().remove(containerId);
  Assert.assertNull(nmContext.getContainers().get(containerId));
  response =
      r.path("ws").path("v1").path("node").path("containerlogs")
          .path(containerIdStr).path(filename).accept(MediaType.TEXT_PLAIN)
          .get(ClientResponse.class);
  responseText = response.getEntity(String.class);
  assertEquals(logMessage, responseText);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:57,代碼來源:TestNMWebServices.java

示例5: getRemoteAppLogDir

import org.apache.hadoop.yarn.api.records.ApplicationId; //導入方法依賴的package包/類
/**
 * Gets the remote app log dir.
 * @param remoteRootLogDir
 * @param appId
 * @param user
 * @param suffix
 * @return the remote application specific log dir.
 */
public static Path getRemoteAppLogDir(Path remoteRootLogDir,
    ApplicationId appId, String user, String suffix) {
  return new Path(getRemoteLogSuffixedDir(remoteRootLogDir, user, suffix),
      appId.toString());
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:14,代碼來源:LogAggregationUtils.java


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