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

动画设计培训中心网店产品seo如何优化

动画设计培训中心,网店产品seo如何优化,wordpress seventeen,德州做网站建设的公司一、说明 基于处理时间或者事件时间处理过一个元素之后, 注册一个定时器, 然后指定的时间执行. Context和OnTimerContext所持有的TimerService对象拥有以下方法: currentProcessingTime(): Long 返回当前处理时间 currentWatermark(): Long 返回当前watermark的时间戳 registe…

一、说明

基于处理时间或者事件时间处理过一个元素之后, 注册一个定时器, 然后指定的时间执行.
Context和OnTimerContext所持有的TimerService对象拥有以下方法:
currentProcessingTime(): Long 返回当前处理时间
currentWatermark(): Long 返回当前watermark的时间戳
registerProcessingTimeTimer(timestamp: Long): Unit 会注册当前key的processing time的定时器。当processing time到达定时时间时,触发timer。
registerEventTimeTimer(timestamp: Long): Unit 会注册当前key的event time 定时器。当水位线大于等于定时器注册的时间时,触发定时器执行回调函数。
deleteProcessingTimeTimer(timestamp: Long): Unit 删除之前注册处理时间定时器。如果没有这个时间戳的定时器,则不执行。
deleteEventTimeTimer(timestamp: Long): Unit 删除之前注册的事件时间定时器,如果没有此时间戳的定时器,则不执行。

二、基于处理时间的定时器

package com.lyh.flink08;import com.lyh.bean.WaterSensor;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.KeyedProcessFunction;
import org.apache.flink.util.Collector;public class ProcessTime {public static void main(String[] args) throws Exception {StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();env.setParallelism(1);SingleOutputStreamOperator<WaterSensor> stream = env.socketTextStream("hadoop100", 9999).map(line -> {String[] datas = line.split(",");return new WaterSensor(datas[0],Long.valueOf(datas[1]),Integer.valueOf(datas[2]));});stream.keyBy(WaterSensor::getId).process(new KeyedProcessFunction<String, WaterSensor, String>() {@Overridepublic void processElement(WaterSensor value,Context ctx,Collector<String> out) throws Exception {ctx.timerService().registerProcessingTimeTimer(ctx.timerService().currentProcessingTime() + 5000);out.collect(value.toString());}@Overridepublic void onTimer(long timestamp, OnTimerContext ctx, Collector<String> out) throws Exception {System.out.println(timestamp);out.collect("wo be chu fa le ");}}).print();env.execute();}
}

三、基于事件时间的定时器

package com.lyh.flink08;import com.lyh.bean.WaterSensor;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.KeyedProcessFunction;
import org.apache.flink.util.Collector;import java.time.Duration;public class EventTime_s {public static void main(String[] args) throws Exception {StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();env.setParallelism(1);SingleOutputStreamOperator<WaterSensor> stream = env.socketTextStream("hadoop100", 9999).map(line -> {String[] datas = line.split(",");return new WaterSensor(datas[0],Long.valueOf(datas[1]),Integer.valueOf(datas[2]));});WatermarkStrategy<WaterSensor> wms = WatermarkStrategy.<WaterSensor>forBoundedOutOfOrderness(Duration.ofSeconds(3)).withTimestampAssigner((element,recordTimestamp) -> element.getTs() * 1000);stream.assignTimestampsAndWatermarks(wms).keyBy(WaterSensor::getId).process(new KeyedProcessFunction<String, WaterSensor, String>() {@Overridepublic void processElement(WaterSensor value,Context ctx,Collector<String> out) throws Exception {System.out.println(ctx.timestamp());ctx.timerService().registerProcessingTimeTimer(ctx.timestamp()+5000);out.collect(value.toString());}@Overridepublic void onTimer(long timestamp, OnTimerContext ctx, Collector<String> out) throws Exception {System.out.println("定时器被触发了");}}).print();env.execute();}
}
http://www.ds6.com.cn/news/41242.html

相关文章:

  • 企业网站案例欣赏郑州seo排名优化公司
  • 网站默认模板关键词seo排名怎么选
  • 益阳做网站搜索引擎优化排名关键字广告
  • 辽宁省人民政府令第316号seo排名赚app靠谱吗
  • 91wan网页游戏平台宁波正规seo快速排名公司
  • asp.net 跳转别的网站家电企业网站推广方案
  • 怎样组建企业网站网页设计流程步骤
  • JSP做网站起到的作用整站排名服务
  • 做网站的开发心得迅雷下载磁力天堂
  • c#做的网站怎么上传图片竞价托管推广哪家好
  • 坪山网站建设行业现状seo推广培训中心
  • 邢台同城工具seo
  • 枣阳市市城乡建设委员会网站在线工具
  • 珠海专业网站建设价格今日新闻最新头条10条内容
  • 沙市做网站weisword个人网页制作教程
  • 做做网站入口小红书信息流广告
  • 一起做网站17杭州女装深圳最好seo
  • 企业年金可以取出来吗seo搜索工具栏
  • 京东网站建设的目标网络营销管理办法
  • 大数据网站建设和新东方留学机构官网
  • 公众号网页制作模板上海seo网站推广公司
  • 网站如何做问卷调查来几个关键词兄弟们
  • 哪里有好网站设计厦门网络推广外包多少钱
  • 珠海做公司网站整站优化案例
  • 西宁微网站建设多少钱seo整站怎么优化
  • 伊春网站推广祁阳seo
  • 柳州哪家公司做网站好百度客服24小时人工服务
  • 2016大型注册域名网站有哪些网络推广电话
  • 邯郸做wap网站费用google搜索引擎入口2022
  • 市场营销策略国内外研究现状百度快速优化软件排名