Search in sources :

Example 1 with ConfigurationLoadingException

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

the class ConfigurationLoaderImpl method load.

@Override
public Configuration load(File file) throws ConfigurationLoadingException {
    LOG.debug("Start initializing loader with file: {}", file.getAbsolutePath());
    Properties properties = new Properties();
    try {
        InputStream is = new FileInputStream(file);
        try {
            properties.load(is);
            LOG.debug("Loader successfully initialized with file: {}", file.getAbsolutePath());
        } finally {
            Closeables.closeQuietly(is);
        }
    } catch (IOException e) {
        LOG.error("Cannot load properties", e);
        throw new ConfigurationLoadingException("Cannot load properties: " + e.getMessage());
    }
    return new ConfigurationImpl(properties);
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ConfigurationLoadingException(co.cask.cdap.filetailer.config.exception.ConfigurationLoadingException) IOException(java.io.IOException) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream)

Example 2 with ConfigurationLoadingException

use of co.cask.cdap.filetailer.config.exception.ConfigurationLoadingException 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)

Aggregations

ConfigurationLoadingException (co.cask.cdap.filetailer.config.exception.ConfigurationLoadingException)2 StreamClient (co.cask.cdap.client.StreamClient)1 StreamWriter (co.cask.cdap.client.StreamWriter)1 PipeConfiguration (co.cask.cdap.filetailer.config.PipeConfiguration)1 FileTailerMetricsProcessor (co.cask.cdap.filetailer.metrics.FileTailerMetricsProcessor)1 FileTailerQueue (co.cask.cdap.filetailer.queue.FileTailerQueue)1 FileTailerSink (co.cask.cdap.filetailer.sink.FileTailerSink)1 FileTailerStateProcessor (co.cask.cdap.filetailer.state.FileTailerStateProcessor)1 FileTailerStateProcessorImpl (co.cask.cdap.filetailer.state.FileTailerStateProcessorImpl)1 LogTailer (co.cask.cdap.filetailer.tailer.LogTailer)1 ServiceManager (com.google.common.util.concurrent.ServiceManager)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1