Java Code Examples for org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlock

The following examples show how to use org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlock. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   Source File: LogCLIHelpers.java    License: Apache License 2.0 4 votes vote down vote up
@Private
@VisibleForTesting
public int dumpAContainersLogs(String appId, String containerId,
    String nodeId, String jobOwner) throws IOException {

  ApplicationId applicationId = ConverterUtils.toApplicationId(appId);
  List<Path> remoteAppLogDirs = AggregatedLogsBlock.getRemoteAppLogDirs(getConf(), applicationId, jobOwner);
  String remoteAppLogDir = StringUtils.join(remoteAppLogDirs, ",");

  RemoteIterator<FileStatus> nodeFiles;
  try {
    nodeFiles = AggregatedLogsBlock.getFileListAtRemoteAppDir(getConf(), remoteAppLogDirs, applicationId, jobOwner);
  } catch (FileNotFoundException fnf) {
    logDirNotExist(remoteAppLogDir.toString());
    return -1;
  }
  boolean foundContainerLogs = false;
  while (nodeFiles.hasNext()) {
    FileStatus thisNodeFile = nodeFiles.next();
    String fileName = thisNodeFile.getPath().getName();
    if (fileName.contains(LogAggregationUtils.getNodeString(nodeId))
        && !fileName.endsWith(LogAggregationUtils.TMP_FILE_SUFFIX)) {
      AggregatedLogFormat.LogReader reader = null;
      try {
        reader =
            new AggregatedLogFormat.LogReader(getConf(),
              thisNodeFile.getPath());
        if (dumpAContainerLogs(containerId, reader, System.out,
            thisNodeFile.getModificationTime()) > -1) {
          foundContainerLogs = true;
        }
      } finally {
        if (reader != null) {
          reader.close();
        }
      }
    }
  }
  if (!foundContainerLogs) {
    containerLogNotFound(containerId);
    return -1;
  }
  return 0;
}
 
Example 2
Source Project: hadoop   Source File: LogCLIHelpers.java    License: Apache License 2.0 4 votes vote down vote up
@Private
public int dumpAllContainersLogs(ApplicationId appId, String appOwner,
    PrintStream out) throws IOException {

  List<Path> remoteAppLogDirs = AggregatedLogsBlock.getRemoteAppLogDirs(getConf(), appId, appOwner);
  String remoteAppLogDir = StringUtils.join(remoteAppLogDirs, ",");
  RemoteIterator<FileStatus> nodeFiles;
  try {
    nodeFiles = AggregatedLogsBlock.getFileListAtRemoteAppDir(getConf(), remoteAppLogDirs, appId, appOwner);
  } catch (FileNotFoundException fnf) {
    logDirNotExist(remoteAppLogDir.toString());
    return -1;
  }
  boolean foundAnyLogs = false;
  while (nodeFiles.hasNext()) {
    FileStatus thisNodeFile = nodeFiles.next();
    if (!thisNodeFile.getPath().getName()
      .endsWith(LogAggregationUtils.TMP_FILE_SUFFIX)) {
      AggregatedLogFormat.LogReader reader =
          new AggregatedLogFormat.LogReader(getConf(), thisNodeFile.getPath());
      try {

        DataInputStream valueStream;
        LogKey key = new LogKey();
        valueStream = reader.next(key);

        while (valueStream != null) {

          String containerString =
              "\n\nContainer: " + key + " on " + thisNodeFile.getPath().getName();
          out.println(containerString);
          out.println(StringUtils.repeat("=", containerString.length()));
          while (true) {
            try {
              LogReader.readAContainerLogsForALogType(valueStream, out,
                thisNodeFile.getModificationTime());
              foundAnyLogs = true;
            } catch (EOFException eof) {
              break;
            }
          }

          // Next container
          key = new LogKey();
          valueStream = reader.next(key);
        }
      } finally {
        reader.close();
      }
    }
  }
  if (! foundAnyLogs) {
    emptyLogDir(remoteAppLogDir.toString());
    return -1;
  }
  return 0;
}
 
Example 3
Source Project: XLearning   Source File: HsLogsPage.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * The content of this page is the JobBlock
 *
 * @return HsJobBlock.class
 */
@Override
protected Class<? extends SubView> content() {
  return AggregatedLogsBlock.class;
}
 
Example 4
Source Project: hadoop   Source File: AHSLogsPage.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * The content of this page is the AggregatedLogsBlock
 * 
 * @return AggregatedLogsBlock.class
 */
@Override
protected Class<? extends SubView> content() {
  return AggregatedLogsBlock.class;
}
 
Example 5
Source Project: hadoop   Source File: HsLogsPage.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * The content of this page is the JobBlock
 * @return HsJobBlock.class
 */
@Override protected Class<? extends SubView> content() {
  return AggregatedLogsBlock.class;
}
 
Example 6
Source Project: big-c   Source File: AHSLogsPage.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * The content of this page is the AggregatedLogsBlock
 * 
 * @return AggregatedLogsBlock.class
 */
@Override
protected Class<? extends SubView> content() {
  return AggregatedLogsBlock.class;
}
 
Example 7
Source Project: big-c   Source File: HsLogsPage.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * The content of this page is the JobBlock
 * @return HsJobBlock.class
 */
@Override protected Class<? extends SubView> content() {
  return AggregatedLogsBlock.class;
}