当前位置: 首页>>代码示例>>Java>>正文


Java NiFiDataPacketBuilder类代码示例

本文整理汇总了Java中org.apache.flink.streaming.connectors.nifi.NiFiDataPacketBuilder的典型用法代码示例。如果您正苦于以下问题:Java NiFiDataPacketBuilder类的具体用法?Java NiFiDataPacketBuilder怎么用?Java NiFiDataPacketBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NiFiDataPacketBuilder类属于org.apache.flink.streaming.connectors.nifi包,在下文中一共展示了NiFiDataPacketBuilder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.flink.streaming.connectors.nifi.NiFiDataPacketBuilder; //导入依赖的package包/类
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();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:20,代码来源:NiFiSinkTopologyExample.java

示例2: main

import org.apache.flink.streaming.connectors.nifi.NiFiDataPacketBuilder; //导入依赖的package包/类
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(), new HashMap<String,String>());
				}
			}));

	env.execute();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:NiFiSinkTopologyExample.java

示例3: main

import org.apache.flink.streaming.connectors.nifi.NiFiDataPacketBuilder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    String propertiesFile = DEFAULT_PROPERTIES_FILE;
    if (args != null && args.length == 1 && args[0] != null) {
        propertiesFile = args[0];
    }

    WindowLogLevelCountProps props = new WindowLogLevelCountProps(propertiesFile);

    // Set up the execution environment
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

    // Configure the SiteToSiteClient
    SiteToSiteClientConfig clientConfig = getSourceConfig(props);

    // Create our data stream with a NiFiSource
    SourceFunction<NiFiDataPacket> nifiSource = new NiFiSource(clientConfig);
    DataStream<NiFiDataPacket> streamSource = env.addSource(nifiSource);

    int windowSize = props.getFlinkWindowMillis();
    LogLevelFlatMap logLevelFlatMap = new LogLevelFlatMap(props.getLogLevelAttribute());

    // Count the occurrences of each log level over a window
    DataStream<LogLevels> counts =
            streamSource.flatMap(logLevelFlatMap)
                    .timeWindowAll(Time.of(windowSize, TimeUnit.MILLISECONDS))
                    .apply(new LogLevelWindowCounter());

    // Add the sink to send the dictionary back to NiFi
    double rateThreshold = props.getFlinkRateThreshold();
    SiteToSiteClientConfig sinkConfig = getSinkConfig(props);
    NiFiDataPacketBuilder<LogLevels> builder = new DictionaryBuilder(windowSize, rateThreshold);
    counts.addSink(new NiFiSink<>(sinkConfig, builder));

    // execute program
    env.execute("WindowLogLevelCount");
}
 
开发者ID:bbende,项目名称:nifi-streaming-examples,代码行数:37,代码来源:WindowLogLevelCount.java


注:本文中的org.apache.flink.streaming.connectors.nifi.NiFiDataPacketBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。