当前位置:网站首页>Good fat man takes you to learn Flink series -flink source code analysis episode I standalone startup script analysis
Good fat man takes you to learn Flink series -flink source code analysis episode I standalone startup script analysis
2022-06-25 17:04:00 【China's fat people】
A good fat man takes you to learn Flink:Flink The first episode of source code analysis Standalone Start script analysis
1、 Preface
Hello, friends , Next I will bring you a complete set of Flink The source code learning tutorial will include several knowledge points :
- Flink Learning the kernel process
- Study Flink Learning from this top-level open source framework
- At the same time, we will provide you with some small issue, Can it be commiter It depends on everyone .
2、 Content
1. start-cluster.sh
At this time, all leaders , You can open your own flink Source code , Or download it Flink Packages and centos above Flink In software bin Catalog .
stay flink Source code , The project where the script is located is flink-dist Under the flink-bin Catalog , At this point we are analyzing start-cluster.
Many friends must say why not watch yarn Submit , Want to see Standalone How to start the cluster , because Standalone Every computing framework exists , for example yarn And so on are all done for compatibility ,standalone Only in this way can we truly reflect flink Some usage of some internal core frameworks ( Because it is relatively simple and easy to analyze ...), Let's analyze , Start script , In fact, many students are analyzing the source code of a framework , Often in order to find the entrance and trouble , At work , This is also the case , For example, look at a not springboot The program , Just look at his main Method .
If it is springboot It depends on the display effect of his page ,debug Interface , This will make you familiar with the source code very quickly , After that, we will look at some internal asynchronous 、 Some methods of timing .
So let's analyze the script .
First, he will execute a very important script config.sh
This script is really important , It is an acquisition configuration , And important scripts to get some parameters , In order to be compatible with Huawei cloud in our company's project , This script is often modified , Add something to this script .
You can see
# Is it highly available
if [[ $HIGH_AVAILABILITY == "zookeeper" ]]; then
# obtain mater The address of
readMasters
# Remote execution
ssh -n $FLINK_SSH_OPTS $master -- "nohup /bin/bash -l \"${FLINK_BIN_DIR}/jobmanager.sh\" start ${master} ${webuiport} &"
fi
done
At this time, many students got confused readMasters What is this ? In fact, does this affect us to watch the script , No effect , I don't really understand shell, But I can probably understand This is a shell Methods , According to the method name He is reading master The address of . then ssh To this master Start the machine jobmanager. Why must it be started on a fixed machine jobmanager, Because he has a commonRpcService, Other components will look for this service. So what must be fixed , You configure that machine to execute on that machine , If the error , Can't access service Of .
Because the passing of all nodes largely depends on the configuration file to generate services , For other components to communicate .
Said so much , Where is this method ? This method is actually config.sh
Let's assume that we are not currently a highly available cluster , We must be leaving else, So what he called must be "$FLINK_BIN_DIR"/jobmanager.sh start This script , Let's go and have a look .
2. Jobmanager Start class analysis
At this point we open , This script , We see the bottom , to glance at What did he write
What we have introduced is start, I'm sure I won't go here at this time if, Is take the else, That is to say
"${FLINK_BIN_DIR}"/flink-daemon.sh $STARTSTOP $ENTRYPOINT "${args[@]}" This command , that $ENTRYPOINT What is it? , It is also defined above
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-gSP8fuOr-1655545235857)(https://gitee.com/wuqingzhi128/blogImg/raw/master/image-20220618171729945.png)]](/img/e5/7e3a283c1aed8cecf144a2d7db8611.png)
If this script is completely written , It can be written.
flink-daemon.sh start standalonesession "${args[@]}"
We enter flink-daemon.sh It's very simple. We found that
[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-N8V6unT4-1655545235858)(https://gitee.com/wuqingzhi128/blogImg/raw/master/image-20220618172152405.png)]
Here is common sense , I don't have to look down , You know jobmanager It must be this kind of walking main Method . start-up JobManager Walking StandaloneApplicationClusterEntryPoint This class main Method
3. TaskManager Start class analysis
We are at this time , We have found ,JobManager The entrance to , But we haven't found it yet Taskmanager Entrance , Let's go back to start-cluster.sh .
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-YrzS3vQi-1655545235858)(https://gitee.com/wuqingzhi128/blogImg/raw/master/image-20220618172438233.png)]](/img/a4/e916b5bc3808cb8e1df4b5f223204c.png)
Below we can see a method start-up , We found this way , This method is config.sh in .
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-qx3f0JyZ-1655545235859)(https://gitee.com/wuqingzhi128/blogImg/raw/master/image-20220618172617129.png)]](/img/fd/5e25d367d789b0db554d969a7ae788.png)
You can see that it is started locally , Start remotely instead of locally taskmanager, Of course, there may be more than one , That is to say for Cycle to start .
We see the internal call taskmanager.sh start, Let's see taskmanager.sh This script , Don't say , Layer by layer .
We searched and searched , We found this piece , Is it right? JobManager Startup is very similar .
It's like
/flink-daemon.sh start taskexecutor "${ARGS[@]}"
Go back to flink-daemon.sh see , We also found ,Taskmanager The last class to execute is TaskManagerRunner This class of main Method .
At this time, we found all the entrances , The rest is to look at the source code .
3、 summary
1、 We analyzed start-cluster.sh Script for , In this script , He will call... First config.sh Get configuration .
2、 Will be based on JobManager Is it right? Ha To determine whether to execute different branches remotely JobManager
3、 We're sure JobManager The startup class of is StandaloneApplicationClusterEntryPoint
4、 We're sure TaskManager The startup class of is TaskManagerRunner This class .
If the interview asks if you have seen flink Source code , It can be said that the summary of our script analysis , Of course, that's not the point , In the next issue, we will analyze JobManager Start source code of .
边栏推荐
- 剑指 Offer 50. 第一个只出现一次的字符
- A complete collection of APP testing tools. It's enough to collect this one
- 【微服务|Sentinel】流控规则概述|针对来源|流控模式详解<直接 关联 链路>
- Cache architecture scheme of ten million level shopping cart system
- 剑指 Offer II 025. 链表中的两数相加
- Xshell connecting VMware virtual machines
- redis 分布式锁整理
- Internship: the annotation under swagger involves the provision of interfaces
- How to view the change trend of cloud database from the behind of the launch of tidb to Alibaba cloud
- 2021年5月云南省网络空间安全比赛赛题复盘
猜你喜欢
随机推荐
[proficient in high concurrency] deeply understand the basics of assembly language
1-8file sharing in VMWare
卡尔曼时间序列预测
旧手机变废为宝,充当服务器使用
XShell连接VMWare虚拟机
pytorch官方文档学习记录
剑指 Offer II 010. 和为 k 的子数组 前缀和差
Which is better for intermediate and advanced soft exam?
Kalman time series prediction
2022-06-17 advanced network engineering (x) is-is-general header, establishment of adjacency relationship, IIH message, DIS and pseudo node
Generate post order traversal according to pre order traversal and mid order traversal
论文笔记:LBCF: A Large-Scale Budget-Constrained Causal Forest Algorithm
剑指 Offer II 014. 字符串中的变位词 滑动窗口
「津津乐道播客」#386 原汤话原食:谁还不是个“白字先生”?
二十九-使用RealSenseD435进行ORBSLAM2实时三维重建
【无标题】
一个 TDD 示例
How did I raise my salary to 20k in three years?
Uniapp to preview pictures (single / multiple)
Effects and laws








