new AggregatedLogFormat.LogReader(conf, thisNodeFile.getPath()); owner = reader.getApplicationOwner(); appAcls = reader.getApplicationAcls(); } catch (IOException e) { LOG.error("Error getting logs for " + logEntity, e); .getContainerLogsReader(containerId); if (logReader == null) { continue; } finally { if (reader != null) reader.close();
AggregatedLogFormat.LogReader reader = null; try { reader = new AggregatedLogFormat.LogReader(conf, thisNodeFile.getPath()); DataInputStream valueStream; LogKey key = new LogKey(); valueStream = reader.next(key); while (valueStream != null) { if (getAllContainers || (key.toString().equals(containerIdStr))) { valueStream = reader.next(key); reader.close();
FsPermission.createImmutable((short) 0640), fsStatus.getPermission()); LogReader logReader = new LogReader(conf, remoteAppLogFile); LogKey rLogKey = new LogKey(); DataInputStream dis = logReader.next(rLogKey); Writer writer = new StringWriter(); LogReader.readAcontainerLogs(dis, writer, System.currentTimeMillis()); } else { LogReader.readAcontainerLogs(dis, writer);
new AggregatedLogFormat.LogReader(conf, thisNodeFile.getPath()); owner = reader.getApplicationOwner(); appAcls = reader.getApplicationAcls(); } catch (IOException e) { LOG.error("Error getting logs for " + logEntity, e); .getContainerLogsReader(containerId); if (logReader == null) { continue; } finally { if (reader != null) reader.close();
continue; reader = new AggregatedLogFormat.LogReader( conf, thisNodeFile.getPath()); Map<ApplicationAccessType, String> appAcls = null; try { owner = reader.getApplicationOwner(); appAcls = reader.getApplicationAcls(); } catch (IOException e) { LOG.error("Error getting logs for " + logEntity, e); .getContainerLogsReader(containerId); if (logReader == null) { continue; } finally { if (reader != null) { reader.close();
.endsWith(LogAggregationUtils.TMP_FILE_SUFFIX)) { AggregatedLogFormat.LogReader reader = new AggregatedLogFormat.LogReader(conf, thisNodeFile.getPath()); try { DataInputStream valueStream; LogKey key = new LogKey(); valueStream = reader.next(key); while (valueStream != null) { if (getAllContainers || (key.toString().equals(containerIdStr))) { try { Pair<String, String> logMeta = LogReader.readContainerMetaDataAndSkipData( valueStream); containerLogMeta.addLogMeta( valueStream = reader.next(key); reader.close();
FsPermission.createImmutable((short) 0640), fsStatus.getPermission()); LogReader logReader = new LogReader(conf, remoteAppLogFile); LogKey rLogKey = new LogKey(); DataInputStream dis = logReader.next(rLogKey); Writer writer = new StringWriter(); LogReader.readAcontainerLogs(dis, writer, System.currentTimeMillis()); } else { LogReader.readAcontainerLogs(dis, writer);
FsPermission.createImmutable((short) 0640), fsStatus.getPermission()); LogReader logReader = new LogReader(conf, remoteAppLogFile); LogKey rLogKey = new LogKey(); DataInputStream dis = logReader.next(rLogKey); Writer writer = new StringWriter(); LogReader.readAcontainerLogs(dis, writer, System.currentTimeMillis()); } else { LogReader.readAcontainerLogs(dis, writer);
.endsWith(LogAggregationUtils.TMP_FILE_SUFFIX)) { AggregatedLogFormat.LogReader reader = new AggregatedLogFormat.LogReader(getConf(), thisNodeFile.getPath()); try { valueStream = reader.next(key); while (true) { try { LogReader.readAContainerLogsForALogType(valueStream, out, thisNodeFile.getModificationTime()); foundAnyLogs = true; valueStream = reader.next(key); reader.close();
.endsWith(LogAggregationUtils.TMP_FILE_SUFFIX)) { AggregatedLogFormat.LogReader reader = new AggregatedLogFormat.LogReader(getConf(), thisNodeFile.getPath()); try { valueStream = reader.next(key); while (true) { try { LogReader.readAContainerLogsForALogType(valueStream, out, thisNodeFile.getModificationTime()); foundAnyLogs = true; valueStream = reader.next(key); reader.close();
try { reader = new AggregatedLogFormat.LogReader(getConf(), thisNodeFile.getPath()); if (dumpAContainerLogs(containerId, reader, System.out, reader.close();
} while(thisNodeFile.getPath().getName().endsWith(TMP_FILE_SUFFIX)); AggregatedLogFormat.LogReader reader = new AggregatedLogFormat.LogReader(hadoopConfig, thisNodeFile.getPath()); DataInputStream valueStream = reader.next(key); AggregatedLogFormat.LogReader.readAContainerLogsForALogType(valueStream, out, thisNodeFile.getModificationTime()); foundAnyLogs = true; } catch (EOFException eofException) { key = new AggregatedLogFormat.LogKey(); valueStream = reader.next(key); break; reader.close();
try { reader = new AggregatedLogFormat.LogReader(getConf(), thisNodeFile.getPath()); if (dumpAContainerLogs(containerId, reader, System.out, reader.close();
@Private public int dumpAContainerLogs(String containerIdStr, AggregatedLogFormat.LogReader reader, PrintStream out, long logUploadedTime) throws IOException { DataInputStream valueStream; LogKey key = new LogKey(); valueStream = reader.next(key); while (valueStream != null && !key.toString().equals(containerIdStr)) { // Next container key = new LogKey(); valueStream = reader.next(key); } if (valueStream == null) { return -1; } boolean foundContainerLogs = false; while (true) { try { LogReader.readAContainerLogsForALogType(valueStream, out, logUploadedTime); foundContainerLogs = true; } catch (EOFException eof) { break; } } if (foundContainerLogs) { return 0; } return -1; }
/** * Writes all logs for a single container to the provided writer. * @param valueStream * @param writer * @param logUploadedTime * @throws IOException */ public static void readAcontainerLogs(DataInputStream valueStream, Writer writer, long logUploadedTime) throws IOException { OutputStream os = null; PrintStream ps = null; try { os = new WriterOutputStream(writer, Charset.forName("UTF-8")); ps = new PrintStream(os); while (true) { try { readContainerLogs(valueStream, ps, logUploadedTime); } catch (EOFException e) { // EndOfFile return; } } } finally { IOUtils.cleanup(LOG, ps); IOUtils.cleanup(LOG, os); } }
@Private public int dumpAContainerLogs(String containerIdStr, AggregatedLogFormat.LogReader reader, PrintStream out, long logUploadedTime) throws IOException { DataInputStream valueStream; LogKey key = new LogKey(); valueStream = reader.next(key); while (valueStream != null && !key.toString().equals(containerIdStr)) { // Next container key = new LogKey(); valueStream = reader.next(key); } if (valueStream == null) { return -1; } boolean foundContainerLogs = false; while (true) { try { LogReader.readAContainerLogsForALogType(valueStream, out, logUploadedTime); foundContainerLogs = true; } catch (EOFException eof) { break; } } if (foundContainerLogs) { return 0; } return -1; }
/** * Read the next key and return the value-stream. * * @param key the log key * @return the valueStream if there are more keys or null otherwise * @throws IOException if we can not get the dataInputStream * for the next key */ public DataInputStream next(LogKey key) throws IOException { if (!this.atBeginning) { this.scanner.advance(); } else { this.atBeginning = false; } if (this.scanner.atEnd()) { return null; } TFile.Reader.Scanner.Entry entry = this.scanner.entry(); key.readFields(entry.getKeyStream()); // Skip META keys if (RESERVED_KEYS.containsKey(key.toString())) { return next(key); } DataInputStream valueStream = entry.getValueStream(); return valueStream; }
/** * Writes all logs for a single container to the provided writer. * @param valueStream * @param writer * @param logUploadedTime * @throws IOException */ public static void readAcontainerLogs(DataInputStream valueStream, Writer writer, long logUploadedTime) throws IOException { OutputStream os = null; PrintStream ps = null; try { os = new WriterOutputStream(writer, Charset.forName("UTF-8")); ps = new PrintStream(os); while (true) { try { readContainerLogs(valueStream, ps, logUploadedTime); } catch (EOFException e) { // EndOfFile return; } } } finally { IOUtils.cleanup(LOG, ps); IOUtils.cleanup(LOG, os); } }
/** * Read the next key and return the value-stream. * * @param key * @return the valueStream if there are more keys or null otherwise. * @throws IOException */ public DataInputStream next(LogKey key) throws IOException { if (!this.atBeginning) { this.scanner.advance(); } else { this.atBeginning = false; } if (this.scanner.atEnd()) { return null; } TFile.Reader.Scanner.Entry entry = this.scanner.entry(); key.readFields(entry.getKeyStream()); // Skip META keys if (RESERVED_KEYS.containsKey(key.toString())) { return next(key); } DataInputStream valueStream = entry.getValueStream(); return valueStream; }
/** * Read the next key and return the value-stream. * * @param key * @return the valueStream if there are more keys or null otherwise. * @throws IOException */ public DataInputStream next(LogKey key) throws IOException { if (!this.atBeginning) { this.scanner.advance(); } else { this.atBeginning = false; } if (this.scanner.atEnd()) { return null; } TFile.Reader.Scanner.Entry entry = this.scanner.entry(); key.readFields(entry.getKeyStream()); // Skip META keys if (RESERVED_KEYS.containsKey(key.toString())) { return next(key); } DataInputStream valueStream = entry.getValueStream(); return valueStream; }