当前位置: 首页>>代码示例>>Java>>正文


Java ContainerLaunch.getRelativeContainerLogDir方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.getRelativeContainerLogDir方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerLaunch.getRelativeContainerLogDir方法的具体用法?Java ContainerLaunch.getRelativeContainerLogDir怎么用?Java ContainerLaunch.getRelativeContainerLogDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch的用法示例。


在下文中一共展示了ContainerLaunch.getRelativeContainerLogDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContainerLogFile

import org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch; //导入方法依赖的package包/类
/**
 * Finds the log file with the given filename for the given container.
 */
public static File getContainerLogFile(ContainerId containerId,
    String fileName, String remoteUser, Context context) throws YarnException {
  Container container = context.getContainers().get(containerId);
  
  Application application = getApplicationForContainer(containerId, context);
  checkAccess(remoteUser, application, context);
  if (container != null) {
    checkState(container.getContainerState());
  }
  
  try {
    LocalDirsHandlerService dirsHandler = context.getLocalDirsHandler();
    String relativeContainerLogDir = ContainerLaunch.getRelativeContainerLogDir(
        application.getAppId().toString(), containerId.toString());
    Path logPath = dirsHandler.getLogPathToRead(
        relativeContainerLogDir + Path.SEPARATOR + fileName);
    URI logPathURI = new File(logPath.toString()).toURI();
    File logFile = new File(logPathURI.getPath());
    return logFile;
  } catch (IOException e) {
    LOG.warn("Failed to find log file", e);
    throw new NotFoundException("Cannot find this log on the local disk.");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:ContainerLogsUtils.java

示例2: getContainerLogFile

import org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch; //导入方法依赖的package包/类
/**
 * Finds the log file with the given filename for the given container.
 */
public static File getContainerLogFile(ContainerId containerId,
    String fileName, String remoteUser, Context context, String userFolder) throws YarnException {
  Container container = context.getContainers().get(containerId);
  
  Application application = getApplicationForContainer(containerId, context);
  checkAccess(remoteUser, application, context);
  if (container != null) {
    checkState(container.getContainerState());
  }
  
  try {
    LocalDirsHandlerService dirsHandler = context.getLocalDirsHandler();
    String relativeContainerLogDir = ContainerLaunch.getRelativeContainerLogDir(
        application.getAppId().toString(), containerId.toString(), userFolder);
    Path logPath = dirsHandler.getLogPathToRead(
        relativeContainerLogDir + Path.SEPARATOR + fileName);
    URI logPathURI = new File(logPath.toString()).toURI();
    File logFile = new File(logPathURI.getPath());
    return logFile;
  } catch (IOException e) {
    LOG.warn("Failed to find log file", e);
    throw new NotFoundException("Cannot find this log on the local disk.");
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:28,代码来源:ContainerLogsUtils.java

示例3: testContainerLogFile

import org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch; //导入方法依赖的package包/类
@Test(timeout=30000)
public void testContainerLogFile() throws IOException, YarnException {
  File absLogDir = new File("target",
      TestNMWebServer.class.getSimpleName() + "LogDir").getAbsoluteFile();
  String logdirwithFile = absLogDir.toURI().toString();
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.NM_LOG_DIRS, logdirwithFile);
  conf.setFloat(YarnConfiguration.NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE,
      0.0f);
  LocalDirsHandlerService dirsHandler = new LocalDirsHandlerService();
  dirsHandler.init(conf);
  NMContext nmContext = new NodeManager.NMContext(null, null, dirsHandler,
      new ApplicationACLsManager(conf), new NMNullStateStoreService());
  // Add an application and the corresponding containers
  String user = "nobody";
  long clusterTimeStamp = 1234;
  ApplicationId appId = BuilderUtils.newApplicationId(
      clusterTimeStamp, 1);
  Application app = mock(Application.class);
  when(app.getUser()).thenReturn(user);
  when(app.getAppId()).thenReturn(appId);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      appId, 1);
  ContainerId containerId = BuilderUtils.newContainerId(
      appAttemptId, 1);
  nmContext.getApplications().put(appId, app);

  MockContainer container =
      new MockContainer(appAttemptId, new AsyncDispatcher(), conf, user,
          appId, 1);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(containerId, container);
  File containerLogDir = new File(absLogDir,
      ContainerLaunch.getRelativeContainerLogDir(appId.toString(),
          containerId.toString()));
  containerLogDir.mkdirs();
  String fileName = "fileName";
  File containerLogFile = new File(containerLogDir, fileName);
  containerLogFile.createNewFile();
  File file = ContainerLogsUtils.getContainerLogFile(containerId,
      fileName, user, nmContext);
  Assert.assertEquals(containerLogFile.toURI().toString(),
      file.toURI().toString());
  FileUtil.fullyDelete(absLogDir);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:46,代码来源:TestContainerLogsPage.java

示例4: testContainerLogFile

import org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch; //导入方法依赖的package包/类
@Test(timeout=30000)
public void testContainerLogFile() throws IOException, YarnException {
  File absLogDir = new File("target",
      TestNMWebServer.class.getSimpleName() + "LogDir").getAbsoluteFile();
  String logdirwithFile = absLogDir.toURI().toString();
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.NM_LOG_DIRS, logdirwithFile);
  conf.setFloat(YarnConfiguration.NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE,
      0.0f);
  LocalDirsHandlerService dirsHandler = new LocalDirsHandlerService();
  dirsHandler.init(conf);
  NMContext nmContext = new NodeManager.NMContext(null, null, dirsHandler,
      new ApplicationACLsManager(conf), new NMNullStateStoreService());
  // Add an application and the corresponding containers
  String user = "nobody";
  String userFolder = "nobodysFolder";
  long clusterTimeStamp = 1234;
  ApplicationId appId = BuilderUtils.newApplicationId(
      clusterTimeStamp, 1);
  Application app = mock(Application.class);
  when(app.getUser()).thenReturn(user);
  when(app.getAppId()).thenReturn(appId);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      appId, 1);
  ContainerId containerId = BuilderUtils.newContainerId(
      appAttemptId, 1);
  nmContext.getApplications().put(appId, app);

  MockContainer container =
      new MockContainer(appAttemptId, new AsyncDispatcher(), conf, user,
          appId, 1, userFolder);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(containerId, container);
  File containerLogDir = new File(absLogDir,
      ContainerLaunch.getRelativeContainerLogDir(appId.toString(),
          containerId.toString(), userFolder));
  containerLogDir.mkdirs();
  String fileName = "fileName";
  File containerLogFile = new File(containerLogDir, fileName);
  containerLogFile.createNewFile();
  File file = ContainerLogsUtils.getContainerLogFile(containerId,
      fileName, user, nmContext, userFolder);
  Assert.assertEquals(containerLogFile.toURI().toString(),
      file.toURI().toString());
  FileUtil.fullyDelete(absLogDir);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:47,代码来源:TestContainerLogsPage.java


注:本文中的org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.getRelativeContainerLogDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。