当前位置:网站首页>Develop the first Flink app
Develop the first Flink app
2022-07-19 09:25:00 【51CTO】
Welcome to visit mine GitHub
Here we classify and summarize all the original works of Xinchen ( Including supporting source code ): https://github.com/zq2599/blog_demos
- stay 《Flink1.7 From installation to experience 》 In the article , We installed and experienced Flink, Use today java Let's develop a simple Flink application ;
Step list
- The actual combat experience is as follows :
- Create an ;
- code ;
- structure ;
- Submit task to Flink, Verification function ;
environmental information
- Flink:1.7;
- Flink The operating system of the machine :CentOS Linux release 7.5.1804;
- development environment JDK:1.8.0_181;
- development environment Maven:3.5.0;
Introduction to application functions
- stay 《Flink1.7 From installation to experience 》 In the article , We are Flink function SocketWindowWordCount.jar, The function realized is from socket Read string , Count the number of each word , Today we will code and develop this application , Realize this function ;
Create an
- The basic application code is through mvn Command created , Enter the following command at the command line :
- Press the prompt on the console to enter groupId、artifactId、version、package Etc , After all the way enter and confirm , It will generate a file that matches your input artifactId A folder with the same name , It's a maven engineering :
use IEDA Import this maven engineering , Here's the picture , There are already two classes :BatchJob and StreamingJob,BatchJob Is for batch processing , This actual battle does not use , So you can delete , Only stream processed StreamingJob:

App created successfully , Now we can start coding ;
code
- You can choose to directly from GitHub Download the source code of this project , The address and link information is shown in the following table :
| name | link | remarks |
|---|---|---|
| Project home page | https://github.com/zq2599/blog_demos | The project is in progress. GitHub Home page on |
| git Warehouse address (https) | https://github.com/zq2599/blog_demos.git | The warehouse address of the source code of the project ,https agreement |
| git Warehouse address (ssh) | [email protected]:zq2599/blog_demos.git | The warehouse address of the source code of the project ,ssh agreement |
This git Multiple folders in project , The source code of this chapter is in socketwordcountdemo Under this folder , As shown in the red box below :

Next, start coding :
stay StreamingJob Add static inner classes to class WordWithCount, This is a PoJo, Used to save a specific word and its frequency :
- Write all business logic in StreamJob Class main In the method , As shown below , Chinese notes are added at key positions :
structure
- stay pom.xml Execute the command in the directory where the file is located :
- After the command is executed , stay target In the catalog socketwordcountdemo-1.0-SNAPSHOT.jar Files are built successfully jar package ;
stay Flink verification
- Flink For installation and start-up, please refer to 《Flink1.7 From installation to experience 》;
- Log in to Flink Location machine , Execute the following command :
My side Flink Of the machine IP The address is 192.168.1.103, Therefore, access with browser Flink Of web The address is : http://192.168.1.103:8081;
Choose the jar File as a new task , Here's the picture :

Click in the red box below "upload", Submit a document :

At present, only jar The file was uploaded , The next step is to manually set the execution class and start the task , Operation as shown below , Red box 2 Filled in the above StreamingJob Full name of the class :

The effect of the submitted page is shown in the following figure , See a job It's already running :

go back to Flink Console of the machine , Entered before nc -l 9999 Input some English sentences in the window of , Then press enter , for example :
Next, let's take a look at our job The implementation effect of , Here's the picture , Click on the left "Task Managers", There is only one in the list on the right Task, Click on it :

Three pages appear tab page , Click on "Stdout" This tab, You can see the statistical results of our task on the words in the previous sentence , Here's the picture :

thus , The first is the simplest Flink It's done. .
Welcome to your attention 51CTO Blog : Xinchen, programmer
On the way to study , You are not alone , Xinchen's original works are accompanied all the way …
边栏推荐
- 06---光在介质中的特性
- MySQL 视图
- SAP Fiori 的附件处理(Attachment handling)
- 多租户 SaaS 的数据库设计模式,你学废了吗?
- 【Flink】Flink 设置检查点失败一次就报错 setTolerableCheckpointFailureNumber 不起作用
- 研究发现DNA纳米设备注射液可安全用于医疗用途
- Latest fruit flstudio20.9 low version upgrade high version tutorial
- After working hard, I found that there were so many messes around
- 日志脱敏-参考
- SSM implementation of one-to-one query detailed tutorial (1)
猜你喜欢

C语言编译过程

面试题-给::memcpy函数设计测试用例

C语言基础篇 —— 2-3 指针与数组

Flink small knowledge -- configuration of task scheduling slots slotsharinggroup

将视频格式转换为gif图片格式

Case sharing | build a one-stop data development platform for hehe information based on linkis+dss

案例分享 | 基于Linkis+DSS构建合合信息一站式数据开发平台

Etcd database source code analysis - initialize etcdserver structure
![[hero planet July training leetcode problem solving daily] 17th kuansou](/img/92/9b8e3a710430d37564d7ea3f28168f.png)
[hero planet July training leetcode problem solving daily] 17th kuansou

【C语言】自定义类型初阶知识点
随机推荐
Anycontrol demo demo demo
C51 常见数据类型详解
Leetcode 197 Rising temperature (July 16, 2022)
目标检测模型大小计算,模型复杂度(参数换算公式)
C语言编译过程
【C语言】指针练习题2——笔试真题及解析
DEDECMS织梦文章列表标题重复显示解决方案
Questions d'entrevue - concevoir des cas d'essai pour:: memcpy
mysqldump全备恢复到新另一个实例然后再执行flush privileges的情况分析
易贝按关键字搜索EBAY商品 API 返回值说明
C语言基础篇 —— 2-1 指针与野指针
【摸鱼神器】UI库秒变低代码工具——表单篇(二)子控件
Vector容器的系列操作( 详解 )
在Pycharm里面如何避免全局索引?如何取消对于某个文件夹的索引?
SSM implementation of one-to-one query detailed tutorial (1)
组件化高级--插槽
Jsp+ajax+servlet+mysql to realize addition, deletion, modification and query (I)
Daily model series: July 11, 2022
【C语言】浮点型在内存的存储
idea卡顿且报错:UI was frozen for xxxxx ms问题解决