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

东莞松山湖网站建设成都seo优化推广

东莞松山湖网站建设,成都seo优化推广,班级网站首页设计,网站百度地图怎么做DIM层代码流程图 维度层的重点和难点在于实时电商数仓需要的维度信息一般是动态的变化的,并且由于实时数仓一般需要一直运行,无法使用常规的配置文件重启加载方式来修改需要读取的ODS层数据,因此需要通过Flink-cdc实时监控MySql中的维度数据…

DIM层代码流程图

维度层的重点和难点在于实时电商数仓需要的维度信息一般是动态的变化的,并且由于实时数仓一般需要一直运行,无法使用常规的配置文件重启加载方式来修改需要读取的ODS层数据,因此需要通过Flink-cdc实时监控MySql中的维度数据配置信息表,实时动态的发布广播信息。主流数据根据广播数据及时调整处理逻辑,并自动在HBase中创建相应的维度表和写入相应的维度数据。

  1. 消费Kafka ods业务主题数据
  2. 数据清洗:是否为JSON格式
  3. 使用flink-cdc读取监控配置表数据
  4. 在HBase中创建维度表
  5. 做成广播流
  6. 连接主流和广播流
  7. 筛选出需要写出的字段
  8. 写出到Hbase

在这里插入图片描述

整体架构

  • realtime-common模块
    • base: 所有Flink程序的基类,负责搭建Flink运行环境和设置并行度和检查点等相关参数。其中我们的数据来源也确定为Kafka,故数据源代码也写在这里。每个Flink程序的具体处理逻辑由handle()函数来负责处理。
    • bean:负责存放项目运行过程中需要用到的bean对象,比如当前flink-cdc程序中需要用到的TableProcessDim类,配置信息表对象。
    • constant:负责存放程序中需要使用到常量参数
    • function:负责存放一些通用的函数方法
    • util:一般存放和数据连接相关的工具类
    • test目录: 用来在写正式代码前测试连接是否通畅,数据是否可以正常发送。
  • realtime-dim模块
    • app:DimApp里面写的是dim层的具体实现,具体步骤如上述流程图所示。
    • function:负责存放数据处理的实现类,一般会继承相应的父类,在dim层可以直接调用这里的子类来实现父类接口,让dim层的代码逻辑更加清晰。
  • realtime-dwd模块:如上
  • realtime-dws模块:如上

在这里插入图片描述

数据清洗ETL

数据清洗,简单来说就是对数据进行简单的转换筛选。首先如果在转换过程中出现异常,直接过滤掉。注意这里无需抛出异常,因为如果throw a exception会导致整个程序异常终止,而在数据处理过程中出现部分数据格式错误而无法正常进行格式转换是很常见的,只需将异常信息打印到控制台即可。如果转换正常,再判断是否满足以下三个条件:

  1. 数据库名为gmall
  2. 数据类型不是bootstrap-start或者bootstrap-complete
  3. data字段不是null且长度不为0

Flink-cdc读取配置表的数据

Flink中获取数据主要有两个步骤:

  1. 获取相应的数据源Source
    • 注意:在构建Flink-cdc对应的MySQLSource时,tableList参数必须是库表.表名结构
  2. 调用env.fromSource()方法将数据源的发送过来的数据转换Ds数据流,在该方法中可以设置数据的水位线。
  3. 获取到数据后,建议先打印到控制台查看数据的具体结构。
  4. 注意读取配置信息表的并发度必须设置为1;如果不为1,只能读取r操作数据,其他更新数据无法读取。
public static MySqlSource<String> getMySqlSource(String databaseName, String tableName){MySqlSource<String> mySqlSource = MySqlSource.<String>builder().hostname(Constant.MYSQL_HOST).port(Constant.MYSQL_PORT).username(Constant.MYSQL_USER_NAME).password(Constant.MYSQL_PASSWORD).databaseList(databaseName) // set captured database.tableList(databaseName+"."+tableName) // set captured table.deserializer(new JsonDebeziumDeserializationSchema()) // converts SourceRecord to JSON String.startupOptions(StartupOptions.initial()).build();return mySqlSource;}

在HBase中创建维度表

数据库中的配置表数据经过Flink-cdc处理后发送到这里是json格式的字符串,这里根据数据的四种类型op在HBase中进行不同的建表删表操作,同时对数json字符数据进行转换映射处理,转换为对应的bean对象数据流。这里一个数据产生一个处理后的对象,故使用Map算子或FlatMap算子都可以。

  • op类型
    • d 代表delete,需要删除before字段中对应的表
    • c 代表create,r 代表 read,需要创建after字段中对应的表
    • u 代表update,需要先删除掉旧表,然后根据新表的字段创建一个新表
  • 创建HBase连接,创建连接是很耗费资源的行为,因此新建连接和关闭连接需要写在open和close方法中
  • HBase中想要对表进行创建和删除等DDL操作,都由Admin对象管理;如果需要对数据进行插入删除等DML操作,需要创建Table对象。详细操作细节请看相应代码即可。
public static SingleOutputStreamOperator<TableProcessDim> createHbaseTable(DataStreamSource<String> mysqlSource) {SingleOutputStreamOperator<TableProcessDim> createHBaseTable = mysqlSource.flatMap(new RichFlatMapFunction<String, TableProcessDim>() {public Connection connection ;@Overridepublic void open(Configuration parameters) throws Exception {//获取连接connection = HBaseUtil.getHBaseConnection();}@Overridepublic void close() throws Exception {//关闭连接HBaseUtil.closeHBaseConn(connection);}@Overridepublic void flatMap(String s, Collector<TableProcessDim> out){//使用读取的配置表数据,到HBase中创建与之对应的表格try {JSONObject jsonObject = JSONObject.parseObject(s);String op = jsonObject.getString("op");TableProcessDim dim;//维度表if ("d".equals(op)) {dim = jsonObject.getObject("before", TableProcessDim.class);dim.setOp(op);//当配置表发送一个D类型的数据,对应的HBase需要删除一张维度表deleteTable(dim);} else if ("c".equals(op) || "r".equals(op)) {dim = jsonObject.getObject("after", TableProcessDim.class);createTable(dim);dim.setOp(op);} else {//op = 'u', 即修改dim = jsonObject.getObject("after", TableProcessDim.class);deleteTable(dim);createTable(dim);}dim.setOp(op);out.collect(dim);} catch (Exception e) {e.printStackTrace();}}private void createTable(TableProcessDim dim) {String sinkFamily = dim.getSinkFamily();String[] split = sinkFamily.split(",");try {HBaseUtil.createHBaseTable(connection,Constant.HBASE_NAMESPACE,dim.getSinkTable(),split);} catch (IOException e) {e.printStackTrace();}}private void deleteTable(TableProcessDim dim) {try {HBaseUtil.dropHBaseTable(connection, Constant.HBASE_NAMESPACE, dim.getSinkTable());} catch (IOException e) {e.printStackTrace();}}});return createHBaseTable;}

主流连接广播流

从Flink-cdc获取的数据(gmall2023_config)是作为一个参数来控制我们对于主流即ODS层数据(gmall数据库的业务数据)的处理逻辑。gmall2023)_config库中的Table_process_dim表决定了后续程序筛选哪个表作为维度信息,并且定义了表中有哪些字段。

  1. 转换为广播流只需要调用上述得到的TableProcessDimStream的broadcast方法
  2. 使用的主流(gmall业务数据)的connect方法,得到一个连接流,然后对连接流进行process处理。
  3. 创建BroadcastProcessFunction,在里面分别有两个函数
    • processBroadcastElement():处理广播流数据
    • processElement():处理主流数据
  4. 广播流处理逻辑:
    • 读取广播状态
    • 将配置表信息写到广播状态中
    • 根据广播状态数据的op对状态做相应的修改
  5. 主流处理逻辑:
    • 查询广播状态,判断当前数据对应的表是否存在于状态中
    • 如果数据比状态来的更早,造成状态为空,需要对状态做预处理(提前从mysql中读取维表配置表信息)
    • 如果根据当前表的表名查询的状态不为空,说明该表为维度数据,使用收集器收集起来。

筛选出需要的字段

在这里插入图片描述
在维度配置信息表中的sink_column字段里定义了维度表需要的字段,使用filter算子对JsonObj里面的data字段进行过滤即可获取到想要的字段数据。

写出到Hbase

过滤后的数据流调用它的addSink方法,方法中需要传入一个SinkFunction接口类。该接口需要实现三个方法分别是:

  • open方法:获取HBase连接
  • close方法:关闭HBase连接
  • invoke方法:写入数据时调用的方法,根据jsonObj中的type做不同处理,如果是delete,需要删除对应的维度表数据;否则都是直接覆盖写入。

代码的Gitee仓库地址:https://gitee.com/langpaian/gmall2023-realtime.git


文章转载自:
http://submaxilla.sqLh.cn
http://inerrancy.sqLh.cn
http://subopposite.sqLh.cn
http://imbower.sqLh.cn
http://assentor.sqLh.cn
http://viscometer.sqLh.cn
http://reverie.sqLh.cn
http://electrochemistry.sqLh.cn
http://turnhall.sqLh.cn
http://enisei.sqLh.cn
http://recent.sqLh.cn
http://pecan.sqLh.cn
http://promiseful.sqLh.cn
http://palpitate.sqLh.cn
http://qiana.sqLh.cn
http://tubule.sqLh.cn
http://cags.sqLh.cn
http://bleb.sqLh.cn
http://latecomer.sqLh.cn
http://semisacred.sqLh.cn
http://algerish.sqLh.cn
http://mesonephros.sqLh.cn
http://bungle.sqLh.cn
http://tuitionary.sqLh.cn
http://upanishad.sqLh.cn
http://alexandrite.sqLh.cn
http://protocontinent.sqLh.cn
http://turbidity.sqLh.cn
http://rebranch.sqLh.cn
http://mynheer.sqLh.cn
http://egoist.sqLh.cn
http://evangelise.sqLh.cn
http://functionalism.sqLh.cn
http://constantia.sqLh.cn
http://preternatural.sqLh.cn
http://moonbeam.sqLh.cn
http://fuller.sqLh.cn
http://sphygmometer.sqLh.cn
http://naupathia.sqLh.cn
http://salability.sqLh.cn
http://adjuster.sqLh.cn
http://tankful.sqLh.cn
http://semimoist.sqLh.cn
http://bretton.sqLh.cn
http://chemigraphically.sqLh.cn
http://wastry.sqLh.cn
http://immunohematological.sqLh.cn
http://cabtrack.sqLh.cn
http://tautomer.sqLh.cn
http://methylthionine.sqLh.cn
http://akala.sqLh.cn
http://disenthrone.sqLh.cn
http://estella.sqLh.cn
http://graphomotor.sqLh.cn
http://exotoxin.sqLh.cn
http://cameral.sqLh.cn
http://secko.sqLh.cn
http://triennial.sqLh.cn
http://regna.sqLh.cn
http://innuit.sqLh.cn
http://anencephalic.sqLh.cn
http://magistral.sqLh.cn
http://nonnatural.sqLh.cn
http://isolated.sqLh.cn
http://ruthfully.sqLh.cn
http://planetabler.sqLh.cn
http://copperhead.sqLh.cn
http://jah.sqLh.cn
http://inche.sqLh.cn
http://mecopteran.sqLh.cn
http://skidder.sqLh.cn
http://planetary.sqLh.cn
http://dogmatize.sqLh.cn
http://cholecystagogue.sqLh.cn
http://ventrotomy.sqLh.cn
http://pleiad.sqLh.cn
http://suckerfish.sqLh.cn
http://undiscovered.sqLh.cn
http://psychokinesis.sqLh.cn
http://saleratus.sqLh.cn
http://perigynous.sqLh.cn
http://apneusis.sqLh.cn
http://prevision.sqLh.cn
http://sensitisation.sqLh.cn
http://oppositionist.sqLh.cn
http://ceratodus.sqLh.cn
http://trouse.sqLh.cn
http://frigidarium.sqLh.cn
http://maidenish.sqLh.cn
http://archegoniate.sqLh.cn
http://jesuitically.sqLh.cn
http://lour.sqLh.cn
http://reprobate.sqLh.cn
http://hyperexcitability.sqLh.cn
http://syllabi.sqLh.cn
http://autocorrelation.sqLh.cn
http://recklessness.sqLh.cn
http://aeroginous.sqLh.cn
http://disfavor.sqLh.cn
http://bedraggle.sqLh.cn
http://www.15wanjia.com/news/90539.html

相关文章:

  • 找网站漏洞赚钱怎么做的哪些平台可以发布推广信息
  • 网站上的定位功能如何实现的安仁网络推广
  • 免费b站推广网站不用windows优化大师破解版
  • 柳州网站开发河南今日头条新闻
  • 假发票网站查询怎么做龙岩网站推广
  • 网站制作设计收费seo优化工具有哪些
  • 邢台做网站推广服务seo知名公司
  • 网站怎么做订单百度一下百度首页官网
  • wordpress插件访客品牌seo是什么
  • wordpress 公司网站seo外链查询工具
  • 织梦网站联系我们的地图怎么做优化seo是什么意思
  • 企业做网站怎么做友链大全
  • 投票网站如何做今天新闻摘抄十条
  • 建物流网站百度网址大全简单版
  • 惠州企业自助建站厨师培训机构 厨师短期培训班
  • 为什么很多公司做网站建设郑州企业网站优化排名
  • 低价做网站seo 优化 工具
  • 建立网站后台知名的建站公司
  • 深圳网站建设选哪家好网络推广员要怎么做
  • 做天猫网站价格表百度站长工具排名
  • 长春设计网站优网营销
  • 电商网站建设方案百度竞价客服
  • 通用精品课程网站建设的需求分析seo是什么专业的课程
  • 构建动态网站设计的理解班级优化大师app
  • 无锡网站建设价格低广州品牌营销策划公司排名
  • 网站建设用php建设优点哪里可以引流到精准客户呢
  • 珠海高端网站设计网络销售怎么做才能做好
  • wordpress子目录站点广州官方新闻
  • 国外网站怎么做近期重大新闻
  • 如何接做网站编程的生意电商大数据查询平台