Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve]Improve flink env check method #3461

Merged
merged 15 commits into from
Jan 8, 2024

Conversation

zzzk1
Copy link
Contributor

@zzzk1 zzzk1 commented Jan 6, 2024

What changes were proposed in this pull request

improve hard code in FlinkEnvServiceImpl check method

Brief change log

add FlinkEnvStatus.java in
streampark-common/src/main/java/org/apache/streampark/common/enums/

modifty FlinkEnvServiceImpl.java in
streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/FlinkEnvServiceImpl.java

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts

  • Dependencies (does it add or upgrade a dependency): (no)

zzzk1 added 3 commits January 7, 2024 01:42
…o improvement-flink-env-check

# Conflicts:
#	streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkEnvStatus.java
@zzzk1 zzzk1 changed the title [Improvement ]Improve flink env check method [Improve ]Improve flink env check method Jan 6, 2024
@wolfboys
Copy link
Member

wolfboys commented Jan 7, 2024

Looks good, The front-end code also needs improvement. Looking forward to your next update! 😊

@github-actions github-actions bot added the WEB UI label Jan 7, 2024
*/
Integer check(FlinkEnv version);
String check(FlinkEnv version);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be better to return type FlinkEnvStatus

FEASIBLE("ok"),

/* defined flink name repeated */
NAME_REPEATED("name repeated"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the code? Need an attribute of type Int(code)

@@ -52,7 +52,7 @@ public RestResponse list() {
@Operation(summary = "Verify flink environment")
@PostMapping("check")
public RestResponse check(FlinkEnv version) {
Integer checkResp = flinkEnvService.check(version);
String checkResp = flinkEnvService.check(version);
return RestResponse.success(checkResp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return the code value of the enum FlinkEnvStatus

const checkResp = parseInt(resp.data);
if (checkResp != 0) {
const checkResp = resp.data;
if (checkResp != 'ok') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is how the front-end (FE) use enums to adapt to the values returned by the back-end (BE), You can refer to it:

https://github.com/apache/incubator-streampark/blob/dev/streampark-console/streampark-console-webapp/src/enums/flinkEnum.ts

@zzzk1 zzzk1 force-pushed the improvement-flink-env-check branch from 27f13ff to 5b90bdf Compare January 7, 2024 10:18
@@ -49,8 +50,6 @@ public class FlinkEnvServiceImpl extends ServiceImpl<FlinkEnvMapper, FlinkEnv>
* two places will be checked: <br>
* 1) name repeated <br>
* 2) flink-dist repeated <br>
* -1) invalid path <br>
* 0) ok <br>
*/
@Override
public Integer check(FlinkEnv version) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be better to return FlinkEnvStatus type instead of Integer

if (checkResp !== FlinkEvnEnum.FEASIBLE) {
switch (checkResp) {
case FlinkEvnEnum.INVALID:
Swal.fire('Failed', 'FLINK_HOME invalid path.', 'error');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error msg should use i18n

case FlinkEvnEnum.FLINK_DIST_REPEATED:
Swal.fire(
'Failed',
'can no found flink-dist or found multiple flink-dist, FLINK_HOME error.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error msg should use i18n, e.g: t('setting.flinkHome.operateMessage.FLINK_DIST_REPEATED')
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sry I know nothing about the front end

@zzzk1 zzzk1 changed the title [Improve ]Improve flink env check method [Improve]Improve flink env check method Jan 8, 2024
@caicancai
Copy link
Member

cc @RocMarshal
thank you for your contribution.

@@ -32,6 +32,8 @@ export default {
flinkNameIsRequired: 'Flink名称必填',
flinkHomeTips: 'Flink所在服务器的绝对路径,举例: /usr/local/flink',
flinkHomeIsRequired: 'Flink安装路径必填',
flinkHomePathIsInvalid: 'Flink所在路径不合法',
flinkDistIsRepeated: '找不到发行版代码',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flink lib 路径下有且只能有一个 flink-dist jar 文件

@@ -32,6 +32,8 @@ export default {
flinkNameIsRequired: 'Flink名称必填',
flinkHomeTips: 'Flink所在服务器的绝对路径,举例: /usr/local/flink',
flinkHomeIsRequired: 'Flink安装路径必填',
flinkHomePathIsInvalid: 'Flink所在路径不合法',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flink Home 路径无效

@wolfboys wolfboys merged commit 3cc2583 into apache:dev Jan 8, 2024
5 of 8 checks passed
zzzk1 added a commit to zzzk1/incubator-streampark that referenced this pull request Jan 12, 2024
* [Improve] improve hard code in FlinkEnvServiceImpl

* improve front end hard code and back end check method

* improve check method return type

* improve front end check method logic

* improve message support i18n

* improve i18n error message

---------

Co-authored-by: benjobs <[email protected]>
@zzzk1 zzzk1 deleted the improvement-flink-env-check branch January 22, 2024 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants