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

wordpress文章分享插件厦门做网站seo

wordpress文章分享插件,厦门做网站seo,pc网站 手机网站 微信,三明做网站的公司概述 SourceFunction:非并行数据源(并行度只能1) --接口 RichSourceFunction:多功能非并行数据源(并行度只能1) --类 ParallelSourceFunction:并行数据源(并行度能够>1) --接口 RichParallelSourceFunction:多功能并行数据源(并行度能够>1) --类 【建议使用的】 ——…

概述

SourceFunction:非并行数据源(并行度只能=1) --接口

RichSourceFunction:多功能非并行数据源(并行度只能=1) --类

ParallelSourceFunction:并行数据源(并行度能够>=1) --接口

RichParallelSourceFunction:多功能并行数据源(并行度能够>=1) --类 【建议使用的】

——Rich 字样代表富有,在编程中,富有代表可以调用的方法很多,功能很全的意思。

 基础案例

package com.bigdata.day02;//1、SourceFunction
// public class ZidingyiSource implements SourceFunction<Student> {
//2、RichSourceFunction
// public class ZidingyiSource extends RichSourceFunction<Student> {
//3、ParallelSourceFunction
//public class ZidingyiSource implements ParallelSourceFunction<Student> {
//4、RichParallelSourceFunction
//public class ZidingyiSource extends RichParallelSourceFunction<Student> {
// 推荐的
public class ZidingyiSource extends RichParallelSourceFunction<Student> {// ctrl + oprivate final Random random = new Random();private boolean flag = true;// 现在不用@Overridepublic void open(Configuration parameters) throws Exception {System.out.println("实现一些资源的开启");}// 现在不用@Overridepublic void close() throws Exception {System.out.println("实现一些资源的关闭");}@Overridepublic void run(SourceContext<Student> sourceContext) throws Exception {while (flag){String stu_id = UUID.randomUUID().toString();String stu_name = "Student_"+stu_id;int stu_age = random.nextInt(8)+10;long stu_timestamp = System.currentTimeMillis();Student student = new Student(stu_id,stu_name,stu_age,stu_timestamp);sourceContext.collect(student);Thread.sleep(1000);}}// 具体什么时候 会调用还不知道@Overridepublic void cancel() {flag = false;System.out.println("停止运行");}
}//调用
public class ZiDingYi {public static void main(String[] args) throws Exception {StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();// add + new DataStreamSource<Student> studentDataStreamSource = env.addSource(new ZidingyiSource());int parallelism = studentDataStreamSource.getParallelism();System.out.println(parallelism);// print之前与之后的并行度是不同的studentDataStreamSource.print().setParallelism(1);env.execute();}
}

cancel+open+close的调用时机

package com.bigdata.day02;import java.util.Objects;/*
* 1、这几个方法都会按照并行度调用多次 调度的次数 按照studentDataStreamSource的并行度
*
*/public class ZiDingYi {public static void main(String[] args) throws Exception {// 在上面案例的基础上实现StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();DataStreamSource<Student> studentDataStreamSource = env.addSource(new ZidingyiSource());// 此时就只会调用一次了studentDataStreamSource.setParallelism(1);// 此时打印也会有多个并行度(8个cpu)studentDataStreamSource.print();// 异步调用 此时会调用open方法JobExecutionResult execute = env.execute();JobClient flink_job = env.executeAsync("Flink Job");Thread.sleep(3000);// 此时会调用 cancel 和 close flink_job.cancel();}
}

 kafkaSource

package com.bigdata.day02;import java.util.Properties;public class KafkaSource {public static void main(String[] args) throws Exception{//envStreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();// properties Properties properties = new Properties();properties.setProperty("bootstrap.servers", "bigdata01:9092");properties.setProperty("group.id", "g1");// consumerFlinkKafkaConsumer<String> consumer= new FlinkKafkaConsumer<String>("yhedu",new SimpleStringSchema(),properties);// sourceDataStreamSource<String> dataStreamSource = env.addSource(consumer);dataStreamSource.filter(new FilterFunction<String>() {@Overridepublic boolean filter(String s) throws Exception {return s.contains("success");}}).print();env.execute();}
}

http://www.yayakq.cn/news/449471/

相关文章:

  • 北京多语言网站建设威县做网站哪儿便宜
  • 山东网站建设开发玉环市建设规划局网站
  • 做网站竞争大吗门户媒体是指什么
  • 电子商务网站建设作业代码购物网站建设基本流程树状图
  • 品牌网站建设十小蝌蚪福州比较大的互联网公司
  • 网站管理建设的需求分析工地找工作哪个软件好
  • 东台市建设局网站做软件实施有前途吗
  • 北京旅行社网站建设公司个体户网上申报
  • 征求网站建设扁平风网站
  • wordpress手机文章列表游戏优化软件
  • html 网站模板下载wordpress去掉导航框
  • 扁平风格网站 模板360提交网站入口
  • 哪里有网站开发团队欧美动物人物ppt免费模板下载网站
  • git怎么做隐私政策网站手机网站后台怎么进
  • 展示形网站怎么建简单的app开发案例
  • 团购网站怎么做推广产品设计和视觉传达设计哪个好
  • 网站建设l临沂网站搭建多少钱
  • 免费行情网站网络服务费税率是多少
  • wap手机网站建设方案做网站需要板块
  • 服装行业网站建设比较好网站后台无法编辑文字
  • 上海魔力网站建设公司高德地图看不到菲律宾
  • 建设网站需要购买哪些p2f网站系统
  • 曲靖做网站需要多少钱高端建站和普通建站有哪些不同
  • 威海住房和城乡建设局网站首页ppt汇报模板免费下载
  • 湖北联兴建设有限公司网站wordpress使用对象储存
  • 网站设置在哪里找彩票做网站
  • 网站建设如何选择服务器eclipse开发安卓app
  • 大庆市建设中专网站python搭建服务器
  • 设计网站做的工作步骤是网站建设公司如何选取
  • 制作一个网站数据库怎么做实训百度搜索引擎的总结