当前位置: 首页 > news >正文

网站程序前台建营销网站

网站程序前台,建营销网站,免费行情软件的特点和优势,本校网站建设背景 在flink中#xff0c;如果你想要访问记录的处理时间或者事件时间#xff0c;注册定时器#xff0c;或者是将记录输出到多个输出流中#xff0c;你都需要处理函数的帮助#xff0c;本文就来通过一个例子来讲解下副输出 副输出 本文还是基于streaming-with-flink这本…背景 在flink中如果你想要访问记录的处理时间或者事件时间注册定时器或者是将记录输出到多个输出流中你都需要处理函数的帮助本文就来通过一个例子来讲解下副输出 副输出 本文还是基于streaming-with-flink这本书的例子作为演示它实现一个把温度低于32度的记录输出到副输出的功能正常的记录还是从主输出中输出.代码如下 package wikiedits.processfunc.job;import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator; import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; import org.apache.flink.util.OutputTag;import wikiedits.processfunc.pojo.SensorReading; import wikiedits.processfunc.process.FreezingMonitor; import wikiedits.processfunc.source.SensorSource;public class SideOutPutJob {public static void main(String[] args) throws Exception {StreamExecutionEnvironment see StreamExecutionEnvironment.getExecutionEnvironment();DataStreamSensorReading readings see.addSource(new SensorSource());SingleOutputStreamOperatorSensorReading monitoredReadings readings.process(new FreezingMonitor());// 打印附输出monitoredReadings.getSideOutput(new OutputTagString(freezing-alarms){}).print();// 打印主输出monitoredReadings.print();see.execute();} }package wikiedits.processfunc.process;import org.apache.flink.streaming.api.functions.ProcessFunction; import org.apache.flink.util.Collector; import org.apache.flink.util.OutputTag;import wikiedits.processfunc.pojo.SensorReading;public class FreezingMonitor extends ProcessFunctionSensorReading, SensorReading {private OutputTagString freezingAlarmOutput new OutputTagString(freezing-alarms) {};Overridepublic void processElement(SensorReading value, Context ctx, CollectorSensorReading out) throws Exception {if (value.temperature 32.0) {ctx.output(freezingAlarmOutput, freezing alarm for value.id : value.temperature);}out.collect(value);}} package wikiedits.processfunc.source;/** Copyright 2015 Fabian Hueske / Vasia Kalavri** Licensed under the Apache License, Version 2.0 (the License);* you may not use this file except in compliance with the License.* You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/ import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction; import wikiedits.processfunc.pojo.SensorReading;import java.util.Calendar; import java.util.Random;/*** Flink SourceFunction to generate SensorReadings with random temperature values.** Each parallel instance of the source simulates 10 sensors which emit one sensor reading every 100 ms.** Note: This is a simple data-generating source function that does not checkpoint its state.* In case of a failure, the source does not replay any data.*/ public class SensorSource extends RichParallelSourceFunctionSensorReading {// flag indicating whether source is still runningprivate boolean running true;/** run() continuously emits SensorReadings by emitting them through the SourceContext. */Overridepublic void run(SourceContextSensorReading srcCtx) throws Exception {// initialize random number generatorRandom rand new Random();// look up index of this parallel taskint taskIdx this.getRuntimeContext().getIndexOfThisSubtask();// initialize sensor ids and temperaturesString[] sensorIds new String[10];double[] curFTemp new double[10];for (int i 0; i 10; i) {sensorIds[i] sensor_ (taskIdx * 10 i);curFTemp[i] 65 (rand.nextGaussian() * 20);}while (running) {// get current timelong curTime Calendar.getInstance().getTimeInMillis();// emit SensorReadingsfor (int i 0; i 10; i) {// update current temperaturecurFTemp[i] rand.nextGaussian() * 0.5;// emit readingsrcCtx.collect(new SensorReading(sensorIds[i], curTime, curFTemp[i]));}// wait for 100 msThread.sleep(3000);}}/** Cancels this SourceFunction. */Overridepublic void cancel() {this.running false;} } 程序运行结果
http://www.zqtcl.cn/news/98135/

相关文章:

  • 盐城网站建设咨询优秀vi设计
  • 网站里面内外链接如何做北京pk10网站建设
  • 网站布局策划的流程百度知道入口
  • 个人网站设计毕业设计论文上海百度seo优化
  • 展台设计网站都有哪些拓者设计吧手机版
  • 河南省级建设主管部门网站免费推广平台哪个好
  • wordpress禁止自动升级seo实战密码怎么样
  • 福永网站建设公司如何利用个人nas做网站
  • 北京网站seo外包wordpress心情
  • 租用服务器一般是谁帮助维护网站安全网站如何看是哪家公司做的
  • 戴尔网站建设的特点开创者wordpress素材
  • 网站假设公司排名不用囤货
  • 有关网站建设合同织梦珠宝网站模板
  • 月牙河做网站公司电商网站开发成本
  • iis7建立网站注册公司地址虚拟地址怎么申请
  • 响应式网站开发的想要去国外网站买东西怎么做
  • 网站建设开发有什么好处百度网盘0基础网站开发教程
  • 桂林整站优化青岛网站制作哪里有
  • 织梦cms手机网站源码天天想你视频免费观看西瓜
  • 怎么做网站弄网盟邯郸超速云_网站建设
  • 桂阳做网站的软件定制开发外包wordpress电子商务插件
  • 10有免费建网站那些公司做网站比较厉害
  • 网站关键词优化推广旅游类网站开发开题报告范文
  • 官方网站营销拟在建项目信息网官网
  • 沈阳做微信和网站的公司湛江网站建设公司哪家好
  • 网站 开发逻辑电话销售电销系统
  • 有哪些做兼职的设计网站有哪些工作可以用asp做哪些网站
  • 装修网站推广方案东莞网站建设0086
  • 知名营销网站开发高端网站建设如何收费
  • 佛山网站建设邓先生沈阳做网站找黑酷科技