Search in sources :

Example 6 with PipeConfiguration

use of co.cask.cdap.filetailer.config.PipeConfiguration in project cdap-ingest by caskdata.

the class PipeManager method setupPipes.

/**
   * Pipes setup
   *
   * @throws IOException in case a client stream cannot be created
   */
private ServiceManager setupPipes() throws IOException {
    StreamClient client = null;
    StreamWriter writer = null;
    try {
        List<PipeConfiguration> pipeConfList = getPipeConfigs();
        for (PipeConfiguration pipeConf : pipeConfList) {
            FileTailerQueue queue = new FileTailerQueue(pipeConf.getQueueSize());
            client = pipeConf.getSinkConfiguration().getStreamClient();
            String streamName = pipeConf.getSinkConfiguration().getStreamName();
            writer = getStreamWriterForPipe(client, streamName);
            FileTailerStateProcessor stateProcessor = new FileTailerStateProcessorImpl(pipeConf.getDaemonDir(), pipeConf.getStateFile());
            FileTailerMetricsProcessor metricsProcessor = new FileTailerMetricsProcessor(pipeConf.getDaemonDir(), pipeConf.getStatisticsFile(), pipeConf.getStatisticsSleepInterval(), pipeConf.getPipeName(), pipeConf.getSourceConfiguration().getFileName());
            pipeList.add(new Pipe(new LogTailer(pipeConf, queue, stateProcessor, metricsProcessor, null), new FileTailerSink(queue, writer, SinkStrategy.LOADBALANCE, stateProcessor, metricsProcessor, null, pipeConf.getSinkConfiguration().getPackSize()), metricsProcessor));
            client = null;
            writer = null;
        }
        return new ServiceManager(pipeList);
    } catch (ConfigurationLoadingException e) {
        throw new ConfigurationLoadingException("Error during loading configuration from file: " + confFile.getAbsolutePath() + e.getMessage());
    } finally {
        if (client != null) {
            client.close();
        }
        if (writer != null) {
            writer.close();
        }
    }
}
Also used : StreamWriter(co.cask.cdap.client.StreamWriter) ConfigurationLoadingException(co.cask.cdap.filetailer.config.exception.ConfigurationLoadingException) FileTailerStateProcessor(co.cask.cdap.filetailer.state.FileTailerStateProcessor) FileTailerMetricsProcessor(co.cask.cdap.filetailer.metrics.FileTailerMetricsProcessor) FileTailerStateProcessorImpl(co.cask.cdap.filetailer.state.FileTailerStateProcessorImpl) PipeConfiguration(co.cask.cdap.filetailer.config.PipeConfiguration) FileTailerQueue(co.cask.cdap.filetailer.queue.FileTailerQueue) StreamClient(co.cask.cdap.client.StreamClient) LogTailer(co.cask.cdap.filetailer.tailer.LogTailer) FileTailerSink(co.cask.cdap.filetailer.sink.FileTailerSink) ServiceManager(com.google.common.util.concurrent.ServiceManager)

Example 7 with PipeConfiguration

use of co.cask.cdap.filetailer.config.PipeConfiguration in project cdap-ingest by caskdata.

the class PollingListenerImpl method setupPipe.

/**
   * Pipe setup
   *
   * @throws IOException if can not setup pipe
   */
private Pipe setupPipe(File file) throws IOException {
    PipeConfiguration pipeConfiguration = observerConf.getPipeConfiguration(file.getName());
    FileTailerQueue queue = new FileTailerQueue(pipeConfiguration.getQueueSize());
    StreamWriter writer = getStreamWriterForPipe(pipeConfiguration);
    FileTailerStateProcessor stateProcessor = new FileTailerStateProcessorImpl(observerConf.getDaemonDir(), pipeConfiguration.getStateFile());
    PipeListener pipeListener = new PipeListenerImpl(pipeConfiguration.getSourceConfiguration().getWorkDir(), file.getAbsolutePath(), observerConf.getDaemonDir() + "/" + pipeConfiguration.getStateFile());
    Pipe pipe = new Pipe(new LogTailer(pipeConfiguration, queue, stateProcessor, metricsProcessor, pipeListener), new FileTailerSink(queue, writer, SinkStrategy.LOADBALANCE, stateProcessor, metricsProcessor, pipeListener, pipeConfiguration.getSinkConfiguration().getPackSize()));
    pipeListener.setPipe(pipe);
    return pipe;
}
Also used : FileTailerStateProcessorImpl(co.cask.cdap.filetailer.state.FileTailerStateProcessorImpl) PipeConfiguration(co.cask.cdap.filetailer.config.PipeConfiguration) FileTailerQueue(co.cask.cdap.filetailer.queue.FileTailerQueue) LogTailer(co.cask.cdap.filetailer.tailer.LogTailer) FileTailerSink(co.cask.cdap.filetailer.sink.FileTailerSink) StreamWriter(co.cask.cdap.client.StreamWriter) PipeListener(co.cask.cdap.filetailer.PipeListener) Pipe(co.cask.cdap.filetailer.Pipe) FileTailerStateProcessor(co.cask.cdap.filetailer.state.FileTailerStateProcessor)

Example 8 with PipeConfiguration

use of co.cask.cdap.filetailer.config.PipeConfiguration in project cdap-ingest by caskdata.

the class TailerLogUtils method clearTestDir.

public static void clearTestDir() throws IOException {
    PipeConfiguration flowConf = loadConfig();
    File dir = flowConf.getSourceConfiguration().getWorkDir();
    FileUtils.cleanDirectory(dir);
}
Also used : PipeConfiguration(co.cask.cdap.filetailer.config.PipeConfiguration) File(java.io.File)

Example 9 with PipeConfiguration

use of co.cask.cdap.filetailer.config.PipeConfiguration in project cdap-ingest by caskdata.

the class TailerLogUtils method deleteTestDir.

public static void deleteTestDir() throws IOException {
    PipeConfiguration flowConf = loadConfig();
    File dir = flowConf.getSourceConfiguration().getWorkDir();
    FileUtils.deleteDirectory(dir);
}
Also used : PipeConfiguration(co.cask.cdap.filetailer.config.PipeConfiguration) File(java.io.File)

Example 10 with PipeConfiguration

use of co.cask.cdap.filetailer.config.PipeConfiguration in project cdap-ingest by caskdata.

the class TailerLogUtils method createTestDirIfNeed.

public static void createTestDirIfNeed() throws ConfigurationLoadingException {
    PipeConfiguration flowConf = loadConfig();
    File dir = flowConf.getSourceConfiguration().getWorkDir();
    if (!dir.exists()) {
        dir.mkdir();
    }
}
Also used : PipeConfiguration(co.cask.cdap.filetailer.config.PipeConfiguration) File(java.io.File)

Aggregations

PipeConfiguration (co.cask.cdap.filetailer.config.PipeConfiguration)17 File (java.io.File)8 FileTailerQueue (co.cask.cdap.filetailer.queue.FileTailerQueue)7 Test (org.junit.Test)7 Logger (ch.qos.logback.classic.Logger)6 FileTailerStateProcessor (co.cask.cdap.filetailer.state.FileTailerStateProcessor)5 FileTailerStateProcessorImpl (co.cask.cdap.filetailer.state.FileTailerStateProcessorImpl)5 ArrayList (java.util.ArrayList)5 FileTailerMetricsProcessor (co.cask.cdap.filetailer.metrics.FileTailerMetricsProcessor)4 StreamWriter (co.cask.cdap.client.StreamWriter)3 Configuration (co.cask.cdap.filetailer.config.Configuration)3 ConfigurationLoader (co.cask.cdap.filetailer.config.ConfigurationLoader)3 ConfigurationLoaderImpl (co.cask.cdap.filetailer.config.ConfigurationLoaderImpl)3 FileTailerSink (co.cask.cdap.filetailer.sink.FileTailerSink)3 LogTailer (co.cask.cdap.filetailer.tailer.LogTailer)3 Field (java.lang.reflect.Field)3 RandomStringUtils (org.apache.commons.lang.RandomStringUtils)3 StreamClient (co.cask.cdap.client.StreamClient)2 ServiceManager (com.google.common.util.concurrent.ServiceManager)2 Pipe (co.cask.cdap.filetailer.Pipe)1