Search in sources :

Example 1 with StandardNiFiDataPacket

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

the class NiFiSinkTopologyExample 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 from Flink").buildConfig();
    DataStreamSink<String> dataStream = env.fromElements("one", "two", "three", "four", "five", "q").addSink(new NiFiSink<>(clientConfig, new NiFiDataPacketBuilder<String>() {

        @Override
        public NiFiDataPacket createNiFiDataPacket(String s, RuntimeContext ctx) {
            return new StandardNiFiDataPacket(s.getBytes(ConfigConstants.DEFAULT_CHARSET), new HashMap<String, String>());
        }
    }));
    env.execute();
}
Also used : SiteToSiteClient(org.apache.nifi.remote.client.SiteToSiteClient) NiFiDataPacketBuilder(org.apache.flink.streaming.connectors.nifi.NiFiDataPacketBuilder) SiteToSiteClientConfig(org.apache.nifi.remote.client.SiteToSiteClientConfig) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) StandardNiFiDataPacket(org.apache.flink.streaming.connectors.nifi.StandardNiFiDataPacket) RuntimeContext(org.apache.flink.api.common.functions.RuntimeContext)

Aggregations

RuntimeContext (org.apache.flink.api.common.functions.RuntimeContext)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 NiFiDataPacketBuilder (org.apache.flink.streaming.connectors.nifi.NiFiDataPacketBuilder)1 StandardNiFiDataPacket (org.apache.flink.streaming.connectors.nifi.StandardNiFiDataPacket)1 SiteToSiteClient (org.apache.nifi.remote.client.SiteToSiteClient)1 SiteToSiteClientConfig (org.apache.nifi.remote.client.SiteToSiteClientConfig)1