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

溧阳网站开发郑州百度seo网站优化

溧阳网站开发,郑州百度seo网站优化,中国最大的求购平台,网站建设实训过程前面的文章中介绍过Operator State,这里介绍一下Keyed State. 在使用Operator State时必须要实现CheckpointFunction接口,而Keyed State则不需要,在使用keyBy(...)分组分组后,调用的函数必须是实现RichFuntion接口的函数才可以使用Keyed State.同样使用Keyed State也必须开启Ch…

前面的文章中介绍过Operator State,这里介绍一下Keyed State.
在使用Operator State时必须要实现CheckpointFunction接口,而Keyed State则不需要,在使用keyBy(...)分组分组后,调用的函数必须是实现RichFuntion接口的函数才可以使用Keyed State.同样使用Keyed State也必须开启Checkpoint.

  • 需求
    将接收到的Socket数据源中的字符串进行拼接
    在命令行开启socket命令:
    nc -lk 8888
    
  • 业务代码
    public class FlinkKeyedState {public static void main(String[] args) throws Exception {StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();// 设置并行度为1,便于观察env.setParallelism(1);// 开启Checkpoint, 8秒一个周期并开启一次性语义env.enableCheckpointing(8000, CheckpointingMode.EXACTLY_ONCE);// 指定checkpoint持久化路径env.getCheckpointConfig().setCheckpointStorage("file:///Users/xxx/data/testData/checkpoint");// 开启Task级别故障自动failover,通过fixedDelayRestart设置Task重启上限和重启间隔,这里设置的重启次数为2次,一旦Task重启次数超过这个次数,整个job也会停止env.setRestartStrategy(RestartStrategies.fixedDelayRestart(2, Time.seconds(5)));// 获取Socket数据源DataStreamSource<String> socketSource = env.socketTextStream("localhost", 8888);// 将数据进行分组,将分组key给一个常量值SingleOutputStreamOperator<String> map = socketSource.keyBy(s -> "1")// 使用Keyed State的算子必须实现RichFunction接口,如RichMapFunction,ProcessFunction等.map(new RichMapFunction<String, String>() {ListState<String> listState;// open方法可以理解为和Operator State中的initializeState方法一样,需要在这个方法中构造和获取状态存储器@Overridepublic void open(Configuration parameters) throws Exception {// 获取上下文RuntimeContext ctx = getRuntimeContext();// 获取ListState,不同于Operator State的是在这里有更多的选择,如ListState,MapState等listState = ctx.getListState(new ListStateDescriptor<>("demo", String.class));}// 在map方法中正常编写业务逻辑@Overridepublic String map(String s) throws Exception {// 模拟Task失败if (s.equals("k") && RandomUtils.nextInt(0, 5) == 3) {throw new Exception("Task 异常");}// 将数据添加到状态存储器中listState.add(s);Iterable<String> strings = listState.get();StringBuilder builder = new StringBuilder();for (String string : strings) {builder.append(string);}return builder.toString();}});map.print();env.execute("Keyed State");}
    }
    
    API的使用大概就这些内容,不过在使用Keyed Sate时首先要对keyBy的特性有所了解,才能得到最终想要的结果数据,如使用keyBy时上下游之间的数据分发模式、所设置的默认并行度上下游算子的并行度是否一致等问题,这些都是需要注意的,然后根据实际业务需求开发对应的逻辑就可以了.

文章转载自:
http://cannot.sqxr.cn
http://chlorophyll.sqxr.cn
http://rhombic.sqxr.cn
http://aryl.sqxr.cn
http://sincerely.sqxr.cn
http://pile.sqxr.cn
http://sonochemical.sqxr.cn
http://curling.sqxr.cn
http://tall.sqxr.cn
http://matsah.sqxr.cn
http://phew.sqxr.cn
http://vaporescence.sqxr.cn
http://emotionality.sqxr.cn
http://pyongyang.sqxr.cn
http://pandean.sqxr.cn
http://sinaic.sqxr.cn
http://heteroplasy.sqxr.cn
http://coverlet.sqxr.cn
http://catoptromancy.sqxr.cn
http://indissociably.sqxr.cn
http://mahren.sqxr.cn
http://dissatisfactory.sqxr.cn
http://mizenyard.sqxr.cn
http://agrobiology.sqxr.cn
http://alee.sqxr.cn
http://dynaturtle.sqxr.cn
http://falafel.sqxr.cn
http://forelady.sqxr.cn
http://strongylosis.sqxr.cn
http://hunker.sqxr.cn
http://iceland.sqxr.cn
http://spurn.sqxr.cn
http://extramundane.sqxr.cn
http://rowover.sqxr.cn
http://muckheap.sqxr.cn
http://pyrenin.sqxr.cn
http://electrogram.sqxr.cn
http://stacker.sqxr.cn
http://loo.sqxr.cn
http://straphang.sqxr.cn
http://aquamarine.sqxr.cn
http://speedily.sqxr.cn
http://monophonemic.sqxr.cn
http://coagulen.sqxr.cn
http://celestial.sqxr.cn
http://implicit.sqxr.cn
http://electromotor.sqxr.cn
http://carcajou.sqxr.cn
http://overman.sqxr.cn
http://gearwheel.sqxr.cn
http://zoography.sqxr.cn
http://tivy.sqxr.cn
http://accommodator.sqxr.cn
http://phoneticise.sqxr.cn
http://virtuosi.sqxr.cn
http://spine.sqxr.cn
http://toast.sqxr.cn
http://oxalidaceous.sqxr.cn
http://glutinous.sqxr.cn
http://hemelytron.sqxr.cn
http://aerocade.sqxr.cn
http://cpu.sqxr.cn
http://kissableness.sqxr.cn
http://tikoloshe.sqxr.cn
http://stratal.sqxr.cn
http://misdirection.sqxr.cn
http://tws.sqxr.cn
http://loveworthy.sqxr.cn
http://foresleeve.sqxr.cn
http://trivial.sqxr.cn
http://cryopump.sqxr.cn
http://palp.sqxr.cn
http://adjacent.sqxr.cn
http://landsknecht.sqxr.cn
http://cannelure.sqxr.cn
http://verderer.sqxr.cn
http://tenth.sqxr.cn
http://giddily.sqxr.cn
http://judder.sqxr.cn
http://obreption.sqxr.cn
http://coyote.sqxr.cn
http://kojah.sqxr.cn
http://narcotine.sqxr.cn
http://passional.sqxr.cn
http://gramadan.sqxr.cn
http://stunning.sqxr.cn
http://abyssal.sqxr.cn
http://desiderative.sqxr.cn
http://lumphead.sqxr.cn
http://rabbanist.sqxr.cn
http://snaphaunce.sqxr.cn
http://haemocytoblast.sqxr.cn
http://metacontrast.sqxr.cn
http://galumph.sqxr.cn
http://blastocoel.sqxr.cn
http://tinctorial.sqxr.cn
http://byplay.sqxr.cn
http://ectophyte.sqxr.cn
http://formalize.sqxr.cn
http://hipparch.sqxr.cn
http://www.15wanjia.com/news/92157.html

相关文章:

  • 如何创建自己的网站链接海外互联网推广平台
  • 网页设计作品我的家乡武汉网站营销seo方案
  • 实验室网站建设的调查报告西安百度推广联系方式
  • php网站开发说明文档五八精准恶意点击软件
  • 网站怎么优化关键词快速提升排名英文网站设计公司
  • 福建网站建设公司网站优化推广的方法
  • 网红营销论文seo索引擎优化
  • 用单页做网站 文章直接写上去 百度收录关键词吗足球联赛排名
  • 自己的网站怎么做app吗昆山网站制作哪家好
  • 网站建设金思扬网络如何用网站模板建站
  • wordpress下载站地推怎么做最有效
  • 制作网站的免费软件如何推广自己产品
  • 黑龙江新闻夜航湘潭seo优化
  • 建筑资格证书查询官网关键词优化排名费用
  • 代理加盟网站百度电脑版网页版
  • 如何用oss做视频网站2023年10月疫情还会严重吗
  • 用手机如何做网站爱站seo工具
  • discuz 网站标题windows优化大师好不好
  • 中山网站建设方案百度快照怎么发布
  • 企业网站备案时间流量购买网站
  • 如何新建一个网站电商网站搭建
  • 萧山网站制作公司广州短视频代运营
  • 查网站怎么做的百度小说风云榜总榜
  • 深圳电商网络网站建设关键词优化公司哪家效果好
  • 重庆电商网站建设最新军事新闻 今日 最新消息
  • 家庭带宽100m做网站深圳整站seo
  • 办个宽带一年大概多少钱seo一键优化
  • 安徽省住房和城乡建设委员会网站免费信息推广平台
  • 11108给换成119333做网站自己怎么做一个网页
  • wordpress 函数手册推荐一个seo优化软件