// Path: src/main/java/org/graylog/collector/inputs/file/FileInput.java
// public class FileInput extends InputService {
//     public enum InitialReadPosition {
//         START,
//         END
//     }
// 
//     public interface Factory extends InputService.Factory<FileInput, FileInputConfiguration> {
//         FileInput create(FileInputConfiguration configuration);
//     }
// 
//     private final FileInputConfiguration configuration;
//     private final Buffer buffer;
//     private final FileObserver fileObserver;
//     private final String collectorHostName;
//     private FileReaderService readerService;
// 
//     @Inject
//     public FileInput(@Assisted FileInputConfiguration inputConfiguration, Buffer buffer, FileObserver fileObserver,
//                      @CollectorHostName String collectorHostName) {
//         this.configuration = inputConfiguration;
//         this.buffer = buffer;
//         this.fileObserver = fileObserver;
//         this.collectorHostName = collectorHostName;
//     }
// 
//     @Override
//     public String getId() {
//         return configuration.getId();
//     }
// 
//     @Override
//     public Set<String> getOutputs() {
//         return configuration.getOutputs();
//     }
// 
//     @Override
//     protected void doStart() {
//         // TODO needs to be an absolute path because otherwise the FileObserver does weird things. Investigate what's wrong with it.
//         final MessageBuilder messageBuilder = new MessageBuilder()
//                 .input(getId())
//                 .outputs(getOutputs())
//                 .source(collectorHostName)
//                 .fields(configuration.getMessageFields());
//         final PathSet pathSet = configuration.getPathSet();
//         readerService = new FileReaderService(
//                 pathSet,
//                 configuration.getCharset(),
//                 InitialReadPosition.END,
//                 this,
//                 messageBuilder,
//                 configuration.createContentSplitter(),
//                 buffer,
//                 configuration.getReaderBufferSize(),
//                 configuration.getReaderInterval(),
//                 fileObserver
//         );
// 
//         readerService.startAsync().awaitRunning();
//         notifyStarted();
//     }
// 
//     @Override
//     protected void doStop() {
//         readerService.stopAsync().awaitTerminated();
//         notifyStopped();
//     }
// 
//     @Override
//     public void setReaderFinished(ChunkReader chunkReader) {
//         // TODO Check if needed and for what it was used.
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         FileInput fileInput = (FileInput) o;
// 
//         return configuration.equals(fileInput.configuration);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return configuration.hashCode();
//     }
// 
//     @Override
//     public String toString() {
//         return ConfigurationUtils.toString(configuration, this);
//     }
// }


import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.graylog.collector.inputs.Input;
import org.graylog.collector.inputs.file.FileInput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.channels.AsynchronousFileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executors;
/**
 * This file is part of Graylog.
 *
 * Graylog is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Graylog is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Graylog.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.graylog.collector.file;



public class ChunkReaderScheduler {
    private static final Logger log = LoggerFactory.getLogger(ChunkReaderScheduler.class);

    private final Input input;
    private final int readerBufferSize;
    private final long readerInterval;
// Path: src/main/java/org/graylog/collector/inputs/file/FileInput.java
// public class FileInput extends InputService {
//     public enum InitialReadPosition {
//         START,
//         END
//     }
// 
//     public interface Factory extends InputService.Factory<FileInput, FileInputConfiguration> {
//         FileInput create(FileInputConfiguration configuration);
//     }
// 
//     private final FileInputConfiguration configuration;
//     private final Buffer buffer;
//     private final FileObserver fileObserver;
//     private final String collectorHostName;
//     private FileReaderService readerService;
// 
//     @Inject
//     public FileInput(@Assisted FileInputConfiguration inputConfiguration, Buffer buffer, FileObserver fileObserver,
//                      @CollectorHostName String collectorHostName) {
//         this.configuration = inputConfiguration;
//         this.buffer = buffer;
//         this.fileObserver = fileObserver;
//         this.collectorHostName = collectorHostName;
//     }
// 
//     @Override
//     public String getId() {
//         return configuration.getId();
//     }
// 
//     @Override
//     public Set<String> getOutputs() {
//         return configuration.getOutputs();
//     }
// 
//     @Override
//     protected void doStart() {
//         // TODO needs to be an absolute path because otherwise the FileObserver does weird things. Investigate what's wrong with it.
//         final MessageBuilder messageBuilder = new MessageBuilder()
//                 .input(getId())
//                 .outputs(getOutputs())
//                 .source(collectorHostName)
//                 .fields(configuration.getMessageFields());
//         final PathSet pathSet = configuration.getPathSet();
//         readerService = new FileReaderService(
//                 pathSet,
//                 configuration.getCharset(),
//                 InitialReadPosition.END,
//                 this,
//                 messageBuilder,
//                 configuration.createContentSplitter(),
//                 buffer,
//                 configuration.getReaderBufferSize(),
//                 configuration.getReaderInterval(),
//                 fileObserver
//         );
// 
//         readerService.startAsync().awaitRunning();
//         notifyStarted();
//     }
// 
//     @Override
//     protected void doStop() {
//         readerService.stopAsync().awaitTerminated();
//         notifyStopped();
//     }
// 
//     @Override
//     public void setReaderFinished(ChunkReader chunkReader) {
//         // TODO Check if needed and for what it was used.
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         FileInput fileInput = (FileInput) o;
// 
//         return configuration.equals(fileInput.configuration);
// 
//     }
// 
//     @Override
//     public int hashCode() {
//         return configuration.hashCode();
//     }
// 
//     @Override
//     public String toString() {
//         return ConfigurationUtils.toString(configuration, this);
//     }
// }


// Path: src/main/java/org/graylog/collector/file/ChunkReaderScheduler.java
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.graylog.collector.inputs.Input;
import org.graylog.collector.inputs.file.FileInput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.nio.channels.AsynchronousFileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executors;

/**
 * This file is part of Graylog.
 *
 * Graylog is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Graylog is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Graylog.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.graylog.collector.file;



public class ChunkReaderScheduler {
    private static final Logger log = LoggerFactory.getLogger(ChunkReaderScheduler.class);

    private final Input input;
    private final int readerBufferSize;
    private final long readerInterval;
    private final FileInput.InitialReadPosition initialReadPosition;