本文整理汇总了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);
}
示例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);
}
示例3: toString
import org.apache.hadoop.yarn.api.records.ApplicationId; //导入方法依赖的package包/类
public static String toString(ApplicationId appId) {
return appId.toString();
}
示例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);
}
示例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());
}