/** * Creates a new instance of this class. * * @param inputDir * The File object for the input directory. * @param recordReceiver * The receiver handling the records. * @param ignoreUnknownRecordTypes * select only records of this type; null selects all * @param shouldDecompress * <code>true</code> if each log file is compressed, otherwise <code>false</code> */ public AsciiLogReaderThread(final File inputDir, final IMonitoringRecordReceiver recordReceiver, final boolean ignoreUnknownRecordTypes, final boolean shouldDecompress) { super(LOGGER, inputDir); if ((inputDir == null) || !inputDir.isDirectory()) { throw new IllegalArgumentException("Invalid or empty inputDir"); } this.inputDir = inputDir; this.recordReceiver = recordReceiver; this.textFileStreamProcessor = new TextFileStreamProcessor(ignoreUnknownRecordTypes, this.stringRegistry, recordReceiver); this.shouldDecompress = shouldDecompress; }
} else { final int numOfBufferedBytes = numOfReadBytes + offset; final int mark = this.processBuffer(buffer, offset, numOfBufferedBytes); this.createRecord();
/** * Reads the records contained in the given normal file and passes them to the registered {@link #recordReceiver}. * * @param inputFile * The input file which should be processed. */ private final void processNormalInputFile(final File inputFile) { try { this.textFileStreamProcessor.processInputChannel(new FileInputStream(inputFile)); this.terminated = true; } catch (final Exception ex) { // NOCS NOPMD (gonna catch them all) LOGGER.error("Error reading {}", inputFile, ex); } }
final char ch = (char) buffer[i]; if (ch == '\n') { this.createRecord(); mark = i; } else if (ch == '\r') { i++; this.createRecord(); mark = i; } else {
/** * Reads the records contained in the given normal file and passes them to the registered {@link #recordReceiver}. * * @param inputFile * The input file which should be processed. */ private final void processNormalInputFile(final File inputFile) { try { this.textFileStreamProcessor.processInputChannel(new FileInputStream(inputFile)); this.terminated = true; } catch (final Exception ex) { // NOCS NOPMD (gonna catch them all) LOGGER.error("Error reading {}", inputFile, ex); } }
/** * Creates a new instance of this class. * * @param inputDir * The File object for the input directory. * @param recordReceiver * The receiver handling the records. * @param ignoreUnknownRecordTypes * select only records of this type; null selects all * @param shouldDecompress * <code>true</code> if each log file is compressed, otherwise <code>false</code> */ public AsciiLogReaderThread(final File inputDir, final IMonitoringRecordReceiver recordReceiver, final boolean ignoreUnknownRecordTypes, final boolean shouldDecompress) { super(LOGGER, inputDir); if ((inputDir == null) || !inputDir.isDirectory()) { throw new IllegalArgumentException("Invalid or empty inputDir"); } this.inputDir = inputDir; this.recordReceiver = recordReceiver; this.textFileStreamProcessor = new TextFileStreamProcessor(ignoreUnknownRecordTypes, this.stringRegistry, recordReceiver); this.shouldDecompress = shouldDecompress; }
/** * Reads the records contained in the given normal file and passes them to the registered {@link #recordReceiver}. * * @param inputFile * The input file which should be processed. */ @Override protected void processNormalInputFile(final File inputFile) { try { InputStream fileInputStream = new FileInputStream(inputFile); if (this.shouldDecompress) { @SuppressWarnings("resource") final ZipInputStream zipInputStream = new ZipInputStream(fileInputStream); zipInputStream.getNextEntry(); fileInputStream = zipInputStream; } this.textFileStreamProcessor.processInputChannel(fileInputStream); } catch (final IOException e) { LOGGER.error("Error reading {} {}", inputFile, e); } catch (final MappingException e) { LOGGER.error("Error reading {} {}", inputFile, e); } catch (final MonitoringRecordException e) { LOGGER.error("Error reading {} {}", inputFile, e); } catch (final UnknownRecordTypeException e) { LOGGER.error("Error reading {} {}", inputFile, e); } }
/** * Creates a new instance of this class. * * @param zipFile * The File object for the zip file. * @param recordReceiver * The receiver handling the records. * @param ignoreUnknownRecordTypes * select only records of this type; null selects all */ public FSZipReader(final File zipFile, final IMonitoringRecordReceiver recordReceiver, final boolean ignoreUnknownRecordTypes) { if ((zipFile == null) || !zipFile.isFile() || !zipFile.getName().endsWith(FSUtil.ZIP_FILE_EXTENSION)) { throw new IllegalArgumentException("Invalid zip file"); } this.zipFile = zipFile; this.recordReceiver = recordReceiver; this.ignoreUnknownRecordTypes = ignoreUnknownRecordTypes; this.binaryFileStreamProcessor = new BinaryFileStreamProcessor(this.stringRegistry, recordReceiver); this.textFileStreamProcessor = new TextFileStreamProcessor(ignoreUnknownRecordTypes, this.stringRegistry, recordReceiver); }
fileInputStream = zipInputStream; this.textFileStreamProcessor.processInputChannel(fileInputStream); } catch (final IOException e) { LOGGER.error("Error reading {} {}", inputFile, e);
/** * Creates a new instance of this class. * * @param inputDir * The File object for the input directory. * @param recordReceiver * The receiver handling the records. * @param ignoreUnknownRecordTypes * select only records of this type; null selects all */ public FSDirectoryReader(final File inputDir, final IMonitoringRecordReceiver recordReceiver, final boolean ignoreUnknownRecordTypes) { if ((inputDir == null) || !inputDir.isDirectory()) { throw new IllegalArgumentException("Invalid or empty inputDir"); } this.inputDir = inputDir; this.recordReceiver = recordReceiver; this.ignoreUnknownRecordTypes = ignoreUnknownRecordTypes; this.textFileStreamProcessor = new TextFileStreamProcessor(ignoreUnknownRecordTypes, this.stringRegistry, recordReceiver); this.binaryFileStreamProcessor = new BinaryFileStreamProcessor(this.stringRegistry, recordReceiver); }
LOGGER.info("< Loading {}", filename); try { this.textFileStreamProcessor.processInputChannel(input); } catch (MappingException | MonitoringRecordException | UnknownRecordTypeException e) { LOGGER.error("Cannot deserialize text record {}", e);
/** * Creates a new instance of this class. * * @param zipFile * The File object for the zip file. * @param recordReceiver * The receiver handling the records. * @param ignoreUnknownRecordTypes * select only records of this type; null selects all */ public FSZipReader(final File zipFile, final IMonitoringRecordReceiver recordReceiver, final boolean ignoreUnknownRecordTypes) { if ((zipFile == null) || !zipFile.isFile() || !zipFile.getName().endsWith(FSUtil.ZIP_FILE_EXTENSION)) { throw new IllegalArgumentException("Invalid zip file"); } this.zipFile = zipFile; this.recordReceiver = recordReceiver; this.ignoreUnknownRecordTypes = ignoreUnknownRecordTypes; this.binaryFileStreamProcessor = new BinaryFileStreamProcessor(this.stringRegistry, recordReceiver); this.textFileStreamProcessor = new TextFileStreamProcessor(ignoreUnknownRecordTypes, this.stringRegistry, recordReceiver); }
LOGGER.info("< Loading {}", filename); try { this.textFileStreamProcessor.processInputChannel(input); } catch (MappingException | MonitoringRecordException | UnknownRecordTypeException e) { LOGGER.error("Cannot deserialize text record {}", e);
/** * Creates a new instance of this class. * * @param inputDir * The File object for the input directory. * @param recordReceiver * The receiver handling the records. * @param ignoreUnknownRecordTypes * select only records of this type; null selects all */ public FSDirectoryReader(final File inputDir, final IMonitoringRecordReceiver recordReceiver, final boolean ignoreUnknownRecordTypes) { if ((inputDir == null) || !inputDir.isDirectory()) { throw new IllegalArgumentException("Invalid or empty inputDir"); } this.inputDir = inputDir; this.recordReceiver = recordReceiver; this.ignoreUnknownRecordTypes = ignoreUnknownRecordTypes; this.textFileStreamProcessor = new TextFileStreamProcessor(ignoreUnknownRecordTypes, this.stringRegistry, recordReceiver); this.binaryFileStreamProcessor = new BinaryFileStreamProcessor(this.stringRegistry, recordReceiver); }