[B]Flink版本适配改造(三)1.0.7+
# 编译细节优化:减负输出 + 应用 Patch
在实际构建 Flink 1.17.2 的过程中,我们观察到 大量输出可能导致 Shell 卡死甚至 IDE 崩溃的问题,尤其是在开启 -X
模式时。
# 问题复现
如果你直接执行如下命令,添加 -X
会产生海量调试日志:
mvn install -Drat.skip=true -DskipTests=true -X
1
在长时间构建过程中,这会造成终端疯狂输出,资源飙升,如下图所示:
# 推荐做法:移除 -X
参数
为了避免非必要的日志堆积,建议你移除 -X
参数,执行如下构建命令:
mvn install -Drat.skip=true -DskipTests=true
1
运行效果明显更稳定,不再疯狂刷屏:
# 创建补丁文件 patch0-FLINK_COMPILE_FAST.diff
我们接下来在 bigtop-packages/src/common/flink/1.17.2/
目录下创建补丁文件,用于:
- 加速 Node 与 npm 安装;
- 修复 npm 权限;
- 明确执行
npm install
与ci-check
。
文件命名建议:patch0-FLINK_COMPILE_FAST.diff
(你也可以自定义)
内容如下:
Subject: [PATCH] fixed: 1.17.2 对于node 的一些加速
---
Index: flink-runtime-web/pom.xml
===================================================================
@@ -247,6 +247,8 @@
</executions>
</plugin>
+
+ <!-- 1) 安装 Node + npm -->
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
@@ -254,33 +256,75 @@
<executions>
<execution>
<id>install node and npm</id>
+ <phase>generate-resources</phase>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v16.13.2</nodeVersion>
<npmVersion>8.1.2</npmVersion>
+ <nodeDownloadRoot>https://cdn.npmmirror.com/binaries/node/</nodeDownloadRoot>
+ <npmDownloadRoot>https://registry.npmmirror.com/npm/-/</npmDownloadRoot>
</configuration>
</execution>
+ </executions>
+ <configuration>
+ <workingDirectory>web-dashboard</workingDirectory>
+ </configuration>
+ </plugin>
+
+ <!-- 2) 修复 npm 可执行权限 -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>fix-npm-permissions</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <target>
+ <echo message=">>> chmod 755 web-dashboard/node/npm" />
+ <chmod file="${project.basedir}/web-dashboard/node/npm" perm="755"/>
+ </target>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- 3) npm install -->
+ <plugin>
+ <groupId>com.github.eirslett</groupId>
+ <artifactId>frontend-maven-plugin</artifactId>
+ <version>1.11.0</version>
+ <executions>
<execution>
<id>npm install</id>
+ <phase>process-resources</phase>
<goals>
<goal>npm</goal>
</goals>
<configuration>
- <arguments>ci --cache-max=0 --no-save ${npm.proxy}</arguments>
+ <arguments>install --unsafe-perm --verbose --progress</arguments>
+ <npmRegistryURL>https://registry.npmmirror.com/</npmRegistryURL>
<environmentVariables>
<HUSKY_SKIP_INSTALL>true</HUSKY_SKIP_INSTALL>
+ <HOME>${project.build.directory}/.npmhome</HOME>
</environmentVariables>
</configuration>
</execution>
+
+ <!-- 4) ci-check -->
<execution>
<id>npm run ci-check</id>
+ <phase>process-resources</phase>
<goals>
<goal>npm</goal>
</goals>
<configuration>
- <arguments>run ci-check</arguments>
+ <arguments>run ci-check --verbose</arguments>
</configuration>
</execution>
</executions>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92