Search in sources :

Example 6 with StreamClient

use of co.cask.cdap.client.StreamClient 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

StreamClient (co.cask.cdap.client.StreamClient)6 StreamWriter (co.cask.cdap.client.StreamWriter)3 PipeConfiguration (co.cask.cdap.filetailer.config.PipeConfiguration)2 FileTailerMetricsProcessor (co.cask.cdap.filetailer.metrics.FileTailerMetricsProcessor)2 FileTailerQueue (co.cask.cdap.filetailer.queue.FileTailerQueue)2 FileTailerSink (co.cask.cdap.filetailer.sink.FileTailerSink)2 FileTailerStateProcessor (co.cask.cdap.filetailer.state.FileTailerStateProcessor)2 FileTailerStateProcessorImpl (co.cask.cdap.filetailer.state.FileTailerStateProcessorImpl)2 LogTailer (co.cask.cdap.filetailer.tailer.LogTailer)2 ServiceManager (com.google.common.util.concurrent.ServiceManager)2 List (java.util.List)2 StreamEvent (co.cask.cdap.api.flow.flowlet.StreamEvent)1 MetricsCollectionService (co.cask.cdap.api.metrics.MetricsCollectionService)1 ServiceStore (co.cask.cdap.app.store.ServiceStore)1 DatasetClient (co.cask.cdap.client.DatasetClient)1 RestStreamClient (co.cask.cdap.client.rest.RestStreamClient)1 EndpointStrategy (co.cask.cdap.common.discovery.EndpointStrategy)1 RandomEndpointStrategy (co.cask.cdap.common.discovery.RandomEndpointStrategy)1 StreamService (co.cask.cdap.data.stream.service.StreamService)1 DatasetService (co.cask.cdap.data2.datafabric.dataset.service.DatasetService)1