Search in sources :

Example 1 with NiFiDataPacket

use of org.apache.flink.streaming.connectors.nifi.NiFiDataPacket in project flink by apache.

the class NiFiSourceTopologyExample method main.

public static void main(String[] args) throws Exception {
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    SiteToSiteClientConfig clientConfig = new SiteToSiteClient.Builder().url("http://localhost:8080/nifi").portName("Data for Flink").requestBatchCount(5).buildConfig();
    SourceFunction<NiFiDataPacket> nifiSource = new NiFiSource(clientConfig);
    DataStream<NiFiDataPacket> streamSource = env.addSource(nifiSource).setParallelism(2);
    DataStream<String> dataStream = streamSource.map(new MapFunction<NiFiDataPacket, String>() {

        @Override
        public String map(NiFiDataPacket value) throws Exception {
            return new String(value.getContent(), Charset.defaultCharset());
        }
    });
    dataStream.print();
    env.execute();
}
Also used : SiteToSiteClientConfig(org.apache.nifi.remote.client.SiteToSiteClientConfig) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) NiFiSource(org.apache.flink.streaming.connectors.nifi.NiFiSource) NiFiDataPacket(org.apache.flink.streaming.connectors.nifi.NiFiDataPacket)

Aggregations

StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 NiFiDataPacket (org.apache.flink.streaming.connectors.nifi.NiFiDataPacket)1 NiFiSource (org.apache.flink.streaming.connectors.nifi.NiFiSource)1 SiteToSiteClientConfig (org.apache.nifi.remote.client.SiteToSiteClientConfig)1