/** * Finds the local directories that logs for the given container are stored * on. */ public static List<File> getContainerLogDirs(ContainerId containerId, String remoteUser, Context context) throws YarnException { Container container = context.getContainers().get(containerId); Application application = getApplicationForContainer(containerId, context); checkAccess(remoteUser, application, context); // It is not required to have null check for container ( container == null ) // and throw back exception.Because when container is completed, NodeManager // remove container information from its NMContext.Configuring log // aggregation to false, container log view request is forwarded to NM. NM // does not have completed container information,but still NM serve request for // reading container logs. if (container != null) { checkState(container.getContainerState()); } return getContainerLogDirs(containerId, context.getLocalDirsHandler()); }
/** * 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."); } }
List<File> logFiles = ContainerLogsUtils.getContainerLogDirs(containerId, request().getRemoteUser(), nmContext); printLogFileDirectory(html, logFiles); } else { File logFile = ContainerLogsUtils.getContainerLogFile(containerId, $(CONTAINER_LOG_TYPE), request().getRemoteUser(), nmContext); printLogFile(html, logFile);
logFile = ContainerLogsUtils.getContainerLogFile( containerId, filename, request.getRemoteUser(), nmContext); } catch (NotFoundException ex) { final FileInputStream fis = ContainerLogsUtils.openLogFileForRead( containerIdStr, logFile, nmContext);
logByteStream = ContainerLogsUtils.openLogFileForRead($(CONTAINER_ID), logFile, nmContext); } catch (IOException ex) {
private List<String> getContainerLogFiles(ContainerId id, String remoteUser, Context nmContext) { List<String> logFiles = new ArrayList<>(); try { List<File> logDirs = ContainerLogsUtils.getContainerLogDirs(id, remoteUser, nmContext); for (File containerLogsDir : logDirs) { File[] logs = containerLogsDir.listFiles(); if (logs != null) { for (File log : logs) { if (log.isFile()) { logFiles.add(log.getName()); } } } } } catch (Exception ye) { return logFiles; } return logFiles; }
/** * 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."); } }
List<File> logFiles = ContainerLogsUtils.getContainerLogDirs(containerId, request().getRemoteUser(), nmContext); printLogFileDirectory(html, logFiles); } else { File logFile = ContainerLogsUtils.getContainerLogFile(containerId, $(CONTAINER_LOG_TYPE), request().getRemoteUser(), nmContext); printLogFile(html, logFile);
logFile = ContainerLogsUtils.getContainerLogFile( containerId, filename, request.getRemoteUser(), nmContext); } catch (NotFoundException ex) { final FileInputStream fis = ContainerLogsUtils.openLogFileForRead( containerIdStr, logFile, nmContext);
logByteStream = ContainerLogsUtils.openLogFileForRead($(CONTAINER_ID), logFile, nmContext); } catch (IOException ex) {
private List<String> getContainerLogFiles(ContainerId id, String remoteUser, Context nmContext) { List<String> logFiles = new ArrayList<>(); try { List<File> logDirs = ContainerLogsUtils.getContainerLogDirs(id, remoteUser, nmContext); for (File containerLogsDir : logDirs) { File[] logs = containerLogsDir.listFiles(); if (logs != null) { for (File log : logs) { if (log.isFile()) { logFiles.add(log.getName()); } } } } } catch (Exception ye) { return logFiles; } return logFiles; }
/** * Finds the local directories that logs for the given container are stored * on. */ public static List<File> getContainerLogDirs(ContainerId containerId, String remoteUser, Context context) throws YarnException { Container container = context.getContainers().get(containerId); Application application = getApplicationForContainer(containerId, context); checkAccess(remoteUser, application, context); // It is not required to have null check for container ( container == null ) // and throw back exception.Because when container is completed, NodeManager // remove container information from its NMContext.Configuring log // aggregation to false, container log view request is forwarded to NM. NM // does not have completed container information,but still NM serve request for // reading container logs. if (container != null) { checkState(container.getContainerState()); } return getContainerLogDirs(containerId, context.getLocalDirsHandler()); }
/** * 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."); } }
List<File> logFiles = ContainerLogsUtils.getContainerLogDirs(containerId, request().getRemoteUser(), nmContext); printLogFileDirectory(html, logFiles); } else { File logFile = ContainerLogsUtils.getContainerLogFile(containerId, $(CONTAINER_LOG_TYPE), request().getRemoteUser(), nmContext, nmContext.getApplications().get(containerId.getApplicationAttemptId().getApplicationId()).getUserFolder());
logFile = ContainerLogsUtils.getContainerLogFile( containerId, filename, request.getRemoteUser(), nmContext, nmContext.getApplications().get(containerId.getApplicationAttemptId().getApplicationId()).getUserFolder()); final FileInputStream fis = ContainerLogsUtils.openLogFileForRead( containerIdStr, logFile, nmContext);
logByteStream = ContainerLogsUtils.openLogFileForRead($(CONTAINER_ID), logFile, nmContext); } catch (IOException ex) {
private static List<ContainerLogFileInfo> getContainerLogsInfo( ContainerId id, String remoteUser, Context nmContext) throws YarnException { List<ContainerLogFileInfo> logFiles = new ArrayList<>(); List<File> logDirs = ContainerLogsUtils.getContainerLogDirs( id, remoteUser, nmContext); for (File containerLogsDir : logDirs) { File[] logs = containerLogsDir.listFiles(); if (logs != null) { for (File log : logs) { if (log.isFile()) { ContainerLogFileInfo logMeta = new ContainerLogFileInfo( log.getName(), Long.toString(log.length()), Times.format(log.lastModified())); logFiles.add(logMeta); } } } } return logFiles; } }
/** * Finds the local directories that logs for the given container are stored * on. */ public static List<File> getContainerLogDirs(ContainerId containerId, String remoteUser, Context context) throws YarnException { Container container = context.getContainers().get(containerId); Application application = getApplicationForContainer(containerId, context); checkAccess(remoteUser, application, context); // It is not required to have null check for container ( container == null ) // and throw back exception.Because when container is completed, NodeManager // remove container information from its NMContext.Configuring log // aggregation to false, container log view request is forwarded to NM. NM // does not have completed container information,but still NM serve request for // reading container logs. if (container != null) { checkState(container.getContainerState()); } return getContainerLogDirs(containerId, context.getLocalDirsHandler()); }
/** * 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."); } }
if ($(CONTAINER_LOG_TYPE).isEmpty()) { html.h2("Local Logs:"); List<File> logFiles = ContainerLogsUtils.getContainerLogDirs(containerId, request().getRemoteUser(), nmContext); printLocalLogFileDirectory(html, logFiles); aggregationType.trim().toLowerCase().equals( LOG_AGGREGATION_LOCAL_TYPE)) { File logFile = ContainerLogsUtils.getContainerLogFile(containerId, $(CONTAINER_LOG_TYPE), request().getRemoteUser(), nmContext); printLocalLogFile(html, logFile);