当前位置: 首页>>代码示例>>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;未经允许,请勿转载。