From ec9f31541ad5a0e84d56dd070384947a131434de Mon Sep 17 00:00:00 2001 From: zhuhuipei Date: Sat, 25 Jun 2022 12:16:17 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E7=BB=9F=E4=B8=80=E4=BD=BF=E7=94=A8=20googleStyle=20?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=202=E3=80=81=E5=BC=95=E5=85=A5=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E8=8C=83checkstyle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- checkstyle.xml | 25 +- deployer/checkstyle.xml | 208 --- .../common/constant/SystemConstant.java | 19 +- .../enums/CheckPointParameterEnums.java | 42 +- .../streaming/common/enums/JobTypeEnum.java | 34 +- .../streaming/common/enums/SqlCommand.java | 221 +-- .../common/model/CheckPointParam.java | 90 +- .../common/model/SqlCommandCall.java | 30 +- .../streaming/common/sql/SqlFileParser.java | 159 +- .../flink/streaming/core/JobApplication.java | 101 +- .../core/checkpoint/CheckPointParams.java | 134 +- .../core/checkpoint/FsCheckPoint.java | 155 +- .../streaming/core/config/Configurations.java | 30 +- .../flink/streaming/core/logs/LogPrint.java | 85 +- .../streaming/core/model/JobRunParam.java | 24 +- .../sql/util/ValidationConstants.java | 14 +- .../sql/validation/SqlValidation.java | 349 +++-- .../validation/test/TestSqlValidation.java | 17 +- .../streaming/web/alarm/DingDingAlarm.java | 12 +- .../flink/streaming/web/alarm/HttpAlarm.java | 16 +- .../web/alarm/impl/DingDingAlarmImpl.java | 69 +- .../web/alarm/impl/HttpAlarmImpl.java | 58 +- .../streaming/web/common/FlinkConstants.java | 8 +- .../web/common/FlinkYarnRestUriConstants.java | 73 +- .../web/common/MessageConstants.java | 22 +- .../streaming/web/common/RestResult.java | 70 +- .../streaming/web/common/SystemConstants.java | 90 +- .../streaming/web/common/TipsConstants.java | 2 +- .../web/common/util/AttributeUtils.java | 27 - .../web/common/util/Base64Coded.java | 66 +- .../web/common/util/CliConfigUtil.java | 270 ++-- .../web/common/util/CommandUtil.java | 224 +-- .../web/common/util/DateFormatUtils.java | 24 +- .../streaming/web/common/util/FileUtils.java | 150 +- .../common/util/HttpServiceCheckerUtil.java | 65 +- .../streaming/web/common/util/HttpUtil.java | 52 +- .../streaming/web/common/util/IpUtil.java | 96 +- .../streaming/web/common/util/JsonUtil.java | 24 - .../web/common/util/LinuxInfoUtil.java | 14 +- .../web/common/util/MatcherUtils.java | 44 +- .../streaming/web/common/util/Md5Utils.java | 65 +- .../streaming/web/common/util/Pages.java | 32 +- .../web/common/util/ParameterTool.java | 531 +++---- .../streaming/web/common/util/UrlUtil.java | 106 +- .../web/common/util/UserSessionUtil.java | 58 +- .../streaming/web/common/util/YarnUtil.java | 15 +- .../web/enums/AlarmLogStatusEnum.java | 37 +- .../streaming/web/enums/AlarmLogTypeEnum.java | 38 +- .../streaming/web/enums/AlarmTypeEnum.java | 39 +- .../streaming/web/enums/DeployModeEnum.java | 22 +- .../streaming/web/enums/IpStatusEnum.java | 10 +- .../streaming/web/enums/JobConfigStatus.java | 39 +- .../streaming/web/enums/JobStatusEnum.java | 24 +- .../streaming/web/enums/SysConfigEnum.java | 138 +- .../web/enums/SysConfigEnumType.java | 2 +- .../streaming/web/enums/SysErrorEnum.java | 80 +- .../streaming/web/enums/UserStatusEnum.java | 33 +- .../com/flink/streaming/web/enums/YN.java | 58 +- .../streaming/web/enums/YarnStateEnum.java | 18 +- .../web/exceptions/BizException.java | 66 +- .../web/exceptions/GlobalException.java | 78 +- .../streaming/web/model/dto/AlartLogDTO.java | 155 +- .../web/model/dto/JobAlarmConfigDTO.java | 102 +- .../streaming/web/model/dto/JobConfigDTO.java | 397 +++-- .../web/model/dto/JobConfigHistoryDTO.java | 294 ++-- .../streaming/web/model/dto/JobRunLogDTO.java | 250 +-- .../web/model/dto/JobRunParamDTO.java | 128 +- .../streaming/web/model/dto/PageModel.java | 46 +- .../web/model/dto/SavepointBackupDTO.java | 54 +- .../web/model/dto/SystemConfigDTO.java | 94 +- .../streaming/web/model/dto/UserDTO.java | 136 +- .../streaming/web/model/dto/UserSession.java | 30 +- .../streaming/web/model/entity/AlartLog.java | 60 +- .../streaming/web/model/entity/IpStatus.java | 54 +- .../web/model/entity/JobAlarmConfig.java | 49 +- .../streaming/web/model/entity/JobConfig.java | 204 ++- .../web/model/entity/JobConfigHistory.java | 108 +- .../streaming/web/model/entity/JobRunLog.java | 102 +- .../web/model/entity/SavepointBackup.java | 39 +- .../web/model/entity/SystemConfig.java | 46 +- .../streaming/web/model/entity/User.java | 88 +- .../streaming/web/model/page/PageParam.java | 16 +- .../web/model/param/AlartLogParam.java | 18 +- .../model/param/JobConfigHisotryParam.java | 19 +- .../web/model/param/JobConfigParam.java | 36 +- .../web/model/param/JobRunLogParam.java | 12 +- .../web/model/param/UpsertJobConfigParam.java | 205 ++- .../streaming/web/model/to/AppListTO.java | 2 +- .../flink/streaming/web/model/to/AppTO.java | 80 +- .../streaming/web/model/to/YarnAppInfo.java | 2 +- .../streaming/web/model/vo/AlartLogVO.java | 125 +- .../streaming/web/model/vo/CallbackDTO.java | 24 +- .../streaming/web/model/vo/Constant.java | 166 +- .../streaming/web/model/vo/DeployFlinkVO.java | 138 +- .../web/model/vo/DetailJobConfigVO.java | 200 +-- .../web/model/vo/JobConfigHistoryVO.java | 184 +-- .../streaming/web/model/vo/JobConfigVO.java | 223 +-- .../streaming/web/model/vo/JobRunLogVO.java | 196 +-- .../flink/streaming/web/model/vo/PageVO.java | 34 +- .../web/model/vo/SavepointBackupVO.java | 51 +- .../streaming/web/model/vo/SysConfigVO.java | 12 +- .../web/model/vo/SystemConfigVO.java | 52 +- .../flink/streaming/web/model/vo/UserVO.java | 129 +- .../streaming/web/config/AlarmPoolConfig.java | 46 +- .../streaming/web/config/CustomConfig.java | 4 +- .../streaming/web/config/JobThreadPool.java | 44 +- .../web/config/SavePointThreadPool.java | 44 +- .../streaming/web/config/TaskPoolConfig.java | 25 +- .../web/config/WaitForPoolConfig.java | 45 +- .../streaming/web/ao/AlarmServiceAO.java | 32 +- .../streaming/web/ao/DingDingService.java | 28 +- .../streaming/web/ao/JobBaseServiceAO.java | 94 +- .../flink/streaming/web/ao/JobConfigAO.java | 32 +- .../flink/streaming/web/ao/JobServerAO.java | 94 +- .../flink/streaming/web/ao/TaskServiceAO.java | 62 +- .../web/ao/impl/AlarmServiceAOImpl.java | 114 +- .../web/ao/impl/DingDingServiceImpl.java | 472 +++--- .../web/ao/impl/JobBaseServiceAOImpl.java | 745 ++++----- .../web/ao/impl/JobConfigAOImpl.java | 34 +- .../ao/impl/JobStandaloneServerAOImpl.java | 261 ++-- .../web/ao/impl/JobYarnServerAOImpl.java | 217 +-- .../web/ao/impl/TaskServiceAOImpl.java | 510 +++--- .../controller/api/AlartApiController.java | 237 +-- .../web/controller/api/ApiController.java | 22 +- .../controller/api/ConfigApiController.java | 83 +- .../controller/api/FlinkLogApiController.java | 54 +- .../api/JobConfigApiController.java | 1201 +++++++------- .../controller/api/JobLogApiController.java | 88 +- .../api/SavepointApiController.java | 113 +- .../api/SqlValidationController.java | 40 +- .../web/controller/api/UserApiController.java | 404 ++--- .../web/controller/web/BaseController.java | 39 +- .../web/controller/web/DefaultController.java | 9 +- .../web/interceptor/InterceptorConfig.java | 26 +- .../web/interceptor/LoginInterceptor.java | 68 +- .../web/listener/ApplicationStopListener.java | 26 +- .../streaming/web/mapper/AlarmLogMapper.java | 6 +- .../streaming/web/mapper/IpStatusMapper.java | 26 +- .../web/mapper/JobAlarmConfigMapper.java | 8 +- .../web/mapper/JobConfigHistoryMapper.java | 10 +- .../streaming/web/mapper/JobConfigMapper.java | 31 +- .../streaming/web/mapper/JobRunLogMapper.java | 10 +- .../web/mapper/SavepointBackupMapper.java | 7 +- .../web/mapper/SystemConfigMapper.java | 10 +- .../streaming/web/mapper/UserMapper.java | 18 +- .../web/rpc/CommandRpcClinetAdapter.java | 61 +- .../web/rpc/FlinkRestRpcAdapter.java | 56 +- .../streaming/web/rpc/YarnRestRpcAdapter.java | 105 +- .../rpc/impl/CommandRpcClinetAdapterImpl.java | 307 ++-- .../web/rpc/impl/FlinkRestRpcAdapterImpl.java | 115 +- .../web/rpc/impl/YarnRestRpcAdapterImpl.java | 265 ++-- .../streaming/web/rpc/model/JobInfo.java | 4 +- .../web/rpc/model/JobStandaloneInfo.java | 6 +- .../web/runner/ApplicationRunner.java | 12 +- .../web/scheduler/SchedulerTask.java | 145 +- .../web/service/AlartLogService.java | 56 +- .../web/service/IpStatusService.java | 76 +- .../web/service/JobAlarmConfigService.java | 49 +- .../web/service/JobConfigHistoryService.java | 78 +- .../web/service/JobConfigService.java | 230 +-- .../web/service/JobRunLogService.java | 96 +- .../web/service/SavepointBackupService.java | 56 +- .../web/service/SystemConfigService.java | 151 +- .../streaming/web/service/UserService.java | 230 ++- .../web/service/impl/AlartLogServiceImpl.java | 62 +- .../web/service/impl/IpStatusServiceImpl.java | 100 +- .../impl/JobAlarmConfigServiceImpl.java | 140 +- .../impl/JobConfigHistoryServiceImpl.java | 63 +- .../service/impl/JobConfigServiceImpl.java | 481 +++--- .../service/impl/JobRunLogServiceImpl.java | 96 +- .../impl/SavepointBackupServiceImpl.java | 42 +- .../service/impl/SystemConfigServiceImpl.java | 4 +- .../web/service/impl/UserServiceImpl.java | 279 ++-- .../web/thread/AlarmDingdingThread.java | 57 +- .../streaming/web/thread/AlarmHttpThread.java | 40 +- .../web/utils/HttpClientToolUtils.java | 1387 +++++++++-------- .../streaming/web/utils/JacksonUtil.java | 513 +++--- .../flink/streaming/web/utils/WebUtil.java | 255 ++- .../resources/application-docker.properties | 6 +- .../resources/application-prod.properties | 6 +- .../src/main/resources/application.properties | 16 +- .../main/resources/logging/logback-dev.xml | 92 +- .../main/resources/logging/logback-docker.xml | 185 +-- .../main/resources/logging/logback-prod.xml | 158 +- .../main/resources/mapper/AlartLogMapper.xml | 126 +- .../main/resources/mapper/IpStatusMapper.xml | 130 +- .../resources/mapper/JobAlarmConfigMapper.xml | 118 +- .../mapper/JobConfigHistoryMapper.xml | 80 +- .../main/resources/mapper/JobConfigMapper.xml | 482 +++--- .../main/resources/mapper/JobRunLogMapper.xml | 229 +-- .../mapper/SavepointBackupMapper.xml | 83 +- .../resources/mapper/SystemConfigMapper.xml | 106 +- .../src/main/resources/mapper/UserMapper.xml | 168 +- .../src/main/resources/static/ui/index.html | 393 ++++- .../ui/static/css/chunk-1147343e.db22aedf.css | 4 +- .../ui/static/css/chunk-176ca70f.f6fe2be1.css | 8 +- .../ui/static/css/chunk-1c7e07ca.8394d684.css | 6 +- .../ui/static/css/chunk-2b6fca86.5cd3a7d8.css | 9 +- .../ui/static/css/chunk-324159a4.90a6ce5e.css | 6 +- .../ui/static/css/chunk-3876589c.0fb6e111.css | 8 +- .../ui/static/css/chunk-3a7c4bfc.ae037ade.css | 4 +- .../ui/static/css/chunk-42990da2.a44d9352.css | 4 +- .../ui/static/css/chunk-7a8911e6.33cb7757.css | 10 +- .../ui/static/css/chunk-a6df3e9a.55203a7a.css | 7 +- .../ui/static/css/chunk-bb4a12f2.55c028b5.css | 8 +- .../ui/static/css/chunk-e0b6b12a.95371419.css | 6 +- .../ui/static/css/chunk-fd4175ca.1d1ddef2.css | 9 +- pom.xml | 2 +- 208 files changed, 11521 insertions(+), 11066 deletions(-) delete mode 100644 deployer/checkstyle.xml delete mode 100644 flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/AttributeUtils.java delete mode 100644 flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/JsonUtil.java diff --git a/checkstyle.xml b/checkstyle.xml index 5b8c96b2..7cec53eb 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -4,6 +4,8 @@ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> + + @@ -12,14 +14,12 @@ + - - - - + @@ -37,7 +37,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -95,20 +95,13 @@ - - - - - - - - + - + - + diff --git a/deployer/checkstyle.xml b/deployer/checkstyle.xml deleted file mode 100644 index 962ff0c4..00000000 --- a/deployer/checkstyle.xml +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/flink-streaming-commom/src/main/java/com/flink/streaming/common/constant/SystemConstant.java b/flink-streaming-commom/src/main/java/com/flink/streaming/common/constant/SystemConstant.java index 2050f428..012e58ae 100644 --- a/flink-streaming-commom/src/main/java/com/flink/streaming/common/constant/SystemConstant.java +++ b/flink-streaming-commom/src/main/java/com/flink/streaming/common/constant/SystemConstant.java @@ -10,26 +10,25 @@ */ public class SystemConstant { - public static final String COMMENT_SYMBOL = "--"; + public static final String COMMENT_SYMBOL = "--"; - public static final String SEMICOLON = ";"; + public static final String SEMICOLON = ";"; - public static final String LINE_FEED = "\n"; + public static final String LINE_FEED = "\n"; - public static final String SPACE = ""; + public static final String SPACE = ""; - public static final String VIRGULE = "/"; + public static final String VIRGULE = "/"; - public static final int DEFAULT_PATTERN_FLAGS = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; + public static final int DEFAULT_PATTERN_FLAGS = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; - public static final String JARVERSION = "lib/flink-streaming-core-1.4.0.RELEASE.jar"; + public static final String JARVERSION = "lib/flink-streaming-core-1.4.0.RELEASE.jar"; - public static final String QUERY_JOBID_KEY_WORD = "job-submitted-success:"; - - public static final String QUERY_JOBID_KEY_WORD_BACKUP = "Job has been submitted with JobID"; + public static final String QUERY_JOBID_KEY_WORD = "job-submitted-success:"; + public static final String QUERY_JOBID_KEY_WORD_BACKUP = "Job has been submitted with JobID"; } diff --git a/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/CheckPointParameterEnums.java b/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/CheckPointParameterEnums.java index 33f42e48..1a39ef66 100644 --- a/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/CheckPointParameterEnums.java +++ b/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/CheckPointParameterEnums.java @@ -10,28 +10,28 @@ */ public enum CheckPointParameterEnums { - checkpointDir, - checkpointingMode, - checkpointInterval, - checkpointTimeout, - tolerableCheckpointFailureNumber, - asynchronousSnapshots, - externalizedCheckpointCleanup, - stateBackendType, - enableIncremental; + checkpointDir, + checkpointingMode, + checkpointInterval, + checkpointTimeout, + tolerableCheckpointFailureNumber, + asynchronousSnapshots, + externalizedCheckpointCleanup, + stateBackendType, + enableIncremental; - public static void isExits(Set keys) { - for (String key : keys) { - boolean exits = false; - for (CheckPointParameterEnums checkPointParameterEnums : CheckPointParameterEnums.values()) { - if (checkPointParameterEnums.name().equalsIgnoreCase(key)) { - exits = true; - continue; - } - } - if (!exits) { - throw new RuntimeException(key + " 暂时不支持使用"); - } + public static void isExits(Set keys) { + for (String key : keys) { + boolean exits = false; + for (CheckPointParameterEnums checkPointParameterEnums : CheckPointParameterEnums.values()) { + if (checkPointParameterEnums.name().equalsIgnoreCase(key)) { + exits = true; + continue; } + } + if (!exits) { + throw new RuntimeException(key + " 暂时不支持使用"); + } } + } } diff --git a/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/JobTypeEnum.java b/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/JobTypeEnum.java index aed7bce0..4ca4b75a 100644 --- a/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/JobTypeEnum.java +++ b/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/JobTypeEnum.java @@ -11,25 +11,25 @@ @Getter public enum JobTypeEnum { - SQL_STREAMING(0), JAR(1), SQL_BATCH(2); + SQL_STREAMING(0), JAR(1), SQL_BATCH(2); - private int code; + private int code; - JobTypeEnum(int code) { - this.code = code; - } + JobTypeEnum(int code) { + this.code = code; + } - public static JobTypeEnum getJobTypeEnum(Integer code) { - if (code == null) { - return null; - } - for (JobTypeEnum jobTypeEnum : JobTypeEnum.values()) { - if (code == jobTypeEnum.getCode()) { - return jobTypeEnum; - } - } - - return null; + public static JobTypeEnum getJobTypeEnum(Integer code) { + if (code == null) { + return null; + } + for (JobTypeEnum jobTypeEnum : JobTypeEnum.values()) { + if (code == jobTypeEnum.getCode()) { + return jobTypeEnum; + } } - + + return null; + } + } diff --git a/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/SqlCommand.java b/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/SqlCommand.java index 16cebf55..b880a520 100644 --- a/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/SqlCommand.java +++ b/flink-streaming-commom/src/main/java/com/flink/streaming/common/enums/SqlCommand.java @@ -15,116 +15,117 @@ */ @Getter public enum SqlCommand { - INSERT_INTO( - "(INSERT\\s+INTO.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - - INSERT_OVERWRITE( - "(INSERT\\s+OVERWRITE.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - - - CREATE_TABLE( - "(CREATE\\s+TABLE.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - - - CREATE_FUNCTION( - "(CREATE\\s+FUNCTION.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - - CREATE_VIEW( - "(CREATE\\s+VIEW.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - - - USE( - "(USE\\s+(?!CATALOG)(.*))", - (operands) -> Optional.of(new String[]{operands[0]})), - - - USE_CATALOG( - "(USE\\s+CATALOG.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - - DROP_TABLE( - "(DROP\\s+TABLE.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - DROP_DATABASE( - "(DROP\\s+DATABASE.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - DROP_VIEW( - "(DROP\\s+VIEW.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - DROP_FUNCTION( - "(DROP\\s+FUNCTION.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - - ALTER_TABLE( - "(ALTER\\s+TABLE.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - ALTER_DATABASE( - "(ALTER\\s+DATABASE.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - ALTER_FUNCTION( - "(ALTER\\s+FUNCTION.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - - SELECT( - "(WITH.*SELECT.*|SELECT.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - - SHOW_CATALOGS( - "SHOW\\s+CATALOGS", - (operands) -> Optional.of(new String[]{"SHOW CATALOGS"})), - - SHOW_DATABASES( - "SHOW\\s+DATABASES", - (operands) -> Optional.of(new String[]{"SHOW DATABASES"})), - - SHOW_TABLES( - "SHOW\\s+TABLES", - (operands) -> Optional.of(new String[]{"SHOW TABLES"})), - - SHOW_FUNCTIONS( - "SHOW\\s+FUNCTIONS", - (operands) -> Optional.of(new String[]{"SHOW FUNCTIONS"})), - - SHOW_MODULES( - "SHOW\\s+MODULES", - (operands) -> Optional.of(new String[]{"SHOW MODULES"})), - - CREATE_CATALOG( - "(CREATE\\s+CATALOG.*)", - (operands) -> Optional.of(new String[]{operands[0]})), - - - SET( - "SET(\\s+(\\S+)\\s*=(.*))?", - (operands) -> { - if (operands.length >= 3) { - if (operands[0] == null) { - return Optional.of(new String[0]); - } - } else { - return Optional.empty(); - } - return Optional.of(new String[]{operands[1], operands[2]}); - }), - - BEGIN_STATEMENT_SET("BEGIN\\s+STATEMENT\\s+SET", (operands) -> Optional.of(new String[]{"BEGIN STATEMENT SET"})), - - END("END", (operands) -> Optional.of(new String[]{"END"})); - - private final Pattern pattern; - - private final Function> operandConverter; - - - SqlCommand(String matchingRegex, Function> operandConverter) { - this.pattern = Pattern.compile(matchingRegex, SystemConstant.DEFAULT_PATTERN_FLAGS); - this.operandConverter = operandConverter; - } + INSERT_INTO( + "(INSERT\\s+INTO.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + + INSERT_OVERWRITE( + "(INSERT\\s+OVERWRITE.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + + + CREATE_TABLE( + "(CREATE\\s+TABLE.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + + + CREATE_FUNCTION( + "(CREATE\\s+FUNCTION.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + + CREATE_VIEW( + "(CREATE\\s+VIEW.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + + + USE( + "(USE\\s+(?!CATALOG)(.*))", + (operands) -> Optional.of(new String[]{operands[0]})), + + + USE_CATALOG( + "(USE\\s+CATALOG.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + + DROP_TABLE( + "(DROP\\s+TABLE.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + DROP_DATABASE( + "(DROP\\s+DATABASE.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + DROP_VIEW( + "(DROP\\s+VIEW.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + DROP_FUNCTION( + "(DROP\\s+FUNCTION.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + + ALTER_TABLE( + "(ALTER\\s+TABLE.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + ALTER_DATABASE( + "(ALTER\\s+DATABASE.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + ALTER_FUNCTION( + "(ALTER\\s+FUNCTION.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + + SELECT( + "(WITH.*SELECT.*|SELECT.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + + SHOW_CATALOGS( + "SHOW\\s+CATALOGS", + (operands) -> Optional.of(new String[]{"SHOW CATALOGS"})), + + SHOW_DATABASES( + "SHOW\\s+DATABASES", + (operands) -> Optional.of(new String[]{"SHOW DATABASES"})), + + SHOW_TABLES( + "SHOW\\s+TABLES", + (operands) -> Optional.of(new String[]{"SHOW TABLES"})), + + SHOW_FUNCTIONS( + "SHOW\\s+FUNCTIONS", + (operands) -> Optional.of(new String[]{"SHOW FUNCTIONS"})), + + SHOW_MODULES( + "SHOW\\s+MODULES", + (operands) -> Optional.of(new String[]{"SHOW MODULES"})), + + CREATE_CATALOG( + "(CREATE\\s+CATALOG.*)", + (operands) -> Optional.of(new String[]{operands[0]})), + + + SET( + "SET(\\s+(\\S+)\\s*=(.*))?", + (operands) -> { + if (operands.length >= 3) { + if (operands[0] == null) { + return Optional.of(new String[0]); + } + } else { + return Optional.empty(); + } + return Optional.of(new String[]{operands[1], operands[2]}); + }), + + BEGIN_STATEMENT_SET("BEGIN\\s+STATEMENT\\s+SET", + (operands) -> Optional.of(new String[]{"BEGIN STATEMENT SET"})), + + END("END", (operands) -> Optional.of(new String[]{"END"})); + + private final Pattern pattern; + + private final Function> operandConverter; + + + SqlCommand(String matchingRegex, Function> operandConverter) { + this.pattern = Pattern.compile(matchingRegex, SystemConstant.DEFAULT_PATTERN_FLAGS); + this.operandConverter = operandConverter; + } } diff --git a/flink-streaming-commom/src/main/java/com/flink/streaming/common/model/CheckPointParam.java b/flink-streaming-commom/src/main/java/com/flink/streaming/common/model/CheckPointParam.java index 2b1167a1..691b5b48 100644 --- a/flink-streaming-commom/src/main/java/com/flink/streaming/common/model/CheckPointParam.java +++ b/flink-streaming-commom/src/main/java/com/flink/streaming/common/model/CheckPointParam.java @@ -14,51 +14,51 @@ @Data public class CheckPointParam { - /** - * 默认60S - */ - private long checkpointInterval = 1000 * 60L; - - /** - * 默认CheckpointingMode.EXACTLY_ONCE - */ - private String checkpointingMode = "EXACTLY_ONCE"; - - /** - * 默认超时10 minutes. - */ - private long checkpointTimeout = 10 * 60 * 1000; - - /** - * 目录 - */ - private String checkpointDir; - - /** - * 设置失败次数 默认一次 - */ - - private int tolerableCheckpointFailureNumber = 1; - - /** - * 是否异步 - */ - private Boolean asynchronousSnapshots; - - /** - * 检查点在作业取消后的保留策略,DELETE_ON_CANCELLATION代表删除,RETAIN_ON_CANCELLATION代表保留 - */ - private String externalizedCheckpointCleanup; - - /** - * 后端状态类型 - */ - private StateBackendEnum stateBackendEnum; - - /** - * 支持增量 - */ - private Boolean enableIncremental; + /** + * 默认60S + */ + private long checkpointInterval = 1000 * 60L; + + /** + * 默认CheckpointingMode.EXACTLY_ONCE + */ + private String checkpointingMode = "EXACTLY_ONCE"; + + /** + * 默认超时10 minutes. + */ + private long checkpointTimeout = 10 * 60 * 1000; + + /** + * 目录 + */ + private String checkpointDir; + + /** + * 设置失败次数 默认一次 + */ + + private int tolerableCheckpointFailureNumber = 1; + + /** + * 是否异步 + */ + private Boolean asynchronousSnapshots; + + /** + * 检查点在作业取消后的保留策略,DELETE_ON_CANCELLATION代表删除,RETAIN_ON_CANCELLATION代表保留 + */ + private String externalizedCheckpointCleanup; + + /** + * 后端状态类型 + */ + private StateBackendEnum stateBackendEnum; + + /** + * 支持增量 + */ + private Boolean enableIncremental; } diff --git a/flink-streaming-commom/src/main/java/com/flink/streaming/common/model/SqlCommandCall.java b/flink-streaming-commom/src/main/java/com/flink/streaming/common/model/SqlCommandCall.java index 4218b962..d6739366 100644 --- a/flink-streaming-commom/src/main/java/com/flink/streaming/common/model/SqlCommandCall.java +++ b/flink-streaming-commom/src/main/java/com/flink/streaming/common/model/SqlCommandCall.java @@ -13,24 +13,24 @@ @Data public class SqlCommandCall { - private SqlCommand sqlCommand; + private SqlCommand sqlCommand; - private String[] operands; + private String[] operands; - public SqlCommandCall(SqlCommand sqlCommand, String[] operands) { - this.sqlCommand = sqlCommand; - this.operands = operands; - } + public SqlCommandCall(SqlCommand sqlCommand, String[] operands) { + this.sqlCommand = sqlCommand; + this.operands = operands; + } - public SqlCommandCall(String[] operands) { - this.operands = operands; - } + public SqlCommandCall(String[] operands) { + this.operands = operands; + } - public SqlCommand getSqlCommand() { - return sqlCommand; - } + public SqlCommand getSqlCommand() { + return sqlCommand; + } - public String[] getOperands() { - return operands; - } + public String[] getOperands() { + return operands; + } } diff --git a/flink-streaming-commom/src/main/java/com/flink/streaming/common/sql/SqlFileParser.java b/flink-streaming-commom/src/main/java/com/flink/streaming/common/sql/SqlFileParser.java index 7ca27bbc..0424d9bc 100644 --- a/flink-streaming-commom/src/main/java/com/flink/streaming/common/sql/SqlFileParser.java +++ b/flink-streaming-commom/src/main/java/com/flink/streaming/common/sql/SqlFileParser.java @@ -16,108 +16,105 @@ * @author zhuhuipei * @Description: * @date 2020-06-23 - * * @time 02:22 */ public class SqlFileParser { - - public static List parserSql(List lineList){ - if (CollectionUtils.isEmpty(lineList)) { - throw new RuntimeException("lineList is null"); - } - List sqlList = new ArrayList<>(); - StringBuilder stmt = new StringBuilder(); - for (String line : lineList) { - //开头是 -- 的表示注释 - if (line.trim().isEmpty() || line.startsWith(SystemConstant.COMMENT_SYMBOL) || - trimStart(line).startsWith(SystemConstant.COMMENT_SYMBOL)) { - continue; - } - stmt.append(SystemConstant.LINE_FEED).append(line); - if (line.trim().endsWith(SystemConstant.SEMICOLON)) { - sqlList.add(stmt.substring(0, stmt.length() - 1)); - //初始化 - stmt.setLength(0); - } - } - return sqlList; + public static List parserSql(List lineList) { + if (CollectionUtils.isEmpty(lineList)) { + throw new RuntimeException("lineList is null"); + } + List sqlList = new ArrayList<>(); + StringBuilder stmt = new StringBuilder(); + for (String line : lineList) { + //开头是 -- 的表示注释 + if (line.trim().isEmpty() || line.startsWith(SystemConstant.COMMENT_SYMBOL) + || trimStart(line).startsWith(SystemConstant.COMMENT_SYMBOL)) { + continue; + } + stmt.append(SystemConstant.LINE_FEED).append(line); + if (line.trim().endsWith(SystemConstant.SEMICOLON)) { + sqlList.add(stmt.substring(0, stmt.length() - 1)); + //初始化 + stmt.setLength(0); + } } + return sqlList; + } + public static List fileToSql(List lineList) { - public static List fileToSql(List lineList) { + if (CollectionUtils.isEmpty(lineList)) { + throw new RuntimeException("lineList is null"); + } - if (CollectionUtils.isEmpty(lineList)) { - throw new RuntimeException("lineList is null"); + List sqlCommandCallList = new ArrayList<>(); + + StringBuilder stmt = new StringBuilder(); + + for (String line : lineList) { + //开头是 -- 的表示注释 + if (line.trim().isEmpty() || line.startsWith(SystemConstant.COMMENT_SYMBOL) + || trimStart(line).startsWith(SystemConstant.COMMENT_SYMBOL)) { + continue; + } + stmt.append(SystemConstant.LINE_FEED).append(line); + if (line.trim().endsWith(SystemConstant.SEMICOLON)) { + Optional optionalCall = parse(stmt.toString()); + if (optionalCall.isPresent()) { + sqlCommandCallList.add(optionalCall.get()); + } else { + throw new RuntimeException("不支持该语法使用" + stmt.toString() + "'"); } + stmt.setLength(0); + } + } - List sqlCommandCallList = new ArrayList<>(); - - StringBuilder stmt = new StringBuilder(); - - for (String line : lineList) { - //开头是 -- 的表示注释 - if (line.trim().isEmpty() || line.startsWith(SystemConstant.COMMENT_SYMBOL) || - trimStart(line).startsWith(SystemConstant.COMMENT_SYMBOL)) { - continue; - } - stmt.append(SystemConstant.LINE_FEED).append(line); - if (line.trim().endsWith(SystemConstant.SEMICOLON)) { - Optional optionalCall = parse(stmt.toString()); - if (optionalCall.isPresent()) { - sqlCommandCallList.add(optionalCall.get()); - } else { - throw new RuntimeException("不支持该语法使用" + stmt.toString() + "'"); - } - stmt.setLength(0); - } - } + return sqlCommandCallList; - return sqlCommandCallList; + } + private static Optional parse(String stmt) { + stmt = stmt.trim(); + if (stmt.endsWith(SystemConstant.SEMICOLON)) { + stmt = stmt.substring(0, stmt.length() - 1).trim(); } - - private static Optional parse(String stmt) { - stmt = stmt.trim(); - if (stmt.endsWith(SystemConstant.SEMICOLON)) { - stmt = stmt.substring(0, stmt.length() - 1).trim(); + for (SqlCommand cmd : SqlCommand.values()) { + final Matcher matcher = cmd.getPattern().matcher(stmt); + if (matcher.matches()) { + final String[] groups = new String[matcher.groupCount()]; + for (int i = 0; i < groups.length; i++) { + groups[i] = matcher.group(i + 1); } - for (SqlCommand cmd : SqlCommand.values()) { - final Matcher matcher = cmd.getPattern().matcher(stmt); - if (matcher.matches()) { - final String[] groups = new String[matcher.groupCount()]; - for (int i = 0; i < groups.length; i++) { - groups[i] = matcher.group(i + 1); - } - return cmd.getOperandConverter().apply(groups) - .map((operands) -> new SqlCommandCall(cmd, operands)); - } - } - return Optional.empty(); + return cmd.getOperandConverter().apply(groups) + .map((operands) -> new SqlCommandCall(cmd, operands)); + } } + return Optional.empty(); + } - private static String trimStart(String str) { - if (StringUtils.isEmpty(str)) { - return str; - } - final char[] value = str.toCharArray(); + private static String trimStart(String str) { + if (StringUtils.isEmpty(str)) { + return str; + } + final char[] value = str.toCharArray(); - int start = 0, last = 0 + str.length() - 1; - int end = last; - while ((start <= end) && (value[start] <= ' ')) { - start++; - } - if (start == 0 && end == last) { - return str; - } - if (start >= end) { - return ""; - } - return str.substring(start, end); + int start = 0, last = 0 + str.length() - 1; + int end = last; + while ((start <= end) && (value[start] <= ' ')) { + start++; + } + if (start == 0 && end == last) { + return str; + } + if (start >= end) { + return ""; } + return str.substring(start, end); + } } diff --git a/flink-streaming-core/src/main/java/com/flink/streaming/core/JobApplication.java b/flink-streaming-core/src/main/java/com/flink/streaming/core/JobApplication.java index ec2bbe32..e6d7378f 100644 --- a/flink-streaming-core/src/main/java/com/flink/streaming/core/JobApplication.java +++ b/flink-streaming-core/src/main/java/com/flink/streaming/core/JobApplication.java @@ -31,75 +31,74 @@ */ public class JobApplication { - private static final Logger log = LoggerFactory.getLogger(JobApplication.class); + private static final Logger LOG = LoggerFactory.getLogger(JobApplication.class); - public static void main(String[] args) { + public static void main(String[] args) { - try { - Arrays.stream(args).forEach(arg -> log.info("{}", arg)); + try { + Arrays.stream(args).forEach(arg -> LOG.info("{}", arg)); - JobRunParam jobRunParam = buildParam(args); + JobRunParam jobRunParam = buildParam(args); - List fileList = Files.readAllLines(Paths.get(jobRunParam.getSqlPath())); + List fileList = Files.readAllLines(Paths.get(jobRunParam.getSqlPath())); + List sqlList = SqlFileParser.parserSql(fileList); - List sqlList = SqlFileParser.parserSql(fileList); + EnvironmentSettings settings = null; - EnvironmentSettings settings = null; + TableEnvironment tEnv = null; - TableEnvironment tEnv = null; + if (jobRunParam.getJobTypeEnum() != null + && JobTypeEnum.SQL_BATCH.equals(jobRunParam.getJobTypeEnum())) { + LOG.info("[SQL_BATCH]本次任务是批任务"); + //批处理 + settings = EnvironmentSettings.newInstance() + .useBlinkPlanner() + .inBatchMode() + .build(); + tEnv = TableEnvironment.create(settings); + } else { + LOG.info("[SQL_STREAMING]本次任务是流任务"); + //默认是流 流处理 目的是兼容之前版本 + StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); - if (jobRunParam.getJobTypeEnum() != null && - JobTypeEnum.SQL_BATCH.equals(jobRunParam.getJobTypeEnum())) { - log.info("[SQL_BATCH]本次任务是批任务"); - //批处理 - settings = EnvironmentSettings.newInstance() - .useBlinkPlanner() - .inBatchMode() - .build(); - tEnv = TableEnvironment.create(settings); - } else { - log.info("[SQL_STREAMING]本次任务是流任务"); - //默认是流 流处理 目的是兼容之前版本 - StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); + settings = EnvironmentSettings.newInstance() + .useBlinkPlanner() + .inStreamingMode() + .build(); + tEnv = StreamTableEnvironment.create(env, settings); + //设置checkPoint + FsCheckPoint.setCheckpoint(env, jobRunParam.getCheckPointParam()); - settings = EnvironmentSettings.newInstance() - .useBlinkPlanner() - .inStreamingMode() - .build(); - tEnv = StreamTableEnvironment.create(env, settings); - //设置checkPoint - FsCheckPoint.setCheckpoint(env, jobRunParam.getCheckPointParam()); + } - } + JobID jobID = ExecuteSql.exeSql(sqlList, tEnv); - JobID jobID = ExecuteSql.exeSql(sqlList, tEnv); + System.out.println(SystemConstant.QUERY_JOBID_KEY_WORD + jobID); - System.out.println(SystemConstant.QUERY_JOBID_KEY_WORD + jobID); + LOG.info(SystemConstant.QUERY_JOBID_KEY_WORD + "{}", jobID); - log.info(SystemConstant.QUERY_JOBID_KEY_WORD + "{}", jobID); - - } catch (Exception e) { - System.err.println("任务执行失败:" + e.getMessage()); - log.error("任务执行失败:", e); - } + } catch (Exception e) { + System.err.println("任务执行失败:" + e.getMessage()); + LOG.error("任务执行失败:", e); + } - } + } - private static JobRunParam buildParam(String[] args) throws Exception { - ParameterTool parameterTool = ParameterTool.fromArgs(args); - String sqlPath = parameterTool.get("sql"); - Preconditions.checkNotNull(sqlPath, "-sql参数 不能为空"); - JobRunParam jobRunParam = new JobRunParam(); - jobRunParam.setSqlPath(sqlPath); - jobRunParam.setCheckPointParam(CheckPointParams.buildCheckPointParam(parameterTool)); - String type = parameterTool.get("type"); - if (StringUtils.isNotEmpty(type)) { - jobRunParam.setJobTypeEnum(JobTypeEnum.getJobTypeEnum(Integer.valueOf(type))); - } - return jobRunParam; + private static JobRunParam buildParam(String[] args) throws Exception { + ParameterTool parameterTool = ParameterTool.fromArgs(args); + String sqlPath = parameterTool.get("sql"); + Preconditions.checkNotNull(sqlPath, "-sql参数 不能为空"); + JobRunParam jobRunParam = new JobRunParam(); + jobRunParam.setSqlPath(sqlPath); + jobRunParam.setCheckPointParam(CheckPointParams.buildCheckPointParam(parameterTool)); + String type = parameterTool.get("type"); + if (StringUtils.isNotEmpty(type)) { + jobRunParam.setJobTypeEnum(JobTypeEnum.getJobTypeEnum(Integer.valueOf(type))); } + return jobRunParam; + } } diff --git a/flink-streaming-core/src/main/java/com/flink/streaming/core/checkpoint/CheckPointParams.java b/flink-streaming-core/src/main/java/com/flink/streaming/core/checkpoint/CheckPointParams.java index dbfdd226..104acc1c 100644 --- a/flink-streaming-core/src/main/java/com/flink/streaming/core/checkpoint/CheckPointParams.java +++ b/flink-streaming-core/src/main/java/com/flink/streaming/core/checkpoint/CheckPointParams.java @@ -19,70 +19,78 @@ @Slf4j public class CheckPointParams { - /** - * 构建checkPoint参数 - * - * @author zhuhuipei - * @date 2020-08-23 - * @time 22:44 - */ - public static CheckPointParam buildCheckPointParam(ParameterTool parameterTool) throws Exception { - - String checkpointDir = parameterTool.get(CheckPointParameterEnums.checkpointDir.name(), SystemConstant.SPACE); - //如果checkpointDir为空不启用CheckPoint - if (StringUtils.isEmpty(checkpointDir)) { - return null; - } - String checkpointingMode = parameterTool.get(CheckPointParameterEnums.checkpointingMode.name(), - CheckpointingMode.EXACTLY_ONCE.name()); - - String checkpointInterval = parameterTool.get(CheckPointParameterEnums.checkpointInterval.name(), - SystemConstant.SPACE); - - String checkpointTimeout = parameterTool.get(CheckPointParameterEnums.checkpointTimeout.name(), SystemConstant.SPACE); - - String tolerableCheckpointFailureNumber = - parameterTool.get(CheckPointParameterEnums.tolerableCheckpointFailureNumber.name(), SystemConstant.SPACE); - - String asynchronousSnapshots = parameterTool.get(CheckPointParameterEnums.asynchronousSnapshots.name(), SystemConstant.SPACE); - - String externalizedCheckpointCleanup = - parameterTool.get(CheckPointParameterEnums.externalizedCheckpointCleanup.name(), SystemConstant.SPACE); - - String stateBackendType = parameterTool.get(CheckPointParameterEnums.stateBackendType.name(), SystemConstant.SPACE); - - String enableIncremental = parameterTool.get(CheckPointParameterEnums.enableIncremental.name(), SystemConstant.SPACE); - - - CheckPointParam checkPointParam = new CheckPointParam(); - if (StringUtils.isNotEmpty(asynchronousSnapshots)) { - checkPointParam.setAsynchronousSnapshots(Boolean.parseBoolean(asynchronousSnapshots)); - } - checkPointParam.setCheckpointDir(checkpointDir); - - checkPointParam.setCheckpointingMode(checkpointingMode); - if (StringUtils.isNotEmpty(checkpointInterval)) { - checkPointParam.setCheckpointInterval(Long.valueOf(checkpointInterval)); - } - if (StringUtils.isNotEmpty(checkpointTimeout)) { - checkPointParam.setCheckpointTimeout(Long.valueOf(checkpointTimeout)); - } - if (StringUtils.isNotEmpty(tolerableCheckpointFailureNumber)) { - checkPointParam.setTolerableCheckpointFailureNumber(Integer.valueOf(tolerableCheckpointFailureNumber)); - } - if (StringUtils.isNotEmpty(externalizedCheckpointCleanup)) { - checkPointParam.setExternalizedCheckpointCleanup(externalizedCheckpointCleanup); - } - - checkPointParam.setStateBackendEnum(StateBackendEnum.getStateBackend(stateBackendType)); - - if (StringUtils.isNotEmpty(enableIncremental)) { - checkPointParam.setEnableIncremental(Boolean.parseBoolean(enableIncremental.trim())); - } - log.info("checkPointParam={}", checkPointParam); - System.out.println("checkPointParam=" + checkPointParam); - return checkPointParam; + /** + * 构建checkPoint参数 + * + * @author zhuhuipei + * @date 2020-08-23 + * @time 22:44 + */ + public static CheckPointParam buildCheckPointParam(ParameterTool parameterTool) throws Exception { + + String checkpointDir = parameterTool + .get(CheckPointParameterEnums.checkpointDir.name(), SystemConstant.SPACE); + //如果checkpointDir为空不启用CheckPoint + if (StringUtils.isEmpty(checkpointDir)) { + return null; + } + String checkpointingMode = parameterTool.get(CheckPointParameterEnums.checkpointingMode.name(), + CheckpointingMode.EXACTLY_ONCE.name()); + + String checkpointInterval = parameterTool + .get(CheckPointParameterEnums.checkpointInterval.name(), + SystemConstant.SPACE); + + String checkpointTimeout = parameterTool + .get(CheckPointParameterEnums.checkpointTimeout.name(), SystemConstant.SPACE); + + String tolerableCheckpointFailureNumber = + parameterTool.get(CheckPointParameterEnums.tolerableCheckpointFailureNumber.name(), + SystemConstant.SPACE); + + String asynchronousSnapshots = parameterTool + .get(CheckPointParameterEnums.asynchronousSnapshots.name(), SystemConstant.SPACE); + String externalizedCheckpointCleanup = + parameterTool.get(CheckPointParameterEnums.externalizedCheckpointCleanup.name(), + SystemConstant.SPACE); + + String stateBackendType = parameterTool + .get(CheckPointParameterEnums.stateBackendType.name(), SystemConstant.SPACE); + + String enableIncremental = parameterTool + .get(CheckPointParameterEnums.enableIncremental.name(), SystemConstant.SPACE); + + CheckPointParam checkPointParam = new CheckPointParam(); + if (StringUtils.isNotEmpty(asynchronousSnapshots)) { + checkPointParam.setAsynchronousSnapshots(Boolean.parseBoolean(asynchronousSnapshots)); } + checkPointParam.setCheckpointDir(checkpointDir); + + checkPointParam.setCheckpointingMode(checkpointingMode); + if (StringUtils.isNotEmpty(checkpointInterval)) { + checkPointParam.setCheckpointInterval(Long.valueOf(checkpointInterval)); + } + if (StringUtils.isNotEmpty(checkpointTimeout)) { + checkPointParam.setCheckpointTimeout(Long.valueOf(checkpointTimeout)); + } + if (StringUtils.isNotEmpty(tolerableCheckpointFailureNumber)) { + checkPointParam + .setTolerableCheckpointFailureNumber(Integer.valueOf(tolerableCheckpointFailureNumber)); + } + if (StringUtils.isNotEmpty(externalizedCheckpointCleanup)) { + checkPointParam.setExternalizedCheckpointCleanup(externalizedCheckpointCleanup); + } + + checkPointParam.setStateBackendEnum(StateBackendEnum.getStateBackend(stateBackendType)); + + if (StringUtils.isNotEmpty(enableIncremental)) { + checkPointParam.setEnableIncremental(Boolean.parseBoolean(enableIncremental.trim())); + } + log.info("checkPointParam={}", checkPointParam); + System.out.println("checkPointParam=" + checkPointParam); + return checkPointParam; + + } } diff --git a/flink-streaming-core/src/main/java/com/flink/streaming/core/checkpoint/FsCheckPoint.java b/flink-streaming-core/src/main/java/com/flink/streaming/core/checkpoint/FsCheckPoint.java index 18cc1076..30082333 100644 --- a/flink-streaming-core/src/main/java/com/flink/streaming/core/checkpoint/FsCheckPoint.java +++ b/flink-streaming-core/src/main/java/com/flink/streaming/core/checkpoint/FsCheckPoint.java @@ -23,88 +23,93 @@ @Slf4j public class FsCheckPoint { - public static void setCheckpoint(StreamExecutionEnvironment env, CheckPointParam checkPointParam) throws Exception { - if (checkPointParam == null) { - log.warn("############没有启用Checkpoint############"); - return; - } - if (StringUtils.isEmpty(checkPointParam.getCheckpointDir())) { - throw new RuntimeException("checkpoint目录不存在"); - } - - // 默认每60s保存一次checkpoint - env.enableCheckpointing(checkPointParam.getCheckpointInterval()); - - CheckpointConfig checkpointConfig = env.getCheckpointConfig(); + public static void setCheckpoint(StreamExecutionEnvironment env, CheckPointParam checkPointParam) + throws Exception { + if (checkPointParam == null) { + log.warn("############没有启用Checkpoint############"); + return; + } + if (StringUtils.isEmpty(checkPointParam.getCheckpointDir())) { + throw new RuntimeException("checkpoint目录不存在"); + } - //开始一致性模式是:精确一次 exactly-once - if (StringUtils.isEmpty(checkPointParam.getCheckpointingMode()) || - CheckpointingMode.EXACTLY_ONCE.name().equalsIgnoreCase(checkPointParam.getCheckpointingMode())) { - checkpointConfig.setCheckpointingMode(CheckpointingMode.EXACTLY_ONCE); - log.info("本次CheckpointingMode模式 精确一次 即exactly-once"); - } else { - checkpointConfig.setCheckpointingMode(CheckpointingMode.AT_LEAST_ONCE); - log.info("本次CheckpointingMode模式 至少一次 即AT_LEAST_ONCE"); - } + // 默认每60s保存一次checkpoint + env.enableCheckpointing(checkPointParam.getCheckpointInterval()); - //默认超时10 minutes. - checkpointConfig.setCheckpointTimeout(checkPointParam.getCheckpointTimeout()); - //确保检查点之间有至少500 ms的间隔【checkpoint最小间隔】 - checkpointConfig.setMinPauseBetweenCheckpoints(500); - //同一时间只允许进行一个检查点 - checkpointConfig.setMaxConcurrentCheckpoints(2); - - //设置失败次数 - checkpointConfig.setTolerableCheckpointFailureNumber(checkPointParam.getTolerableCheckpointFailureNumber()); - - //设置后端状态 - setStateBackend(env, checkPointParam); - - //检查点在作业取消后的保留策略,DELETE_ON_CANCELLATION代表删除,RETAIN_ON_CANCELLATION代表保留 - if (checkPointParam.getExternalizedCheckpointCleanup() != null) { - if (checkPointParam.getExternalizedCheckpointCleanup(). - equalsIgnoreCase(ExternalizedCheckpointCleanup.DELETE_ON_CANCELLATION.name())) { - env.getCheckpointConfig() - .enableExternalizedCheckpoints(ExternalizedCheckpointCleanup.DELETE_ON_CANCELLATION); - log.info("本次使用DELETE_ON_CANCELLATION代表删除"); - } else if (checkPointParam.getExternalizedCheckpointCleanup(). - equalsIgnoreCase(ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION.name())) { - env.getCheckpointConfig() - .enableExternalizedCheckpoints(ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION); - log.info("本次使用RETAIN_ON_CANCELLATION代表保留"); - } - } + CheckpointConfig checkpointConfig = env.getCheckpointConfig(); + //开始一致性模式是:精确一次 exactly-once + if (StringUtils.isEmpty(checkPointParam.getCheckpointingMode()) + || CheckpointingMode.EXACTLY_ONCE.name() + .equalsIgnoreCase(checkPointParam.getCheckpointingMode())) { + checkpointConfig.setCheckpointingMode(CheckpointingMode.EXACTLY_ONCE); + log.info("本次CheckpointingMode模式 精确一次 即exactly-once"); + } else { + checkpointConfig.setCheckpointingMode(CheckpointingMode.AT_LEAST_ONCE); + log.info("本次CheckpointingMode模式 至少一次 即AT_LEAST_ONCE"); } - private static void setStateBackend(StreamExecutionEnvironment env, CheckPointParam checkPointParam) throws IOException { - switch (checkPointParam.getStateBackendEnum()) { - case MEMORY: - log.info("开启MEMORY模式"); - env.setStateBackend(new MemoryStateBackend(MemoryStateBackend.DEFAULT_MAX_STATE_SIZE * 100)); - break; - case FILE: - log.info("开启FILE模式"); - if (checkPointParam.getAsynchronousSnapshots() != null) { - env.setStateBackend(new FsStateBackend(checkPointParam.getCheckpointDir(), - checkPointParam.getAsynchronousSnapshots())); - } else { - env.setStateBackend(new FsStateBackend(checkPointParam.getCheckpointDir())); - } - break; - case ROCKSDB: - log.info("开启ROCKSDB模式"); - if (checkPointParam.getEnableIncremental() != null) { - env.setStateBackend(new RocksDBStateBackend(checkPointParam.getCheckpointDir(), - checkPointParam.getEnableIncremental())); - } else { - env.setStateBackend(new RocksDBStateBackend(checkPointParam.getCheckpointDir())); - } - break; - default: - throw new RuntimeException("不支持这种后端状态" + checkPointParam.getStateBackendEnum()); + //默认超时10 minutes. + checkpointConfig.setCheckpointTimeout(checkPointParam.getCheckpointTimeout()); + //确保检查点之间有至少500 ms的间隔【checkpoint最小间隔】 + checkpointConfig.setMinPauseBetweenCheckpoints(500); + //同一时间只允许进行一个检查点 + checkpointConfig.setMaxConcurrentCheckpoints(2); + + //设置失败次数 + checkpointConfig + .setTolerableCheckpointFailureNumber(checkPointParam.getTolerableCheckpointFailureNumber()); + + //设置后端状态 + setStateBackend(env, checkPointParam); + + //检查点在作业取消后的保留策略,DELETE_ON_CANCELLATION代表删除,RETAIN_ON_CANCELLATION代表保留 + if (checkPointParam.getExternalizedCheckpointCleanup() != null) { + if (checkPointParam.getExternalizedCheckpointCleanup(). + equalsIgnoreCase(ExternalizedCheckpointCleanup.DELETE_ON_CANCELLATION.name())) { + env.getCheckpointConfig() + .enableExternalizedCheckpoints(ExternalizedCheckpointCleanup.DELETE_ON_CANCELLATION); + log.info("本次使用DELETE_ON_CANCELLATION代表删除"); + } else if (checkPointParam.getExternalizedCheckpointCleanup(). + equalsIgnoreCase(ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION.name())) { + env.getCheckpointConfig() + .enableExternalizedCheckpoints(ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION); + log.info("本次使用RETAIN_ON_CANCELLATION代表保留"); + } + } + } + + private static void setStateBackend(StreamExecutionEnvironment env, + CheckPointParam checkPointParam) throws IOException { + switch (checkPointParam.getStateBackendEnum()) { + case MEMORY: + log.info("开启MEMORY模式"); + env.setStateBackend( + new MemoryStateBackend(MemoryStateBackend.DEFAULT_MAX_STATE_SIZE * 100)); + break; + case FILE: + log.info("开启FILE模式"); + if (checkPointParam.getAsynchronousSnapshots() != null) { + env.setStateBackend(new FsStateBackend(checkPointParam.getCheckpointDir(), + checkPointParam.getAsynchronousSnapshots())); + } else { + env.setStateBackend(new FsStateBackend(checkPointParam.getCheckpointDir())); } + break; + case ROCKSDB: + log.info("开启ROCKSDB模式"); + if (checkPointParam.getEnableIncremental() != null) { + env.setStateBackend(new RocksDBStateBackend(checkPointParam.getCheckpointDir(), + checkPointParam.getEnableIncremental())); + } else { + env.setStateBackend(new RocksDBStateBackend(checkPointParam.getCheckpointDir())); + } + break; + default: + throw new RuntimeException("不支持这种后端状态" + checkPointParam.getStateBackendEnum()); + } + } } diff --git a/flink-streaming-core/src/main/java/com/flink/streaming/core/config/Configurations.java b/flink-streaming-core/src/main/java/com/flink/streaming/core/config/Configurations.java index c7e3813d..6a38b361 100644 --- a/flink-streaming-core/src/main/java/com/flink/streaming/core/config/Configurations.java +++ b/flink-streaming-core/src/main/java/com/flink/streaming/core/config/Configurations.java @@ -15,22 +15,22 @@ public class Configurations { - /** - * 单个设置Configuration - * - * @author zhuhuipei - * @date 2021/3/23 - * @time 23:58 - */ - public static void setSingleConfiguration(TableEnvironment tEnv, String key, String value) { - if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value)) { - return; - } - Configuration configuration = tEnv.getConfig().getConfiguration(); - log.info("#############setConfiguration#############\n key={} value={}", key, value); - configuration.setString(key, value); - + /** + * 单个设置Configuration + * + * @author zhuhuipei + * @date 2021/3/23 + * @time 23:58 + */ + public static void setSingleConfiguration(TableEnvironment tEnv, String key, String value) { + if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value)) { + return; } + Configuration configuration = tEnv.getConfig().getConfiguration(); + log.info("#############setConfiguration#############\n key={} value={}", key, value); + configuration.setString(key, value); + + } } diff --git a/flink-streaming-core/src/main/java/com/flink/streaming/core/logs/LogPrint.java b/flink-streaming-core/src/main/java/com/flink/streaming/core/logs/LogPrint.java index 8ea5a90b..6396a89c 100644 --- a/flink-streaming-core/src/main/java/com/flink/streaming/core/logs/LogPrint.java +++ b/flink-streaming-core/src/main/java/com/flink/streaming/core/logs/LogPrint.java @@ -14,48 +14,53 @@ @Slf4j public class LogPrint { - /** - * 打印SqlCommandCall 日志信息 - * - * @author zhuhuipei - * @date 2021/3/21 - * @time 11:25 - */ - public static void logPrint(SqlCommandCall sqlCommandCall) { - if (sqlCommandCall == null) { - throw new NullPointerException("sqlCommandCall is null"); - } - switch(sqlCommandCall.getSqlCommand()) { - case SET: - System.out.println("\n############# " + sqlCommandCall.getSqlCommand().name() + " ############# \nSET " - + sqlCommandCall.getOperands()[0] + "=" + sqlCommandCall.getOperands()[1]); - log.info("\n############# {} ############# \nSET{}={}", sqlCommandCall.getSqlCommand().name(), sqlCommandCall.getOperands()[0], sqlCommandCall.getOperands()[1]); - break; - default: - System.out.println("\n############# " + sqlCommandCall.getSqlCommand().name() + " ############# \n" + sqlCommandCall.getOperands()[0]); - log.info("\n############# {} ############# \n {}", sqlCommandCall.getSqlCommand().name(), sqlCommandCall.getOperands()[0]); - } + /** + * 打印SqlCommandCall 日志信息 + * + * @author zhuhuipei + * @date 2021/3/21 + * @time 11:25 + */ + public static void logPrint(SqlCommandCall sqlCommandCall) { + if (sqlCommandCall == null) { + throw new NullPointerException("sqlCommandCall is null"); } + switch (sqlCommandCall.getSqlCommand()) { + case SET: + System.out.println( + "\n############# " + sqlCommandCall.getSqlCommand().name() + " ############# \nSET " + + sqlCommandCall.getOperands()[0] + "=" + sqlCommandCall.getOperands()[1]); + log.info("\n############# {} ############# \nSET{}={}", + sqlCommandCall.getSqlCommand().name(), sqlCommandCall.getOperands()[0], + sqlCommandCall.getOperands()[1]); + break; + default: + System.out.println( + "\n############# " + sqlCommandCall.getSqlCommand().name() + " ############# \n" + + sqlCommandCall.getOperands()[0]); + log.info("\n############# {} ############# \n {}", sqlCommandCall.getSqlCommand().name(), + sqlCommandCall.getOperands()[0]); + } + } - /** - * show 语句 select语句结果打印 - * - * @author zhuhuipei - * @date 2021/3/21 - * @time 11:23 - */ - public static void queryRestPrint(TableEnvironment tEnv, SqlCommandCall sqlCommandCall) { - if (sqlCommandCall == null) { - throw new NullPointerException("sqlCommandCall is null"); - } - LogPrint.logPrint(sqlCommandCall); - + /** + * show 语句 select语句结果打印 + * + * @author zhuhuipei + * @date 2021/3/21 + * @time 11:23 + */ + public static void queryRestPrint(TableEnvironment tEnv, SqlCommandCall sqlCommandCall) { + if (sqlCommandCall == null) { + throw new NullPointerException("sqlCommandCall is null"); + } + LogPrint.logPrint(sqlCommandCall); - if (sqlCommandCall.getSqlCommand().name().equalsIgnoreCase(SqlCommand.SELECT.name())) { - throw new RuntimeException("目前不支持select 语法使用"); - } else { - tEnv.executeSql(sqlCommandCall.getOperands()[0]).print(); - } + if (sqlCommandCall.getSqlCommand().name().equalsIgnoreCase(SqlCommand.SELECT.name())) { + throw new RuntimeException("目前不支持select 语法使用"); + } else { + tEnv.executeSql(sqlCommandCall.getOperands()[0]).print(); + } // if (sqlCommandCall.getSqlCommand().name().equalsIgnoreCase(SqlCommand.SELECT.name())) { // Iterator it = tEnv.executeSql(sqlCommandCall.operands[0]).collect(); @@ -64,6 +69,6 @@ public static void queryRestPrint(TableEnvironment tEnv, SqlCommandCall sqlComma // log.info("数据结果 {}", res); // } // } - } + } } diff --git a/flink-streaming-core/src/main/java/com/flink/streaming/core/model/JobRunParam.java b/flink-streaming-core/src/main/java/com/flink/streaming/core/model/JobRunParam.java index 1c615ff6..e5ec7ac5 100644 --- a/flink-streaming-core/src/main/java/com/flink/streaming/core/model/JobRunParam.java +++ b/flink-streaming-core/src/main/java/com/flink/streaming/core/model/JobRunParam.java @@ -12,21 +12,21 @@ */ @Data public class JobRunParam { - /** - * sql语句目录 - */ - private String sqlPath; - /** - * 任务类型 - */ - private JobTypeEnum jobTypeEnum; + /** + * sql语句目录 + */ + private String sqlPath; - /** - * CheckPoint 参数 - */ - private CheckPointParam checkPointParam; + /** + * 任务类型 + */ + private JobTypeEnum jobTypeEnum; + /** + * CheckPoint 参数 + */ + private CheckPointParam checkPointParam; } diff --git a/flink-streaming-validation/src/main/java/com/flink/streaming/sql/util/ValidationConstants.java b/flink-streaming-validation/src/main/java/com/flink/streaming/sql/util/ValidationConstants.java index e7afa345..79a9ef50 100644 --- a/flink-streaming-validation/src/main/java/com/flink/streaming/sql/util/ValidationConstants.java +++ b/flink-streaming-validation/src/main/java/com/flink/streaming/sql/util/ValidationConstants.java @@ -8,16 +8,16 @@ */ public class ValidationConstants { - public static final String MESSAGE_010 = "必须包含 insert or insert overwrite 语句"; + public static final String MESSAGE_010 = "必须包含 insert or insert overwrite 语句"; - public static final String MESSAGE_011 = "暂时不支持直接使用select语句,请使用 insert into select 语法 或者使用 print 连接器打印结果"; + public static final String MESSAGE_011 = "暂时不支持直接使用select语句,请使用 insert into select 语法 或者使用 print 连接器打印结果"; - public static final String TABLE_SQL_DIALECT_1= "table.sql-dialect"; + public static final String TABLE_SQL_DIALECT_1 = "table.sql-dialect"; - public static final String INSERT= "INSERT"; + public static final String INSERT = "INSERT"; - public static final String SELECT = "SELECT"; - public static final String SPLIT_1 = "'"; - public static final String SPACE = ""; + public static final String SELECT = "SELECT"; + public static final String SPLIT_1 = "'"; + public static final String SPACE = ""; } diff --git a/flink-streaming-validation/src/main/java/com/flink/streaming/sql/validation/SqlValidation.java b/flink-streaming-validation/src/main/java/com/flink/streaming/sql/validation/SqlValidation.java index c82547fa..a96a337a 100644 --- a/flink-streaming-validation/src/main/java/com/flink/streaming/sql/validation/SqlValidation.java +++ b/flink-streaming-validation/src/main/java/com/flink/streaming/sql/validation/SqlValidation.java @@ -33,212 +33,217 @@ import org.apache.flink.table.planner.utils.TableConfigUtils; +/* + * 数据校验 + * @Author: zhuhuipei + * @date 2022/6/25 + */ @Slf4j public class SqlValidation { - public static void explainStmt(List stmtList) { - StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); + public static void explainStmt(List stmtList) { + StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); - EnvironmentSettings settings = EnvironmentSettings.newInstance() - .useBlinkPlanner() - .inStreamingMode() - .build(); + EnvironmentSettings settings = EnvironmentSettings.newInstance() + .useBlinkPlanner() + .inStreamingMode() + .build(); - TableEnvironment tEnv = StreamTableEnvironment.create(env, settings); - TableConfig config = tEnv.getConfig(); - String sql=null; + TableEnvironment tEnv = StreamTableEnvironment.create(env, settings); + TableConfig config = tEnv.getConfig(); + String sql = null; - boolean isInsertSql = false; + boolean isInsertSql = false; - boolean isSelectSql = false; + boolean isSelectSql = false; - try { - for (String stmt : stmtList) { - sql = stmt.trim(); - Boolean setSuccess = setSqlDialect(sql, config); - CalciteParser parser = new CalciteParser(getSqlParserConfig(config)); - if (setSuccess) { - log.info("set 成功 sql={}",sql); - continue; - } - SqlNode sqlNode=parser.parse(sql); - if (ValidationConstants.INSERT.equalsIgnoreCase(sqlNode.getKind().name())) { - isInsertSql = true; - } - if (ValidationConstants.SELECT.equalsIgnoreCase(sqlNode.getKind().name())) { - isSelectSql = true; - } - log.info("sql:{} 校验通过",sql); - } - }catch (Exception e) { - log.error("语法错误: {} 原因是: ", sql, e); - throw new RuntimeException("语法错误:" + sql + " 原因: " + e.getMessage()); + try { + for (String stmt : stmtList) { + sql = stmt.trim(); + Boolean setSuccess = setSqlDialect(sql, config); + CalciteParser parser = new CalciteParser(getSqlParserConfig(config)); + if (setSuccess) { + log.info("set 成功 sql={}", sql); + continue; } - if (!isInsertSql) { - throw new RuntimeException(ValidationConstants.MESSAGE_010); + SqlNode sqlNode = parser.parse(sql); + if (ValidationConstants.INSERT.equalsIgnoreCase(sqlNode.getKind().name())) { + isInsertSql = true; } - if (isSelectSql) { - throw new RuntimeException(ValidationConstants.MESSAGE_011); + if (ValidationConstants.SELECT.equalsIgnoreCase(sqlNode.getKind().name())) { + isSelectSql = true; } - log.info("全部语法校验成功"); - + log.info("sql:{} 校验通过", sql); + } + } catch (Exception e) { + log.error("语法错误: {} 原因是: ", sql, e); + throw new RuntimeException("语法错误:" + sql + " 原因: " + e.getMessage()); + } + if (!isInsertSql) { + throw new RuntimeException(ValidationConstants.MESSAGE_010); } + if (isSelectSql) { + throw new RuntimeException(ValidationConstants.MESSAGE_011); + } + log.info("全部语法校验成功"); + } - /** - * @author zhuhuipei - * @date 2021/3/27 - * @time 10:10 - * - */ - @Deprecated - public static void preCheckSql(List sql) { + /** + * @author zhuhuipei + * @date 2021/3/27 + * @time 10:10 + */ + @Deprecated + public static void preCheckSql(List sql) { - StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); + StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); - EnvironmentSettings settings = EnvironmentSettings.newInstance() - .useBlinkPlanner() - .inStreamingMode() - .build(); + EnvironmentSettings settings = EnvironmentSettings.newInstance() + .useBlinkPlanner() + .inStreamingMode() + .build(); - TableEnvironment tEnv = StreamTableEnvironment.create(env, settings); + TableEnvironment tEnv = StreamTableEnvironment.create(env, settings); - List sqlCommandCallList = SqlFileParser.fileToSql(sql); - if (CollectionUtils.isEmpty(sqlCommandCallList)) { - throw new RuntimeException("没解析出sql,请检查语句 如 缺少;号"); - } + List sqlCommandCallList = SqlFileParser.fileToSql(sql); + if (CollectionUtils.isEmpty(sqlCommandCallList)) { + throw new RuntimeException("没解析出sql,请检查语句 如 缺少;号"); + } - TableConfig config = tEnv.getConfig(); - String value = null; - - boolean isInsertSql = false; - - boolean isSelectSql = false; - try { - for (SqlCommandCall sqlCommandCall : sqlCommandCallList) { - - value = sqlCommandCall.getOperands()[0]; - - switch (sqlCommandCall.getSqlCommand()) { - //配置 - case SET: - String key = sqlCommandCall.getOperands()[0]; - String val = sqlCommandCall.getOperands()[1]; - if (val.contains(SystemConstant.LINE_FEED)) { - throw new RuntimeException("set 语法值异常:" + val); - } - if (TableConfigOptions.TABLE_SQL_DIALECT.key().equalsIgnoreCase(key.trim()) - && SqlDialect.HIVE.name().equalsIgnoreCase(val.trim())) { - config.setSqlDialect(SqlDialect.HIVE); - } else { - config.setSqlDialect(SqlDialect.DEFAULT); - } - - break; - case BEGIN_STATEMENT_SET: - case END: - break; - //其他 - default: - if (SqlCommand.INSERT_INTO.equals(sqlCommandCall.getSqlCommand()) - || SqlCommand.INSERT_OVERWRITE.equals(sqlCommandCall.getSqlCommand())) { - isInsertSql = true; - } - if (SqlCommand.SELECT.equals(sqlCommandCall.getSqlCommand())) { - isSelectSql = true; - } - CalciteParser parser = new CalciteParser(getSqlParserConfig(config)); - parser.parse(sqlCommandCall.getOperands()[0]); - break; - } - } - } catch (Exception e) { - log.warn("语法异常: sql={} 原因是: {}", value, e); - throw new RuntimeException("语法异常 sql=" + value + " 原因: " + e.getMessage()); - } - if (!isInsertSql) { - throw new RuntimeException(ValidationConstants.MESSAGE_010); - } + TableConfig config = tEnv.getConfig(); + String value = null; - if (isSelectSql) { - throw new RuntimeException(ValidationConstants.MESSAGE_011); - } + boolean isInsertSql = false; - } + boolean isSelectSql = false; + try { + for (SqlCommandCall sqlCommandCall : sqlCommandCallList) { - private static SqlParser.Config getSqlParserConfig(TableConfig tableConfig) { - return JavaScalaConversionUtil.toJava(getCalciteConfig(tableConfig).getSqlParserConfig()).orElseGet( - () -> { - SqlConformance conformance = getSqlConformance(tableConfig.getSqlDialect()); - return SqlParser - .config() - .withParserFactory(FlinkSqlParserFactories.create(conformance)) - .withConformance(conformance) - .withLex(Lex.JAVA) - .withIdentifierMaxLength(256); - } - ); - } + value = sqlCommandCall.getOperands()[0]; - private static CalciteConfig getCalciteConfig(TableConfig tableConfig) { - return TableConfigUtils.getCalciteConfig(tableConfig); - } + switch (sqlCommandCall.getSqlCommand()) { + //配置 + case SET: + String key = sqlCommandCall.getOperands()[0]; + String val = sqlCommandCall.getOperands()[1]; + if (val.contains(SystemConstant.LINE_FEED)) { + throw new RuntimeException("set 语法值异常:" + val); + } + if (TableConfigOptions.TABLE_SQL_DIALECT.key().equalsIgnoreCase(key.trim()) + && SqlDialect.HIVE.name().equalsIgnoreCase(val.trim())) { + config.setSqlDialect(SqlDialect.HIVE); + } else { + config.setSqlDialect(SqlDialect.DEFAULT); + } - private static FlinkSqlConformance getSqlConformance(SqlDialect sqlDialect) { - switch (sqlDialect) { - case HIVE: - return FlinkSqlConformance.HIVE; - case DEFAULT: - return FlinkSqlConformance.DEFAULT; - default: - throw new TableException("Unsupported SQL dialect: " + sqlDialect); + break; + case BEGIN_STATEMENT_SET: + case END: + break; + //其他 + default: + if (SqlCommand.INSERT_INTO.equals(sqlCommandCall.getSqlCommand()) + || SqlCommand.INSERT_OVERWRITE.equals(sqlCommandCall.getSqlCommand())) { + isInsertSql = true; + } + if (SqlCommand.SELECT.equals(sqlCommandCall.getSqlCommand())) { + isSelectSql = true; + } + CalciteParser parser = new CalciteParser(getSqlParserConfig(config)); + parser.parse(sqlCommandCall.getOperands()[0]); + break; } + } + } catch (Exception e) { + log.warn("语法异常: sql={} 原因是: {}", value, e); + throw new RuntimeException("语法异常 sql=" + value + " 原因: " + e.getMessage()); } - - /** - * 字符串转sql - */ - public static List toSqlList(String sql) { - if (StringUtils.isEmpty(sql)) { - return Collections.emptyList(); - } - return Arrays.asList(sql.split(SystemConstant.LINE_FEED)); + if (!isInsertSql) { + throw new RuntimeException(ValidationConstants.MESSAGE_010); } + if (isSelectSql) { + throw new RuntimeException(ValidationConstants.MESSAGE_011); + } - /** - *设置方言 - * @Param:[sql, tableConfig] - * @return: java.lang.Boolean - * @Author: zhuhuipei - * @date 2022/6/24 - */ - private static Boolean setSqlDialect(String sql,TableConfig tableConfig){ - final Matcher matcher = SqlCommand.SET.getPattern().matcher(sql); - if (matcher.matches()) { - final String[] groups = new String[matcher.groupCount()]; - for (int i = 0; i < groups.length; i++) { - groups[i] = matcher.group(i + 1); - } - String key=groups[1].replace(ValidationConstants.SPLIT_1,ValidationConstants.SPACE).trim(); - String val=groups[2]; - if (ValidationConstants.TABLE_SQL_DIALECT_1.equalsIgnoreCase(key)){ - if ( SqlDialect.HIVE.name().equalsIgnoreCase( - val.replace(ValidationConstants.SPLIT_1,ValidationConstants.SPACE).trim())) { - tableConfig.setSqlDialect(SqlDialect.HIVE); - } else { - tableConfig.setSqlDialect(SqlDialect.DEFAULT); - } - }else { - Configuration configuration = tableConfig.getConfiguration(); - configuration.setString(key, val); + } + + private static SqlParser.Config getSqlParserConfig(TableConfig tableConfig) { + return JavaScalaConversionUtil.toJava(getCalciteConfig(tableConfig).getSqlParserConfig()) + .orElseGet( + () -> { + SqlConformance conformance = getSqlConformance(tableConfig.getSqlDialect()); + return SqlParser + .config() + .withParserFactory(FlinkSqlParserFactories.create(conformance)) + .withConformance(conformance) + .withLex(Lex.JAVA) + .withIdentifierMaxLength(256); } - return true; + ); + } + + private static CalciteConfig getCalciteConfig(TableConfig tableConfig) { + return TableConfigUtils.getCalciteConfig(tableConfig); + } + + private static FlinkSqlConformance getSqlConformance(SqlDialect sqlDialect) { + switch (sqlDialect) { + case HIVE: + return FlinkSqlConformance.HIVE; + case DEFAULT: + return FlinkSqlConformance.DEFAULT; + default: + throw new TableException("Unsupported SQL dialect: " + sqlDialect); + } + } + + /** + * 字符串转sql + */ + public static List toSqlList(String sql) { + if (StringUtils.isEmpty(sql)) { + return Collections.emptyList(); + } + return Arrays.asList(sql.split(SystemConstant.LINE_FEED)); + } + + + /** + * 设置方言 + * + * @Param:[sql, tableConfig] + * @return: java.lang.Boolean + * @Author: zhuhuipei + * @date 2022/6/24 + */ + private static Boolean setSqlDialect(String sql, TableConfig tableConfig) { + final Matcher matcher = SqlCommand.SET.getPattern().matcher(sql); + if (matcher.matches()) { + final String[] groups = new String[matcher.groupCount()]; + for (int i = 0; i < groups.length; i++) { + groups[i] = matcher.group(i + 1); + } + String key = groups[1].replace(ValidationConstants.SPLIT_1, ValidationConstants.SPACE).trim(); + String val = groups[2]; + if (ValidationConstants.TABLE_SQL_DIALECT_1.equalsIgnoreCase(key)) { + if (SqlDialect.HIVE.name().equalsIgnoreCase( + val.replace(ValidationConstants.SPLIT_1, ValidationConstants.SPACE).trim())) { + tableConfig.setSqlDialect(SqlDialect.HIVE); + } else { + tableConfig.setSqlDialect(SqlDialect.DEFAULT); } - return false; + } else { + Configuration configuration = tableConfig.getConfiguration(); + configuration.setString(key, val); + } + return true; } + return false; + } } diff --git a/flink-streaming-validation/src/test/java/com/flink/streaming/sql/validation/test/TestSqlValidation.java b/flink-streaming-validation/src/test/java/com/flink/streaming/sql/validation/test/TestSqlValidation.java index 91ffeb47..e39270b5 100644 --- a/flink-streaming-validation/src/test/java/com/flink/streaming/sql/validation/test/TestSqlValidation.java +++ b/flink-streaming-validation/src/test/java/com/flink/streaming/sql/validation/test/TestSqlValidation.java @@ -16,13 +16,14 @@ * @time 22:30 */ public class TestSqlValidation { - private static String test_sql_file = "/Users/edy/git/flink-streaming-platform-web/flink-streaming-core/src/hive-test.sql"; - @Test - public void checkSql() throws IOException { - List list = Files.readAllLines(Paths.get(test_sql_file)); - List sqlList = SqlFileParser.parserSql(list); - SqlValidation.explainStmt(sqlList); - //SqlValidation.preCheckSql(list); - } + private static String test_sql_file = "/Users/edy/git/flink-streaming-platform-web/flink-streaming-core/src/hive-test.sql"; + + @Test + public void checkSql() throws IOException { + List list = Files.readAllLines(Paths.get(test_sql_file)); + List sqlList = SqlFileParser.parserSql(list); + SqlValidation.explainStmt(sqlList); + //SqlValidation.preCheckSql(list); + } } diff --git a/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/DingDingAlarm.java b/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/DingDingAlarm.java index 523f9343..d185ce52 100644 --- a/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/DingDingAlarm.java +++ b/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/DingDingAlarm.java @@ -9,11 +9,11 @@ public interface DingDingAlarm { - /** - * @author zhuhuipei - * @date 2020-09-25 - * @time 23:02 - */ - boolean send(String url, String content); + /** + * @author zhuhuipei + * @date 2020-09-25 + * @time 23:02 + */ + boolean send(String url, String content); } diff --git a/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/HttpAlarm.java b/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/HttpAlarm.java index a6088abc..58ad4bec 100644 --- a/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/HttpAlarm.java +++ b/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/HttpAlarm.java @@ -10,12 +10,12 @@ */ public interface HttpAlarm { - /** - * 回调http - * - * @author zhuhuipei - * @date 2021/2/21 - * @time 11:39 - */ - boolean send(String url, CallbackDTO callbackDTO); + /** + * 回调http + * + * @author zhuhuipei + * @date 2021/2/21 + * @time 11:39 + */ + boolean send(String url, CallbackDTO callbackDTO); } diff --git a/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/impl/DingDingAlarmImpl.java b/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/impl/DingDingAlarmImpl.java index 2f57ee3d..e98ac423 100644 --- a/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/impl/DingDingAlarmImpl.java +++ b/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/impl/DingDingAlarmImpl.java @@ -25,45 +25,46 @@ public class DingDingAlarmImpl implements DingDingAlarm { - @Override - public boolean send(String url, String content) { + @Override + public boolean send(String url, String content) { - String res = null; - try { - log.info("开始发送钉钉消息 url ={} content={}", url, content); - if (StringUtils.isEmpty(url) || StringUtils.isEmpty(content)) { - log.error("url or content is null url={} content={}", url, content); - throw new BizException("请求参数url or content is null"); - } + String res = null; + try { + log.info("开始发送钉钉消息 url ={} content={}", url, content); + if (StringUtils.isEmpty(url) || StringUtils.isEmpty(content)) { + log.error("url or content is null url={} content={}", url, content); + throw new BizException("请求参数url or content is null"); + } - HttpHeaders httpHeaders = HttpUtil.buildHttpHeaders(MediaType.APPLICATION_JSON_VALUE); - HttpEntity httpEntity = new HttpEntity(buildContent(content), httpHeaders); - RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_15_S); - res = restTemplate.postForObject(url, httpEntity, String.class); - if (StringUtils.isEmpty(res)) { - throw new BizException("消息发送失败 res is null"); - } - JSONObject jsonObject = JSON.parseObject(res); - if (jsonObject == null || (jsonObject.get("errcode") != null && !"0".equals(jsonObject.get("errcode").toString()))) { - log.error("消息发送失败 url={},content={},res={}", url, content, res); - throw new BizException("消息发送失败" + res); - } - } catch (Exception e) { - log.error("消息发送失败 url={},content={},res={}", url, content, res, e); - throw new BizException("消息发送失败" + e.getMessage()); - } - - return true; + HttpHeaders httpHeaders = HttpUtil.buildHttpHeaders(MediaType.APPLICATION_JSON_VALUE); + HttpEntity httpEntity = new HttpEntity(buildContent(content), httpHeaders); + RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_15_S); + res = restTemplate.postForObject(url, httpEntity, String.class); + if (StringUtils.isEmpty(res)) { + throw new BizException("消息发送失败 res is null"); + } + JSONObject jsonObject = JSON.parseObject(res); + if (jsonObject == null || (jsonObject.get("errcode") != null && !"0" + .equals(jsonObject.get("errcode").toString()))) { + log.error("消息发送失败 url={},content={},res={}", url, content, res); + throw new BizException("消息发送失败" + res); + } + } catch (Exception e) { + log.error("消息发送失败 url={},content={},res={}", url, content, res, e); + throw new BizException("消息发送失败" + e.getMessage()); } + return true; + } - private String buildContent(String text) { - StringBuilder txt = new StringBuilder(); - txt.append("{\"msgtype\": \"text\", \"text\": { \"content\": \""); - txt.append(DateUtil.date().toStringDefaultTimeZone() + " "); - txt.append(text).append("\" } }"); - return txt.toString(); - } + + private String buildContent(String text) { + StringBuilder txt = new StringBuilder(); + txt.append("{\"msgtype\": \"text\", \"text\": { \"content\": \""); + txt.append(DateUtil.date().toStringDefaultTimeZone() + " "); + txt.append(text).append("\" } }"); + return txt.toString(); + } } diff --git a/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/impl/HttpAlarmImpl.java b/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/impl/HttpAlarmImpl.java index 101117b9..bfbeff3b 100644 --- a/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/impl/HttpAlarmImpl.java +++ b/flink-streaming-web-alarm/src/main/java/com/flink/streaming/web/alarm/impl/HttpAlarmImpl.java @@ -27,36 +27,36 @@ public class HttpAlarmImpl implements HttpAlarm { - @Override - public boolean send(String url, CallbackDTO callbackDTO) { - if (StringUtils.isEmpty(url) || callbackDTO == null) { - log.error("url={} is null or callbackDTO={} is null", url, callbackDTO); - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_15_S); - try { - MultiValueMap map = new LinkedMultiValueMap<>(); - map.add("appId", callbackDTO.getAppId()); - map.add("deployMode", callbackDTO.getDeployMode()); - map.add("jobName", callbackDTO.getJobName()); - - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); - HttpEntity> param = new HttpEntity(map, headers); - //发起请求,服务地址,请求参数,返回消息体的数据类型 - ResponseEntity response = restTemplate.postForEntity(url, param, String.class); - if (response != null && response.getStatusCode().is2xxSuccessful()) { - return true; - } - log.error("http请求失败 response={}", response); - throw new BizException("http请求失败 status=" + response.getStatusCode().value()); - } catch (BizException bizException) { - throw bizException; - } catch (Exception e) { - log.error("请求失败 url={} callbackDTO={}", url, callbackDTO, e); - throw new BizException("http请求失败"); - } + @Override + public boolean send(String url, CallbackDTO callbackDTO) { + if (StringUtils.isEmpty(url) || callbackDTO == null) { + log.error("url={} is null or callbackDTO={} is null", url, callbackDTO); + throw new BizException(SysErrorEnum.PARAM_IS_NULL); + } + RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_15_S); + try { + MultiValueMap map = new LinkedMultiValueMap<>(); + map.add("appId", callbackDTO.getAppId()); + map.add("deployMode", callbackDTO.getDeployMode()); + map.add("jobName", callbackDTO.getJobName()); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + HttpEntity> param = new HttpEntity(map, headers); + //发起请求,服务地址,请求参数,返回消息体的数据类型 + ResponseEntity response = restTemplate.postForEntity(url, param, String.class); + if (response != null && response.getStatusCode().is2xxSuccessful()) { + return true; + } + log.error("http请求失败 response={}", response); + throw new BizException("http请求失败 status=" + response.getStatusCode().value()); + } catch (BizException bizException) { + throw bizException; + } catch (Exception e) { + log.error("请求失败 url={} callbackDTO={}", url, callbackDTO, e); + throw new BizException("http请求失败"); } + } + } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/FlinkConstants.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/FlinkConstants.java index 438f6246..85ee981f 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/FlinkConstants.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/FlinkConstants.java @@ -8,13 +8,13 @@ */ public class FlinkConstants { - public static final String EXACTLY_ONCE = "EXACTLY_ONCE"; + public static final String EXACTLY_ONCE = "EXACTLY_ONCE"; - public static final String AT_LEAST_ONCE = "AT_LEAST_ONCE"; + public static final String AT_LEAST_ONCE = "AT_LEAST_ONCE"; - public static final String DELETE_ON_CANCELLATION = "DELETE_ON_CANCELLATION"; + public static final String DELETE_ON_CANCELLATION = "DELETE_ON_CANCELLATION"; - public static final String RETAIN_ON_CANCELLATION = "RETAIN_ON_CANCELLATION"; + public static final String RETAIN_ON_CANCELLATION = "RETAIN_ON_CANCELLATION"; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/FlinkYarnRestUriConstants.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/FlinkYarnRestUriConstants.java index bac3a831..0a2fc316 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/FlinkYarnRestUriConstants.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/FlinkYarnRestUriConstants.java @@ -8,62 +8,61 @@ */ public class FlinkYarnRestUriConstants { - public final static String URI_PROXY = "proxy/"; + public static final String URI_PROXY = "proxy/"; - public final static String URI_JOBS = "jobs"; + public static final String URI_JOBS = "jobs"; - public final static String URI_YARN_CANCEL = "/yarn-cancel"; + public static final String URI_YARN_CANCEL = "/yarn-cancel"; - public final static String URI_YARN_CHECKPOINT = "/checkpoints"; + public static final String URI_YARN_CHECKPOINT = "/checkpoints"; - public final static String URI_YARN_INFO = "ws/v1/cluster/info"; + public static final String URI_YARN_INFO = "ws/v1/cluster/info"; - public final static String URI_YARN_OVERVIEW = "#/overview"; + public static final String URI_YARN_OVERVIEW = "#/overview"; - public final static String URI_YARN_JOB_OVERVIEW = "#/job/%s/overview"; + public static final String URI_YARN_JOB_OVERVIEW = "#/job/%s/overview"; - public final static String URI_CHECKPOINTS_JOB = "jobs/%s/checkpoints"; + public static final String URI_CHECKPOINTS_JOB = "jobs/%s/checkpoints"; + public static String getUriJobsForYarn(String appId) { + return rootUriForYarn(appId) + URI_JOBS; + } - public static String getUriJobsForYarn(String appId) { - return rootUriForYarn(appId) + URI_JOBS; - } + public static String getUriOverviewForYarn(String appId) { + return rootUriForYarn(appId) + URI_YARN_OVERVIEW; + } - public static String getUriOverviewForYarn(String appId) { - return rootUriForYarn(appId) + URI_YARN_OVERVIEW; - } + public static String getUriJobsForStandalone(String appId) { + return URI_JOBS + "/" + appId; + } - public static String getUriJobsForStandalone(String appId) { - return URI_JOBS + "/" + appId; - } + public static String getUriCancelForYarn(String appId, String jobId) { + return getUriJobsForYarn(appId) + "/" + jobId + URI_YARN_CANCEL; + } - public static String getUriCancelForYarn(String appId, String jobId) { - return getUriJobsForYarn(appId) + "/" + jobId + URI_YARN_CANCEL; - } + public static String getUriCancelForStandalone(String jobId) { + return URI_JOBS + "/" + jobId + URI_YARN_CANCEL; + } - public static String getUriCancelForStandalone(String jobId) { - return URI_JOBS + "/" + jobId + URI_YARN_CANCEL; - } + public static String getUriCheckpointForYarn(String appId, String jobId) { + return getUriJobsForYarn(appId) + "/" + jobId + URI_YARN_CHECKPOINT; + } - public static String getUriCheckpointForYarn(String appId, String jobId) { - return getUriJobsForYarn(appId) + "/" + jobId + URI_YARN_CHECKPOINT; - } + public static String rootUriForYarn(String appId) { + return String.format(URI_PROXY + "%s/", appId); + } - public static String rootUriForYarn(String appId) { - return String.format(URI_PROXY + "%s/", appId); - } + public static String getUriCheckpoints(String appId) { + return String.format(URI_CHECKPOINTS_JOB, appId); + } - public static String getUriCheckpoints(String appId) { - return String.format(URI_CHECKPOINTS_JOB, appId); - } - - public static void main(String[] args) { - System.out.println(FlinkYarnRestUriConstants.getUriJobsForYarn("xxxx")); - System.out.println(FlinkYarnRestUriConstants.getUriCheckpoints("xxxx")); - } + public static void main(String[] args) { + System.out.println(FlinkYarnRestUriConstants.getUriJobsForYarn("xxxx")); + System.out.println(FlinkYarnRestUriConstants.getUriCheckpoints("xxxx")); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/MessageConstants.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/MessageConstants.java index 6f08aecc..b0132c0b 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/MessageConstants.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/MessageConstants.java @@ -10,28 +10,28 @@ */ public class MessageConstants { - public static final String MESSAGE_001 = "任务启动中! 请稍后刷新查看日志。。。"; + public static final String MESSAGE_001 = "任务启动中! 请稍后刷新查看日志。。。"; - public static final String MESSAGE_002 = "任务正在运行中,请先停止任务。。。"; + public static final String MESSAGE_002 = "任务正在运行中,请先停止任务。。。"; - public static final String MESSAGE_003 = "任务正在启动中 请稍等..。。。"; + public static final String MESSAGE_003 = "任务正在启动中 请稍等..。。。"; - public static final String MESSAGE_004 = "没有配置Checkpoint 不能能执行savepoint {}"; + public static final String MESSAGE_004 = "没有配置Checkpoint 不能能执行savepoint {}"; - public static final String MESSAGE_005 = "任务没有运行不能执行savepoint {}"; + public static final String MESSAGE_005 = "任务没有运行不能执行savepoint {}"; - public static final String MESSAGE_006 = "自定义jar任务不支持savePoint 任务:{}"; + public static final String MESSAGE_006 = "自定义jar任务不支持savePoint 任务:{}"; - public static final String MESSAGE_007 = "yarn集群上没有找到对应任务 任务:{}"; + public static final String MESSAGE_007 = "yarn集群上没有找到对应任务 任务:{}"; - public static final String MESSAGE_008 = "执行savePoint失败了 详见错误日志 任务:{}"; + public static final String MESSAGE_008 = "执行savePoint失败了 详见错误日志 任务:{}"; - public static final String MESSAGE_009 = "没有获取到savepointPath路径目录 任务:{}"; + public static final String MESSAGE_009 = "没有获取到savepointPath路径目录 任务:{}"; - public static final String MESSAGE_010 = "批任务不支持savePoint 任务:{}"; + public static final String MESSAGE_010 = "批任务不支持savePoint 任务:{}"; - public static final String MESSAGE_011 = "无法获取 user.name"; + public static final String MESSAGE_011 = "无法获取 user.name"; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/RestResult.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/RestResult.java index 559eaf4e..c718c235 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/RestResult.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/RestResult.java @@ -14,57 +14,57 @@ public class RestResult { - public static final String SUCCESS = "200"; + public static final String SUCCESS = "200"; - private String code = SUCCESS; + private String code = SUCCESS; - private boolean success; + private boolean success; - private String message; + private String message; - private T data; + private T data; - private Pages page; + private Pages page; - public RestResult() { - } + public RestResult() { + } - public static RestResult newInstance(String code, String message, T data, Pages page) { - RestResult result = new RestResult(); - result.code = code; - result.success = (code.equalsIgnoreCase(SUCCESS)); - result.message = message; - result.data = data; - result.page = page; - return result; - } + public static RestResult newInstance(String code, String message, T data, Pages page) { + RestResult result = new RestResult(); + result.code = code; + result.success = (code.equalsIgnoreCase(SUCCESS)); + result.message = message; + result.data = data; + result.page = page; + return result; + } - public static RestResult newInstance(String code, String message, T data) { - return newInstance(code, message, data, null); - } + public static RestResult newInstance(String code, String message, T data) { + return newInstance(code, message, data, null); + } - public static RestResult success() { - return newInstance(SUCCESS, "", null); - } + public static RestResult success() { + return newInstance(SUCCESS, "", null); + } - public static RestResult success(T data) { - return newInstance(SUCCESS, "", data); - } + public static RestResult success(T data) { + return newInstance(SUCCESS, "", data); + } - public static RestResult error(String code, String message) { - return newInstance(code, message, null, null); - } + public static RestResult error(String code, String message) { + return newInstance(code, message, null, null); + } - public static RestResult error(String message) { - return newInstance("500", message, null, null); - } + public static RestResult error(String message) { + return newInstance("500", message, null, null); + } - public static RestResult error(SysErrorEnum sysErrorEnum) { - return error(sysErrorEnum.getCode(), sysErrorEnum.getErrorMsg()); - } + public static RestResult error(SysErrorEnum sysErrorEnum) { + return error(sysErrorEnum.getCode(), sysErrorEnum.getErrorMsg()); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/SystemConstants.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/SystemConstants.java index 65729f44..31ba1b5f 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/SystemConstants.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/SystemConstants.java @@ -13,67 +13,67 @@ */ public class SystemConstants { - public static final String COOKIE_NAME_SESSION_ID = "flink-streaming-platform-web-sessionid"; + public static final String COOKIE_NAME_SESSION_ID = "flink-streaming-platform-web-sessionid"; - public static final String STATUS_RUNNING = "RUNNING"; + public static final String STATUS_RUNNING = "RUNNING"; - public static final String STATUS_FINISHED = "FINISHED"; + public static final String STATUS_FINISHED = "FINISHED"; - public static final String STATUS_RESTARTING = "RESTARTING"; + public static final String STATUS_RESTARTING = "RESTARTING"; - public static final String USER_NAME_TASK_AUTO = "task-auto"; + public static final String USER_NAME_TASK_AUTO = "task-auto"; - public static final String CODE_UTF_8 = "UTF-8"; + public static final String CODE_UTF_8 = "UTF-8"; - public static final String DEFAULT_SAVEPOINT_ROOT_PATH = "hdfs:///flink/savepoint/flink-streaming-platform-web/"; + public static final String DEFAULT_SAVEPOINT_ROOT_PATH = "hdfs:///flink/savepoint/flink-streaming-platform-web/"; - public static final String SLASH = "/"; + public static final String SLASH = "/"; - public static final String HTTP_KEY = "http"; + public static final String HTTP_KEY = "http"; - public static final String HTTPS_KEY = "https"; + public static final String HTTPS_KEY = "https"; - private static final String HTTP_YARN_APPS_QUERY = "ws/v1/cluster/apps?queue="; + private static final String HTTP_YARN_APPS_QUERY = "ws/v1/cluster/apps?queue="; - public static final String HTTP_YARN_APPS = "ws/v1/cluster/apps/"; + public static final String HTTP_YARN_APPS = "ws/v1/cluster/apps/"; - public static final String HTTP_YARN_CLUSTER_APPS = "cluster/app/"; + public static final String HTTP_YARN_CLUSTER_APPS = "cluster/app/"; - public static final String HTTP_STANDALONE_APPS = "#/job/"; + public static final String HTTP_STANDALONE_APPS = "#/job/"; - public static final String YQU = "yqu"; + public static final String YQU = "yqu"; - public static String buildHttpQuery(String queueName) { - if (StringUtils.isEmpty(queueName)) { - throw new BizException("yarn 队列参数(-yqu)为空 "); - } - return HTTP_YARN_APPS_QUERY + queueName; + public static String buildHttpQuery(String queueName) { + if (StringUtils.isEmpty(queueName)) { + throw new BizException("yarn 队列参数(-yqu)为空 "); } - - /** - * 获取flink 运行文件 - * - * @author zhuhuipei - * @date 2020-09-21 - * @time 23:24 - */ - public static String buildFlinkBin(String flinkHome) { - if (StringUtils.isEmpty(flinkHome)) { - throw new BizException("flinkHome 不存在"); - } - return flinkHome + "bin/flink"; - } - - - /** - * 构建钉钉告警消息内容 - * - * @author zhuhuipei - * @date 2020-09-23 - * @time 00:54 - */ - public static String buildDingdingMessage(String content) { - return "Flink任务告警:" + content; + return HTTP_YARN_APPS_QUERY + queueName; + } + + /** + * 获取flink 运行文件 + * + * @author zhuhuipei + * @date 2020-09-21 + * @time 23:24 + */ + public static String buildFlinkBin(String flinkHome) { + if (StringUtils.isEmpty(flinkHome)) { + throw new BizException("flinkHome 不存在"); } + return flinkHome + "bin/flink"; + } + + + /** + * 构建钉钉告警消息内容 + * + * @author zhuhuipei + * @date 2020-09-23 + * @time 00:54 + */ + public static String buildDingdingMessage(String content) { + return "Flink任务告警:" + content; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/TipsConstants.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/TipsConstants.java index 3d892797..c1fcb022 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/TipsConstants.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/TipsConstants.java @@ -8,6 +8,6 @@ */ public class TipsConstants { - public static String TIPS_1="请登陆服务器分别 查看flink客户端日志、web日志、集群上任务运行历史日志(如果任务提交成功)"; + public static final String TIPS_1 = "请登陆服务器分别 查看flink客户端日志、web日志、集群上任务运行历史日志(如果任务提交成功)"; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/AttributeUtils.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/AttributeUtils.java deleted file mode 100644 index 6c1d5db7..00000000 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/AttributeUtils.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.flink.streaming.web.common.util; - -import org.apache.commons.lang3.StringUtils; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - - -public class AttributeUtils { - - /** - * attributes字段中的属性之间的分隔符 - */ - private static final String SEMICOLON = ";"; - - - public static Set toSet(String attributes) { - if (StringUtils.isEmpty(attributes)) { - return Collections.EMPTY_SET; - } - String[] keyValue = attributes.split(SEMICOLON); - - return new HashSet<>(Arrays.asList(keyValue)); - } -} diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Base64Coded.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Base64Coded.java index 70b31894..4e79c479 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Base64Coded.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Base64Coded.java @@ -11,38 +11,38 @@ */ public class Base64Coded { - /** - * base64 解码 - * - * @author zhuhuipei - * @date 2020-07-13 - * @time 23:16 - */ - public static String decode(byte[] bytes) { - return new String(Base64.decodeBase64(bytes)); - } - - /** - * base64 编码 - * - * @author zhuhuipei - * @date 2020-07-13 - * @time 23:16 - */ - public static String encode(byte[] bytes) { - return new String(Base64.encodeBase64(bytes)); - } - - - public static void main(String[] args) { - String string = UserSession.toJsonString(1, "zhuhuipei", "123456"); - //编码 - String encode = encode(string.getBytes()); - System.out.println(string + "\t编码后的字符串为:" + encode); - //解码 - String decode = decode(encode.getBytes()); - System.out.println(encode + "\t字符串解码后为:" + decode + " " + UserSession.toUserSession(decode)); - - } + /** + * base64 解码 + * + * @author zhuhuipei + * @date 2020-07-13 + * @time 23:16 + */ + public static String decode(byte[] bytes) { + return new String(Base64.decodeBase64(bytes)); + } + + /** + * base64 编码 + * + * @author zhuhuipei + * @date 2020-07-13 + * @time 23:16 + */ + public static String encode(byte[] bytes) { + return new String(Base64.encodeBase64(bytes)); + } + + + public static void main(String[] args) { + String string = UserSession.toJsonString(1, "zhuhuipei", "123456"); + //编码 + String encode = encode(string.getBytes()); + System.out.println(string + "\t编码后的字符串为:" + encode); + //解码 + String decode = decode(encode.getBytes()); + System.out.println(encode + "\t字符串解码后为:" + decode + " " + UserSession.toUserSession(decode)); + + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/CliConfigUtil.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/CliConfigUtil.java index bf75975f..72f77ed0 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/CliConfigUtil.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/CliConfigUtil.java @@ -25,141 +25,151 @@ @Slf4j public class CliConfigUtil { - /** - * 检查flink运行启动参数 - * - * @author zhuhuipei - * @date 2020-09-11 - * @time 00:04 - */ - public static RestResult checkFlinkRunConfigForYarn(String flinkRunConfig) { - try { - CommandLine cl = getFlinkRunByCli(flinkRunConfig); - if (!cl.hasOption(SystemConstants.YQU)) { - return RestResult.error("任务必须包含队列参数 -yqu "); - } - } catch (UnrecognizedOptionException e) { - log.error("checkFlinkRunConfig is error", e); - return RestResult.error("flink运行配置参数校验通不过,不允许使用参数:" + e.getOption() + " 参数只支持 -p -yjm -yn -ytm -ys -yqu -yD"); - } catch (Exception e) { - log.error("checkFlinkRunConfig is error", e); - return RestResult.error("flink运行配置参数校验通不过"); - } - return null; + /** + * 检查flink运行启动参数 + * + * @author zhuhuipei + * @date 2020-09-11 + * @time 00:04 + */ + public static RestResult checkFlinkRunConfigForYarn(String flinkRunConfig) { + try { + CommandLine cl = getFlinkRunByCli(flinkRunConfig); + if (!cl.hasOption(SystemConstants.YQU)) { + return RestResult.error("任务必须包含队列参数 -yqu "); + } + } catch (UnrecognizedOptionException e) { + log.error("checkFlinkRunConfig is error", e); + return RestResult.error( + "flink运行配置参数校验通不过,不允许使用参数:" + e.getOption() + " 参数只支持 -p -yjm -yn -ytm -ys -yqu -yD"); + } catch (Exception e) { + log.error("checkFlinkRunConfig is error", e); + return RestResult.error("flink运行配置参数校验通不过"); } - - - /** - * 检查CheckPoint参数 - * - * @author zhuhuipei - * @date 2020-09-11 - * @time 00:04 - */ - public static CheckPointParam checkFlinkCheckPoint(String flinkCheckpointConfig) { - try { - String[] config = trim(flinkCheckpointConfig); - - ParameterTool parameterTool = ParameterTool.fromArgs(config); - if (parameterTool == null || parameterTool.getUnrequestedParameters() == null) { - throw new BizException("parameterTool or parameterTool.getUnrequestedParameters() is null "); - } - - CheckPointParameterEnums.isExits(parameterTool.getUnrequestedParameters()); - - String checkpointDir = parameterTool.get(CheckPointParameterEnums.checkpointDir.name()); - - String checkpointingMode = parameterTool.get(CheckPointParameterEnums.checkpointingMode.name(), - FlinkConstants.EXACTLY_ONCE); - String tolerableCheckpointFailureNumber = parameterTool.get(CheckPointParameterEnums.tolerableCheckpointFailureNumber.name()); - String asynchronousSnapshots = parameterTool.get(CheckPointParameterEnums.asynchronousSnapshots.name()); - String checkpointInterval = parameterTool.get(CheckPointParameterEnums.checkpointInterval.name()); - String checkpointTimeout = parameterTool.get(CheckPointParameterEnums.checkpointTimeout.name()); - String externalizedCheckpointCleanup = parameterTool.get(CheckPointParameterEnums.externalizedCheckpointCleanup.name()); - String stateBackendType = parameterTool.get(CheckPointParameterEnums.stateBackendType.name()); - String enableIncremental = parameterTool.get(CheckPointParameterEnums.enableIncremental.name()); - - CheckPointParam checkPointParam = new CheckPointParam(); - if (StringUtils.isNotEmpty(asynchronousSnapshots)) { - if (Boolean.FALSE.toString().equals(asynchronousSnapshots.toLowerCase()) - || Boolean.TRUE.toString().equals(asynchronousSnapshots.toLowerCase())) { - checkPointParam.setAsynchronousSnapshots(Boolean.valueOf(asynchronousSnapshots)); - } else { - throw new BizException("asynchronousSnapshots 参数必须是 Boolean 类型或者为空 "); - } - } - if (StringUtils.isNotEmpty(checkpointTimeout)) { - checkPointParam.setCheckpointTimeout(Long.valueOf(checkpointTimeout)); - } - - checkPointParam.setCheckpointingMode(checkpointingMode); - if (StringUtils.isNotEmpty(checkpointInterval)) { - checkPointParam.setCheckpointInterval(Long.valueOf(checkpointInterval)); - } - - if (StringUtils.isNotEmpty(tolerableCheckpointFailureNumber)) { - checkPointParam.setTolerableCheckpointFailureNumber(Integer.valueOf(tolerableCheckpointFailureNumber)); - } - if (StringUtils.isNotEmpty(externalizedCheckpointCleanup)) { - checkPointParam.setExternalizedCheckpointCleanup(externalizedCheckpointCleanup); - } - - //内存模式下不需要填写checkpointDir - if (!StateBackendEnum.MEMORY.getType().equalsIgnoreCase(stateBackendType) - && StringUtils.isEmpty(checkpointDir)) { - throw new BizException("checkpointDir不存在或者没有对应的值"); - } - checkPointParam.setCheckpointDir(checkpointDir); - - checkPointParam.setStateBackendEnum(StateBackendEnum.getStateBackend(stateBackendType)); - - if (StringUtils.isNotEmpty(enableIncremental)) { - if (Boolean.FALSE.toString().equals(enableIncremental.toLowerCase()) - || Boolean.TRUE.toString().equals(enableIncremental.toLowerCase())) { - checkPointParam.setEnableIncremental(Boolean.getBoolean(enableIncremental.trim())); - } else { - throw new BizException("enableIncremental 参数必须是 Boolean 类型或者为空 "); - } - } - - log.info("checkPointParam ={}", checkPointParam); - - return checkPointParam; - } catch (BizException e) { - log.error("checkFlinkCheckPoint is error", e); - throw e; - } catch (Exception e) { - log.error("checkFlinkCheckPoint is error", e); - throw new BizException("Checkpoint参数校验不通过:" + e.getMessage()); + return null; + } + + + /** + * 检查CheckPoint参数 + * + * @author zhuhuipei + * @date 2020-09-11 + * @time 00:04 + */ + public static CheckPointParam checkFlinkCheckPoint(String flinkCheckpointConfig) { + try { + String[] config = trim(flinkCheckpointConfig); + + ParameterTool parameterTool = ParameterTool.fromArgs(config); + if (parameterTool == null || parameterTool.getUnrequestedParameters() == null) { + throw new BizException( + "parameterTool or parameterTool.getUnrequestedParameters() is null "); + } + + CheckPointParameterEnums.isExits(parameterTool.getUnrequestedParameters()); + + String checkpointDir = parameterTool.get(CheckPointParameterEnums.checkpointDir.name()); + + String checkpointingMode = parameterTool + .get(CheckPointParameterEnums.checkpointingMode.name(), + FlinkConstants.EXACTLY_ONCE); + String tolerableCheckpointFailureNumber = parameterTool + .get(CheckPointParameterEnums.tolerableCheckpointFailureNumber.name()); + String asynchronousSnapshots = parameterTool + .get(CheckPointParameterEnums.asynchronousSnapshots.name()); + String checkpointInterval = parameterTool + .get(CheckPointParameterEnums.checkpointInterval.name()); + String checkpointTimeout = parameterTool + .get(CheckPointParameterEnums.checkpointTimeout.name()); + String externalizedCheckpointCleanup = parameterTool + .get(CheckPointParameterEnums.externalizedCheckpointCleanup.name()); + String stateBackendType = parameterTool.get(CheckPointParameterEnums.stateBackendType.name()); + String enableIncremental = parameterTool + .get(CheckPointParameterEnums.enableIncremental.name()); + + CheckPointParam checkPointParam = new CheckPointParam(); + if (StringUtils.isNotEmpty(asynchronousSnapshots)) { + if (Boolean.FALSE.toString().equals(asynchronousSnapshots.toLowerCase()) + || Boolean.TRUE.toString().equals(asynchronousSnapshots.toLowerCase())) { + checkPointParam.setAsynchronousSnapshots(Boolean.valueOf(asynchronousSnapshots)); + } else { + throw new BizException("asynchronousSnapshots 参数必须是 Boolean 类型或者为空 "); } - } + } + if (StringUtils.isNotEmpty(checkpointTimeout)) { + checkPointParam.setCheckpointTimeout(Long.valueOf(checkpointTimeout)); + } + + checkPointParam.setCheckpointingMode(checkpointingMode); + if (StringUtils.isNotEmpty(checkpointInterval)) { + checkPointParam.setCheckpointInterval(Long.valueOf(checkpointInterval)); + } + + if (StringUtils.isNotEmpty(tolerableCheckpointFailureNumber)) { + checkPointParam + .setTolerableCheckpointFailureNumber(Integer.valueOf(tolerableCheckpointFailureNumber)); + } + if (StringUtils.isNotEmpty(externalizedCheckpointCleanup)) { + checkPointParam.setExternalizedCheckpointCleanup(externalizedCheckpointCleanup); + } + + //内存模式下不需要填写checkpointDir + if (!StateBackendEnum.MEMORY.getType().equalsIgnoreCase(stateBackendType) + && StringUtils.isEmpty(checkpointDir)) { + throw new BizException("checkpointDir不存在或者没有对应的值"); + } + checkPointParam.setCheckpointDir(checkpointDir); + + checkPointParam.setStateBackendEnum(StateBackendEnum.getStateBackend(stateBackendType)); + + if (StringUtils.isNotEmpty(enableIncremental)) { + if (Boolean.FALSE.toString().equals(enableIncremental.toLowerCase()) + || Boolean.TRUE.toString().equals(enableIncremental.toLowerCase())) { + checkPointParam.setEnableIncremental(Boolean.getBoolean(enableIncremental.trim())); + } else { + throw new BizException("enableIncremental 参数必须是 Boolean 类型或者为空 "); + } + } + log.info("checkPointParam ={}", checkPointParam); - public static CommandLine getFlinkRunByCli(String flinkRunConfig) throws ParseException { - String[] config = trim(flinkRunConfig); - Options options = new Options(); - options.addOption("p", false, ""); - options.addOption("yjm", false, ""); - options.addOption("yn", false, ""); - options.addOption("ytm", false, ""); - options.addOption("ys", false, ""); - options.addOption("yD", false, ""); - options.addOption(SystemConstants.YQU, true, ""); - CommandLineParser parser = new DefaultParser(); - return parser.parse(options, config); + return checkPointParam; + } catch (BizException e) { + log.error("checkFlinkCheckPoint is error", e); + throw e; + } catch (Exception e) { + log.error("checkFlinkCheckPoint is error", e); + throw new BizException("Checkpoint参数校验不通过:" + e.getMessage()); } - - - private static String[] trim(String cliConfig) { - - List list = new ArrayList<>(); - String[] config = cliConfig.split(" "); - for (String str : config) { - if (StringUtils.isNotEmpty(str)) { - list.add(str); - } - } - return list.toArray(new String[list.size()]); + } + + + public static CommandLine getFlinkRunByCli(String flinkRunConfig) throws ParseException { + String[] config = trim(flinkRunConfig); + Options options = new Options(); + options.addOption("p", false, ""); + options.addOption("yjm", false, ""); + options.addOption("yn", false, ""); + options.addOption("ytm", false, ""); + options.addOption("ys", false, ""); + options.addOption("yD", false, ""); + options.addOption(SystemConstants.YQU, true, ""); + CommandLineParser parser = new DefaultParser(); + return parser.parse(options, config); + } + + + private static String[] trim(String cliConfig) { + + List list = new ArrayList<>(); + String[] config = cliConfig.split(" "); + for (String str : config) { + if (StringUtils.isNotEmpty(str)) { + list.add(str); + } } + return list.toArray(new String[list.size()]); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/CommandUtil.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/CommandUtil.java index e0281512..1ff677fb 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/CommandUtil.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/CommandUtil.java @@ -17,124 +17,130 @@ @Slf4j public class CommandUtil { - private static final String APP_CLASS_NAME = "com.flink.streaming.core.JobApplication"; - - /** - * 本地/Standalone Cluster模式 - * - * @author zhuhuipei - * @date 2020/11/1 - * @time 09:59 - */ - public static String buildRunCommandForCluster(JobRunParamDTO jobRunParamDTO, - JobConfigDTO jobConfigDTO, String savepointPath) throws Exception { - StringBuilder command = new StringBuilder(); - command.append(jobRunParamDTO.getFlinkBinPath()).append(" run -d"); - - if (StringUtils.isNotEmpty(savepointPath)) { - command.append(" -s ").append(savepointPath); - } - - if (jobConfigDTO.getDeployModeEnum() == DeployModeEnum.STANDALONE) { - command.append(" ").append(jobConfigDTO.getFlinkRunConfig()); - } - - if (StringUtils.isNotEmpty(jobConfigDTO.getExtJarPath())) { - String[] urls = jobConfigDTO.getExtJarPath().split(SystemConstant.LINE_FEED); - for (String url : urls) { - command.append(" -C ").append(url.trim()); - } - } - switch (jobConfigDTO.getJobTypeEnum()) { - case SQL_BATCH: - case SQL_STREAMING: - command.append(" -c ").append(APP_CLASS_NAME); - command.append(" ").append(jobRunParamDTO.getSysHome()).append(SystemConstant.JARVERSION); - command.append(" -sql ").append(jobRunParamDTO.getSqlPath()); - if (StringUtils.isNotEmpty(jobRunParamDTO.getFlinkCheckpointConfig())) { - command.append(" ").append(jobRunParamDTO.getFlinkCheckpointConfig()); - } - command.append(" -type ").append(jobConfigDTO.getJobTypeEnum().getCode()); - break; - case JAR: - command.append(" -c ").append(jobConfigDTO.getCustomMainClass()); - command.append(" ").append(jobRunParamDTO.getMainJarPath()); - command.append(" ").append(jobConfigDTO.getCustomArgs()); - break; - } - - log.info("buildRunCommandForLocal runCommand={}", command.toString()); - return command.toString(); + private static final String APP_CLASS_NAME = "com.flink.streaming.core.JobApplication"; + + /** + * 本地/Standalone Cluster模式 + * + * @author zhuhuipei + * @date 2020/11/1 + * @time 09:59 + */ + public static String buildRunCommandForCluster(JobRunParamDTO jobRunParamDTO, + JobConfigDTO jobConfigDTO, String savepointPath) throws Exception { + StringBuilder command = new StringBuilder(); + command.append(jobRunParamDTO.getFlinkBinPath()).append(" run -d"); + + if (StringUtils.isNotEmpty(savepointPath)) { + command.append(" -s ").append(savepointPath); } - /** - * jar并且构建运行命令 - * - * @author zhuhuipei - * @date 2020-09-18 - * @time 00:57 - */ - public static String buildRunCommandForYarnCluster(JobRunParamDTO jobRunParamDTO, - JobConfigDTO jobConfigDTO, String savepointPath) throws Exception { - StringBuilder command = new StringBuilder(); - command.append(jobRunParamDTO.getFlinkBinPath()).append(" run"); - if (StringUtils.isNotEmpty(savepointPath)) { - command.append(" -s ").append(savepointPath); - } - command.append(" ").append(jobRunParamDTO.getFlinkRunParam()); - command.append(" -ynm ").append(JobConfigDTO.buildRunName(jobConfigDTO.getJobName())); - command.append(" -yd -m yarn-cluster"); - - if (StringUtils.isNotEmpty(jobConfigDTO.getExtJarPath())) { - String[] urls = jobConfigDTO.getExtJarPath().split(SystemConstant.LINE_FEED); - for (String url : urls) { - command.append(" -C ").append(url.trim()); - } - } + if (jobConfigDTO.getDeployModeEnum() == DeployModeEnum.STANDALONE) { + command.append(" ").append(jobConfigDTO.getFlinkRunConfig()); + } - switch (jobConfigDTO.getJobTypeEnum()) { - case SQL_STREAMING: - case SQL_BATCH: - command.append(" -c ").append(APP_CLASS_NAME); - command.append(" ").append(jobRunParamDTO.getSysHome()).append(SystemConstant.JARVERSION); - command.append(" -sql ").append(jobRunParamDTO.getSqlPath()); - if (StringUtils.isNotEmpty(jobRunParamDTO.getFlinkCheckpointConfig())) { - command.append(" ").append(jobRunParamDTO.getFlinkCheckpointConfig()); - } - command.append(" -type ").append(jobConfigDTO.getJobTypeEnum().getCode()); - break; - case JAR: - command.append(" -c ").append(jobConfigDTO.getCustomMainClass()); - command.append(" ").append(jobRunParamDTO.getMainJarPath()); - command.append(" ").append(jobConfigDTO.getCustomArgs()); + if (StringUtils.isNotEmpty(jobConfigDTO.getExtJarPath())) { + String[] urls = jobConfigDTO.getExtJarPath().split(SystemConstant.LINE_FEED); + for (String url : urls) { + command.append(" -C ").append(url.trim()); + } + } + switch (jobConfigDTO.getJobTypeEnum()) { + case SQL_BATCH: + case SQL_STREAMING: + command.append(" -c ").append(APP_CLASS_NAME); + command.append(" ").append(jobRunParamDTO.getSysHome()).append(SystemConstant.JARVERSION); + command.append(" -sql ").append(jobRunParamDTO.getSqlPath()); + if (StringUtils.isNotEmpty(jobRunParamDTO.getFlinkCheckpointConfig())) { + command.append(" ").append(jobRunParamDTO.getFlinkCheckpointConfig()); } - - log.info("buildRunCommandForYarnCluster runCommand={}", command.toString()); - return command.toString(); + command.append(" -type ").append(jobConfigDTO.getJobTypeEnum().getCode()); + break; + case JAR: + command.append(" -c ").append(jobConfigDTO.getCustomMainClass()); + command.append(" ").append(jobRunParamDTO.getMainJarPath()); + command.append(" ").append(jobConfigDTO.getCustomArgs()); + break; + default: + log.warn("不支持的模式 {}", jobConfigDTO.getJobTypeEnum()); } - - public static String buildSavepointCommandForYarn(String jobId, String targetDirectory, String yarnAppId, - String flinkHome) { - StringBuilder command = new StringBuilder( - SystemConstants.buildFlinkBin(flinkHome)); - command.append(" savepoint ") - .append(jobId).append(" ") - .append(targetDirectory).append(" ") - .append("-yid ").append(yarnAppId); - return command.toString(); + log.info("buildRunCommandForLocal runCommand={}", command); + return command.toString(); + } + + /** + * jar并且构建运行命令 + * + * @author zhuhuipei + * @date 2020-09-18 + * @time 00:57 + */ + public static String buildRunCommandForYarnCluster(JobRunParamDTO jobRunParamDTO, + JobConfigDTO jobConfigDTO, String savepointPath) throws Exception { + StringBuilder command = new StringBuilder(); + command.append(jobRunParamDTO.getFlinkBinPath()).append(" run"); + if (StringUtils.isNotEmpty(savepointPath)) { + command.append(" -s ").append(savepointPath); + } + command.append(" ").append(jobRunParamDTO.getFlinkRunParam()); + command.append(" -ynm ").append(JobConfigDTO.buildRunName(jobConfigDTO.getJobName())); + command.append(" -yd -m yarn-cluster"); + + if (StringUtils.isNotEmpty(jobConfigDTO.getExtJarPath())) { + String[] urls = jobConfigDTO.getExtJarPath().split(SystemConstant.LINE_FEED); + for (String url : urls) { + command.append(" -C ").append(url.trim()); + } } - - public static String buildSavepointCommandForCluster(String jobId, String targetDirectory, - String flinkHome) { - StringBuilder command = new StringBuilder( - SystemConstants.buildFlinkBin(flinkHome)); - command.append(" savepoint ") - .append(jobId).append(" ") - .append(targetDirectory).append(" "); - return command.toString(); + switch (jobConfigDTO.getJobTypeEnum()) { + case SQL_STREAMING: + case SQL_BATCH: + command.append(" -c ").append(APP_CLASS_NAME); + command.append(" ").append(jobRunParamDTO.getSysHome()).append(SystemConstant.JARVERSION); + command.append(" -sql ").append(jobRunParamDTO.getSqlPath()); + if (StringUtils.isNotEmpty(jobRunParamDTO.getFlinkCheckpointConfig())) { + command.append(" ").append(jobRunParamDTO.getFlinkCheckpointConfig()); + } + command.append(" -type ").append(jobConfigDTO.getJobTypeEnum().getCode()); + break; + case JAR: + command.append(" -c ").append(jobConfigDTO.getCustomMainClass()); + command.append(" ").append(jobRunParamDTO.getMainJarPath()); + command.append(" ").append(jobConfigDTO.getCustomArgs()); + break; + default: + log.warn("不支持的模式 {}", jobConfigDTO.getJobTypeEnum()); } + log.info("buildRunCommandForYarnCluster runCommand={}", command.toString()); + return command.toString(); + } + + + public static String buildSavepointCommandForYarn(String jobId, String targetDirectory, + String yarnAppId, + String flinkHome) { + StringBuilder command = new StringBuilder( + SystemConstants.buildFlinkBin(flinkHome)); + command.append(" savepoint ") + .append(jobId).append(" ") + .append(targetDirectory).append(" ") + .append("-yid ").append(yarnAppId); + return command.toString(); + } + + + public static String buildSavepointCommandForCluster(String jobId, String targetDirectory, + String flinkHome) { + StringBuilder command = new StringBuilder( + SystemConstants.buildFlinkBin(flinkHome)); + command.append(" savepoint ") + .append(jobId).append(" ") + .append(targetDirectory).append(" "); + return command.toString(); + } + } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/DateFormatUtils.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/DateFormatUtils.java index 64f17532..c30f10d3 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/DateFormatUtils.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/DateFormatUtils.java @@ -15,19 +15,19 @@ public class DateFormatUtils { - public static final String FORMAT_FULL_TIME_NO_ZONE = "yyyy-MM-dd HH:mm:ss"; + public static final String FORMAT_FULL_TIME_NO_ZONE = "yyyy-MM-dd HH:mm:ss"; - public static Date toFormatDate(String dateTimeStr) { - DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(FORMAT_FULL_TIME_NO_ZONE); - DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr); - return dateTime.toDate(); - } + public static Date toFormatDate(String dateTimeStr) { + DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(FORMAT_FULL_TIME_NO_ZONE); + DateTime dateTime = dateTimeFormatter.parseDateTime(dateTimeStr); + return dateTime.toDate(); + } - public static String toFormatString(Date date) { - return new DateTime(date).toString(FORMAT_FULL_TIME_NO_ZONE); - } + public static String toFormatString(Date date) { + return new DateTime(date).toString(FORMAT_FULL_TIME_NO_ZONE); + } - public static String toFormatString(Date date, String pattern) { - return new DateTime(date).toString(pattern); - } + public static String toFormatString(Date date, String pattern) { + return new DateTime(date).toString(pattern); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/FileUtils.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/FileUtils.java index 8d9ca82c..8d40513c 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/FileUtils.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/FileUtils.java @@ -22,90 +22,90 @@ public class FileUtils { - private static final String DIR_SQL = "sql/"; + private static final String DIR_SQL = "sql/"; - /** - * 存放sql文件路径 - * - * @author zhuhuipei - * @date 2020-07-20 - * @time 00:02 - */ - public static void createSqlHome(String sysHome) { - if (StringUtils.isEmpty(sysHome)) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - if (!StrUtil.endWith(sysHome.trim(), SystemConstants.SLASH)) { - throw new BizException("必须以/结尾"); - } - if (!StrUtil.startWith(sysHome.trim(), SystemConstants.SLASH)) { - throw new BizException("必须以/开头"); - } - File dir = new File(sysHome + DIR_SQL); - if (!dir.exists()) { - dir.mkdirs(); - } + /** + * 存放sql文件路径 + * + * @author zhuhuipei + * @date 2020-07-20 + * @time 00:02 + */ + public static void createSqlHome(String sysHome) { + if (StringUtils.isEmpty(sysHome)) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL); } - - public static String getSqlHome(String sysHome) { - createSqlHome(sysHome); - return sysHome + DIR_SQL; + if (!StrUtil.endWith(sysHome.trim(), SystemConstants.SLASH)) { + throw new BizException("必须以/结尾"); + } + if (!StrUtil.startWith(sysHome.trim(), SystemConstants.SLASH)) { + throw new BizException("必须以/开头"); } + File dir = new File(sysHome + DIR_SQL); + if (!dir.exists()) { + dir.mkdirs(); + } + } + public static String getSqlHome(String sysHome) { + createSqlHome(sysHome); + return sysHome + DIR_SQL; + } - /** - * 生产文件名称(sql的文件名) - * - * @author zhuhuipei - * @date 2020-07-20 - * @time 00:01 - */ - public static String createFileName(String id) { - return new StringBuffer("job_sql_").append(id).append(".sql").toString(); - } - /** - * 文件写入 - * - * @author zhuhuipei - * @date 2020-07-20 - * @time 00:29 - */ - public static void writeText(String filePath, String content, boolean isAppend) { - log.info("写入文件 filePath={}", filePath); - FileOutputStream outputStream = null; - OutputStreamWriter outputStreamWriter = null; - BufferedWriter bufferedWriter = null; - try { - outputStream = new FileOutputStream(filePath, isAppend); - outputStreamWriter = new OutputStreamWriter(outputStream); - bufferedWriter = new BufferedWriter(outputStreamWriter); - bufferedWriter.write(content); - } catch (Exception e) { - log.error("写入异常", e); - throw new BizException("文件写入失败"); - } finally { - try { - if (bufferedWriter != null) { - bufferedWriter.close(); - } - if (outputStreamWriter != null) { - outputStreamWriter.close(); - } - if (outputStream != null) { - outputStream.close(); - } - } catch (Exception e) { - log.error("关闭写入文件异常", e); - } + /** + * 生产文件名称(sql的文件名) + * + * @author zhuhuipei + * @date 2020-07-20 + * @time 00:01 + */ + public static String createFileName(String id) { + return new StringBuffer("job_sql_").append(id).append(".sql").toString(); + } + + /** + * 文件写入 + * + * @author zhuhuipei + * @date 2020-07-20 + * @time 00:29 + */ + public static void writeText(String filePath, String content, boolean isAppend) { + log.info("写入文件 filePath={}", filePath); + FileOutputStream outputStream = null; + OutputStreamWriter outputStreamWriter = null; + BufferedWriter bufferedWriter = null; + try { + outputStream = new FileOutputStream(filePath, isAppend); + outputStreamWriter = new OutputStreamWriter(outputStream); + bufferedWriter = new BufferedWriter(outputStreamWriter); + bufferedWriter.write(content); + } catch (Exception e) { + log.error("写入异常", e); + throw new BizException("文件写入失败"); + } finally { + try { + if (bufferedWriter != null) { + bufferedWriter.close(); } + if (outputStreamWriter != null) { + outputStreamWriter.close(); + } + if (outputStream != null) { + outputStream.close(); + } + } catch (Exception e) { + log.error("关闭写入文件异常", e); + } } + } - public static void mkdirs(String path) { - File dir = new File(path); - if (!dir.exists()) { - dir.mkdirs(); - } + public static void mkdirs(String path) { + File dir = new File(path); + if (!dir.exists()) { + dir.mkdirs(); } + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/HttpServiceCheckerUtil.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/HttpServiceCheckerUtil.java index 35a676d2..74a5ed2a 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/HttpServiceCheckerUtil.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/HttpServiceCheckerUtil.java @@ -19,41 +19,42 @@ @Slf4j public class HttpServiceCheckerUtil { - /** - * 检查url地址连接是否正常 - * - * @author zhuhuipei - * @date 2020/11/09 - * @time 22:45 - */ - public static boolean checkUrlConnect(String url) { - try { - log.info("checkUrlConnect url is {}", url); - RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_20_S); - restTemplate.exchange(url.trim(), HttpMethod.GET, new HttpEntity(null, - new HttpHeaders()), String.class); - } catch (ResourceAccessException e) { - if (e.getCause() instanceof ConnectException || e.getCause() instanceof SocketTimeoutException) { - log.error("[checkUrlConnect]网络异常或者超时 url={}", url, e); - return false; - } else { - log.warn("[checkUrlConnect]url={} 出错了 {}", e); - return false; - } - } catch (Exception e) { - log.error("[checkUrlConnect]url={} 出错了 {}", e); - return false; - } - log.info("网络检查正常 url={}", url); - return true; + /** + * 检查url地址连接是否正常 + * + * @author zhuhuipei + * @date 2020/11/09 + * @time 22:45 + */ + public static boolean checkUrlConnect(String url) { + try { + log.info("checkUrlConnect url is {}", url); + RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_20_S); + restTemplate.exchange(url.trim(), HttpMethod.GET, new HttpEntity(null, + new HttpHeaders()), String.class); + } catch (ResourceAccessException e) { + if (e.getCause() instanceof ConnectException || e + .getCause() instanceof SocketTimeoutException) { + log.error("[checkUrlConnect]网络异常或者超时 url={}", url, e); + return false; + } else { + log.warn("[checkUrlConnect]url={} 出错了 {}", e); + return false; + } + } catch (Exception e) { + log.error("[checkUrlConnect]url={} 出错了 {}", e); + return false; } + log.info("网络检查正常 url={}", url); + return true; + } - public static void main(String[] args) { + public static void main(String[] args) { // String url = "https://youtube.com/"; - String url = "http://pre-hadoop-master002:8088/xxx"; - System.out.println(HttpServiceCheckerUtil.checkUrlConnect(url)); - ; + String url = "http://pre-hadoop-master002:8088/xxx"; + System.out.println(HttpServiceCheckerUtil.checkUrlConnect(url)); - } + + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/HttpUtil.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/HttpUtil.java index f6b20d11..f7e92ebc 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/HttpUtil.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/HttpUtil.java @@ -17,43 +17,43 @@ public class HttpUtil { - public final static int TIME_OUT_30_S = 1000 * 30; + public static final int TIME_OUT_30_S = 1000 * 30; - public final static int TIME_OUT_15_S = 1000 * 15; + public static final int TIME_OUT_15_S = 1000 * 15; - public final static int TIME_OUT_20_S = 1000 * 20; + public static final int TIME_OUT_20_S = 1000 * 20; - public final static int TIME_OUT_3_S = 1000 * 3; + public static final int TIME_OUT_3_S = 1000 * 3; - public final static int TIME_OUT_5_M = 1000 * 60 * 5; + public static final int TIME_OUT_5_M = 1000 * 60 * 5; - public final static int TIME_OUT_1_M = 1000 * 60 * 1; + public static final int TIME_OUT_1_M = 1000 * 60 * 1; - public static HttpHeaders buildHttpHeaders(String contentType) { - HttpHeaders httpHeaders = new HttpHeaders(); - if (StringUtils.isEmpty(contentType)) { - httpHeaders.add("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE); - } else { - httpHeaders.add("Content-Type", contentType); - } - httpHeaders.add("X-Requested-With", "XMLHttpRequest"); - httpHeaders.add("Accept", "text/plain;charset=utf-8"); - return httpHeaders; + public static HttpHeaders buildHttpHeaders(String contentType) { + HttpHeaders httpHeaders = new HttpHeaders(); + if (StringUtils.isEmpty(contentType)) { + httpHeaders.add("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE); + } else { + httpHeaders.add("Content-Type", contentType); } + httpHeaders.add("X-Requested-With", "XMLHttpRequest"); + httpHeaders.add("Accept", "text/plain;charset=utf-8"); + return httpHeaders; + } - public static RestTemplate buildRestTemplate(Integer connectTimeout) { - SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); - requestFactory.setConnectTimeout(connectTimeout); - requestFactory.setReadTimeout(connectTimeout); - RestTemplate restTemplate = new RestTemplate(requestFactory); - return restTemplate; - } + public static RestTemplate buildRestTemplate(Integer connectTimeout) { + SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); + requestFactory.setConnectTimeout(connectTimeout); + requestFactory.setReadTimeout(connectTimeout); + RestTemplate restTemplate = new RestTemplate(requestFactory); + return restTemplate; + } - public static String buildUrl(String domain,String urn){ + public static String buildUrl(String domain, String urn) { - return new StringBuilder(domain).append(urn).toString(); - } + return new StringBuilder(domain).append(urn).toString(); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/IpUtil.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/IpUtil.java index f656d696..1d9eee02 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/IpUtil.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/IpUtil.java @@ -14,65 +14,65 @@ * @time 下午6:18 */ @Slf4j -public class IpUtil { +public final class IpUtil { - private static String ip; + private static String ip; - private static IpUtil ipUtil = new IpUtil(); + private static IpUtil ipUtil = new IpUtil(); - private IpUtil() { - ip = getIp(); - } + private IpUtil() { + ip = getIp(); + } - public static IpUtil getInstance() { - return ipUtil; - } + public static IpUtil getInstance() { + return ipUtil; + } - /** - * 获取本机的ip地址 - */ - public String getLocalIP() { - if (StringUtils.isEmpty(ip)) { - return getIp(); - } - return ip; + /** + * 获取本机的ip地址 + */ + public String getLocalIP() { + if (StringUtils.isEmpty(ip)) { + return getIp(); } + return ip; + } - private String getIp() { - InetAddress addr = null; - try { - addr = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { - return "UnknownHost"; - } - byte[] ipAddr = addr.getAddress(); - String ipAddrStr = ""; - for (int i = 0; i < ipAddr.length; i++) { - if (i > 0) { - ipAddrStr += "."; - } - ipAddrStr += ipAddr[i] & 0xFF; - } - return ipAddrStr; + private String getIp() { + InetAddress addr = null; + try { + addr = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + return "UnknownHost"; + } + byte[] ipAddr = addr.getAddress(); + String ipAddrStr = ""; + for (int i = 0; i < ipAddr.length; i++) { + if (i > 0) { + ipAddrStr += "."; + } + ipAddrStr += ipAddr[i] & 0xFF; } + return ipAddrStr; + } - public static String getHostName() { - try { - InetAddress addr = InetAddress.getLocalHost(); - return addr.getHostName(); //获取本机计算机名称 - } catch (Exception e) { - log.error("getHostName is error", e); - throw new BizException(e.getMessage()); - } + public static String getHostName() { + try { + InetAddress addr = InetAddress.getLocalHost(); + return addr.getHostName(); //获取本机计算机名称 + } catch (Exception e) { + log.error("getHostName is error", e); + throw new BizException(e.getMessage()); + } - } + } - public static void main(String[] args) { - System.out.println(IpUtil.getInstance().getLocalIP()); - System.out.println(IpUtil.getInstance().getLocalIP()); - System.out.println(getHostName()); - System.out.println(System.getProperty("user.name")); - } + public static void main(String[] args) { + System.out.println(IpUtil.getInstance().getLocalIP()); + System.out.println(IpUtil.getInstance().getLocalIP()); + System.out.println(getHostName()); + System.out.println(System.getProperty("user.name")); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/JsonUtil.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/JsonUtil.java deleted file mode 100644 index a4ff8657..00000000 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/JsonUtil.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.flink.streaming.web.common.util; - -import com.alibaba.fastjson.JSON; -import lombok.extern.slf4j.Slf4j; - -/** - * @author zhuhuipei - * @Description: - * @date 2021/3/31 - * @time 19:14 - */ -@Slf4j -public class JsonUtil { - - public static T tojson(String res, Class clazz) { - - try { - return JSON.parseObject(res, clazz); - } catch (Exception e) { - log.error("parseObject is error"); - } - return null; - } -} diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/LinuxInfoUtil.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/LinuxInfoUtil.java index b07db0ba..d43c18f6 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/LinuxInfoUtil.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/LinuxInfoUtil.java @@ -12,12 +12,12 @@ */ public class LinuxInfoUtil { - public static String loginName(){ - String userName=System.getProperty("user.name"); - if (StringUtils.isNotEmpty(userName)){ - return userName; - } - throw new BizException(MessageConstants.MESSAGE_011); - + public static String loginName() { + String userName = System.getProperty("user.name"); + if (StringUtils.isNotEmpty(userName)) { + return userName; } + throw new BizException(MessageConstants.MESSAGE_011); + + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/MatcherUtils.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/MatcherUtils.java index a76bce33..ab2575a8 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/MatcherUtils.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/MatcherUtils.java @@ -17,33 +17,33 @@ @Slf4j public class MatcherUtils { - private static String REG_1 = "^([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\\\/])+$"; + private static final String REG_1 = "^([hH][tT]{2}[pP]://|[hH][tT]{2}[pP][sS]://)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~\\\\/])+$"; - public static boolean isHttpsOrHttp(String url) { - Pattern p = Pattern.compile(REG_1); - Matcher m = p.matcher(url.trim()); - if (!m.matches()) { - return false; - } - return true; + public static boolean isHttpsOrHttp(String url) { + Pattern p = Pattern.compile(REG_1); + Matcher m = p.matcher(url.trim()); + if (!m.matches()) { + return false; } + return true; + } - public static String lastUrlValue(String url) { - if (StringUtils.isEmpty(url)) { - return null; - } - if (!isHttpsOrHttp(url)) { - log.error("非法的url :{}", url); - throw new BizException("非法的url"); - } - String[] val = url.trim().split(SystemConstant.VIRGULE); - return val[val.length - 1]; + public static String lastUrlValue(String url) { + if (StringUtils.isEmpty(url)) { + return null; + } + if (!isHttpsOrHttp(url)) { + log.error("非法的url :{}", url); + throw new BizException("非法的url"); + } + String[] val = url.trim().split(SystemConstant.VIRGULE); + return val[val.length - 1]; - } + } - public static void main(String[] args) { - System.out.println(MatcherUtils.lastUrlValue("http://ccblog.cn/jars/flink-streaming-udf.jar ")); - } + public static void main(String[] args) { + System.out.println(MatcherUtils.lastUrlValue("http://ccblog.cn/jars/flink-streaming-udf.jar ")); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Md5Utils.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Md5Utils.java index 9c3591ea..95e79099 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Md5Utils.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Md5Utils.java @@ -16,40 +16,41 @@ @Slf4j public class Md5Utils { - public static String getMD5String(String value) { - - return DigestUtils.md5Hex(value); - + private static final char HEXDIGITS[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F'}; + public static String getMD5String(String value) { + + return DigestUtils.md5Hex(value); + + } + + public static final String md5(String s) { + + try { + byte[] btInput = s.getBytes("UTF-8"); + MessageDigest mdInst = MessageDigest.getInstance("MD5"); + mdInst.update(btInput); + byte[] md = mdInst.digest(); + + int j = md.length; + char str[] = new char[j * 2]; + int k = 0; + for (int i = 0; i < j; i++) { + byte byte0 = md[i]; + str[k++] = HEXDIGITS[byte0 >>> 4 & 0xf]; + str[k++] = HEXDIGITS[byte0 & 0xf]; + } + return new String(str); + } catch (Exception e) { + e.printStackTrace(); + return null; } + } - public final static String MD5(String s) { - char hexDigits[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; - - try { - byte[] btInput = s.getBytes("UTF-8"); - MessageDigest mdInst = MessageDigest.getInstance("MD5"); - mdInst.update(btInput); - byte[] md = mdInst.digest(); - - int j = md.length; - char str[] = new char[j * 2]; - int k = 0; - for (int i = 0; i < j; i++) { - byte byte0 = md[i]; - str[k++] = hexDigits[byte0 >>> 4 & 0xf]; - str[k++] = hexDigits[byte0 & 0xf]; - } - return new String(str); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } + public static void main(String[] args) { - public static void main(String[] args) { + System.out.println(getMD5String("123456")); + System.out.println(getMD5String("123456")); - System.out.println(getMD5String("123456")); - System.out.println(getMD5String("123456")); - - } + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Pages.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Pages.java index 13f6e515..0ad41b83 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Pages.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/Pages.java @@ -11,20 +11,20 @@ @Data public class Pages { - /** - * 当前页码 - */ - private int pageNum; - /** - * 每页数量 - */ - private int pageSize; - /** - * 记录总数 - */ - private long totalSize; - /** - * 页码总数 - */ - private int totalPages; + /** + * 当前页码 + */ + private int pageNum; + /** + * 每页数量 + */ + private int pageSize; + /** + * 记录总数 + */ + private long totalSize; + /** + * 页码总数 + */ + private int totalPages; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/ParameterTool.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/ParameterTool.java index 141bb06f..c500f0a1 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/ParameterTool.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/ParameterTool.java @@ -30,293 +30,294 @@ import java.util.concurrent.ConcurrentHashMap; /** - * This class provides simple utility methods for reading and parsing program arguments from different sources. - * Only single value parameter could be supported in args. + * This class provides simple utility methods for reading and parsing program arguments from + * different sources. Only single value parameter could be supported in args. */ @Public -public class ParameterTool extends AbstractParameterTool { - private static final long serialVersionUID = 1L; - - // ------------------ Constructors ------------------------ - - /** - * Returns {@link ParameterTool} for the given arguments. The arguments are keys followed by values. - * Keys have to start with '-' or '--' - * - *

Example arguments: - * --key1 value1 --key2 value2 -key3 value3 - * - * @param args Input array arguments - * @return A {@link ParameterTool} - */ - public static ParameterTool fromArgs(String[] args) { - final Map map = new HashMap<>(args.length / 2); - - int i = 0; - while (i < args.length) { - final String key = Utils.getKeyFromArgs(args, i); - - if (key.isEmpty()) { - throw new IllegalArgumentException( - "The input " + Arrays.toString(args) + " contains an empty argument"); - } - - i += 1; // try to find the value - - if (i >= args.length) { - map.put(key, null); - } else if (NumberUtils.isNumber(args[i])) { - map.put(key, args[i]); - i += 1; - } else if (args[i].startsWith("--") || args[i].startsWith("-")) { - // the argument cannot be a negative number because we checked earlier - // -> the next argument is a parameter name - map.put(key, null); - } else { - map.put(key, args[i]); - i += 1; - } - } - - return fromMap(map); +public final class ParameterTool extends AbstractParameterTool { + + private static final long serialVersionUID = 1L; + + // ------------------ Constructors ------------------------ + + /** + * Returns {@link ParameterTool} for the given arguments. The arguments are keys followed by + * values. Keys have to start with '-' or '--' + * + *

Example arguments: + * --key1 value1 --key2 value2 -key3 value3 + * + * @param args Input array arguments + * @return A {@link ParameterTool} + */ + public static ParameterTool fromArgs(String[] args) { + final Map map = new HashMap<>(args.length / 2); + + int i = 0; + while (i < args.length) { + final String key = Utils.getKeyFromArgs(args, i); + + if (key.isEmpty()) { + throw new IllegalArgumentException( + "The input " + Arrays.toString(args) + " contains an empty argument"); + } + + i += 1; // try to find the value + + if (i >= args.length) { + map.put(key, null); + } else if (NumberUtils.isNumber(args[i])) { + map.put(key, args[i]); + i += 1; + } else if (args[i].startsWith("--") || args[i].startsWith("-")) { + // the argument cannot be a negative number because we checked earlier + // -> the next argument is a parameter name + map.put(key, null); + } else { + map.put(key, args[i]); + i += 1; + } } - /** - * Returns {@link ParameterTool} for the given {@link Properties} file. - * - * @param path Path to the properties file - * @return A {@link ParameterTool} - * @throws IOException If the file does not exist - * @see Properties - */ - public static ParameterTool fromPropertiesFile(String path) throws IOException { - File propertiesFile = new File(path); - return fromPropertiesFile(propertiesFile); + return fromMap(map); + } + + /** + * Returns {@link ParameterTool} for the given {@link Properties} file. + * + * @param path Path to the properties file + * @return A {@link ParameterTool} + * @throws IOException If the file does not exist + * @see Properties + */ + public static ParameterTool fromPropertiesFile(String path) throws IOException { + File propertiesFile = new File(path); + return fromPropertiesFile(propertiesFile); + } + + /** + * Returns {@link ParameterTool} for the given {@link Properties} file. + * + * @param file File object to the properties file + * @return A {@link ParameterTool} + * @throws IOException If the file does not exist + * @see Properties + */ + public static ParameterTool fromPropertiesFile(File file) throws IOException { + if (!file.exists()) { + throw new FileNotFoundException( + "Properties file " + file.getAbsolutePath() + " does not exist"); } - - /** - * Returns {@link ParameterTool} for the given {@link Properties} file. - * - * @param file File object to the properties file - * @return A {@link ParameterTool} - * @throws IOException If the file does not exist - * @see Properties - */ - public static ParameterTool fromPropertiesFile(File file) throws IOException { - if (!file.exists()) { - throw new FileNotFoundException("Properties file " + file.getAbsolutePath() + " does not exist"); - } - try (FileInputStream fis = new FileInputStream(file)) { - return fromPropertiesFile(fis); - } + try (FileInputStream fis = new FileInputStream(file)) { + return fromPropertiesFile(fis); } - - /** - * Returns {@link ParameterTool} for the given InputStream from {@link Properties} file. - * - * @param inputStream InputStream from the properties file - * @return A {@link ParameterTool} - * @throws IOException If the file does not exist - * @see Properties - */ - public static ParameterTool fromPropertiesFile(InputStream inputStream) throws IOException { - Properties props = new Properties(); - props.load(inputStream); - return fromMap((Map) props); + } + + /** + * Returns {@link ParameterTool} for the given InputStream from {@link Properties} file. + * + * @param inputStream InputStream from the properties file + * @return A {@link ParameterTool} + * @throws IOException If the file does not exist + * @see Properties + */ + public static ParameterTool fromPropertiesFile(InputStream inputStream) throws IOException { + Properties props = new Properties(); + props.load(inputStream); + return fromMap((Map) props); + } + + /** + * Returns {@link ParameterTool} for the given map. + * + * @param map A map of arguments. Both Key and Value have to be Strings + * @return A {@link ParameterTool} + */ + public static ParameterTool fromMap(Map map) { + Preconditions.checkNotNull(map, "Unable to initialize from empty map"); + return new ParameterTool(map); + } + + /** + * Returns {@link ParameterTool} from the system properties. Example on how to pass system + * properties: -Dkey1=value1 -Dkey2=value2 + * + * @return A {@link ParameterTool} + */ + public static ParameterTool fromSystemProperties() { + return fromMap((Map) System.getProperties()); + } + + // ------------------ ParameterUtil ------------------------ + protected final Map data; + + private ParameterTool(Map data) { + this.data = Collections.unmodifiableMap(new HashMap<>(data)); + + this.defaultData = new ConcurrentHashMap<>(data.size()); + + this.unrequestedParameters = Collections.newSetFromMap(new ConcurrentHashMap<>(data.size())); + + unrequestedParameters.addAll(data.keySet()); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; } - - /** - * Returns {@link ParameterTool} for the given map. - * - * @param map A map of arguments. Both Key and Value have to be Strings - * @return A {@link ParameterTool} - */ - public static ParameterTool fromMap(Map map) { - Preconditions.checkNotNull(map, "Unable to initialize from empty map"); - return new ParameterTool(map); + if (o == null || getClass() != o.getClass()) { + return false; } - - /** - * Returns {@link ParameterTool} from the system properties. - * Example on how to pass system properties: - * -Dkey1=value1 -Dkey2=value2 - * - * @return A {@link ParameterTool} - */ - public static ParameterTool fromSystemProperties() { - return fromMap((Map) System.getProperties()); + ParameterTool that = (ParameterTool) o; + return Objects.equals(data, that.data) + && Objects.equals(defaultData, that.defaultData) + && Objects.equals(unrequestedParameters, that.unrequestedParameters); + } + + @Override + public int hashCode() { + return Objects.hash(data, defaultData, unrequestedParameters); + } + + // ------------------ Get data from the util ---------------- + + /** + * Returns number of parameters in {@link ParameterTool}. + */ + @Override + public int getNumberOfParameters() { + return data.size(); + } + + /** + * Returns the String value for the given key. If the key does not exist it will return null. + */ + @Override + public String get(String key) { + addToDefaults(key, null); + unrequestedParameters.remove(key); + return data.get(key); + } + + /** + * Check if value is set. + */ + @Override + public boolean has(String value) { + addToDefaults(value, null); + unrequestedParameters.remove(value); + return data.containsKey(value); + } + + // ------------------------- Export to different targets ------------------------- + + /** + * Returns a {@link Configuration} object from this {@link ParameterTool}. + * + * @return A {@link Configuration} + */ + public Configuration getConfiguration() { + final Configuration conf = new Configuration(); + for (Map.Entry entry : data.entrySet()) { + conf.setString(entry.getKey(), entry.getValue()); } - - // ------------------ ParameterUtil ------------------------ - protected final Map data; - - private ParameterTool(Map data) { - this.data = Collections.unmodifiableMap(new HashMap<>(data)); - - this.defaultData = new ConcurrentHashMap<>(data.size()); - - this.unrequestedParameters = Collections.newSetFromMap(new ConcurrentHashMap<>(data.size())); - - unrequestedParameters.addAll(data.keySet()); + return conf; + } + + /** + * Returns a {@link Properties} object from this {@link ParameterTool}. + * + * @return A {@link Properties} + */ + public Properties getProperties() { + Properties props = new Properties(); + props.putAll(this.data); + return props; + } + + /** + * Create a properties file with all the known parameters (call after the last get*() call). Set + * the default value, if available. + * + *

Use this method to create a properties file skeleton. + * + * @param pathToFile Location of the default properties file. + */ + public void createPropertiesFile(String pathToFile) throws IOException { + createPropertiesFile(pathToFile, true); + } + + /** + * Create a properties file with all the known parameters (call after the last get*() call). Set + * the default value, if overwrite is true. + * + * @param pathToFile Location of the default properties file. + * @param overwrite Boolean flag indicating whether or not to overwrite the file + * @throws IOException If overwrite is not allowed and the file exists + */ + public void createPropertiesFile(String pathToFile, boolean overwrite) throws IOException { + final File file = new File(pathToFile); + if (file.exists()) { + if (overwrite) { + file.delete(); + } else { + throw new RuntimeException("File " + pathToFile + " exists and overwriting is not allowed"); + } } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ParameterTool that = (ParameterTool) o; - return Objects.equals(data, that.data) && - Objects.equals(defaultData, that.defaultData) && - Objects.equals(unrequestedParameters, that.unrequestedParameters); + final Properties defaultProps = new Properties(); + defaultProps.putAll(this.defaultData); + try (final OutputStream out = new FileOutputStream(file)) { + defaultProps + .store(out, "Default file created by Flink's ParameterUtil.createPropertiesFile()"); } + } - @Override - public int hashCode() { - return Objects.hash(data, defaultData, unrequestedParameters); - } + @Override + protected Object clone() throws CloneNotSupportedException { + return new ParameterTool(this.data); + } - // ------------------ Get data from the util ---------------- + // ------------------------- Interaction with other ParameterUtils ------------------------- - /** - * Returns number of parameters in {@link ParameterTool}. - */ - @Override - public int getNumberOfParameters() { - return data.size(); - } + /** + * Merges two {@link ParameterTool}. + * + * @param other Other {@link ParameterTool} object + * @return The Merged {@link ParameterTool} + */ + public ParameterTool mergeWith(ParameterTool other) { + final Map resultData = new HashMap<>(data.size() + other.data.size()); + resultData.putAll(data); + resultData.putAll(other.data); - /** - * Returns the String value for the given key. - * If the key does not exist it will return null. - */ - @Override - public String get(String key) { - addToDefaults(key, null); - unrequestedParameters.remove(key); - return data.get(key); - } + final ParameterTool ret = new ParameterTool(resultData); - /** - * Check if value is set. - */ - @Override - public boolean has(String value) { - addToDefaults(value, null); - unrequestedParameters.remove(value); - return data.containsKey(value); - } + final HashSet requestedParametersLeft = new HashSet<>(data.keySet()); + requestedParametersLeft.removeAll(unrequestedParameters); - // ------------------------- Export to different targets ------------------------- - - /** - * Returns a {@link Configuration} object from this {@link ParameterTool}. - * - * @return A {@link Configuration} - */ - public Configuration getConfiguration() { - final Configuration conf = new Configuration(); - for (Map.Entry entry : data.entrySet()) { - conf.setString(entry.getKey(), entry.getValue()); - } - return conf; - } + final HashSet requestedParametersRight = new HashSet<>(other.data.keySet()); + requestedParametersRight.removeAll(other.unrequestedParameters); - /** - * Returns a {@link Properties} object from this {@link ParameterTool}. - * - * @return A {@link Properties} - */ - public Properties getProperties() { - Properties props = new Properties(); - props.putAll(this.data); - return props; - } + ret.unrequestedParameters.removeAll(requestedParametersLeft); + ret.unrequestedParameters.removeAll(requestedParametersRight); - /** - * Create a properties file with all the known parameters (call after the last get*() call). - * Set the default value, if available. - * - *

Use this method to create a properties file skeleton. - * - * @param pathToFile Location of the default properties file. - */ - public void createPropertiesFile(String pathToFile) throws IOException { - createPropertiesFile(pathToFile, true); - } - - /** - * Create a properties file with all the known parameters (call after the last get*() call). - * Set the default value, if overwrite is true. - * - * @param pathToFile Location of the default properties file. - * @param overwrite Boolean flag indicating whether or not to overwrite the file - * @throws IOException If overwrite is not allowed and the file exists - */ - public void createPropertiesFile(String pathToFile, boolean overwrite) throws IOException { - final File file = new File(pathToFile); - if (file.exists()) { - if (overwrite) { - file.delete(); - } else { - throw new RuntimeException("File " + pathToFile + " exists and overwriting is not allowed"); - } - } - final Properties defaultProps = new Properties(); - defaultProps.putAll(this.defaultData); - try (final OutputStream out = new FileOutputStream(file)) { - defaultProps.store(out, "Default file created by Flink's ParameterUtil.createPropertiesFile()"); - } - } - - @Override - protected Object clone() throws CloneNotSupportedException { - return new ParameterTool(this.data); - } - - // ------------------------- Interaction with other ParameterUtils ------------------------- + return ret; + } - /** - * Merges two {@link ParameterTool}. - * - * @param other Other {@link ParameterTool} object - * @return The Merged {@link ParameterTool} - */ - public ParameterTool mergeWith(ParameterTool other) { - final Map resultData = new HashMap<>(data.size() + other.data.size()); - resultData.putAll(data); - resultData.putAll(other.data); + // ------------------------- ExecutionConfig.UserConfig interface ------------------------- - final ParameterTool ret = new ParameterTool(resultData); + @Override + public Map toMap() { + return data; + } - final HashSet requestedParametersLeft = new HashSet<>(data.keySet()); - requestedParametersLeft.removeAll(unrequestedParameters); + // ------------------------- Serialization --------------------------------------------- - final HashSet requestedParametersRight = new HashSet<>(other.data.keySet()); - requestedParametersRight.removeAll(other.unrequestedParameters); + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); - ret.unrequestedParameters.removeAll(requestedParametersLeft); - ret.unrequestedParameters.removeAll(requestedParametersRight); - - return ret; - } - - // ------------------------- ExecutionConfig.UserConfig interface ------------------------- - - @Override - public Map toMap() { - return data; - } - - // ------------------------- Serialization --------------------------------------------- - - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - - defaultData = new ConcurrentHashMap<>(data.size()); - unrequestedParameters = Collections.newSetFromMap(new ConcurrentHashMap<>(data.size())); - } + defaultData = new ConcurrentHashMap<>(data.size()); + unrequestedParameters = Collections.newSetFromMap(new ConcurrentHashMap<>(data.size())); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/UrlUtil.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/UrlUtil.java index dfc4c2c0..2f02bf07 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/UrlUtil.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/UrlUtil.java @@ -15,67 +15,67 @@ @Slf4j public class UrlUtil { - public static String downLoadFromUrl(String urlStr, String savePath) throws Exception { - URL url = new URL(urlStr); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - //设置超时间为3秒 - conn.setConnectTimeout(HttpUtil.TIME_OUT_1_M); - //防止屏蔽程序抓取而返回403错误 - conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); - //得到输入流 - InputStream inputStream = conn.getInputStream(); - //获取自己数组 - byte[] getData = readInputStream(inputStream); + public static String downLoadFromUrl(String urlStr, String savePath) throws Exception { + URL url = new URL(urlStr); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + //设置超时间为3秒 + conn.setConnectTimeout(HttpUtil.TIME_OUT_1_M); + //防止屏蔽程序抓取而返回403错误 + conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); + //得到输入流 + InputStream inputStream = conn.getInputStream(); + //获取自己数组 + byte[] getData = readInputStream(inputStream); - //文件保存位置 - File saveDir = new File(savePath); - if (!saveDir.exists()) { - log.info("创建文件夹 {}", savePath); - saveDir.mkdirs(); - } - String fileName = MatcherUtils.lastUrlValue(urlStr); + //文件保存位置 + File saveDir = new File(savePath); + if (!saveDir.exists()) { + log.info("创建文件夹 {}", savePath); + saveDir.mkdirs(); + } + String fileName = MatcherUtils.lastUrlValue(urlStr); - String pathName = saveDir + File.separator + fileName; + String pathName = saveDir + File.separator + fileName; - File file = new File(pathName); - FileOutputStream fos = new FileOutputStream(file); - fos.write(getData); - if (fos != null) { - fos.close(); - } - if (inputStream != null) { - inputStream.close(); - } - log.info("文件下载成功 {}", pathName); - return pathName; + File file = new File(pathName); + FileOutputStream fos = new FileOutputStream(file); + fos.write(getData); + if (fos != null) { + fos.close(); + } + if (inputStream != null) { + inputStream.close(); } + log.info("文件下载成功 {}", pathName); + return pathName; + } - /** - * 从输入流中获取字节数组 - * - * @param inputStream - * @return - * @throws IOException - */ - public static byte[] readInputStream(InputStream inputStream) throws IOException { - byte[] buffer = new byte[1024]; - int len = 0; - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - while ((len = inputStream.read(buffer)) != -1) { - bos.write(buffer, 0, len); - } - bos.close(); - return bos.toByteArray(); + /** + * 从输入流中获取字节数组 + * + * @param inputStream + * @return + * @throws IOException + */ + public static byte[] readInputStream(InputStream inputStream) throws IOException { + byte[] buffer = new byte[1024]; + int len = 0; + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + while ((len = inputStream.read(buffer)) != -1) { + bos.write(buffer, 0, len); } + bos.close(); + return bos.toByteArray(); + } - public static void main(String[] args) { - try { - downLoadFromUrl("http://ccblog.cn/jars/flink-streaming-udf.jar", - "/Users/huipeizhu/logs/"); - } catch (Exception e) { - e.printStackTrace(); - } + public static void main(String[] args) { + try { + downLoadFromUrl("http://ccblog.cn/jars/flink-streaming-udf.jar", + "/Users/huipeizhu/logs/"); + } catch (Exception e) { + e.printStackTrace(); } + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/UserSessionUtil.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/UserSessionUtil.java index 57158287..3cc176ac 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/UserSessionUtil.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/UserSessionUtil.java @@ -17,37 +17,35 @@ @Slf4j public class UserSessionUtil { - /** - * 根据cookie获取登陆信息 - * - * @author zhuhuipei - * @date 2020-08-12 - * @time 19:06 - */ - public static UserSession userSession(HttpServletRequest request) { - if (request == null) { - return null; - } - Cookie[] cookies = request.getCookies(); - if (cookies == null) { - return null; - } + /** + * 根据cookie获取登陆信息 + * + * @author zhuhuipei + * @date 2020-08-12 + * @time 19:06 + */ + public static UserSession userSession(HttpServletRequest request) { + if (request == null || request.getCookies() == null) { + return null; + } + Cookie[] cookies = request.getCookies(); - for (Cookie cookie : cookies) { - if (cookie.getName().equals(SystemConstants.COOKIE_NAME_SESSION_ID)) { - try { - if (StringUtils.isEmpty(cookie.getValue())) { - log.warn("登陆信息失效 请重新登陆"); - return null; - } - UserSession userSession = UserSession.toUserSession(Base64Coded.decode(cookie.getValue().getBytes())); - return userSession; - } catch (Exception e) { - log.error("解析登陆信息 请重新登陆 {}", cookie.getValue(), e); - } - } + for (Cookie cookie : cookies) { + if (cookie.getName().equals(SystemConstants.COOKIE_NAME_SESSION_ID)) { + try { + if (StringUtils.isEmpty(cookie.getValue())) { + log.warn("登陆信息失效 请重新登陆"); + return null; + } + UserSession userSession = UserSession + .toUserSession(Base64Coded.decode(cookie.getValue().getBytes())); + return userSession; + } catch (Exception e) { + log.error("解析登陆信息 请重新登陆 {}", cookie.getValue(), e); } - - return null; + } } + + return null; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/YarnUtil.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/YarnUtil.java index f783160d..9b86eb04 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/YarnUtil.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/common/util/YarnUtil.java @@ -12,13 +12,14 @@ */ public class YarnUtil { - public static String getQueueName(String flinkRunConfig) throws ParseException { - CommandLine cl = CliConfigUtil.getFlinkRunByCli(flinkRunConfig); - return cl.getOptionValue(SystemConstants.YQU); - } + public static String getQueueName(String flinkRunConfig) throws ParseException { + CommandLine cl = CliConfigUtil.getFlinkRunByCli(flinkRunConfig); + return cl.getOptionValue(SystemConstants.YQU); + } - public static void main(String[] args) throws ParseException { - System.out.println(YarnUtil.getQueueName("-yqu streaming -yjm 1024m -ytm 2048m -p 1 ")); - } + public static void main(String[] args) throws ParseException { + System.out + .println(YarnUtil.getQueueName("-yqu streaming -yjm 1024m -ytm 2048m -p 1 ")); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmLogStatusEnum.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmLogStatusEnum.java index e9106e94..0961d1aa 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmLogStatusEnum.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmLogStatusEnum.java @@ -10,32 +10,31 @@ */ @Getter public enum AlarmLogStatusEnum { - SUCCESS(1, "成功"), - FAIL(0, "失败"), - ; + SUCCESS(1, "成功"), + FAIL(0, "失败"); - private int code; + private int code; - private String desc; + private String desc; - AlarmLogStatusEnum(int code, String desc) { - this.code = code; - this.desc = desc; - } + AlarmLogStatusEnum(int code, String desc) { + this.code = code; + this.desc = desc; + } - public static AlarmLogStatusEnum getAlarmLogStatusEnum(Integer code) { - if (code == null) { - return null; - } + public static AlarmLogStatusEnum getAlarmLogStatusEnum(Integer code) { + if (code == null) { + return null; + } - for (AlarmLogStatusEnum alarmLogStatusEnum : AlarmLogStatusEnum.values()) { - if (alarmLogStatusEnum.getCode() == code.intValue()) { - return alarmLogStatusEnum; - } + for (AlarmLogStatusEnum alarmLogStatusEnum : AlarmLogStatusEnum.values()) { + if (alarmLogStatusEnum.getCode() == code.intValue()) { + return alarmLogStatusEnum; + } - } - return null; } + return null; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmLogTypeEnum.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmLogTypeEnum.java index c4c71448..af5dc158 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmLogTypeEnum.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmLogTypeEnum.java @@ -11,32 +11,32 @@ @Getter public enum AlarmLogTypeEnum { - DINGDING(1, "钉钉"), - CALLBACK_URL(2, "自定义回调http"), - OTHER(3, "其他"); + DINGDING(1, "钉钉"), + CALLBACK_URL(2, "自定义回调http"), + OTHER(3, "其他"); - private int code; + private int code; - private String desc; + private String desc; - AlarmLogTypeEnum(int code, String desc) { - this.code = code; - this.desc = desc; - } + AlarmLogTypeEnum(int code, String desc) { + this.code = code; + this.desc = desc; + } - public static AlarmLogTypeEnum getAlarmLogTypeEnum(Integer code) { - if (code == null) { - return null; - } + public static AlarmLogTypeEnum getAlarmLogTypeEnum(Integer code) { + if (code == null) { + return null; + } - for (AlarmLogTypeEnum alarMLogTypeEnum : AlarmLogTypeEnum.values()) { - if (alarMLogTypeEnum.getCode() == code.intValue()) { - return alarMLogTypeEnum; - } + for (AlarmLogTypeEnum alarMLogTypeEnum : AlarmLogTypeEnum.values()) { + if (alarMLogTypeEnum.getCode() == code.intValue()) { + return alarMLogTypeEnum; + } - } - return null; } + return null; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmTypeEnum.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmTypeEnum.java index f8d9751e..2cd836f3 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmTypeEnum.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/AlarmTypeEnum.java @@ -10,32 +10,31 @@ */ @Getter public enum AlarmTypeEnum { - DINGDING(1, "钉钉告警"), - CALLBACK_URL(2, "回调http告警"), - AUTO_START_JOB(3, "任务退出自动拉起"), - ; + DINGDING(1, "钉钉告警"), + CALLBACK_URL(2, "回调http告警"), + AUTO_START_JOB(3, "任务退出自动拉起"); - private int code; + private int code; - private String desc; + private String desc; - AlarmTypeEnum(int code, String desc) { - this.code = code; - this.desc = desc; - } + AlarmTypeEnum(int code, String desc) { + this.code = code; + this.desc = desc; + } - public static AlarmTypeEnum getAlarmTypeEnum(Integer code) { - if (code == null) { - return null; - } + public static AlarmTypeEnum getAlarmTypeEnum(Integer code) { + if (code == null) { + return null; + } - for (AlarmTypeEnum alarMLogTypeEnum : AlarmTypeEnum.values()) { - if (alarMLogTypeEnum.getCode() == code.intValue()) { - return alarMLogTypeEnum; - } + for (AlarmTypeEnum alarMLogTypeEnum : AlarmTypeEnum.values()) { + if (alarMLogTypeEnum.getCode() == code.intValue()) { + return alarMLogTypeEnum; + } - } - return null; } + return null; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/DeployModeEnum.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/DeployModeEnum.java index 704a5cc5..50606722 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/DeployModeEnum.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/DeployModeEnum.java @@ -10,18 +10,18 @@ * @time 20:41 */ public enum DeployModeEnum { - YARN_PER, STANDALONE, LOCAL; + YARN_PER, STANDALONE, LOCAL; - public static DeployModeEnum getModel(String model) { - if (StringUtils.isEmpty(model)) { - throw new BizException("运行模式不能为空"); - } - for (DeployModeEnum deployModeEnum : DeployModeEnum.values()) { - if (deployModeEnum.name().equals(model.trim().toUpperCase())) { - return deployModeEnum; - } + public static DeployModeEnum getModel(String model) { + if (StringUtils.isEmpty(model)) { + throw new BizException("运行模式不能为空"); + } + for (DeployModeEnum deployModeEnum : DeployModeEnum.values()) { + if (deployModeEnum.name().equals(model.trim().toUpperCase())) { + return deployModeEnum; + } - } - throw new BizException("运行模式不存在"); } + throw new BizException("运行模式不存在"); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/IpStatusEnum.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/IpStatusEnum.java index 703dfa72..3fa50e95 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/IpStatusEnum.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/IpStatusEnum.java @@ -11,13 +11,13 @@ @Getter public enum IpStatusEnum { - START(1), STOP(-1); + START(1), STOP(-1); - private int code; + private int code; - IpStatusEnum(int code) { - this.code = code; - } + IpStatusEnum(int code) { + this.code = code; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/JobConfigStatus.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/JobConfigStatus.java index c99f45b6..e2d98a0b 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/JobConfigStatus.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/JobConfigStatus.java @@ -11,35 +11,34 @@ @Getter public enum JobConfigStatus { - FAIL(-1, "失败"), + FAIL(-1, "失败"), - RUN(1, "运行中"), + RUN(1, "运行中"), - STOP(0, "停止"), + STOP(0, "停止"), - STARTING(2, "启动中"), + STARTING(2, "启动中"), - SUCCESS(3, "提交成功"), + SUCCESS(3, "提交成功"), - UNKNOWN(-2, "未知"), - ; + UNKNOWN(-2, "未知"); - private Integer code; + private Integer code; - private String desc; + private String desc; - JobConfigStatus(Integer code, String desc) { - this.code = code; - this.desc = desc; - } + JobConfigStatus(Integer code, String desc) { + this.code = code; + this.desc = desc; + } - public static JobConfigStatus getJobConfigStatus(Integer code) { - for (JobConfigStatus jobConfigStatus : JobConfigStatus.values()) { - if (jobConfigStatus.getCode().equals(code)) { - return jobConfigStatus; - } - } - return JobConfigStatus.UNKNOWN; + public static JobConfigStatus getJobConfigStatus(Integer code) { + for (JobConfigStatus jobConfigStatus : JobConfigStatus.values()) { + if (jobConfigStatus.getCode().equals(code)) { + return jobConfigStatus; + } } + return JobConfigStatus.UNKNOWN; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/JobStatusEnum.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/JobStatusEnum.java index 399e3a85..824a794b 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/JobStatusEnum.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/JobStatusEnum.java @@ -11,20 +11,20 @@ @Getter public enum JobStatusEnum { - SUCCESS("成功"), FAIL("失败"), STARTING("启动中"), ERROR("未知异常"); + SUCCESS("成功"), FAIL("失败"), STARTING("启动中"), ERROR("未知异常"); - private String desc; + private String desc; - JobStatusEnum(String desc) { - this.desc = desc; - } + JobStatusEnum(String desc) { + this.desc = desc; + } - public static JobStatusEnum getJobStatusEnum(String name) { - for (JobStatusEnum jobStatusEnum : JobStatusEnum.values()) { - if (jobStatusEnum.name().equals(name)) { - return jobStatusEnum; - } - } - return JobStatusEnum.ERROR; + public static JobStatusEnum getJobStatusEnum(String name) { + for (JobStatusEnum jobStatusEnum : JobStatusEnum.values()) { + if (jobStatusEnum.name().equals(name)) { + return jobStatusEnum; + } } + return JobStatusEnum.ERROR; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysConfigEnum.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysConfigEnum.java index e2cd1f04..8ab2517c 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysConfigEnum.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysConfigEnum.java @@ -16,104 +16,102 @@ @Getter public enum SysConfigEnum { - FLINK_HOME("flink_home", - "flink客户端目录(必选)", - SysConfigEnumType.SYS.name()), + FLINK_HOME("flink_home", + "flink客户端目录(必选)", + SysConfigEnumType.SYS.name()), - AUTO_SAVEPOINT ("auto_savepoint", - "自动开启savepoint(全局配置 默认开启 变量值 true 或 false)", - SysConfigEnumType.SYS.name()), + AUTO_SAVEPOINT("auto_savepoint", + "自动开启savepoint(全局配置 默认开启 变量值 true 或 false)", + SysConfigEnumType.SYS.name()), - FLINK_STREAMING_PLATFORM_WEB_HOME("flink_streaming_platform_web_home", - "flink-streaming-platform-web应用安装的目录(必选)", - SysConfigEnumType.SYS.name()), + FLINK_STREAMING_PLATFORM_WEB_HOME("flink_streaming_platform_web_home", + "flink-streaming-platform-web应用安装的目录(必选)", + SysConfigEnumType.SYS.name()), - YARN_RM_HTTP_ADDRESS("yarn_rm_http_address", - "yarn的rm Http地址(yarn per 模式必须) ", - SysConfigEnumType.SYS.name()), + YARN_RM_HTTP_ADDRESS("yarn_rm_http_address", + "yarn的rm Http地址(yarn per 模式必须) ", + SysConfigEnumType.SYS.name()), - FLINK_REST_HTTP_ADDRESS("flink_rest_http_address", - "flink Rest & web frontend 地址(Local Cluster模式)", - SysConfigEnumType.SYS.name()), + FLINK_REST_HTTP_ADDRESS("flink_rest_http_address", + "flink Rest & web frontend 地址(Local Cluster模式)", + SysConfigEnumType.SYS.name()), - FLINK_REST_HA_HTTP_ADDRESS("flink_rest_ha_http_address", - "flink Rest & web frontend HA 地址(Standalone Cluster模式 支持HA 可以填写多个地址 ;用分隔)", - SysConfigEnumType.SYS.name()), + FLINK_REST_HA_HTTP_ADDRESS("flink_rest_ha_http_address", + "flink Rest & web frontend HA 地址(Standalone Cluster模式 支持HA 可以填写多个地址 ;用分隔)", + SysConfigEnumType.SYS.name()), - DINGDING_ALARM_URL("dingding_alart_url", - "钉钉告警所需的url(如果不填写将无法告警)", - SysConfigEnumType.ALART.name()), + DINGDING_ALARM_URL("dingding_alart_url", + "钉钉告警所需的url(如果不填写将无法告警)", + SysConfigEnumType.ALART.name()), - CALLBACK_ALARM_URL("callback_alart_url", - "自定义http回调告警(只需填写url即可如:http://127.0.0.1/alarmCallback 地址必须是alarmCallback )", - SysConfigEnumType.ALART.name()), + CALLBACK_ALARM_URL("callback_alart_url", + "自定义http回调告警(只需填写url即可如:http://127.0.0.1/alarmCallback 地址必须是alarmCallback )", + SysConfigEnumType.ALART.name()); - ; + private String key; - private String key; + private String desc; - private String desc; + private String type; - private String type; + SysConfigEnum(String key, String desc, String type) { + this.key = key; + this.desc = desc; + this.type = type; + } - SysConfigEnum(String key, String desc, String type) { - this.key = key; - this.desc = desc; - this.type = type; + public static SysConfigEnum getSysConfigEnum(String key) { + if (StringUtils.isEmpty(key)) { + return null; } + for (SysConfigEnum sysConfigEnum : SysConfigEnum.values()) { + if (sysConfigEnum.getKey().equals(key.toLowerCase())) { + return sysConfigEnum; + } - public static SysConfigEnum getSysConfigEnum(String key) { - if (StringUtils.isEmpty(key)) { - return null; - } - for (SysConfigEnum sysConfigEnum : SysConfigEnum.values()) { - if (sysConfigEnum.getKey().equals(key.toLowerCase())) { - return sysConfigEnum; - } + } + return null; - } - return null; + } + public static String getType(String key) { + if (StringUtils.isEmpty(key)) { + return null; } + for (SysConfigEnum sysConfigEnum : SysConfigEnum.values()) { + if (sysConfigEnum.getKey().equals(key.toLowerCase())) { + return sysConfigEnum.getType(); + } - public static String getType(String key) { - if (StringUtils.isEmpty(key)) { - return null; - } - for (SysConfigEnum sysConfigEnum : SysConfigEnum.values()) { - if (sysConfigEnum.getKey().equals(key.toLowerCase())) { - return sysConfigEnum.getType(); - } - - } - return null; } + return null; + } - public static List getSysConfigEnumByType(String type) { - if (StringUtils.isEmpty(type)) { - return null; - } - List list = new ArrayList<>(); - for (SysConfigEnum sysConfigEnum : SysConfigEnum.values()) { - if (sysConfigEnum.getType().equals(type.toUpperCase())) { - list.add(new SysConfigVO(sysConfigEnum.getKey(), sysConfigEnum.getDesc())); - } - } - return list; + public static List getSysConfigEnumByType(String type) { + if (StringUtils.isEmpty(type)) { + return null; + } + List list = new ArrayList<>(); + for (SysConfigEnum sysConfigEnum : SysConfigEnum.values()) { + if (sysConfigEnum.getType().equals(type.toUpperCase())) { + list.add(new SysConfigVO(sysConfigEnum.getKey(), sysConfigEnum.getDesc())); + } } + return list; + } - public static List getMustKey() { - List list = new ArrayList<>(); - list.add(SysConfigEnum.FLINK_HOME.getKey()); - list.add(SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey()); - return list; - } + public static List getMustKey() { + List list = new ArrayList<>(); + list.add(SysConfigEnum.FLINK_HOME.getKey()); + list.add(SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey()); + return list; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysConfigEnumType.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysConfigEnumType.java index 77839d7a..638a21e3 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysConfigEnumType.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysConfigEnumType.java @@ -7,5 +7,5 @@ * @time 01:30 */ public enum SysConfigEnumType { - SYS, ALART + SYS, ALART } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysErrorEnum.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysErrorEnum.java index 7c58bdab..8172b3dd 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysErrorEnum.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/SysErrorEnum.java @@ -12,60 +12,58 @@ public enum SysErrorEnum { - SYSTEM_ERROR("500", "系统异常"), - CUSTOMER_SYSTEM_ERROR("501", "自定义异常"), - BODY_NOT_MATCH("400", "请求的数据格式不符!"), - SIGNATURE_NOT_MATCH("401", "请求的数字签名不匹配!"), - NOT_FOUND("404", "未找到该资源!"), - INTERNAL_SERVER_ERROR("501", "服务器内部错误!"), - SERVER_BUSY("503", "服务器正忙,请稍后再试!"), + SYSTEM_ERROR("500", "系统异常"), + CUSTOMER_SYSTEM_ERROR("501", "自定义异常"), + BODY_NOT_MATCH("400", "请求的数据格式不符!"), + SIGNATURE_NOT_MATCH("401", "请求的数字签名不匹配!"), + NOT_FOUND("404", "未找到该资源!"), + INTERNAL_SERVER_ERROR("501", "服务器内部错误!"), + SERVER_BUSY("503", "服务器正忙,请稍后再试!"), - PARAM_IS_NULL("100", "参数为空"), - PARAM_IS_NULL_YARN_APPID("101", "appid参数为空"), - HTTP_REQUEST_IS_NULL("102", "appid参数为空"), - START_JOB_FAIL("103", "开启任务失败"), - STOP_JOB_FAIL("104", "关闭任务失败"), - SAVEPOINT_JOB_FAIL("105", "savepoint任务失败 详见错误日志"), + PARAM_IS_NULL("100", "参数为空"), + PARAM_IS_NULL_YARN_APPID("101", "appid参数为空"), + HTTP_REQUEST_IS_NULL("102", "appid参数为空"), + START_JOB_FAIL("103", "开启任务失败"), + STOP_JOB_FAIL("104", "关闭任务失败"), + SAVEPOINT_JOB_FAIL("105", "savepoint任务失败 详见错误日志"), - USER_IS_NOT_NULL("10000", "帐号不存在"), - USER_PASSWORD_ERROR("10001", "帐号密码错误"), - USER_PASSWORD_EXPIRED("10002", "密码已经被修改"), - USER_IS_EXIST("10003", "帐号已存在"), - USER_IS_STOP("10004", "帐号已停用"), + USER_IS_NOT_NULL("10000", "帐号不存在"), + USER_PASSWORD_ERROR("10001", "帐号密码错误"), + USER_PASSWORD_EXPIRED("10002", "密码已经被修改"), + USER_IS_EXIST("10003", "帐号已存在"), + USER_IS_STOP("10004", "帐号已停用"), - JOB_CONFIG_PARAM_IS_NULL("20000", "参数不能为空"), - JOB_CONFIG_JOB_NAME_IS_EXIST("20001", "任务名称已经存在"), - JOB_CONFIG_JOB_IS_NOT_EXIST("20002", "任务配置不存在"), - JOB_CONFIG_JOB_IS_OPEN("20003", "任务开启或者运行状态不能修改,请先关闭任务"), - JOB_CONFIG_DEPLOY_MODE_ENUM_NULL("20004", "DeployModeEnum 参数为空"), + JOB_CONFIG_PARAM_IS_NULL("20000", "参数不能为空"), + JOB_CONFIG_JOB_NAME_IS_EXIST("20001", "任务名称已经存在"), + JOB_CONFIG_JOB_IS_NOT_EXIST("20002", "任务配置不存在"), + JOB_CONFIG_JOB_IS_OPEN("20003", "任务开启或者运行状态不能修改,请先关闭任务"), + JOB_CONFIG_DEPLOY_MODE_ENUM_NULL("20004", "DeployModeEnum 参数为空"), - SYSTEM_CONFIG_IS_NULL("30000", "请先配置系统环境 "), - SYSTEM_CONFIG_IS_NULL_FLINK_HOME("30001", "请先flink_home环境的目录地址"), - SYSTEM_CONFIG_IS_NULL_YARN_RM_HTTP_ADDRESS("30002", "请先配置yarn的http地址"), - SYSTEM_CONFIG_IS_NULL_FLINK_REST_HTTP_ADDRESS("30004", "请先配置flink rest 的http地址"), - SYSTEM_CONFIG_IS_NULL_FLINK_REST_HA_HTTP_ADDRESS("30005", "请先配置flink rest ha 的http地址"), - SYSTEM_CONFIG_IS_NULL_FLINK_STREAMING_PLATFORM_WEB_HOME("30003", "请先配置web平台的目录地址"), + SYSTEM_CONFIG_IS_NULL("30000", "请先配置系统环境 "), + SYSTEM_CONFIG_IS_NULL_FLINK_HOME("30001", "请先flink_home环境的目录地址"), + SYSTEM_CONFIG_IS_NULL_YARN_RM_HTTP_ADDRESS("30002", "请先配置yarn的http地址"), + SYSTEM_CONFIG_IS_NULL_FLINK_REST_HTTP_ADDRESS("30004", "请先配置flink rest 的http地址"), + SYSTEM_CONFIG_IS_NULL_FLINK_REST_HA_HTTP_ADDRESS("30005", "请先配置flink rest ha 的http地址"), + SYSTEM_CONFIG_IS_NULL_FLINK_STREAMING_PLATFORM_WEB_HOME("30003", "请先配置web平台的目录地址"), - YARN_CODE("00000", "yarn队列中没有找到运行的任务"), + YARN_CODE("00000", "yarn队列中没有找到运行的任务"), - ADD_SAVEPOINT_ERROR("40000", "手动添加SAVEPOINT失败"), + ADD_SAVEPOINT_ERROR("40000", "手动添加SAVEPOINT失败"), - ALARM_DINGDING_NULL("50000","请到报警管理-报警设置 配置钉钉告警url"), + ALARM_DINGDING_NULL("50000", "请到报警管理-报警设置 配置钉钉告警url"), - ALARM_HTTP_NULL("50001","请到报警管理-报警设置 配置回调url"), + ALARM_HTTP_NULL("50001", "请到报警管理-报警设置 配置回调url"); - ; + private String code; - private String code; + private String errorMsg; - private String errorMsg; - - SysErrorEnum(String code, String errorMsg) { - this.code = code; - this.errorMsg = errorMsg; - } + SysErrorEnum(String code, String errorMsg) { + this.code = code; + this.errorMsg = errorMsg; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/UserStatusEnum.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/UserStatusEnum.java index 6c759871..88662802 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/UserStatusEnum.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/UserStatusEnum.java @@ -11,28 +11,27 @@ @Getter public enum UserStatusEnum { - CLOSE(0, "停用"), + CLOSE(0, "停用"), - OPEN(1, "启用"), + OPEN(1, "启用"), - UNKNOWN(-1, "未知"), - ; + UNKNOWN(-1, "未知"); - private Integer code; + private Integer code; - private String desc; + private String desc; - UserStatusEnum(Integer code, String desc) { - this.code = code; - this.desc = desc; - } + UserStatusEnum(Integer code, String desc) { + this.code = code; + this.desc = desc; + } - public static UserStatusEnum getStatus(Integer code) { - for (UserStatusEnum userStatusEnum : UserStatusEnum.values()) { - if (userStatusEnum.getCode().equals(code)) { - return userStatusEnum; - } - } - return UserStatusEnum.UNKNOWN; + public static UserStatusEnum getStatus(Integer code) { + for (UserStatusEnum userStatusEnum : UserStatusEnum.values()) { + if (userStatusEnum.getCode().equals(code)) { + return userStatusEnum; + } } + return UserStatusEnum.UNKNOWN; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/YN.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/YN.java index d791eb3c..aa419a09 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/YN.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/YN.java @@ -10,41 +10,41 @@ */ @Getter public enum YN { - Y(Boolean.TRUE, 1, "是"), N(Boolean.FALSE, 0, "否"); + Y(Boolean.TRUE, 1, "是"), N(Boolean.FALSE, 0, "否"); - private Boolean code; - private int value; - private String describe; + private Boolean code; + private int value; + private String describe; - YN(Boolean code, int value, String describe) { - this.code = code; - this.value = value; - this.describe = describe; - } + YN(Boolean code, int value, String describe) { + this.code = code; + this.value = value; + this.describe = describe; + } - public static YN getYNByValue(Integer value) { - if (value == null) { - return null; - } - for (YN obj : YN.values()) { - if (obj.value == value) { - return obj; - } - } - return null; + public static YN getYNByValue(Integer value) { + if (value == null) { + return null; + } + for (YN obj : YN.values()) { + if (obj.value == value) { + return obj; + } } + return null; + } - public static int getValueByCode(Boolean code) { - if (code == null) { - return YN.N.getValue(); - } - for (YN obj : YN.values()) { - if (obj.code == code.booleanValue()) { - return obj.value; - } - } - return YN.N.getValue(); + public static int getValueByCode(Boolean code) { + if (code == null) { + return YN.N.getValue(); + } + for (YN obj : YN.values()) { + if (obj.code == code.booleanValue()) { + return obj.value; + } } + return YN.N.getValue(); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/YarnStateEnum.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/YarnStateEnum.java index 14256200..297f734d 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/YarnStateEnum.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/enums/YarnStateEnum.java @@ -7,16 +7,16 @@ * @time 21:42 */ public enum YarnStateEnum { - NEW, NEW_SAVING, SUBMITTED, ACCEPTED, RUNNING, FINISHED, FAILED, KILLED, UNKNOWN; + NEW, NEW_SAVING, SUBMITTED, ACCEPTED, RUNNING, FINISHED, FAILED, KILLED, UNKNOWN; - public static YarnStateEnum getYarnStateEnum(String state) { - for (YarnStateEnum stateEnum : YarnStateEnum.values()) { - if (stateEnum.name().equals(state)) { - return stateEnum; - } + public static YarnStateEnum getYarnStateEnum(String state) { + for (YarnStateEnum stateEnum : YarnStateEnum.values()) { + if (stateEnum.name().equals(state)) { + return stateEnum; + } - } - - return UNKNOWN; } + + return UNKNOWN; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/exceptions/BizException.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/exceptions/BizException.java index 069ef73f..eca723d2 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/exceptions/BizException.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/exceptions/BizException.java @@ -12,48 +12,48 @@ @Data public class BizException extends RuntimeException { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final String ERROR_CODE_500 = SysErrorEnum.CUSTOMER_SYSTEM_ERROR.getCode(); - private static final String ERROR_MESSAGE_500 = SysErrorEnum.SYSTEM_ERROR.getErrorMsg(); + private static final String ERROR_CODE_500 = SysErrorEnum.CUSTOMER_SYSTEM_ERROR.getCode(); + private static final String ERROR_MESSAGE_500 = SysErrorEnum.SYSTEM_ERROR.getErrorMsg(); - /** - * 错误异常业务码 - */ - private String code; + /** + * 错误异常业务码 + */ + private String code; - private String errorMsg; + private String errorMsg; - public BizException(String errorMsg) { - super(errorMsg); - this.code = ERROR_CODE_500; - this.errorMsg = errorMsg; - } + public BizException(String errorMsg) { + super(errorMsg); + this.code = ERROR_CODE_500; + this.errorMsg = errorMsg; + } - public BizException(SysErrorEnum sysErrorEnum) { - super(sysErrorEnum.getErrorMsg()); - this.code = sysErrorEnum.getCode(); - this.errorMsg = sysErrorEnum.getErrorMsg(); - } + public BizException(SysErrorEnum sysErrorEnum) { + super(sysErrorEnum.getErrorMsg()); + this.code = sysErrorEnum.getCode(); + this.errorMsg = sysErrorEnum.getErrorMsg(); + } - public BizException(String errorMsg, String code) { - super(errorMsg); - this.code = code; - this.errorMsg = errorMsg; - } + public BizException(String errorMsg, String code) { + super(errorMsg); + this.code = code; + this.errorMsg = errorMsg; + } - public BizException(String errorMsg, Throwable cause, String code) { - super(errorMsg, cause); - this.code = code; - this.errorMsg = errorMsg; - } + public BizException(String errorMsg, Throwable cause, String code) { + super(errorMsg, cause); + this.code = code; + this.errorMsg = errorMsg; + } - public BizException(Throwable cause, String code) { - super(cause); - this.code = code; - this.errorMsg = ERROR_MESSAGE_500; - } + public BizException(Throwable cause, String code) { + super(cause); + this.code = code; + this.errorMsg = ERROR_MESSAGE_500; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/exceptions/GlobalException.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/exceptions/GlobalException.java index 1e04a90f..2b01ac5f 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/exceptions/GlobalException.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/exceptions/GlobalException.java @@ -19,46 +19,46 @@ @Slf4j public class GlobalException { - /** - * 处理自定义的业务异常 - * - * @param req - * @param e - * @return - */ - @ExceptionHandler(value = BizException.class) - @ResponseBody - public RestResult bizExceptionHandler(HttpServletRequest req, BizException e) { - log.error("发生业务异常!原因是:{}", e); - return RestResult.error(e.getCode(), e.getErrorMsg()); - } + /** + * 处理自定义的业务异常 + * + * @param req + * @param e + * @return + */ + @ExceptionHandler(value = BizException.class) + @ResponseBody + public RestResult bizExceptionHandler(HttpServletRequest req, BizException e) { + log.error("发生业务异常!原因是:{}", e); + return RestResult.error(e.getCode(), e.getErrorMsg()); + } - /** - * 处理空指针的异常 - * - * @param req - * @param e - * @return - */ - @ExceptionHandler(value = NullPointerException.class) - @ResponseBody - public RestResult exceptionHandler(HttpServletRequest req, NullPointerException e) { - log.error("发生空指针异常!原因是:", e); - return RestResult.error(SysErrorEnum.BODY_NOT_MATCH); - } + /** + * 处理空指针的异常 + * + * @param req + * @param e + * @return + */ + @ExceptionHandler(value = NullPointerException.class) + @ResponseBody + public RestResult exceptionHandler(HttpServletRequest req, NullPointerException e) { + log.error("发生空指针异常!原因是:", e); + return RestResult.error(SysErrorEnum.BODY_NOT_MATCH); + } - /** - * 处理其他异常 - * - * @param req - * @param e - * @return - */ - @ExceptionHandler(value = Exception.class) - @ResponseBody - public RestResult exceptionHandler(HttpServletRequest req, Exception e) { - log.error("未知异常!原因是:", e); - return RestResult.error(SysErrorEnum.INTERNAL_SERVER_ERROR); - } + /** + * 处理其他异常 + * + * @param req + * @param e + * @return + */ + @ExceptionHandler(value = Exception.class) + @ResponseBody + public RestResult exceptionHandler(HttpServletRequest req, Exception e) { + log.error("未知异常!原因是:", e); + return RestResult.error(SysErrorEnum.INTERNAL_SERVER_ERROR); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/AlartLogDTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/AlartLogDTO.java index 7e028287..a9d1d5ce 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/AlartLogDTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/AlartLogDTO.java @@ -17,102 +17,103 @@ @Data public class AlartLogDTO { - private Long id; + private Long id; - private Long jobConfigId; + private Long jobConfigId; - private String jobName; + private String jobName; - /** - * 消息内容 - */ - private String message; + /** + * 消息内容 + */ + private String message; - /** - * 1:钉钉 - */ - private AlarmLogTypeEnum alarMLogTypeEnum; + /** + * 1:钉钉 + */ + private AlarmLogTypeEnum alarMLogTypeEnum; - /** - * 1:成功 0:失败 - */ - private AlarmLogStatusEnum alarmLogStatusEnum; + /** + * 1:成功 0:失败 + */ + private AlarmLogStatusEnum alarmLogStatusEnum; - /** - * 失败原因 - */ - private String failLog; + /** + * 失败原因 + */ + private String failLog; - /** - * 创建时间 - */ - private Date createTime; + /** + * 创建时间 + */ + private Date createTime; - /** - * 修改时间 - */ - private Date editTime; + /** + * 修改时间 + */ + private Date editTime; - private String creator; + private String creator; - private String editor; + private String editor; - public static AlartLog toEntity(AlartLogDTO alartLogDTO) { - if (alartLogDTO == null) { - return null; - } - AlartLog alartLog = new AlartLog(); - alartLog.setId(alartLogDTO.getId()); - alartLog.setJobConfigId(alartLogDTO.getJobConfigId()); - alartLog.setMessage(alartLogDTO.getMessage()); - alartLog.setType(alartLogDTO.getAlarMLogTypeEnum().getCode()); - alartLog.setStatus(alartLogDTO.getAlarmLogStatusEnum().getCode()); - alartLog.setFailLog(alartLogDTO.getFailLog()); - alartLog.setCreateTime(alartLogDTO.getCreateTime()); - alartLog.setEditTime(alartLogDTO.getEditTime()); - alartLog.setCreator(alartLogDTO.getCreator()); - alartLog.setEditor(alartLogDTO.getEditor()); - alartLog.setJobName(alartLogDTO.getJobName()); - return alartLog; + public static AlartLog toEntity(AlartLogDTO alartLogDTO) { + if (alartLogDTO == null) { + return null; } - - public static AlartLogDTO toDTO(AlartLog alartLog) { - if (alartLog == null) { - return null; - } - AlartLogDTO alartLogDTO = new AlartLogDTO(); - alartLogDTO.setId(alartLog.getId()); - alartLogDTO.setJobConfigId(alartLog.getJobConfigId()); - alartLogDTO.setMessage(alartLog.getMessage()); - alartLogDTO.setAlarMLogTypeEnum(AlarmLogTypeEnum.getAlarmLogTypeEnum(alartLog.getType())); - alartLogDTO.setAlarmLogStatusEnum(AlarmLogStatusEnum.getAlarmLogStatusEnum(alartLog.getStatus())); - alartLogDTO.setFailLog(alartLog.getFailLog()); - alartLogDTO.setCreateTime(alartLog.getCreateTime()); - alartLogDTO.setEditTime(alartLog.getEditTime()); - alartLogDTO.setCreator(alartLog.getCreator()); - alartLogDTO.setEditor(alartLog.getEditor()); - alartLogDTO.setJobName(alartLog.getJobName()); - return alartLogDTO; + AlartLog alartLog = new AlartLog(); + alartLog.setId(alartLogDTO.getId()); + alartLog.setJobConfigId(alartLogDTO.getJobConfigId()); + alartLog.setMessage(alartLogDTO.getMessage()); + alartLog.setType(alartLogDTO.getAlarMLogTypeEnum().getCode()); + alartLog.setStatus(alartLogDTO.getAlarmLogStatusEnum().getCode()); + alartLog.setFailLog(alartLogDTO.getFailLog()); + alartLog.setCreateTime(alartLogDTO.getCreateTime()); + alartLog.setEditTime(alartLogDTO.getEditTime()); + alartLog.setCreator(alartLogDTO.getCreator()); + alartLog.setEditor(alartLogDTO.getEditor()); + alartLog.setJobName(alartLogDTO.getJobName()); + return alartLog; + } + + public static AlartLogDTO toDTO(AlartLog alartLog) { + if (alartLog == null) { + return null; } - - public static List toListDTO(List alartLogList) { - if (CollectionUtil.isEmpty(alartLogList)) { - return Collections.emptyList(); - } - List list = new ArrayList<>(); - for (AlartLog alartLog : alartLogList) { - AlartLogDTO alartLogDTO = AlartLogDTO.toDTO(alartLog); - if (alartLog != null) { - list.add(alartLogDTO); - } - } - return list; + AlartLogDTO alartLogDTO = new AlartLogDTO(); + alartLogDTO.setId(alartLog.getId()); + alartLogDTO.setJobConfigId(alartLog.getJobConfigId()); + alartLogDTO.setMessage(alartLog.getMessage()); + alartLogDTO.setAlarMLogTypeEnum(AlarmLogTypeEnum.getAlarmLogTypeEnum(alartLog.getType())); + alartLogDTO + .setAlarmLogStatusEnum(AlarmLogStatusEnum.getAlarmLogStatusEnum(alartLog.getStatus())); + alartLogDTO.setFailLog(alartLog.getFailLog()); + alartLogDTO.setCreateTime(alartLog.getCreateTime()); + alartLogDTO.setEditTime(alartLog.getEditTime()); + alartLogDTO.setCreator(alartLog.getCreator()); + alartLogDTO.setEditor(alartLog.getEditor()); + alartLogDTO.setJobName(alartLog.getJobName()); + return alartLogDTO; + } + + public static List toListDTO(List alartLogList) { + if (CollectionUtil.isEmpty(alartLogList)) { + return Collections.emptyList(); + } + List list = new ArrayList<>(); + for (AlartLog alartLog : alartLogList) { + AlartLogDTO alartLogDTO = AlartLogDTO.toDTO(alartLog); + if (alartLog != null) { + list.add(alartLogDTO); + } } + return list; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobAlarmConfigDTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobAlarmConfigDTO.java index 500e426d..1bdf6eb3 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobAlarmConfigDTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobAlarmConfigDTO.java @@ -17,66 +17,66 @@ @Data public class JobAlarmConfigDTO { - private Long id; - - /** - * job_config主表id - */ - private Long jobId; - - /** - * 类型 1:钉钉告警 2:url回调 3:异常自动拉起任务 - */ - private Integer type; - - - public static JobAlarmConfigDTO toDTO(JobAlarmConfig jobAlarmConfig) { - if (jobAlarmConfig == null) { - return null; - } - JobAlarmConfigDTO jobAlarmConfigDTO = new JobAlarmConfigDTO(); - jobAlarmConfigDTO.setId(jobAlarmConfig.getId()); - jobAlarmConfigDTO.setJobId(jobAlarmConfig.getJobId()); - jobAlarmConfigDTO.setType(jobAlarmConfig.getType()); - return jobAlarmConfigDTO; - } + private Long id; - public static JobAlarmConfig toEntity(JobAlarmConfigDTO jobAlarmConfigDTO) { - if (jobAlarmConfigDTO == null) { - return null; - } - JobAlarmConfig jobAlarmConfig = new JobAlarmConfig(); - jobAlarmConfig.setId(jobAlarmConfigDTO.getId()); - jobAlarmConfig.setJobId(jobAlarmConfigDTO.getJobId()); - jobAlarmConfig.setType(jobAlarmConfigDTO.getType()); - return jobAlarmConfig; - } + /** + * job_config主表id + */ + private Long jobId; - public static List toEntityList(List jobAlarmConfigDTOList) { - if (CollectionUtils.isEmpty(jobAlarmConfigDTOList)) { - return Collections.emptyList(); - } - List list = new ArrayList<>(); + /** + * 类型 1:钉钉告警 2:url回调 3:异常自动拉起任务 + */ + private Integer type; - for (JobAlarmConfigDTO jobAlarmConfigDTO : jobAlarmConfigDTOList) { - list.add(toEntity(jobAlarmConfigDTO)); - } - return list; + + public static JobAlarmConfigDTO toDTO(JobAlarmConfig jobAlarmConfig) { + if (jobAlarmConfig == null) { + return null; + } + JobAlarmConfigDTO jobAlarmConfigDTO = new JobAlarmConfigDTO(); + jobAlarmConfigDTO.setId(jobAlarmConfig.getId()); + jobAlarmConfigDTO.setJobId(jobAlarmConfig.getJobId()); + jobAlarmConfigDTO.setType(jobAlarmConfig.getType()); + return jobAlarmConfigDTO; + } + + public static JobAlarmConfig toEntity(JobAlarmConfigDTO jobAlarmConfigDTO) { + if (jobAlarmConfigDTO == null) { + return null; } + JobAlarmConfig jobAlarmConfig = new JobAlarmConfig(); + jobAlarmConfig.setId(jobAlarmConfigDTO.getId()); + jobAlarmConfig.setJobId(jobAlarmConfigDTO.getJobId()); + jobAlarmConfig.setType(jobAlarmConfigDTO.getType()); + return jobAlarmConfig; + } + + public static List toEntityList(List jobAlarmConfigDTOList) { + if (CollectionUtils.isEmpty(jobAlarmConfigDTOList)) { + return Collections.emptyList(); + } + List list = new ArrayList<>(); + for (JobAlarmConfigDTO jobAlarmConfigDTO : jobAlarmConfigDTOList) { + list.add(toEntity(jobAlarmConfigDTO)); + } + return list; + } - public static List toListDTO(List jobAlarmConfigList) { - if (CollectionUtil.isEmpty(jobAlarmConfigList)) { - return Collections.emptyList(); - } - List list = new ArrayList<>(); - for (JobAlarmConfig jobAlarmConfig : jobAlarmConfigList) { - list.add(toDTO(jobAlarmConfig)); - } - return list; + public static List toListDTO(List jobAlarmConfigList) { + if (CollectionUtil.isEmpty(jobAlarmConfigList)) { + return Collections.emptyList(); + } + List list = new ArrayList<>(); + for (JobAlarmConfig jobAlarmConfig : jobAlarmConfigList) { + list.add(toDTO(jobAlarmConfig)); } + return list; + + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobConfigDTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobConfigDTO.java index 8d144bc3..b9956e01 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobConfigDTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobConfigDTO.java @@ -22,214 +22,213 @@ @Data public class JobConfigDTO implements Serializable { - private static final long serialVersionUID = 1L; - - private Long id; - - /** - * 任务名称 - */ - private String jobName; - - /** - * 任务描述 - */ - private String jobDesc; - - /** - * flink的模式 - */ - private DeployModeEnum deployModeEnum; - - /** - * flink运行配置 - */ - private String flinkRunConfig; - - /** - * checkpointConfig 配置 - */ - private String flinkCheckpointConfig; - - /** - * flink运行配置 - */ - private String jobId; - - /** - * 1:开启 0: 关闭 - */ - private Integer isOpen; - - /** - * @see JobConfigStatus - * 1:运行中 0: 停止中 -1:运行失败 - */ - private JobConfigStatus status; - - - /** - * 三方jar udf、 连接器 等jar如http://xxx.xxx.com/flink-streaming-udf.jar - */ - private String extJarPath; - - /** - * 最后一次启动时间 - */ - private Date lastStartTime; - - /** - * 更新版本号 用于乐观锁 - */ - private Integer version; - - /** - * sql语句 - */ - private String flinkSql; - - - /** - * 任务类型 - */ - private JobTypeEnum jobTypeEnum; - - /** - * 启动jar可能需要使用的自定义参数 - */ - private String customArgs; - - /** - * 程序入口类 - */ - private String customMainClass; - - /** - * 自定义jar的http地址 如:http://ccblog.cn/xx.jar - */ - private String customJarUrl; - - private List alarmTypes; - - private List alarmTypeEnumList; - - private Long lastRunLogId; - - - /** - * 创建时间 - */ - private Date createTime; - - /** - * 修改时间 - */ - private Date editTime; - - private String creator; - - private String editor; - - private String flinkRunUrl; - - private String alarmStrs; - - private Integer isDeleted; - - public static JobConfig toEntity(JobConfigDTO jobConfigDTO) { - if (jobConfigDTO == null) { - return null; - } - JobConfig jobConfig = new JobConfig(); - jobConfig.setId(jobConfigDTO.getId()); - jobConfig.setJobName(jobConfigDTO.getJobName()); - jobConfig.setJobDesc(jobConfigDTO.getJobDesc()); - if (jobConfigDTO.getDeployModeEnum() != null) { - jobConfig.setDeployMode(jobConfigDTO.getDeployModeEnum().name()); - } - jobConfig.setFlinkRunConfig(jobConfigDTO.getFlinkRunConfig()); - jobConfig.setFlinkCheckpointConfig(jobConfigDTO.getFlinkCheckpointConfig()); - jobConfig.setJobId(jobConfigDTO.getJobId()); - jobConfig.setIsOpen(jobConfigDTO.getIsOpen()); - jobConfig.setStatus(jobConfigDTO.getStatus().getCode()); - jobConfig.setLastStartTime(jobConfigDTO.getLastStartTime()); - jobConfig.setVersion(jobConfigDTO.getVersion()); - jobConfig.setFlinkSql(jobConfigDTO.getFlinkSql()); - jobConfig.setCreateTime(jobConfigDTO.getCreateTime()); - jobConfig.setEditTime(jobConfigDTO.getEditTime()); - jobConfig.setCreator(jobConfigDTO.getCreator()); - jobConfig.setEditor(jobConfigDTO.getEditor()); - jobConfig.setLastRunLogId(jobConfigDTO.getLastRunLogId()); - jobConfig.setExtJarPath(jobConfigDTO.getExtJarPath()); - - if (jobConfigDTO.getJobTypeEnum() != null) { - jobConfig.setJobType(jobConfigDTO.getJobTypeEnum().getCode()); - } - jobConfig.setCustomArgs(jobConfigDTO.getCustomArgs()); - jobConfig.setCustomMainClass(jobConfigDTO.getCustomMainClass()); - jobConfig.setCustomJarUrl(jobConfigDTO.getCustomJarUrl()); - jobConfig.setIsDeleted(jobConfigDTO.getIsDeleted()); - return jobConfig; - } + private static final long serialVersionUID = 1L; - public static JobConfigDTO toDTO(JobConfig jobConfig) { - if (jobConfig == null) { - return null; - } - JobConfigDTO jobConfigDTO = new JobConfigDTO(); - jobConfigDTO.setId(jobConfig.getId()); - jobConfigDTO.setJobName(jobConfig.getJobName()); - jobConfigDTO.setJobDesc(jobConfig.getJobDesc()); - jobConfigDTO.setDeployModeEnum(DeployModeEnum.getModel(jobConfig.getDeployMode())); - jobConfigDTO.setFlinkRunConfig(jobConfig.getFlinkRunConfig()); - jobConfigDTO.setFlinkCheckpointConfig(jobConfig.getFlinkCheckpointConfig()); - jobConfigDTO.setJobId(jobConfig.getJobId()); - jobConfigDTO.setIsOpen(jobConfig.getIsOpen()); - jobConfigDTO.setStatus(JobConfigStatus.getJobConfigStatus(jobConfig.getStatus())); - jobConfigDTO.setLastStartTime(jobConfig.getLastStartTime()); - jobConfigDTO.setVersion(jobConfig.getVersion()); - jobConfigDTO.setCreateTime(jobConfig.getCreateTime()); - jobConfigDTO.setEditTime(jobConfig.getEditTime()); - jobConfigDTO.setCreator(jobConfig.getCreator()); - jobConfigDTO.setEditor(jobConfig.getEditor()); - jobConfigDTO.setFlinkSql(jobConfig.getFlinkSql()); - jobConfigDTO.setLastRunLogId(jobConfig.getLastRunLogId()); - jobConfigDTO.setExtJarPath(jobConfig.getExtJarPath()); - - jobConfigDTO.setJobTypeEnum(JobTypeEnum.getJobTypeEnum(jobConfig.getJobType())); - jobConfigDTO.setCustomArgs(jobConfig.getCustomArgs()); - jobConfigDTO.setCustomMainClass(jobConfig.getCustomMainClass()); - jobConfigDTO.setCustomJarUrl(jobConfig.getCustomJarUrl()); - jobConfigDTO.setIsDeleted(jobConfig.getIsDeleted()); - return jobConfigDTO; - } + private Long id; - public static List toListDTO(List jobConfigList) { - if (CollectionUtils.isEmpty(jobConfigList)) { - return Collections.emptyList(); - } + /** + * 任务名称 + */ + private String jobName; - List jobConfigDTOList = new ArrayList(); + /** + * 任务描述 + */ + private String jobDesc; - for (JobConfig jobConfig : jobConfigList) { - jobConfigDTOList.add(toDTO(jobConfig)); - } + /** + * flink的模式 + */ + private DeployModeEnum deployModeEnum; - return jobConfigDTOList; - } + /** + * flink运行配置 + */ + private String flinkRunConfig; + + /** + * checkpointConfig 配置 + */ + private String flinkCheckpointConfig; + + /** + * flink运行配置 + */ + private String jobId; + + /** + * 1:开启 0: 关闭 + */ + private Integer isOpen; + + /** + * @see JobConfigStatus 1:运行中 0: 停止中 -1:运行失败 + */ + private JobConfigStatus status; + + + /** + * 三方jar udf、 连接器 等jar如http://xxx.xxx.com/flink-streaming-udf.jar + */ + private String extJarPath; + + /** + * 最后一次启动时间 + */ + private Date lastStartTime; + + /** + * 更新版本号 用于乐观锁 + */ + private Integer version; + + /** + * sql语句 + */ + private String flinkSql; + + + /** + * 任务类型 + */ + private JobTypeEnum jobTypeEnum; + + /** + * 启动jar可能需要使用的自定义参数 + */ + private String customArgs; + + /** + * 程序入口类 + */ + private String customMainClass; + + /** + * 自定义jar的http地址 如:http://ccblog.cn/xx.jar + */ + private String customJarUrl; + + private List alarmTypes; - public static String buildRunName(String jobName) { + private List alarmTypeEnumList; - return "flink@" + jobName; + private Long lastRunLogId; + + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date editTime; + + private String creator; + + private String editor; + + private String flinkRunUrl; + + private String alarmStrs; + + private Integer isDeleted; + + public static JobConfig toEntity(JobConfigDTO jobConfigDTO) { + if (jobConfigDTO == null) { + return null; } + JobConfig jobConfig = new JobConfig(); + jobConfig.setId(jobConfigDTO.getId()); + jobConfig.setJobName(jobConfigDTO.getJobName()); + jobConfig.setJobDesc(jobConfigDTO.getJobDesc()); + if (jobConfigDTO.getDeployModeEnum() != null) { + jobConfig.setDeployMode(jobConfigDTO.getDeployModeEnum().name()); + } + jobConfig.setFlinkRunConfig(jobConfigDTO.getFlinkRunConfig()); + jobConfig.setFlinkCheckpointConfig(jobConfigDTO.getFlinkCheckpointConfig()); + jobConfig.setJobId(jobConfigDTO.getJobId()); + jobConfig.setIsOpen(jobConfigDTO.getIsOpen()); + jobConfig.setStatus(jobConfigDTO.getStatus().getCode()); + jobConfig.setLastStartTime(jobConfigDTO.getLastStartTime()); + jobConfig.setVersion(jobConfigDTO.getVersion()); + jobConfig.setFlinkSql(jobConfigDTO.getFlinkSql()); + jobConfig.setCreateTime(jobConfigDTO.getCreateTime()); + jobConfig.setEditTime(jobConfigDTO.getEditTime()); + jobConfig.setCreator(jobConfigDTO.getCreator()); + jobConfig.setEditor(jobConfigDTO.getEditor()); + jobConfig.setLastRunLogId(jobConfigDTO.getLastRunLogId()); + jobConfig.setExtJarPath(jobConfigDTO.getExtJarPath()); + + if (jobConfigDTO.getJobTypeEnum() != null) { + jobConfig.setJobType(jobConfigDTO.getJobTypeEnum().getCode()); + } + jobConfig.setCustomArgs(jobConfigDTO.getCustomArgs()); + jobConfig.setCustomMainClass(jobConfigDTO.getCustomMainClass()); + jobConfig.setCustomJarUrl(jobConfigDTO.getCustomJarUrl()); + jobConfig.setIsDeleted(jobConfigDTO.getIsDeleted()); + return jobConfig; + } + + public static JobConfigDTO toDTO(JobConfig jobConfig) { + if (jobConfig == null) { + return null; + } + JobConfigDTO jobConfigDTO = new JobConfigDTO(); + jobConfigDTO.setId(jobConfig.getId()); + jobConfigDTO.setJobName(jobConfig.getJobName()); + jobConfigDTO.setJobDesc(jobConfig.getJobDesc()); + jobConfigDTO.setDeployModeEnum(DeployModeEnum.getModel(jobConfig.getDeployMode())); + jobConfigDTO.setFlinkRunConfig(jobConfig.getFlinkRunConfig()); + jobConfigDTO.setFlinkCheckpointConfig(jobConfig.getFlinkCheckpointConfig()); + jobConfigDTO.setJobId(jobConfig.getJobId()); + jobConfigDTO.setIsOpen(jobConfig.getIsOpen()); + jobConfigDTO.setStatus(JobConfigStatus.getJobConfigStatus(jobConfig.getStatus())); + jobConfigDTO.setLastStartTime(jobConfig.getLastStartTime()); + jobConfigDTO.setVersion(jobConfig.getVersion()); + jobConfigDTO.setCreateTime(jobConfig.getCreateTime()); + jobConfigDTO.setEditTime(jobConfig.getEditTime()); + jobConfigDTO.setCreator(jobConfig.getCreator()); + jobConfigDTO.setEditor(jobConfig.getEditor()); + jobConfigDTO.setFlinkSql(jobConfig.getFlinkSql()); + jobConfigDTO.setLastRunLogId(jobConfig.getLastRunLogId()); + jobConfigDTO.setExtJarPath(jobConfig.getExtJarPath()); + + jobConfigDTO.setJobTypeEnum(JobTypeEnum.getJobTypeEnum(jobConfig.getJobType())); + jobConfigDTO.setCustomArgs(jobConfig.getCustomArgs()); + jobConfigDTO.setCustomMainClass(jobConfig.getCustomMainClass()); + jobConfigDTO.setCustomJarUrl(jobConfig.getCustomJarUrl()); + jobConfigDTO.setIsDeleted(jobConfig.getIsDeleted()); + return jobConfigDTO; + } + + public static List toListDTO(List jobConfigList) { + if (CollectionUtils.isEmpty(jobConfigList)) { + return Collections.emptyList(); + } + + List jobConfigDTOList = new ArrayList(); - public static JobConfigDTO bulidStop(Long id) { - JobConfigDTO jobConfig = new JobConfigDTO(); - jobConfig.setStatus(JobConfigStatus.STOP); - jobConfig.setEditor("sys_auto"); - jobConfig.setId(id); - // jobConfig.setJobId(""); - return jobConfig; + for (JobConfig jobConfig : jobConfigList) { + jobConfigDTOList.add(toDTO(jobConfig)); } + return jobConfigDTOList; + } + + public static String buildRunName(String jobName) { + + return "flink@" + jobName; + } + + public static JobConfigDTO bulidStop(Long id) { + JobConfigDTO jobConfig = new JobConfigDTO(); + jobConfig.setStatus(JobConfigStatus.STOP); + jobConfig.setEditor("sys_auto"); + jobConfig.setId(id); + // jobConfig.setJobId(""); + return jobConfig; + } + } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobConfigHistoryDTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobConfigHistoryDTO.java index c86b2bcd..49d9597e 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobConfigHistoryDTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobConfigHistoryDTO.java @@ -21,162 +21,162 @@ @Data public class JobConfigHistoryDTO implements Serializable { - private static final long serialVersionUID = 1L; - - private Long id; - - /** - * job_config主表Id - */ - private Long jobConfigId; - - /** - * 任务名称 - */ - private String jobName; - - /** - * 任务描述 - */ - private String jobDesc; - - /** - * 提交模式: standalone 、yarn 、yarn-session - */ - private String deployMode; - - /** - * flink运行配置 - */ - private String flinkRunConfig; - - /** - * checkPoint配置 - */ - private String flinkCheckpointConfig; - - /** - * udf地址及连接器jar 如http://xxx.xxx.com/flink-streaming-udf.jar - */ - private String extJarPath; - - /** - * 更新版本号 - */ - private Integer version; - - /** - * 创建时间 - */ - private Date createTime; - - /** - * 修改时间 - */ - private Date editTime; - - private String creator; - - private String editor; - - /** - * sql语句 - */ - private String flinkSql; - - /** - * 任务类型 - */ - private JobTypeEnum jobTypeEnum; - - - public static JobConfigHistory toEntity(JobConfigHistoryDTO jobConfigHistoryDTO) { - if (jobConfigHistoryDTO == null) { - return null; - } - JobConfigHistory jobConfigHistory = new JobConfigHistory(); - jobConfigHistory.setId(jobConfigHistoryDTO.getId()); - jobConfigHistory.setJobConfigId(jobConfigHistoryDTO.getJobConfigId()); - jobConfigHistory.setJobName(jobConfigHistoryDTO.getJobName()); - jobConfigHistory.setJobDesc(jobConfigHistoryDTO.getJobDesc()); - jobConfigHistory.setDeployMode(jobConfigHistoryDTO.getDeployMode()); - jobConfigHistory.setFlinkRunConfig(jobConfigHistoryDTO.getFlinkRunConfig()); - jobConfigHistory.setFlinkCheckpointConfig(jobConfigHistoryDTO.getFlinkCheckpointConfig()); - jobConfigHistory.setExtJarPath(jobConfigHistoryDTO.getExtJarPath()); - jobConfigHistory.setVersion(jobConfigHistoryDTO.getVersion()); - jobConfigHistory.setCreateTime(jobConfigHistoryDTO.getCreateTime()); - jobConfigHistory.setEditTime(jobConfigHistoryDTO.getEditTime()); - jobConfigHistory.setCreator(jobConfigHistoryDTO.getCreator()); - jobConfigHistory.setEditor(jobConfigHistoryDTO.getEditor()); - jobConfigHistory.setFlinkSql(jobConfigHistoryDTO.getFlinkSql()); - if (jobConfigHistoryDTO.getJobTypeEnum() != null) { - jobConfigHistory.setJobType(jobConfigHistoryDTO.getJobTypeEnum().getCode()); - } - return jobConfigHistory; + private static final long serialVersionUID = 1L; + + private Long id; + + /** + * job_config主表Id + */ + private Long jobConfigId; + + /** + * 任务名称 + */ + private String jobName; + + /** + * 任务描述 + */ + private String jobDesc; + + /** + * 提交模式: standalone 、yarn 、yarn-session + */ + private String deployMode; + + /** + * flink运行配置 + */ + private String flinkRunConfig; + + /** + * checkPoint配置 + */ + private String flinkCheckpointConfig; + + /** + * udf地址及连接器jar 如http://xxx.xxx.com/flink-streaming-udf.jar + */ + private String extJarPath; + + /** + * 更新版本号 + */ + private Integer version; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date editTime; + + private String creator; + + private String editor; + + /** + * sql语句 + */ + private String flinkSql; + + /** + * 任务类型 + */ + private JobTypeEnum jobTypeEnum; + + + public static JobConfigHistory toEntity(JobConfigHistoryDTO jobConfigHistoryDTO) { + if (jobConfigHistoryDTO == null) { + return null; } - - - public static JobConfigHistoryDTO toDTO(JobConfigHistory jobConfigHistory) { - if (jobConfigHistory == null) { - return null; - } - JobConfigHistoryDTO jobConfigHistoryDTO = new JobConfigHistoryDTO(); - jobConfigHistoryDTO.setId(jobConfigHistory.getId()); - jobConfigHistoryDTO.setJobConfigId(jobConfigHistory.getJobConfigId()); - jobConfigHistoryDTO.setJobName(jobConfigHistory.getJobName()); - jobConfigHistoryDTO.setJobDesc(jobConfigHistory.getJobDesc()); - jobConfigHistoryDTO.setDeployMode(jobConfigHistory.getDeployMode()); - jobConfigHistoryDTO.setFlinkRunConfig(jobConfigHistory.getFlinkRunConfig()); - jobConfigHistoryDTO.setFlinkCheckpointConfig(jobConfigHistory.getFlinkCheckpointConfig()); - jobConfigHistoryDTO.setExtJarPath(jobConfigHistory.getExtJarPath()); - jobConfigHistoryDTO.setVersion(jobConfigHistory.getVersion()); - jobConfigHistoryDTO.setCreateTime(jobConfigHistory.getCreateTime()); - jobConfigHistoryDTO.setEditTime(jobConfigHistory.getEditTime()); - jobConfigHistoryDTO.setCreator(jobConfigHistory.getCreator()); - jobConfigHistoryDTO.setEditor(jobConfigHistory.getEditor()); - jobConfigHistoryDTO.setFlinkSql(jobConfigHistory.getFlinkSql()); - jobConfigHistoryDTO.setJobTypeEnum(JobTypeEnum.getJobTypeEnum(jobConfigHistory.getJobType())); - return jobConfigHistoryDTO; + JobConfigHistory jobConfigHistory = new JobConfigHistory(); + jobConfigHistory.setId(jobConfigHistoryDTO.getId()); + jobConfigHistory.setJobConfigId(jobConfigHistoryDTO.getJobConfigId()); + jobConfigHistory.setJobName(jobConfigHistoryDTO.getJobName()); + jobConfigHistory.setJobDesc(jobConfigHistoryDTO.getJobDesc()); + jobConfigHistory.setDeployMode(jobConfigHistoryDTO.getDeployMode()); + jobConfigHistory.setFlinkRunConfig(jobConfigHistoryDTO.getFlinkRunConfig()); + jobConfigHistory.setFlinkCheckpointConfig(jobConfigHistoryDTO.getFlinkCheckpointConfig()); + jobConfigHistory.setExtJarPath(jobConfigHistoryDTO.getExtJarPath()); + jobConfigHistory.setVersion(jobConfigHistoryDTO.getVersion()); + jobConfigHistory.setCreateTime(jobConfigHistoryDTO.getCreateTime()); + jobConfigHistory.setEditTime(jobConfigHistoryDTO.getEditTime()); + jobConfigHistory.setCreator(jobConfigHistoryDTO.getCreator()); + jobConfigHistory.setEditor(jobConfigHistoryDTO.getEditor()); + jobConfigHistory.setFlinkSql(jobConfigHistoryDTO.getFlinkSql()); + if (jobConfigHistoryDTO.getJobTypeEnum() != null) { + jobConfigHistory.setJobType(jobConfigHistoryDTO.getJobTypeEnum().getCode()); } + return jobConfigHistory; + } - public static List toListDTO(List jobConfigHistoryList) { - if (CollectionUtil.isEmpty(jobConfigHistoryList)) { - return Collections.EMPTY_LIST; - } - List list = Lists.newArrayList(); + public static JobConfigHistoryDTO toDTO(JobConfigHistory jobConfigHistory) { + if (jobConfigHistory == null) { + return null; + } + JobConfigHistoryDTO jobConfigHistoryDTO = new JobConfigHistoryDTO(); + jobConfigHistoryDTO.setId(jobConfigHistory.getId()); + jobConfigHistoryDTO.setJobConfigId(jobConfigHistory.getJobConfigId()); + jobConfigHistoryDTO.setJobName(jobConfigHistory.getJobName()); + jobConfigHistoryDTO.setJobDesc(jobConfigHistory.getJobDesc()); + jobConfigHistoryDTO.setDeployMode(jobConfigHistory.getDeployMode()); + jobConfigHistoryDTO.setFlinkRunConfig(jobConfigHistory.getFlinkRunConfig()); + jobConfigHistoryDTO.setFlinkCheckpointConfig(jobConfigHistory.getFlinkCheckpointConfig()); + jobConfigHistoryDTO.setExtJarPath(jobConfigHistory.getExtJarPath()); + jobConfigHistoryDTO.setVersion(jobConfigHistory.getVersion()); + jobConfigHistoryDTO.setCreateTime(jobConfigHistory.getCreateTime()); + jobConfigHistoryDTO.setEditTime(jobConfigHistory.getEditTime()); + jobConfigHistoryDTO.setCreator(jobConfigHistory.getCreator()); + jobConfigHistoryDTO.setEditor(jobConfigHistory.getEditor()); + jobConfigHistoryDTO.setFlinkSql(jobConfigHistory.getFlinkSql()); + jobConfigHistoryDTO.setJobTypeEnum(JobTypeEnum.getJobTypeEnum(jobConfigHistory.getJobType())); + return jobConfigHistoryDTO; + } + + public static List toListDTO(List jobConfigHistoryList) { + if (CollectionUtil.isEmpty(jobConfigHistoryList)) { + return Collections.EMPTY_LIST; + } - for (JobConfigHistory jobConfigHistory : jobConfigHistoryList) { + List list = Lists.newArrayList(); - JobConfigHistoryDTO jobConfigHistoryDTO = JobConfigHistoryDTO.toDTO(jobConfigHistory); - if (jobConfigHistoryDTO != null) { - list.add(jobConfigHistoryDTO); - } - } + for (JobConfigHistory jobConfigHistory : jobConfigHistoryList) { - return list; + JobConfigHistoryDTO jobConfigHistoryDTO = JobConfigHistoryDTO.toDTO(jobConfigHistory); + if (jobConfigHistoryDTO != null) { + list.add(jobConfigHistoryDTO); + } } + return list; + } + - public static JobConfigHistoryDTO to(JobConfig jobConfig) { - if (jobConfig == null) { - return null; - } - JobConfigHistoryDTO jobConfigHistoryDTO = new JobConfigHistoryDTO(); - jobConfigHistoryDTO.setJobConfigId (jobConfig.getId()); - jobConfigHistoryDTO.setJobName(jobConfig.getJobName()); - jobConfigHistoryDTO.setJobDesc(jobConfig.getJobDesc()); - jobConfigHistoryDTO.setDeployMode(jobConfig.getDeployMode()); - jobConfigHistoryDTO.setFlinkRunConfig(jobConfig.getFlinkRunConfig()); - jobConfigHistoryDTO.setFlinkCheckpointConfig(jobConfig.getFlinkCheckpointConfig()); - jobConfigHistoryDTO.setExtJarPath(jobConfig.getExtJarPath()); - jobConfigHistoryDTO.setVersion(jobConfig.getVersion()); - jobConfigHistoryDTO.setCreateTime(jobConfig.getCreateTime()); - jobConfigHistoryDTO.setEditTime(jobConfig.getEditTime()); - jobConfigHistoryDTO.setCreator(jobConfig.getCreator()); - jobConfigHistoryDTO.setEditor(jobConfig.getEditor()); - jobConfigHistoryDTO.setFlinkSql(jobConfig.getFlinkSql()); - jobConfigHistoryDTO.setJobTypeEnum(JobTypeEnum.getJobTypeEnum(jobConfig.getJobType())); - return jobConfigHistoryDTO; + public static JobConfigHistoryDTO to(JobConfig jobConfig) { + if (jobConfig == null) { + return null; } + JobConfigHistoryDTO jobConfigHistoryDTO = new JobConfigHistoryDTO(); + jobConfigHistoryDTO.setJobConfigId(jobConfig.getId()); + jobConfigHistoryDTO.setJobName(jobConfig.getJobName()); + jobConfigHistoryDTO.setJobDesc(jobConfig.getJobDesc()); + jobConfigHistoryDTO.setDeployMode(jobConfig.getDeployMode()); + jobConfigHistoryDTO.setFlinkRunConfig(jobConfig.getFlinkRunConfig()); + jobConfigHistoryDTO.setFlinkCheckpointConfig(jobConfig.getFlinkCheckpointConfig()); + jobConfigHistoryDTO.setExtJarPath(jobConfig.getExtJarPath()); + jobConfigHistoryDTO.setVersion(jobConfig.getVersion()); + jobConfigHistoryDTO.setCreateTime(jobConfig.getCreateTime()); + jobConfigHistoryDTO.setEditTime(jobConfig.getEditTime()); + jobConfigHistoryDTO.setCreator(jobConfig.getCreator()); + jobConfigHistoryDTO.setEditor(jobConfig.getEditor()); + jobConfigHistoryDTO.setFlinkSql(jobConfig.getFlinkSql()); + jobConfigHistoryDTO.setJobTypeEnum(JobTypeEnum.getJobTypeEnum(jobConfig.getJobType())); + return jobConfigHistoryDTO; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobRunLogDTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobRunLogDTO.java index e72650ca..938d798a 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobRunLogDTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobRunLogDTO.java @@ -18,138 +18,138 @@ @Data public class JobRunLogDTO implements Serializable { - private static final long serialVersionUID = 1L; - - private Long id; - - private Long jobConfigId; - - /** - * 任务名称 - */ - private String jobName; - - /** - * 任务描述 - */ - private String jobDesc; - - /** - * 提交模式: standalone 、yarn 、yarn-session - */ - private String deployMode; - - /** - * 运行后的任务id - */ - private String jobId; - - /** - * 远程日志url的地址 - */ - private String remoteLogUrl; - - /** - * 启动时间 - */ - private Date startTime; - - /** - * 结束时间 - */ - private Date endTime; - - /** - * 任务状态 - */ - private String jobStatus; - - - private String creator; - - private String editor; - - /** - * 创建时间 - */ - private Date createTime; - - /** - * 修改时间 - */ - private Date editTime; - - - /** - * 启动时本地日志 - */ - private String localLog; - - private String runIp; - - - public static JobRunLog toEntity(JobRunLogDTO jobRunLogDTO) { - if (jobRunLogDTO == null) { - return null; - } - JobRunLog jobRunLog = new JobRunLog(); - jobRunLog.setId(jobRunLogDTO.getId()); - jobRunLog.setJobConfigId(jobRunLogDTO.getJobConfigId()); - jobRunLog.setJobName(jobRunLogDTO.getJobName()); - jobRunLog.setJobDesc(jobRunLogDTO.getJobDesc()); - jobRunLog.setDeployMode(jobRunLogDTO.getDeployMode()); - jobRunLog.setJobId(jobRunLogDTO.getJobId()); - jobRunLog.setRemoteLogUrl(jobRunLogDTO.getRemoteLogUrl()); - jobRunLog.setStartTime(jobRunLogDTO.getStartTime()); - jobRunLog.setEndTime(jobRunLogDTO.getEndTime()); - jobRunLog.setJobStatus(jobRunLogDTO.getJobStatus()); - jobRunLog.setCreator(jobRunLogDTO.getCreator()); - jobRunLog.setEditor(jobRunLogDTO.getEditor()); - jobRunLog.setCreateTime(jobRunLogDTO.getCreateTime()); - jobRunLog.setEditTime(jobRunLogDTO.getEditTime()); - jobRunLog.setLocalLog(jobRunLogDTO.getLocalLog()); - jobRunLog.setRunIp(jobRunLogDTO.getRunIp()); - return jobRunLog; - } + private static final long serialVersionUID = 1L; + private Long id; + + private Long jobConfigId; + + /** + * 任务名称 + */ + private String jobName; + + /** + * 任务描述 + */ + private String jobDesc; + + /** + * 提交模式: standalone 、yarn 、yarn-session + */ + private String deployMode; + + /** + * 运行后的任务id + */ + private String jobId; + + /** + * 远程日志url的地址 + */ + private String remoteLogUrl; + + /** + * 启动时间 + */ + private Date startTime; + + /** + * 结束时间 + */ + private Date endTime; + + /** + * 任务状态 + */ + private String jobStatus; - public static JobRunLogDTO toDTO(JobRunLog jobRunLog) { - if (jobRunLog == null) { - return null; - } - JobRunLogDTO jobRunLogDTO = new JobRunLogDTO(); - jobRunLogDTO.setId(jobRunLog.getId()); - jobRunLogDTO.setJobConfigId(jobRunLog.getJobConfigId()); - jobRunLogDTO.setJobName(jobRunLog.getJobName()); - jobRunLogDTO.setJobDesc(jobRunLog.getJobDesc()); - jobRunLogDTO.setDeployMode(jobRunLog.getDeployMode()); - jobRunLogDTO.setJobId(jobRunLog.getJobId()); - jobRunLogDTO.setRemoteLogUrl(jobRunLog.getRemoteLogUrl()); - jobRunLogDTO.setStartTime(jobRunLog.getStartTime()); - jobRunLogDTO.setEndTime(jobRunLog.getEndTime()); - jobRunLogDTO.setJobStatus(jobRunLog.getJobStatus()); - jobRunLogDTO.setCreateTime(jobRunLog.getCreateTime()); - jobRunLogDTO.setEditTime(jobRunLog.getEditTime()); - jobRunLogDTO.setCreator(jobRunLog.getCreator()); - jobRunLogDTO.setEditor(jobRunLog.getEditor()); - jobRunLogDTO.setLocalLog(jobRunLog.getLocalLog()); - jobRunLogDTO.setRunIp(jobRunLog.getRunIp()); - return jobRunLogDTO; - } - public static List toListDTO(List jobRunLogList) { - if (CollectionUtils.isEmpty(jobRunLogList)) { - return Collections.emptyList(); - } - List list = new ArrayList<>(); + private String creator; - for (JobRunLog jobRunLog : jobRunLogList) { - list.add(JobRunLogDTO.toDTO(jobRunLog)); - } - return list; + private String editor; + /** + * 创建时间 + */ + private Date createTime; + /** + * 修改时间 + */ + private Date editTime; + + + /** + * 启动时本地日志 + */ + private String localLog; + + private String runIp; + + + public static JobRunLog toEntity(JobRunLogDTO jobRunLogDTO) { + if (jobRunLogDTO == null) { + return null; + } + JobRunLog jobRunLog = new JobRunLog(); + jobRunLog.setId(jobRunLogDTO.getId()); + jobRunLog.setJobConfigId(jobRunLogDTO.getJobConfigId()); + jobRunLog.setJobName(jobRunLogDTO.getJobName()); + jobRunLog.setJobDesc(jobRunLogDTO.getJobDesc()); + jobRunLog.setDeployMode(jobRunLogDTO.getDeployMode()); + jobRunLog.setJobId(jobRunLogDTO.getJobId()); + jobRunLog.setRemoteLogUrl(jobRunLogDTO.getRemoteLogUrl()); + jobRunLog.setStartTime(jobRunLogDTO.getStartTime()); + jobRunLog.setEndTime(jobRunLogDTO.getEndTime()); + jobRunLog.setJobStatus(jobRunLogDTO.getJobStatus()); + jobRunLog.setCreator(jobRunLogDTO.getCreator()); + jobRunLog.setEditor(jobRunLogDTO.getEditor()); + jobRunLog.setCreateTime(jobRunLogDTO.getCreateTime()); + jobRunLog.setEditTime(jobRunLogDTO.getEditTime()); + jobRunLog.setLocalLog(jobRunLogDTO.getLocalLog()); + jobRunLog.setRunIp(jobRunLogDTO.getRunIp()); + return jobRunLog; + } + + + public static JobRunLogDTO toDTO(JobRunLog jobRunLog) { + if (jobRunLog == null) { + return null; } + JobRunLogDTO jobRunLogDTO = new JobRunLogDTO(); + jobRunLogDTO.setId(jobRunLog.getId()); + jobRunLogDTO.setJobConfigId(jobRunLog.getJobConfigId()); + jobRunLogDTO.setJobName(jobRunLog.getJobName()); + jobRunLogDTO.setJobDesc(jobRunLog.getJobDesc()); + jobRunLogDTO.setDeployMode(jobRunLog.getDeployMode()); + jobRunLogDTO.setJobId(jobRunLog.getJobId()); + jobRunLogDTO.setRemoteLogUrl(jobRunLog.getRemoteLogUrl()); + jobRunLogDTO.setStartTime(jobRunLog.getStartTime()); + jobRunLogDTO.setEndTime(jobRunLog.getEndTime()); + jobRunLogDTO.setJobStatus(jobRunLog.getJobStatus()); + jobRunLogDTO.setCreateTime(jobRunLog.getCreateTime()); + jobRunLogDTO.setEditTime(jobRunLog.getEditTime()); + jobRunLogDTO.setCreator(jobRunLog.getCreator()); + jobRunLogDTO.setEditor(jobRunLog.getEditor()); + jobRunLogDTO.setLocalLog(jobRunLog.getLocalLog()); + jobRunLogDTO.setRunIp(jobRunLog.getRunIp()); + return jobRunLogDTO; + } + + public static List toListDTO(List jobRunLogList) { + if (CollectionUtils.isEmpty(jobRunLogList)) { + return Collections.emptyList(); + } + List list = new ArrayList<>(); + + for (JobRunLog jobRunLog : jobRunLogList) { + list.add(JobRunLogDTO.toDTO(jobRunLog)); + } + return list; + + + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobRunParamDTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobRunParamDTO.java index f24392cf..6362776c 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobRunParamDTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/JobRunParamDTO.java @@ -15,67 +15,69 @@ @Data public class JobRunParamDTO { - /** - * flink bin目录地址 - */ - private String flinkBinPath; - - /** - * flink 运行参数 如:-yjm 1024m -ytm 2048m -yd -m yarn-cluster - */ - private String flinkRunParam; - - /** - * sql语句存放的目录 - */ - private String sqlPath; - - - /** - * checkpointConfig - */ - private String flinkCheckpointConfig; - - /** - * flink-streaming-platform-web 所在目录 如:/use/local/flink-streaming-platform-web - */ - private String sysHome; - - /** - * 主类jar地址 - */ - private String mainJarPath; - - - public JobRunParamDTO(String flinkBinPath, - String flinkRunParam, - String sqlPath, - String sysHome, - String flinkCheckpointConfig) { - this.flinkBinPath = flinkBinPath; - this.flinkRunParam = flinkRunParam; - this.sqlPath = sqlPath; - this.sysHome = sysHome; - this.flinkCheckpointConfig = flinkCheckpointConfig; - } - - public static JobRunParamDTO buildJobRunParam(Map systemConfigMap, JobConfigDTO jobConfigDTO, String sqlPath) { - - String flinkBinPath = SystemConstants.buildFlinkBin(systemConfigMap.get(SysConfigEnum.FLINK_HOME.getKey())); - - String flinkRunParam = jobConfigDTO.getFlinkRunConfig(); - - String sysHome = systemConfigMap.get(SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey()); - - JobRunParamDTO jobRunParamDTO = new JobRunParamDTO( - flinkBinPath, - flinkRunParam, - sqlPath, - sysHome, - jobConfigDTO.getFlinkCheckpointConfig() - ); - - return jobRunParamDTO; - - } + /** + * flink bin目录地址 + */ + private String flinkBinPath; + + /** + * flink 运行参数 如:-yjm 1024m -ytm 2048m -yd -m yarn-cluster + */ + private String flinkRunParam; + + /** + * sql语句存放的目录 + */ + private String sqlPath; + + + /** + * checkpointConfig + */ + private String flinkCheckpointConfig; + + /** + * flink-streaming-platform-web 所在目录 如:/use/local/flink-streaming-platform-web + */ + private String sysHome; + + /** + * 主类jar地址 + */ + private String mainJarPath; + + + public JobRunParamDTO(String flinkBinPath, + String flinkRunParam, + String sqlPath, + String sysHome, + String flinkCheckpointConfig) { + this.flinkBinPath = flinkBinPath; + this.flinkRunParam = flinkRunParam; + this.sqlPath = sqlPath; + this.sysHome = sysHome; + this.flinkCheckpointConfig = flinkCheckpointConfig; + } + + public static JobRunParamDTO buildJobRunParam(Map systemConfigMap, + JobConfigDTO jobConfigDTO, String sqlPath) { + + String flinkBinPath = SystemConstants + .buildFlinkBin(systemConfigMap.get(SysConfigEnum.FLINK_HOME.getKey())); + + String flinkRunParam = jobConfigDTO.getFlinkRunConfig(); + + String sysHome = systemConfigMap.get(SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey()); + + JobRunParamDTO jobRunParamDTO = new JobRunParamDTO( + flinkBinPath, + flinkRunParam, + sqlPath, + sysHome, + jobConfigDTO.getFlinkCheckpointConfig() + ); + + return jobRunParamDTO; + + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/PageModel.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/PageModel.java index b0768390..de7fb151 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/PageModel.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/PageModel.java @@ -14,29 +14,29 @@ @Data public class PageModel extends ArrayList { - /** - * 当前页码 - */ - private int pageNum; - - /** - * 每页数量 - */ - private int pageSize; - - /** - * 页码 - */ - private int pages; - - /** - * 总条数 - */ - private long total; - - public List getResult() { - return this; - } + /** + * 当前页码 + */ + private int pageNum; + + /** + * 每页数量 + */ + private int pageSize; + + /** + * 页码 + */ + private int pages; + + /** + * 总条数 + */ + private long total; + + public List getResult() { + return this; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/SavepointBackupDTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/SavepointBackupDTO.java index 86ca1e28..4d574943 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/SavepointBackupDTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/SavepointBackupDTO.java @@ -14,41 +14,41 @@ @Data public class SavepointBackupDTO { - private Long id; + private Long id; - private Long jobConfigId; + private Long jobConfigId; - /** - * backup地址 - */ - private String savepointPath; + /** + * backup地址 + */ + private String savepointPath; - private Date backupTime; + private Date backupTime; - public static SavepointBackupDTO toDTO(SavepointBackup savepointBackup) { - if (savepointBackup == null) { - return null; - } - SavepointBackupDTO savepointBackupDTO = new SavepointBackupDTO(); - savepointBackupDTO.setId(savepointBackup.getId()); - savepointBackupDTO.setJobConfigId(savepointBackup.getJobConfigId()); - savepointBackupDTO.setSavepointPath(savepointBackup.getSavepointPath()); - savepointBackupDTO.setBackupTime(savepointBackup.getBackupTime()); - return savepointBackupDTO; + public static SavepointBackupDTO toDTO(SavepointBackup savepointBackup) { + if (savepointBackup == null) { + return null; } - - public static List toDTOList(List savepointBackupList) { - if (CollectionUtil.isEmpty(savepointBackupList)) { - return Collections.emptyList(); - } - List list = CollectionUtil.newArrayList(); - for (SavepointBackup savepointBackup : savepointBackupList) { - list.add(toDTO(savepointBackup)); - } - return list; + SavepointBackupDTO savepointBackupDTO = new SavepointBackupDTO(); + savepointBackupDTO.setId(savepointBackup.getId()); + savepointBackupDTO.setJobConfigId(savepointBackup.getJobConfigId()); + savepointBackupDTO.setSavepointPath(savepointBackup.getSavepointPath()); + savepointBackupDTO.setBackupTime(savepointBackup.getBackupTime()); + return savepointBackupDTO; + } + + public static List toDTOList(List savepointBackupList) { + if (CollectionUtil.isEmpty(savepointBackupList)) { + return Collections.emptyList(); + } + List list = CollectionUtil.newArrayList(); + for (SavepointBackup savepointBackup : savepointBackupList) { + list.add(toDTO(savepointBackup)); } + return list; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/SystemConfigDTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/SystemConfigDTO.java index ee352f86..fb555d61 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/SystemConfigDTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/SystemConfigDTO.java @@ -20,68 +20,68 @@ @Data public class SystemConfigDTO implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private Long id; + private Long id; - private String key; + private String key; - private String val; + private String val; - private SysConfigEnumType sysConfigEnumType; + private SysConfigEnumType sysConfigEnumType; - public SystemConfigDTO() { + public SystemConfigDTO() { - } + } - public SystemConfigDTO(String key, String val) { - this.key = key; - this.val = val; - } + public SystemConfigDTO(String key, String val) { + this.key = key; + this.val = val; + } - public static SystemConfig toEntity(SystemConfigDTO systemConfigDTO) { - if (systemConfigDTO == null) { - return null; - } - SystemConfig systemConfig = new SystemConfig(); - systemConfig.setId(systemConfigDTO.getId()); - systemConfig.setKey(systemConfigDTO.getKey()); - systemConfig.setVal(systemConfigDTO.getVal()); - return systemConfig; + public static SystemConfig toEntity(SystemConfigDTO systemConfigDTO) { + if (systemConfigDTO == null) { + return null; } - - public static SystemConfigDTO toDTO(SystemConfig systemConfig) { - if (systemConfig == null) { - return null; - } - SystemConfigDTO systemConfigDTO = new SystemConfigDTO(); - systemConfigDTO.setId(systemConfig.getId()); - systemConfigDTO.setKey(systemConfig.getKey()); - systemConfigDTO.setVal(systemConfig.getVal()); - return systemConfigDTO; + SystemConfig systemConfig = new SystemConfig(); + systemConfig.setId(systemConfigDTO.getId()); + systemConfig.setKey(systemConfigDTO.getKey()); + systemConfig.setVal(systemConfigDTO.getVal()); + return systemConfig; + } + + public static SystemConfigDTO toDTO(SystemConfig systemConfig) { + if (systemConfig == null) { + return null; } - - public static List toListDTO(List systemConfigList) { - if (CollectionUtils.isEmpty(systemConfigList)) { - return Collections.emptyList(); - } - List list = new ArrayList(); - for (SystemConfig systemConfig : systemConfigList) { - list.add(toDTO(systemConfig)); - } - return list; + SystemConfigDTO systemConfigDTO = new SystemConfigDTO(); + systemConfigDTO.setId(systemConfig.getId()); + systemConfigDTO.setKey(systemConfig.getKey()); + systemConfigDTO.setVal(systemConfig.getVal()); + return systemConfigDTO; + } + + public static List toListDTO(List systemConfigList) { + if (CollectionUtils.isEmpty(systemConfigList)) { + return Collections.emptyList(); } + List list = new ArrayList(); + for (SystemConfig systemConfig : systemConfigList) { + list.add(toDTO(systemConfig)); + } + return list; + } - public static Map toMap(List systemConfigDTOList) { - if (CollectionUtils.isEmpty(systemConfigDTOList)) { - return Collections.EMPTY_MAP; - } + public static Map toMap(List systemConfigDTOList) { + if (CollectionUtils.isEmpty(systemConfigDTOList)) { + return Collections.EMPTY_MAP; + } - return systemConfigDTOList.stream().collect(Collectors.toMap(SystemConfigDTO::getKey, - SystemConfigDTO::getVal, (key1, key2) -> key2)); + return systemConfigDTOList.stream().collect(Collectors.toMap(SystemConfigDTO::getKey, + SystemConfigDTO::getVal, (key1, key2) -> key2)); - } + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/UserDTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/UserDTO.java index 44c4b16e..e97e9868 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/UserDTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/UserDTO.java @@ -16,77 +16,77 @@ */ @Data public class UserDTO { - /** - * 用户编号 - */ - private Integer id; - - /** - * 用户帐号 - */ - private String username; - - /** - * 用户名称 - */ - private String name; - - /** - * 密码 - */ - private String password; - - /** - * @see com.flink.streaming.web.enums.UserStatusEnum - * 1:启用 0: 停用 - */ - private Integer status; - - /** - * 创建时间 - */ - private Date createTime; - - /** - * 修改时间 - */ - private Date editTime; - - private String creator; - - private String editor; - - - public static UserDTO toDTO(User user) { - if (user == null) { - return null; - } - UserDTO userDTO = new UserDTO(); - userDTO.setId(user.getId()); - userDTO.setUsername(user.getUsername()); - userDTO.setName(user.getName()); - userDTO.setPassword(user.getPassword()); - userDTO.setStatus(user.getStatus()); - userDTO.setCreateTime(user.getCreateTime()); - userDTO.setEditTime(user.getEditTime()); - userDTO.setCreator(user.getCreator()); - userDTO.setEditor(user.getEditor()); - return userDTO; + + /** + * 用户编号 + */ + private Integer id; + + /** + * 用户帐号 + */ + private String username; + + /** + * 用户名称 + */ + private String name; + + /** + * 密码 + */ + private String password; + + /** + * @see com.flink.streaming.web.enums.UserStatusEnum 1:启用 0: 停用 + */ + private Integer status; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date editTime; + + private String creator; + + private String editor; + + + public static UserDTO toDTO(User user) { + if (user == null) { + return null; } + UserDTO userDTO = new UserDTO(); + userDTO.setId(user.getId()); + userDTO.setUsername(user.getUsername()); + userDTO.setName(user.getName()); + userDTO.setPassword(user.getPassword()); + userDTO.setStatus(user.getStatus()); + userDTO.setCreateTime(user.getCreateTime()); + userDTO.setEditTime(user.getEditTime()); + userDTO.setCreator(user.getCreator()); + userDTO.setEditor(user.getEditor()); + return userDTO; + } - public static List toListDTO(List userList) { - if (CollectionUtils.isEmpty(userList)) { - return Collections.EMPTY_LIST; - } - List list = new ArrayList<>(); - for (User user : userList) { - if (user == null) { - continue; - } - list.add(UserDTO.toDTO(user)); - } - return list; + public static List toListDTO(List userList) { + if (CollectionUtils.isEmpty(userList)) { + return Collections.EMPTY_LIST; + } + List list = new ArrayList<>(); + for (User user : userList) { + if (user == null) { + continue; + } + list.add(UserDTO.toDTO(user)); } + return list; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/UserSession.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/UserSession.java index c4e3fbe1..8bd1c6ae 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/UserSession.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/dto/UserSession.java @@ -12,25 +12,25 @@ */ @Data public class UserSession { - - private Integer userid; - private String name; + private Integer userid; - private String password; + private String name; + private String password; - public UserSession(Integer userid, String name, String password) { - this.userid = userid; - this.name = name; - this.password = password; - } - public static String toJsonString(Integer userid, String name, String password) { - return JSON.toJSONString(new UserSession(userid, name, Md5Utils.getMD5String(password))); - } + public UserSession(Integer userid, String name, String password) { + this.userid = userid; + this.name = name; + this.password = password; + } - public static UserSession toUserSession(String json) { - return JSON.parseObject(json, UserSession.class); - } + public static String toJsonString(Integer userid, String name, String password) { + return JSON.toJSONString(new UserSession(userid, name, Md5Utils.getMD5String(password))); + } + + public static UserSession toUserSession(String json) { + return JSON.parseObject(json, UserSession.class); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/AlartLog.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/AlartLog.java index 9239cc02..f3094068 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/AlartLog.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/AlartLog.java @@ -10,47 +10,47 @@ @Data public class AlartLog { - private Long id; + private Long id; - private Long jobConfigId; + private Long jobConfigId; - private String jobName; + private String jobName; - /** - * 消息内容 - */ - private String message; + /** + * 消息内容 + */ + private String message; - /** - * 1:钉钉 - */ - private Integer type; + /** + * 1:钉钉 + */ + private Integer type; - /** - * 1:成功 0:失败 - */ - private Integer status; + /** + * 1:成功 0:失败 + */ + private Integer status; - /** - * 失败原因 - */ - private String failLog; + /** + * 失败原因 + */ + private String failLog; - private Integer isDeleted; + private Integer isDeleted; - /** - * 创建时间 - */ - private Date createTime; + /** + * 创建时间 + */ + private Date createTime; - /** - * 修改时间 - */ - private Date editTime; + /** + * 修改时间 + */ + private Date editTime; - private String creator; + private String creator; - private String editor; + private String editor; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/IpStatus.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/IpStatus.java index 45da2e3c..f1271e7d 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/IpStatus.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/IpStatus.java @@ -11,42 +11,42 @@ @Data public class IpStatus implements Serializable { - private Long id; + private Long id; - /** - * ip - */ - private String ip; + /** + * ip + */ + private String ip; - /** - * 1:运行 2:停止 - * - * @see com.flink.streaming.web.enums.IpStatusEnum - */ - private Integer status; + /** + * 1:运行 2:停止 + * + * @see com.flink.streaming.web.enums.IpStatusEnum + */ + private Integer status; - /** - * 最后一次启动时间 - */ - private Date lastTime; + /** + * 最后一次启动时间 + */ + private Date lastTime; - private Integer isDeleted; + private Integer isDeleted; - /** - * 创建时间 - */ - private Date createTime; + /** + * 创建时间 + */ + private Date createTime; - /** - * 修改时间 - */ - private Date editTime; + /** + * 修改时间 + */ + private Date editTime; - private String creator; + private String creator; - private String editor; + private String editor; - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobAlarmConfig.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobAlarmConfig.java index df717c5b..39eea1d2 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobAlarmConfig.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobAlarmConfig.java @@ -5,7 +5,6 @@ import java.util.Date; /** - * * @author zhuhuipei * @date 2021/2/27 * @time 17:09 @@ -13,38 +12,38 @@ @Data public class JobAlarmConfig { - private Long id; + private Long id; - /** - * job_config主表id - */ - private Long jobId; + /** + * job_config主表id + */ + private Long jobId; - /** - * 类型 1:钉钉告警 2:url回调 3:异常自动拉起任务 - */ - private Integer type; + /** + * 类型 1:钉钉告警 2:url回调 3:异常自动拉起任务 + */ + private Integer type; - /** - * 更新版本号 - */ - private Integer version; + /** + * 更新版本号 + */ + private Integer version; - private Integer isDeleted; + private Integer isDeleted; - /** - * 创建时间 - */ - private Date createTime; + /** + * 创建时间 + */ + private Date createTime; - /** - * 修改时间 - */ - private Date editTime; + /** + * 修改时间 + */ + private Date editTime; - private String creator; + private String creator; - private String editor; + private String editor; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobConfig.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobConfig.java index ae71d55d..9a3d2225 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobConfig.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobConfig.java @@ -13,109 +13,107 @@ public class JobConfig { - private Long id; - - /** - * 任务名称 - */ - private String jobName; - - /** - * 任务描述 - */ - private String jobDesc; - - /** - * flink的本地目录 - */ - private String deployMode; - - /** - * flink运行配置 - */ - private String flinkRunConfig; - - /** - * flink运行配置 - */ - private String flinkCheckpointConfig; - - /** - * flink运行配置 - */ - private String jobId; - - /** - * 1:开启 0: 关闭 - */ - private Integer isOpen; - - /** - * @see com.flink.streaming.web.enums.JobConfigStatus - * 1:运行中 0: 停止中 -1:运行失败 - */ - private Integer status; - - - /** - * 三方jar udf、 连接器 等jar如http://xxx.xxx.com/flink-streaming-udf.jar - */ - private String extJarPath; - - /** - * 最后一次启动时间 - */ - private Date lastStartTime; - - private Long lastRunLogId; - - /** - * 更新版本号 用于乐观锁 - */ - private Integer version; - - /** - * 任务类型 0:sql 1:自定义jar' - */ - private Integer jobType; - - /** - * 启动jar可能需要使用的自定义参数 - */ - private String customArgs; - - /** - * 程序入口类 - */ - private String customMainClass; - - /** - * 自定义jar的http地址 如:http://ccblog.cn/xx.jar - */ - private String customJarUrl; - - - - private Integer isDeleted; - - /** - * 创建时间 - */ - private Date createTime; - - /** - * 修改时间 - */ - private Date editTime; - - private String creator; - - private String editor; - - /** - * sql语句 - */ - private String flinkSql; + private Long id; + + /** + * 任务名称 + */ + private String jobName; + + /** + * 任务描述 + */ + private String jobDesc; + + /** + * flink的本地目录 + */ + private String deployMode; + + /** + * flink运行配置 + */ + private String flinkRunConfig; + + /** + * flink运行配置 + */ + private String flinkCheckpointConfig; + + /** + * flink运行配置 + */ + private String jobId; + + /** + * 1:开启 0: 关闭 + */ + private Integer isOpen; + + /** + * @see com.flink.streaming.web.enums.JobConfigStatus 1:运行中 0: 停止中 -1:运行失败 + */ + private Integer status; + + + /** + * 三方jar udf、 连接器 等jar如http://xxx.xxx.com/flink-streaming-udf.jar + */ + private String extJarPath; + + /** + * 最后一次启动时间 + */ + private Date lastStartTime; + + private Long lastRunLogId; + + /** + * 更新版本号 用于乐观锁 + */ + private Integer version; + + /** + * 任务类型 0:sql 1:自定义jar' + */ + private Integer jobType; + + /** + * 启动jar可能需要使用的自定义参数 + */ + private String customArgs; + + /** + * 程序入口类 + */ + private String customMainClass; + + /** + * 自定义jar的http地址 如:http://ccblog.cn/xx.jar + */ + private String customJarUrl; + + + private Integer isDeleted; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date editTime; + + private String creator; + + private String editor; + + /** + * sql语句 + */ + private String flinkSql; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobConfigHistory.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobConfigHistory.java index 34c79d56..81038abf 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobConfigHistory.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobConfigHistory.java @@ -6,7 +6,6 @@ import java.util.Date; /** - * * @author zhuhuipei * @date 2021/5/5 * @time 19:49 @@ -14,76 +13,75 @@ @Data public class JobConfigHistory implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private Long id; + private Long id; - /** - * job_config主表Id - */ - private Long jobConfigId; + /** + * job_config主表Id + */ + private Long jobConfigId; - /** - * 任务名称 - */ - private String jobName; + /** + * 任务名称 + */ + private String jobName; - /** - * 任务描述 - */ - private String jobDesc; + /** + * 任务描述 + */ + private String jobDesc; - /** - * 提交模式: standalone 、yarn 、yarn-session - */ - private String deployMode; + /** + * 提交模式: standalone 、yarn 、yarn-session + */ + private String deployMode; - /** - * flink运行配置 - */ - private String flinkRunConfig; + /** + * flink运行配置 + */ + private String flinkRunConfig; - /** - * checkPoint配置 - */ - private String flinkCheckpointConfig; + /** + * checkPoint配置 + */ + private String flinkCheckpointConfig; - /** - * udf地址及连接器jar 如http://xxx.xxx.com/flink-streaming-udf.jar - */ - private String extJarPath; + /** + * udf地址及连接器jar 如http://xxx.xxx.com/flink-streaming-udf.jar + */ + private String extJarPath; - /** - * 更新版本号 - */ - private Integer version; - - /** - * 任务类型 0:sql 1:自定义jar' - */ - private Integer jobType; + /** + * 更新版本号 + */ + private Integer version; - private Boolean isDeleted; + /** + * 任务类型 0:sql 1:自定义jar' + */ + private Integer jobType; - /** - * 创建时间 - */ - private Date createTime; + private Boolean isDeleted; - /** - * 修改时间 - */ - private Date editTime; + /** + * 创建时间 + */ + private Date createTime; - private String creator; + /** + * 修改时间 + */ + private Date editTime; - private String editor; + private String creator; - /** - * sql语句 - */ - private String flinkSql; + private String editor; + /** + * sql语句 + */ + private String flinkSql; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobRunLog.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobRunLog.java index 14221d7c..e6a084d3 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobRunLog.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/JobRunLog.java @@ -13,74 +13,74 @@ @Data public class JobRunLog implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private Long id; + private Long id; - private Long jobConfigId; + private Long jobConfigId; - /** - * 任务名称 - */ - private String jobName; + /** + * 任务名称 + */ + private String jobName; - /** - * 任务描述 - */ - private String jobDesc; + /** + * 任务描述 + */ + private String jobDesc; - /** - * 提交模式: standalone 、yarn 、yarn-session - */ - private String deployMode; + /** + * 提交模式: standalone 、yarn 、yarn-session + */ + private String deployMode; - /** - * 运行后的任务id - */ - private String jobId; + /** + * 运行后的任务id + */ + private String jobId; - /** - * 远程日志url的地址 - */ - private String remoteLogUrl; + /** + * 远程日志url的地址 + */ + private String remoteLogUrl; - /** - * 启动时间 - */ - private Date startTime; + /** + * 启动时间 + */ + private Date startTime; - /** - * 启动时间 - */ - private Date endTime; + /** + * 启动时间 + */ + private Date endTime; - /** - * 任务状态 - */ - private String jobStatus; + /** + * 任务状态 + */ + private String jobStatus; - private Integer isDeleted; + private Integer isDeleted; - /** - * 创建时间 - */ - private Date createTime; + /** + * 创建时间 + */ + private Date createTime; - /** - * 修改时间 - */ - private Date editTime; + /** + * 修改时间 + */ + private Date editTime; - private String creator; + private String creator; - private String editor; + private String editor; - /** - * 启动时本地日志 - */ - private String localLog; + /** + * 启动时本地日志 + */ + private String localLog; - private String runIp; + private String runIp; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/SavepointBackup.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/SavepointBackup.java index 4271ca27..d3283656 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/SavepointBackup.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/SavepointBackup.java @@ -10,33 +10,34 @@ */ @Data public class SavepointBackup implements Serializable { - private Long id; - private Long jobConfigId; + private Long id; - /** - * 报错地址 - */ - private String savepointPath; + private Long jobConfigId; - private Integer isDeleted; + /** + * 报错地址 + */ + private String savepointPath; - private Date backupTime; + private Integer isDeleted; - /** - * 创建时间 - */ - private Date createTime; + private Date backupTime; - /** - * 修改时间 - */ - private Date editTime; + /** + * 创建时间 + */ + private Date createTime; - private String creator; + /** + * 修改时间 + */ + private Date editTime; - private String editor; + private String creator; - private static final long serialVersionUID = 1L; + private String editor; + + private static final long serialVersionUID = 1L; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/SystemConfig.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/SystemConfig.java index 74c5189b..5752f256 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/SystemConfig.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/SystemConfig.java @@ -14,41 +14,41 @@ @Data public class SystemConfig implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private Long id; + private Long id; - private String key; + private String key; - private String val; + private String val; - private String type; + private String type; - private Integer isDeleted; + private Integer isDeleted; - /** - * 创建时间 - */ - private Date createTime; + /** + * 创建时间 + */ + private Date createTime; - /** - * 修改时间 - */ - private Date editTime; + /** + * 修改时间 + */ + private Date editTime; - private String creator; + private String creator; - private String editor; + private String editor; - public SystemConfig() { + public SystemConfig() { - } + } - public SystemConfig(String key, String val) { - this.key = key; - this.val = val; - this.type = SysConfigEnum.getType(key); - } + public SystemConfig(String key, String val) { + this.key = key; + this.val = val; + this.type = SysConfigEnum.getType(key); + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/User.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/User.java index 35d9b028..ddfd6749 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/User.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/entity/User.java @@ -11,49 +11,49 @@ */ @Data public class User { - /** - * 用户编号 - */ - private Integer id; - - /** - * 用户帐号 - */ - private String username; - - /** - * 用户名称 - */ - private String name; - - /** - * 密码 - */ - private String password; - - /** - * @see com.flink.streaming.web.enums.UserStatusEnum - * 1:启用 0: 停用 - */ - private Integer status; - - /** - * 1:删除 0: 未删除 - */ - private Integer isDeleted; - - /** - * 创建时间 - */ - private Date createTime; - - /** - * 修改时间 - */ - private Date editTime; - - private String creator; - - private String editor; + + /** + * 用户编号 + */ + private Integer id; + + /** + * 用户帐号 + */ + private String username; + + /** + * 用户名称 + */ + private String name; + + /** + * 密码 + */ + private String password; + + /** + * @see com.flink.streaming.web.enums.UserStatusEnum 1:启用 0: 停用 + */ + private Integer status; + + /** + * 1:删除 0: 未删除 + */ + private Integer isDeleted; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date editTime; + + private String creator; + + private String editor; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/page/PageParam.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/page/PageParam.java index 3c9d4590..3d7d7a9e 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/page/PageParam.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/page/PageParam.java @@ -11,13 +11,13 @@ @Data public class PageParam { - /** - * 当前页码 - */ - private int pageNum = 1; - /** - * 每页数量 - */ - private int pageSize = 15; + /** + * 当前页码 + */ + private int pageNum = 1; + /** + * 每页数量 + */ + private int pageSize = 15; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/AlartLogParam.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/AlartLogParam.java index 882b5362..d6fe9b61 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/AlartLogParam.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/AlartLogParam.java @@ -12,17 +12,17 @@ @Data public class AlartLogParam extends PageParam { - private Long jobConfigId; + private Long jobConfigId; - /** - * 1:钉钉 - */ - private Integer type; + /** + * 1:钉钉 + */ + private Integer type; - /** - * 1:成功 0:失败 - */ - private Integer status; + /** + * 1:成功 0:失败 + */ + private Integer status; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobConfigHisotryParam.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobConfigHisotryParam.java index 966b607f..ccbe5e8a 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobConfigHisotryParam.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobConfigHisotryParam.java @@ -4,22 +4,21 @@ import lombok.Data; /** - * * @author wxj - * @date 2021年12月20日 上午11:23:11 * @version V1.0 + * @date 2021年12月20日 上午11:23:11 */ @Data public class JobConfigHisotryParam extends PageParam { - /** - * 任务编号 - */ - private Integer jobConfigId; + /** + * 任务编号 + */ + private Integer jobConfigId; - /** - * 任务名称 - */ - private String jobName; + /** + * 任务名称 + */ + private String jobName; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobConfigParam.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobConfigParam.java index 9f32ec48..f33a0aac 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobConfigParam.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobConfigParam.java @@ -12,30 +12,30 @@ @Data public class JobConfigParam extends PageParam { - /** - * @author zhuhuipei - * @date 2020-07-15 - * @time 02:07 - * @see com.flink.streaming.web.enums.JobConfigStatus - */ - private Integer status; + /** + * @author zhuhuipei + * @date 2020-07-15 + * @time 02:07 + * @see com.flink.streaming.web.enums.JobConfigStatus + */ + private Integer status; - /** - * 任务名称 - */ - private String jobName; + /** + * 任务名称 + */ + private String jobName; - /** - * 任务类型 0:sql 1:自定义jar' - */ - private Integer jobType; + /** + * 任务类型 0:sql 1:自定义jar' + */ + private Integer jobType; - private Integer open; + private Integer open; - private String jobId; + private String jobId; - private String deployMode; + private String deployMode; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobRunLogParam.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobRunLogParam.java index 4ada0f37..e951067b 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobRunLogParam.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/JobRunLogParam.java @@ -12,12 +12,12 @@ @Data public class JobRunLogParam extends PageParam { - private Long jobConfigId; + private Long jobConfigId; - /** - * 运行后的任务id - */ - private String jobId; + /** + * 运行后的任务id + */ + private String jobId; - private String jobName; + private String jobName; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/UpsertJobConfigParam.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/UpsertJobConfigParam.java index 1b60a1ed..8d33da36 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/UpsertJobConfigParam.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/param/UpsertJobConfigParam.java @@ -20,133 +20,132 @@ @Data public class UpsertJobConfigParam { - private Long id; + private Long id; - /** - * 任务名称 - */ - private String jobName; + /** + * 任务名称 + */ + private String jobName; - /** - * 任务描述 - */ - private String jobDesc; + /** + * 任务描述 + */ + private String jobDesc; - /** - * - */ - private String deployMode; + /** + * + */ + private String deployMode; - /** - * flink运行配置 - */ - private String flinkRunConfig; + /** + * flink运行配置 + */ + private String flinkRunConfig; - /** - * Checkpoint信息 - */ - private String flinkCheckpointConfig; + /** + * Checkpoint信息 + */ + private String flinkCheckpointConfig; - /** - * sql语句 - */ - private String flinkSql; + /** + * sql语句 + */ + private String flinkSql; - /** - * 三方jar udf、 连接器 等jar如http://xxx.xxx.com/flink-streaming-udf.jar - */ - private String extJarPath; + /** + * 三方jar udf、 连接器 等jar如http://xxx.xxx.com/flink-streaming-udf.jar + */ + private String extJarPath; - /** - * @see AlarmTypeEnum - */ - private String alarmTypes; + /** + * @see AlarmTypeEnum + */ + private String alarmTypes; - /** - * 任务类型 0:sql 1:自定义jar' - */ - private Integer jobType; + /** + * 任务类型 0:sql 1:自定义jar' + */ + private Integer jobType; - /** - * 启动jar可能需要使用的自定义参数 - */ - private String customArgs; + /** + * 启动jar可能需要使用的自定义参数 + */ + private String customArgs; - /** - * 程序入口类 - */ - private String customMainClass; + /** + * 程序入口类 + */ + private String customMainClass; - /** - * 自定义jar的http地址 如:http://ccblog.cn/xx.jar - */ - private String customJarUrl; + /** + * 自定义jar的http地址 如:http://ccblog.cn/xx.jar + */ + private String customJarUrl; - /** - * 1:开启 0: 关闭 - */ - private Integer isOpen = YN.N.getValue(); + /** + * 1:开启 0: 关闭 + */ + private Integer isOpen = YN.N.getValue(); - /** - * @see JobConfigStatus - * 1:运行中 0: 停止中 -1:运行失败 - */ - private Integer status = JobConfigStatus.STOP.getCode(); + /** + * @see JobConfigStatus 1:运行中 0: 停止中 -1:运行失败 + */ + private Integer status = JobConfigStatus.STOP.getCode(); - public static JobConfigDTO toDTO(UpsertJobConfigParam upsertJobConfigParam) { - if (upsertJobConfigParam == null) { - return null; - } - JobConfigDTO jobConfigDTO = new JobConfigDTO(); - jobConfigDTO.setId(upsertJobConfigParam.getId()); - jobConfigDTO.setDeployModeEnum(DeployModeEnum.getModel(upsertJobConfigParam.getDeployMode())); - jobConfigDTO.setJobName(upsertJobConfigParam.getJobName()); - jobConfigDTO.setJobDesc(upsertJobConfigParam.getJobDesc()); - jobConfigDTO.setFlinkRunConfig(upsertJobConfigParam.getFlinkRunConfig()); - jobConfigDTO.setFlinkCheckpointConfig(upsertJobConfigParam.getFlinkCheckpointConfig()); - - if (StringUtils.isNotEmpty(upsertJobConfigParam.getFlinkSql()) - && (JobTypeEnum.SQL_STREAMING.getCode() == upsertJobConfigParam.getJobType().intValue() - || JobTypeEnum.SQL_BATCH.getCode() == upsertJobConfigParam.getJobType().intValue())) { - jobConfigDTO.setFlinkSql(upsertJobConfigParam.getFlinkSql()); - } else { - jobConfigDTO.setFlinkSql(SystemConstant.SPACE); - } + public static JobConfigDTO toDTO(UpsertJobConfigParam upsertJobConfigParam) { + if (upsertJobConfigParam == null) { + return null; + } + JobConfigDTO jobConfigDTO = new JobConfigDTO(); + jobConfigDTO.setId(upsertJobConfigParam.getId()); + jobConfigDTO.setDeployModeEnum(DeployModeEnum.getModel(upsertJobConfigParam.getDeployMode())); + jobConfigDTO.setJobName(upsertJobConfigParam.getJobName()); + jobConfigDTO.setJobDesc(upsertJobConfigParam.getJobDesc()); + jobConfigDTO.setFlinkRunConfig(upsertJobConfigParam.getFlinkRunConfig()); + jobConfigDTO.setFlinkCheckpointConfig(upsertJobConfigParam.getFlinkCheckpointConfig()); + + if (StringUtils.isNotEmpty(upsertJobConfigParam.getFlinkSql()) + && (JobTypeEnum.SQL_STREAMING.getCode() == upsertJobConfigParam.getJobType().intValue() + || JobTypeEnum.SQL_BATCH.getCode() == upsertJobConfigParam.getJobType().intValue())) { + jobConfigDTO.setFlinkSql(upsertJobConfigParam.getFlinkSql()); + } else { + jobConfigDTO.setFlinkSql(SystemConstant.SPACE); + } - jobConfigDTO.setJobTypeEnum(JobTypeEnum.getJobTypeEnum(upsertJobConfigParam.getJobType())); - jobConfigDTO.setCustomArgs(upsertJobConfigParam.getCustomArgs()); - jobConfigDTO.setCustomMainClass(upsertJobConfigParam.getCustomMainClass()); - jobConfigDTO.setCustomJarUrl(upsertJobConfigParam.getCustomJarUrl()); - - jobConfigDTO.setIsOpen(upsertJobConfigParam.getIsOpen()); - jobConfigDTO.setStatus(JobConfigStatus.getJobConfigStatus(upsertJobConfigParam.getStatus())); - if (StringUtils.isNotEmpty(upsertJobConfigParam.getExtJarPath())) { - jobConfigDTO.setExtJarPath(upsertJobConfigParam.getExtJarPath().trim()); - }else{ - jobConfigDTO.setExtJarPath(SystemConstant.SPACE); - } - if (StringUtils.isNotEmpty(upsertJobConfigParam.getAlarmTypes())) { - List list = new ArrayList<>(); - String[] types = upsertJobConfigParam.getAlarmTypes().split(","); - for (String code : types) { - AlarmTypeEnum alarmTypeEnum = AlarmTypeEnum.getAlarmTypeEnum(Integer.valueOf(code)); - if (alarmTypeEnum != null) { - list.add(alarmTypeEnum); - } - } - if (CollectionUtils.isNotEmpty(list)) { - jobConfigDTO.setAlarmTypeEnumList(list); - } + jobConfigDTO.setJobTypeEnum(JobTypeEnum.getJobTypeEnum(upsertJobConfigParam.getJobType())); + jobConfigDTO.setCustomArgs(upsertJobConfigParam.getCustomArgs()); + jobConfigDTO.setCustomMainClass(upsertJobConfigParam.getCustomMainClass()); + jobConfigDTO.setCustomJarUrl(upsertJobConfigParam.getCustomJarUrl()); + + jobConfigDTO.setIsOpen(upsertJobConfigParam.getIsOpen()); + jobConfigDTO.setStatus(JobConfigStatus.getJobConfigStatus(upsertJobConfigParam.getStatus())); + if (StringUtils.isNotEmpty(upsertJobConfigParam.getExtJarPath())) { + jobConfigDTO.setExtJarPath(upsertJobConfigParam.getExtJarPath().trim()); + } else { + jobConfigDTO.setExtJarPath(SystemConstant.SPACE); + } + if (StringUtils.isNotEmpty(upsertJobConfigParam.getAlarmTypes())) { + List list = new ArrayList<>(); + String[] types = upsertJobConfigParam.getAlarmTypes().split(","); + for (String code : types) { + AlarmTypeEnum alarmTypeEnum = AlarmTypeEnum.getAlarmTypeEnum(Integer.valueOf(code)); + if (alarmTypeEnum != null) { + list.add(alarmTypeEnum); } - - return jobConfigDTO; + } + if (CollectionUtils.isNotEmpty(list)) { + jobConfigDTO.setAlarmTypeEnumList(list); + } } + return jobConfigDTO; + } + } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/AppListTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/AppListTO.java index ee696cf9..a7367403 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/AppListTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/AppListTO.java @@ -13,5 +13,5 @@ @Data public class AppListTO { - private List app; + private List app; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/AppTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/AppTO.java index efe207d9..d79b32f1 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/AppTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/AppTO.java @@ -13,60 +13,60 @@ @Data public class AppTO { - /** - * yarn appid - */ - private String id; + /** + * yarn appid + */ + private String id; - /** - * 运行用户 如 hadoop - */ - private String user; + /** + * 运行用户 如 hadoop + */ + private String user; - /** - * 运行的任务名称 - */ - private String name; + /** + * 运行的任务名称 + */ + private String name; - /** - * 队列名称 - */ - private String queue; + /** + * 队列名称 + */ + private String queue; - /** - * 运行状态 - */ - private String state; + /** + * 运行状态 + */ + private String state; - private String finalStatus; + private String finalStatus; - private Integer progress; + private Integer progress; - private String trackingUI; + private String trackingUI; - /** - * 连接地址 - */ - private String trackingUrl; + /** + * 连接地址 + */ + private String trackingUrl; - /** - * 应用类型 - */ - private String applicationType; + /** + * 应用类型 + */ + private String applicationType; - /** - * 运行开始时间 - */ - private Long startedTime; + /** + * 运行开始时间 + */ + private Long startedTime; - private Long finishedTime; + private Long finishedTime; - /** - * AM 容器地址 - */ - private String amContainerLogs; + /** + * AM 容器地址 + */ + private String amContainerLogs; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/YarnAppInfo.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/YarnAppInfo.java index 9828fb62..209c7ba5 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/YarnAppInfo.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/to/YarnAppInfo.java @@ -11,5 +11,5 @@ @Data public class YarnAppInfo { - private AppListTO apps; + private AppListTO apps; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/AlartLogVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/AlartLogVO.java index 68dfae78..e8d11e85 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/AlartLogVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/AlartLogVO.java @@ -20,86 +20,89 @@ @Data public class AlartLogVO { - private Long id; + private Long id; - private Long jobConfigId; + private Long jobConfigId; - private String jobName; + private String jobName; - /** - * 消息内容 - */ - private String message; + /** + * 消息内容 + */ + private String message; - /** - * 1:钉钉 - */ - private String typeDesc; + /** + * 1:钉钉 + */ + private String typeDesc; - /** - * 1:成功 0:失败 - */ - private String statusDesc; + /** + * 1:成功 0:失败 + */ + private String statusDesc; - private Integer status; + private Integer status; - /** - * 失败原因 - */ - private String failLog; + /** + * 失败原因 + */ + private String failLog; - /** - * 创建时间 - */ - private String createTime; + /** + * 创建时间 + */ + private String createTime; - public static AlartLogVO toVO(AlartLogDTO alartLogDTO) { - if (alartLogDTO == null) { - return null; - } - AlartLogVO alartLogVO = new AlartLogVO(); - alartLogVO.setId(alartLogDTO.getId()); - alartLogVO.setJobConfigId(alartLogDTO.getJobConfigId()); - alartLogVO.setJobName(alartLogDTO.getJobName()); - alartLogVO.setMessage(alartLogDTO.getMessage()); - alartLogVO.setStatus(alartLogDTO.getAlarmLogStatusEnum().getCode()); - if (alartLogDTO.getAlarMLogTypeEnum() != null) { - alartLogVO.setTypeDesc(alartLogDTO.getAlarMLogTypeEnum().getDesc()); - } - if (alartLogDTO.getAlarmLogStatusEnum() != null) { - if (AlarmLogStatusEnum.SUCCESS.equals(alartLogDTO.getAlarmLogStatusEnum())) { - alartLogVO.setStatusDesc(alartLogDTO.getAlarmLogStatusEnum().getDesc()); - } else { - alartLogVO.setStatusDesc("" + alartLogDTO.getAlarmLogStatusEnum().getDesc() + ""); - } - - } - alartLogVO.setFailLog(alartLogDTO.getFailLog()); - alartLogVO.setCreateTime(DateUtil.format(alartLogDTO.getCreateTime(), DatePattern.NORM_DATETIME_PATTERN)); - - return alartLogVO; + public static AlartLogVO toVO(AlartLogDTO alartLogDTO) { + if (alartLogDTO == null) { + return null; } + AlartLogVO alartLogVO = new AlartLogVO(); + alartLogVO.setId(alartLogDTO.getId()); + alartLogVO.setJobConfigId(alartLogDTO.getJobConfigId()); + alartLogVO.setJobName(alartLogDTO.getJobName()); + alartLogVO.setMessage(alartLogDTO.getMessage()); + alartLogVO.setStatus(alartLogDTO.getAlarmLogStatusEnum().getCode()); + if (alartLogDTO.getAlarMLogTypeEnum() != null) { + alartLogVO.setTypeDesc(alartLogDTO.getAlarMLogTypeEnum().getDesc()); + } + if (alartLogDTO.getAlarmLogStatusEnum() != null) { + if (AlarmLogStatusEnum.SUCCESS.equals(alartLogDTO.getAlarmLogStatusEnum())) { + alartLogVO.setStatusDesc(alartLogDTO.getAlarmLogStatusEnum().getDesc()); + } else { + alartLogVO.setStatusDesc( + "" + alartLogDTO.getAlarmLogStatusEnum().getDesc() + + ""); + } + } + alartLogVO.setFailLog(alartLogDTO.getFailLog()); + alartLogVO.setCreateTime( + DateUtil.format(alartLogDTO.getCreateTime(), DatePattern.NORM_DATETIME_PATTERN)); - public static List toListVO(List alartLogDTOList) { - if (CollectionUtil.isEmpty(alartLogDTOList)) { - return Collections.emptyList(); - } + return alartLogVO; + } - List list = new ArrayList<>(); - for (AlartLogDTO alartLogDTO : alartLogDTOList) { - AlartLogVO alartLogVO = AlartLogVO.toVO(alartLogDTO); - if (alartLogVO != null) { - list.add(alartLogVO); - } - } - return list; + public static List toListVO(List alartLogDTOList) { + if (CollectionUtil.isEmpty(alartLogDTOList)) { + return Collections.emptyList(); + } + List list = new ArrayList<>(); + for (AlartLogDTO alartLogDTO : alartLogDTOList) { + AlartLogVO alartLogVO = AlartLogVO.toVO(alartLogDTO); + if (alartLogVO != null) { + list.add(alartLogVO); + } } + return list; + + } + } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/CallbackDTO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/CallbackDTO.java index bfe2ef6d..ce05748e 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/CallbackDTO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/CallbackDTO.java @@ -12,21 +12,21 @@ @Data public class CallbackDTO { - private String appId; + private String appId; - private String jobName; + private String jobName; - private String deployMode; + private String deployMode; - private Long jobConfigId; + private Long jobConfigId; - public static CallbackDTO to(JobConfigDTO jobConfigDTO) { - CallbackDTO callbackDTO = new CallbackDTO(); - callbackDTO.setJobConfigId(jobConfigDTO.getId()); - callbackDTO.setJobName(jobConfigDTO.getJobName()); - callbackDTO.setDeployMode(jobConfigDTO.getDeployModeEnum().name()); - callbackDTO.setAppId(jobConfigDTO.getJobId()); - return callbackDTO; - } + public static CallbackDTO to(JobConfigDTO jobConfigDTO) { + CallbackDTO callbackDTO = new CallbackDTO(); + callbackDTO.setJobConfigId(jobConfigDTO.getId()); + callbackDTO.setJobName(jobConfigDTO.getJobName()); + callbackDTO.setDeployMode(jobConfigDTO.getDeployModeEnum().name()); + callbackDTO.setAppId(jobConfigDTO.getJobId()); + return callbackDTO; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/Constant.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/Constant.java index 301879fb..8f5a966e 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/Constant.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/Constant.java @@ -2,92 +2,94 @@ /** * 常量定义 + * * @author wxj - * @date 2021年11月30日 上午10:20:27 * @version V1.0 + * @date 2021年11月30日 上午10:20:27 */ public class Constant { - /** - * 前端请求响应状态:成功 - */ - public static final String RESPONE_STATUS_SUCCESS = "200"; - /** - * 前端请求响应状态:重定向 - */ - public static final String RESPONE_STATUS_MOVED = "301"; - /** - * 前端请求响应状态:未认证 - */ - public static final String RESPONE_STATUS_UNAUTH = "401"; - /** - * 前端请求响应状态:未授权 - */ - public static final String RESPONE_STATUS_FORBIDDEN = "403"; - /** - * 前端请求响应状态:资源缺失 - */ - public static final String RESPONE_STATUS_NOTFOUND = "404"; - /** - * 前端请求响应状态:应用错误 - */ - public static final String RESPONE_STATUS_ERROR = "500"; - /** - * 超级用户角色 - */ - public static final int ADMIN_ROLE_ID = 1; - /** - * 超级用户编号 - */ - public static final int ADMIN_OP_ID = 1; - /** - * 超级用户帐号 - */ - public static final String ADMIN_OP_NAME = "admin"; - /** - * 超级用户权限 - */ - public static final String AUTH_ADMIN = "ROLE_ADMIN"; - /** - * 角色权限编码前缀 - */ - public static final String AUTH_ROLE_PREFIX = "ROLE_"; - /** - * 数据删除状态 - */ - public static final short DATA_STATUS_DELETE = -1; - /** - * 数据有效状态 - */ - public static final short DATA_STATUS_ENABEL = 1; - /** - * 数据无效状态 - */ - public static final short DATA_STATUS_DISABLE = 0; - /** - * 数据锁定状态 - */ - public static final short DATA_STATUS_LOCKED = 2; + /** + * 前端请求响应状态:成功 + */ + public static final String RESPONE_STATUS_SUCCESS = "200"; + /** + * 前端请求响应状态:重定向 + */ + public static final String RESPONE_STATUS_MOVED = "301"; + /** + * 前端请求响应状态:未认证 + */ + public static final String RESPONE_STATUS_UNAUTH = "401"; + /** + * 前端请求响应状态:未授权 + */ + public static final String RESPONE_STATUS_FORBIDDEN = "403"; + /** + * 前端请求响应状态:资源缺失 + */ + public static final String RESPONE_STATUS_NOTFOUND = "404"; + /** + * 前端请求响应状态:应用错误 + */ + public static final String RESPONE_STATUS_ERROR = "500"; + + /** + * 超级用户角色 + */ + public static final int ADMIN_ROLE_ID = 1; + /** + * 超级用户编号 + */ + public static final int ADMIN_OP_ID = 1; + /** + * 超级用户帐号 + */ + public static final String ADMIN_OP_NAME = "admin"; + /** + * 超级用户权限 + */ + public static final String AUTH_ADMIN = "ROLE_ADMIN"; + /** + * 角色权限编码前缀 + */ + public static final String AUTH_ROLE_PREFIX = "ROLE_"; + /** + * 数据删除状态 + */ + public static final short DATA_STATUS_DELETE = -1; + /** + * 数据有效状态 + */ + public static final short DATA_STATUS_ENABEL = 1; + /** + * 数据无效状态 + */ + public static final short DATA_STATUS_DISABLE = 0; + /** + * 数据锁定状态 + */ + public static final short DATA_STATUS_LOCKED = 2; + + /** + * 根结点(应用模块) + */ + public static final int MENU_TYPE_ROOT = 1; + /** + * 菜单项 + */ + public static final int MENU_TYPE_ITEM = 2; + /** + * 叶子菜单项 + */ + public static final int MENU_TYPE_LEAF = 3; + /** + * 功能按钮项 + */ + public static final int MENU_TYPE_BUTTON = 4; + /** + * 功能权限 + */ + public static final int MENU_TYPE_FUNCTION = 5; - /** - * 根结点(应用模块) - */ - public static final int MENU_TYPE_ROOT = 1; - /** - * 菜单项 - */ - public static final int MENU_TYPE_ITEM = 2; - /** - * 叶子菜单项 - */ - public static final int MENU_TYPE_LEAF = 3; - /** - * 功能按钮项 - */ - public static final int MENU_TYPE_BUTTON = 4; - /** - * 功能权限 - */ - public static final int MENU_TYPE_FUNCTION = 5; - } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/DeployFlinkVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/DeployFlinkVO.java index 0920622a..ef7260c1 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/DeployFlinkVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/DeployFlinkVO.java @@ -10,73 +10,73 @@ @Data public class DeployFlinkVO { - - @Data - public static class FlinkTask { - - /** - * 任务编号 - */ - private Long id; - - /** - * 任务名称 - */ - private String jobName; - - /** - * 任务描述 - */ - private String jobDesc; - - /** - * sql语句 - */ - private String sqlFile; - - /** - * 任务类型:SQL_STREAMING, JAR, SQL_BATCH; 为空默认为:SQL_STREAMING - */ - private JobTypeEnum jobType; - - /** - * 运行模式:YARN_PER, STANDALONE, LOCAL; 为空默认为:STANDALONE - */ - private DeployModeEnum deployMode; - - private String flinkRunConfig; - - private String flinkCheckpointConfig; - - private String extJarPath; - - /** - * 启动jar可能需要使用的自定义参数 - */ - private String customArgs; - - /** - * 程序入口类 - */ - private String customMainClass; - - /** - * 自定义jar的http地址 如:http://ccblog.cn/xx.jar - */ - private String customJarUrl; - - /** - * 钉钉告警、回调、自动重启(DINGDING、CALLBACK_URL、AUTO_START_JOB) - */ - private List alarmTypes; - - /** - * 发布启动标记:默认为true,表示发布时自动启动 - */ - private Boolean deployStartFlag; - - } - - private List taskList; - + + @Data + public static class FlinkTask { + + /** + * 任务编号 + */ + private Long id; + + /** + * 任务名称 + */ + private String jobName; + + /** + * 任务描述 + */ + private String jobDesc; + + /** + * sql语句 + */ + private String sqlFile; + + /** + * 任务类型:SQL_STREAMING, JAR, SQL_BATCH; 为空默认为:SQL_STREAMING + */ + private JobTypeEnum jobType; + + /** + * 运行模式:YARN_PER, STANDALONE, LOCAL; 为空默认为:STANDALONE + */ + private DeployModeEnum deployMode; + + private String flinkRunConfig; + + private String flinkCheckpointConfig; + + private String extJarPath; + + /** + * 启动jar可能需要使用的自定义参数 + */ + private String customArgs; + + /** + * 程序入口类 + */ + private String customMainClass; + + /** + * 自定义jar的http地址 如:http://ccblog.cn/xx.jar + */ + private String customJarUrl; + + /** + * 钉钉告警、回调、自动重启(DINGDING、CALLBACK_URL、AUTO_START_JOB) + */ + private List alarmTypes; + + /** + * 发布启动标记:默认为true,表示发布时自动启动 + */ + private Boolean deployStartFlag; + + } + + private List taskList; + } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/DetailJobConfigVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/DetailJobConfigVO.java index 7914355c..ce506f39 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/DetailJobConfigVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/DetailJobConfigVO.java @@ -20,136 +20,136 @@ @Data public class DetailJobConfigVO { - private Long id; + private Long id; - /** - * 任务名称 - */ - private String jobName; + /** + * 任务名称 + */ + private String jobName; - /** - * flink运行配置 - */ - private String jobId; + /** + * flink运行配置 + */ + private String jobId; - private String deployMode; - /** - * 1:开启 0: 关闭 - */ - private Integer isOpen; + private String deployMode; + /** + * 1:开启 0: 关闭 + */ + private Integer isOpen; - private String openStr; + private String openStr; - private Integer status; + private Integer status; - private String statusStr; + private String statusStr; - private String lastStartTime; + private String lastStartTime; - /** - * 创建时间 - */ - private String createTime; + /** + * 创建时间 + */ + private String createTime; - /** - * 修改时间 - */ - private String editTime; + /** + * 修改时间 + */ + private String editTime; - /** - * flink运行配置 - */ - private String flinkRunConfig; + /** + * flink运行配置 + */ + private String flinkRunConfig; - /** - * flink运行配置 - */ - private String flinkCheckpointConfig; + /** + * flink运行配置 + */ + private String flinkCheckpointConfig; - /** - * 三方jar udf、 连接器 等jar如http://xxx.xxx.com/flink-streaming-udf.jar - */ - private String extJarPath; + /** + * 三方jar udf、 连接器 等jar如http://xxx.xxx.com/flink-streaming-udf.jar + */ + private String extJarPath; - /** - * sql语句 - */ - private String flinkSql; + /** + * sql语句 + */ + private String flinkSql; + /** + * 任务类型 + */ + private Integer jobType; - /** - * 任务类型 - */ - private Integer jobType; + /** + * 启动jar可能需要使用的自定义参数 + */ + private String customArgs; - /** - * 启动jar可能需要使用的自定义参数 - */ - private String customArgs; + /** + * 程序入口类 + */ + private String customMainClass; - /** - * 程序入口类 - */ - private String customMainClass; + /** + * 自定义jar的http地址 如:http://ccblog.cn/xx.jar + */ + private String customJarUrl; - /** - * 自定义jar的http地址 如:http://ccblog.cn/xx.jar - */ - private String customJarUrl; + private List types; - private List types; + public static DetailJobConfigVO toVO(JobConfigDTO jobConfigDTO) { + if (jobConfigDTO == null) { + return null; + } + DetailJobConfigVO detailJobConfigVO = new DetailJobConfigVO(); + detailJobConfigVO.setId(jobConfigDTO.getId()); + detailJobConfigVO.setJobName(jobConfigDTO.getJobName()); + detailJobConfigVO.setFlinkRunConfig(jobConfigDTO.getFlinkRunConfig()); + if (StringUtils.isNotEmpty(jobConfigDTO.getFlinkCheckpointConfig())) { + detailJobConfigVO.setFlinkCheckpointConfig( + jobConfigDTO.getFlinkCheckpointConfig().replaceAll("\"", """)); + } + detailJobConfigVO.setJobId(jobConfigDTO.getJobId()); + detailJobConfigVO.setIsOpen(jobConfigDTO.getIsOpen()); + detailJobConfigVO.setOpenStr(YN.getYNByValue(jobConfigDTO.getIsOpen()).getDescribe()); + detailJobConfigVO.setStatusStr(jobConfigDTO.getStatus().getDesc()); + detailJobConfigVO.setStatus(jobConfigDTO.getStatus().getCode()); + detailJobConfigVO + .setLastStartTime(DateFormatUtils.toFormatString(jobConfigDTO.getLastStartTime())); + detailJobConfigVO.setCreateTime(DateFormatUtils.toFormatString(jobConfigDTO.getCreateTime())); + detailJobConfigVO.setEditTime(DateFormatUtils.toFormatString(jobConfigDTO.getEditTime())); + detailJobConfigVO.setFlinkSql(jobConfigDTO.getFlinkSql()); + detailJobConfigVO.setDeployMode(jobConfigDTO.getDeployModeEnum().name()); + detailJobConfigVO.setExtJarPath(jobConfigDTO.getExtJarPath()); + if (CollectionUtils.isNotEmpty(jobConfigDTO.getAlarmTypeEnumList())) { + + List alarmTypeEnumList = jobConfigDTO.getAlarmTypeEnumList(); + List types = Lists.newArrayList(); + for (AlarmTypeEnum alarmTypeEnum : alarmTypeEnumList) { + types.add(alarmTypeEnum.getCode()); + } + detailJobConfigVO.setTypes(types); + } - public static DetailJobConfigVO toVO(JobConfigDTO jobConfigDTO) { - if (jobConfigDTO == null) { - return null; - } - DetailJobConfigVO detailJobConfigVO = new DetailJobConfigVO(); - detailJobConfigVO.setId(jobConfigDTO.getId()); - detailJobConfigVO.setJobName(jobConfigDTO.getJobName()); - detailJobConfigVO.setFlinkRunConfig(jobConfigDTO.getFlinkRunConfig()); - if (StringUtils.isNotEmpty(jobConfigDTO.getFlinkCheckpointConfig())) { - detailJobConfigVO.setFlinkCheckpointConfig(jobConfigDTO.getFlinkCheckpointConfig().replaceAll("\"", """)); - } - detailJobConfigVO.setJobId(jobConfigDTO.getJobId()); - detailJobConfigVO.setIsOpen(jobConfigDTO.getIsOpen()); - detailJobConfigVO.setOpenStr(YN.getYNByValue(jobConfigDTO.getIsOpen()).getDescribe()); - detailJobConfigVO.setStatusStr(jobConfigDTO.getStatus().getDesc()); - detailJobConfigVO.setStatus(jobConfigDTO.getStatus().getCode()); - detailJobConfigVO.setLastStartTime(DateFormatUtils.toFormatString(jobConfigDTO.getLastStartTime())); - detailJobConfigVO.setCreateTime(DateFormatUtils.toFormatString(jobConfigDTO.getCreateTime())); - detailJobConfigVO.setEditTime(DateFormatUtils.toFormatString(jobConfigDTO.getEditTime())); - detailJobConfigVO.setFlinkSql(jobConfigDTO.getFlinkSql()); - detailJobConfigVO.setDeployMode(jobConfigDTO.getDeployModeEnum().name()); - detailJobConfigVO.setExtJarPath(jobConfigDTO.getExtJarPath()); - if (CollectionUtils.isNotEmpty(jobConfigDTO.getAlarmTypeEnumList())) { - - List alarmTypeEnumList = jobConfigDTO.getAlarmTypeEnumList(); - List types = Lists.newArrayList(); - for (AlarmTypeEnum alarmTypeEnum : alarmTypeEnumList) { - types.add(alarmTypeEnum.getCode()); - } - detailJobConfigVO.setTypes(types); - } - - detailJobConfigVO.setCustomArgs(jobConfigDTO.getCustomArgs()); - detailJobConfigVO.setCustomJarUrl(jobConfigDTO.getCustomJarUrl()); - detailJobConfigVO.setCustomMainClass(jobConfigDTO.getCustomMainClass()); - if (jobConfigDTO.getJobTypeEnum()!=null){ - detailJobConfigVO.setJobType(jobConfigDTO.getJobTypeEnum().getCode()); - } - - - return detailJobConfigVO; + detailJobConfigVO.setCustomArgs(jobConfigDTO.getCustomArgs()); + detailJobConfigVO.setCustomJarUrl(jobConfigDTO.getCustomJarUrl()); + detailJobConfigVO.setCustomMainClass(jobConfigDTO.getCustomMainClass()); + if (jobConfigDTO.getJobTypeEnum() != null) { + detailJobConfigVO.setJobType(jobConfigDTO.getJobTypeEnum().getCode()); } + return detailJobConfigVO; + } + } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobConfigHistoryVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobConfigHistoryVO.java index d028b2de..e561abd6 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobConfigHistoryVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobConfigHistoryVO.java @@ -18,98 +18,102 @@ @Data public class JobConfigHistoryVO implements Serializable { - private static final long serialVersionUID = 1L; - - private Long id; - - /** - * job_config主表Id - */ - private Long jobConfigId; - - /** - * 任务名称 - */ - private String jobName; - - /** - * 提交模式: standalone 、yarn 、yarn-session - */ - private String deployMode; - - /** - * flink运行配置 - */ - private String flinkRunConfig; - - /** - * checkPoint配置 - */ - private String flinkCheckpointConfig; - - /** - * udf地址及连接器jar 如http://xxx.xxx.com/flink-streaming-udf.jar - */ - private String extJarPath; - - /** - * 更新版本号 - */ - private Integer version; - - /** - * 创建时间 - */ - private String createTime; - - /** - * 修改时间 - */ - private String editTime; - - private String creator; - - private String editor; - - /** - * sql语句 - */ - private String flinkSql; - - - public static JobConfigHistoryVO toVO(JobConfigHistoryDTO jobConfigHistoryDTO, boolean isFlinkSql) { - if (jobConfigHistoryDTO == null) { - return null; - } - JobConfigHistoryVO jobConfigHistoryVO = new JobConfigHistoryVO(); - jobConfigHistoryVO.setId(jobConfigHistoryDTO.getId()); - jobConfigHistoryVO.setJobConfigId(jobConfigHistoryDTO.getJobConfigId()); - jobConfigHistoryVO.setJobName(jobConfigHistoryDTO.getJobName()); - jobConfigHistoryVO.setDeployMode(jobConfigHistoryDTO.getDeployMode()); - jobConfigHistoryVO.setFlinkRunConfig(jobConfigHistoryDTO.getFlinkRunConfig()); - jobConfigHistoryVO.setFlinkCheckpointConfig(jobConfigHistoryDTO.getFlinkCheckpointConfig()); - jobConfigHistoryVO.setExtJarPath(jobConfigHistoryDTO.getExtJarPath()); - jobConfigHistoryVO.setVersion(jobConfigHistoryDTO.getVersion()); - jobConfigHistoryVO.setCreateTime(DateFormatUtils.toFormatString(jobConfigHistoryDTO.getCreateTime())); - jobConfigHistoryVO.setEditTime(DateFormatUtils.toFormatString(jobConfigHistoryDTO.getEditTime())); - jobConfigHistoryVO.setCreator(jobConfigHistoryDTO.getCreator()); - jobConfigHistoryVO.setEditor(jobConfigHistoryDTO.getEditor()); - if (isFlinkSql) { - jobConfigHistoryVO.setFlinkSql(jobConfigHistoryDTO.getFlinkSql()); - } - return jobConfigHistoryVO; - } + private static final long serialVersionUID = 1L; + + private Long id; + + /** + * job_config主表Id + */ + private Long jobConfigId; + + /** + * 任务名称 + */ + private String jobName; + + /** + * 提交模式: standalone 、yarn 、yarn-session + */ + private String deployMode; + + /** + * flink运行配置 + */ + private String flinkRunConfig; + + /** + * checkPoint配置 + */ + private String flinkCheckpointConfig; + + /** + * udf地址及连接器jar 如http://xxx.xxx.com/flink-streaming-udf.jar + */ + private String extJarPath; + + /** + * 更新版本号 + */ + private Integer version; + + /** + * 创建时间 + */ + private String createTime; - public static List toListVO(List jobConfigHistoryDTOList) { - if (CollectionUtil.isEmpty(jobConfigHistoryDTOList)) { - return Collections.EMPTY_LIST; - } - List list = new ArrayList<>(); + /** + * 修改时间 + */ + private String editTime; - for (JobConfigHistoryDTO jobConfigHistoryDTO : jobConfigHistoryDTOList) { - list.add(toVO(jobConfigHistoryDTO, Boolean.FALSE)); - } + private String creator; - return list; + private String editor; + + /** + * sql语句 + */ + private String flinkSql; + + + public static JobConfigHistoryVO toVO(JobConfigHistoryDTO jobConfigHistoryDTO, + boolean isFlinkSql) { + if (jobConfigHistoryDTO == null) { + return null; } + JobConfigHistoryVO jobConfigHistoryVO = new JobConfigHistoryVO(); + jobConfigHistoryVO.setId(jobConfigHistoryDTO.getId()); + jobConfigHistoryVO.setJobConfigId(jobConfigHistoryDTO.getJobConfigId()); + jobConfigHistoryVO.setJobName(jobConfigHistoryDTO.getJobName()); + jobConfigHistoryVO.setDeployMode(jobConfigHistoryDTO.getDeployMode()); + jobConfigHistoryVO.setFlinkRunConfig(jobConfigHistoryDTO.getFlinkRunConfig()); + jobConfigHistoryVO.setFlinkCheckpointConfig(jobConfigHistoryDTO.getFlinkCheckpointConfig()); + jobConfigHistoryVO.setExtJarPath(jobConfigHistoryDTO.getExtJarPath()); + jobConfigHistoryVO.setVersion(jobConfigHistoryDTO.getVersion()); + jobConfigHistoryVO + .setCreateTime(DateFormatUtils.toFormatString(jobConfigHistoryDTO.getCreateTime())); + jobConfigHistoryVO + .setEditTime(DateFormatUtils.toFormatString(jobConfigHistoryDTO.getEditTime())); + jobConfigHistoryVO.setCreator(jobConfigHistoryDTO.getCreator()); + jobConfigHistoryVO.setEditor(jobConfigHistoryDTO.getEditor()); + if (isFlinkSql) { + jobConfigHistoryVO.setFlinkSql(jobConfigHistoryDTO.getFlinkSql()); + } + return jobConfigHistoryVO; + } + + public static List toListVO( + List jobConfigHistoryDTOList) { + if (CollectionUtil.isEmpty(jobConfigHistoryDTOList)) { + return Collections.EMPTY_LIST; + } + List list = new ArrayList<>(); + + for (JobConfigHistoryDTO jobConfigHistoryDTO : jobConfigHistoryDTOList) { + list.add(toVO(jobConfigHistoryDTO, Boolean.FALSE)); + } + + return list; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobConfigVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobConfigVO.java index 38d5f465..ad5f1d89 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobConfigVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobConfigVO.java @@ -27,146 +27,151 @@ @Data public class JobConfigVO { - private Long id; + private Long id; - /** - * 任务名称 - */ - private String jobName; + /** + * 任务名称 + */ + private String jobName; - private String deployMode; + private String deployMode; - /** - * flink运行配置 - */ - private String jobId; + /** + * flink运行配置 + */ + private String jobId; - /** - * 1:开启 0: 关闭 - */ - private Integer isOpen; + /** + * 1:开启 0: 关闭 + */ + private Integer isOpen; - private String isOpenStr; + private String isOpenStr; - private Integer status; + private Integer status; - private String statusStr; + private String statusStr; - private String lastStartTime; + private String lastStartTime; - private Long lastRunLogId; + private Long lastRunLogId; - private String flinkRunUrl; + private String flinkRunUrl; - /** - * 创建时间 - */ - private String createTime; + /** + * 创建时间 + */ + private String createTime; - /** - * 修改时间 - */ - private String editTime; + /** + * 修改时间 + */ + private String editTime; - private String alarmStrs; + private String alarmStrs; - public static JobConfigVO toVO(JobConfigDTO jobConfigDTO, Map map) { - if (jobConfigDTO == null) { - return null; - } - JobConfigVO jobConfigVO = new JobConfigVO(); - jobConfigVO.setId(jobConfigDTO.getId()); - jobConfigVO.setJobName(jobConfigDTO.getJobName()); - jobConfigVO.setJobId(jobConfigDTO.getJobId()); - jobConfigVO.setIsOpen(jobConfigDTO.getIsOpen()); - jobConfigVO.setIsOpenStr(YN.getYNByValue(jobConfigDTO.getIsOpen()).getDescribe()); - jobConfigVO.setStatus(jobConfigDTO.getStatus().getCode()); - jobConfigVO.setStatusStr(jobConfigDTO.getStatus().getDesc()); - if (jobConfigDTO.getDeployModeEnum() != null) { - jobConfigVO.setDeployMode(jobConfigDTO.getDeployModeEnum().name()); - } + public static JobConfigVO toVO(JobConfigDTO jobConfigDTO, Map map) { + if (jobConfigDTO == null) { + return null; + } + JobConfigVO jobConfigVO = new JobConfigVO(); + jobConfigVO.setId(jobConfigDTO.getId()); + jobConfigVO.setJobName(jobConfigDTO.getJobName()); + jobConfigVO.setJobId(jobConfigDTO.getJobId()); + jobConfigVO.setIsOpen(jobConfigDTO.getIsOpen()); + jobConfigVO.setIsOpenStr(YN.getYNByValue(jobConfigDTO.getIsOpen()).getDescribe()); + jobConfigVO.setStatus(jobConfigDTO.getStatus().getCode()); + jobConfigVO.setStatusStr(jobConfigDTO.getStatus().getDesc()); + if (jobConfigDTO.getDeployModeEnum() != null) { + jobConfigVO.setDeployMode(jobConfigDTO.getDeployModeEnum().name()); + } - String domain = map.get(jobConfigDTO.getDeployModeEnum()); - - if (StringUtils.isNotEmpty(domain)) { - if (DeployModeEnum.YARN_PER.equals(jobConfigDTO.getDeployModeEnum()) - && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { - jobConfigVO.setFlinkRunUrl(HttpUtil.buildUrl( domain , - FlinkYarnRestUriConstants.getUriOverviewForYarn(jobConfigDTO.getJobId()))); - } - if (DeployModeEnum.LOCAL.equals(jobConfigDTO.getDeployModeEnum()) - && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { - jobConfigVO.setFlinkRunUrl(domain + String.format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, - jobConfigDTO.getJobId())); - } - if (DeployModeEnum.STANDALONE.equals(jobConfigDTO.getDeployModeEnum()) - && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { - String[] urls = domain.split(";"); - for (String url : urls) { - if (HttpServiceCheckerUtil.checkUrlConnect(url)) { - jobConfigVO.setFlinkRunUrl(url.trim() + - String.format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, jobConfigDTO.getJobId())); - break; - } - } - } + String domain = map.get(jobConfigDTO.getDeployModeEnum()); + + if (StringUtils.isNotEmpty(domain)) { + if (DeployModeEnum.YARN_PER.equals(jobConfigDTO.getDeployModeEnum()) + && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { + jobConfigVO.setFlinkRunUrl(HttpUtil.buildUrl(domain, + FlinkYarnRestUriConstants.getUriOverviewForYarn(jobConfigDTO.getJobId()))); + } + if (DeployModeEnum.LOCAL.equals(jobConfigDTO.getDeployModeEnum()) + && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { + jobConfigVO + .setFlinkRunUrl(domain + String.format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, + jobConfigDTO.getJobId())); + } + if (DeployModeEnum.STANDALONE.equals(jobConfigDTO.getDeployModeEnum()) + && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { + String[] urls = domain.split(";"); + for (String url : urls) { + if (HttpServiceCheckerUtil.checkUrlConnect(url)) { + jobConfigVO.setFlinkRunUrl(url.trim() + + String.format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, + jobConfigDTO.getJobId())); + break; + } } - - jobConfigVO.setLastRunLogId(jobConfigDTO.getLastRunLogId()); - jobConfigVO.setLastStartTime(DateFormatUtils.toFormatString(jobConfigDTO.getLastStartTime())); - jobConfigVO.setCreateTime(DateFormatUtils.toFormatString(jobConfigDTO.getCreateTime())); - jobConfigVO.setEditTime(DateFormatUtils.toFormatString(jobConfigDTO.getEditTime())); - return jobConfigVO; + } } + jobConfigVO.setLastRunLogId(jobConfigDTO.getLastRunLogId()); + jobConfigVO.setLastStartTime(DateFormatUtils.toFormatString(jobConfigDTO.getLastStartTime())); + jobConfigVO.setCreateTime(DateFormatUtils.toFormatString(jobConfigDTO.getCreateTime())); + jobConfigVO.setEditTime(DateFormatUtils.toFormatString(jobConfigDTO.getEditTime())); + return jobConfigVO; + } - public static List toListVO(List jobConfigDTOList, Map map) { - if (CollectionUtils.isEmpty(jobConfigDTOList)) { - return Collections.emptyList(); - } - List list = new ArrayList(); + public static List toListVO(List jobConfigDTOList, + Map map) { + if (CollectionUtils.isEmpty(jobConfigDTOList)) { + return Collections.emptyList(); + } - for (JobConfigDTO jobConfigDTO : jobConfigDTOList) { - list.add(JobConfigVO.toVO(jobConfigDTO, map)); - } - return list; + List list = new ArrayList(); + + for (JobConfigDTO jobConfigDTO : jobConfigDTOList) { + list.add(JobConfigVO.toVO(jobConfigDTO, map)); } + return list; + } - public static void buildAlarm(List jobConfigVOList, - Map> map) { - if (CollectionUtils.isEmpty(map)) { - return; - } - for (JobConfigVO jobConfigVO : jobConfigVOList) { - List list = map.get(jobConfigVO.getId()); - if (CollectionUtil.isNotEmpty(list)) { - StringBuilder str = new StringBuilder("["); - for (AlarmTypeEnum alarmTypeEnum : list) { - switch (alarmTypeEnum) { - case DINGDING: - str.append(" 钉钉"); - break; - case CALLBACK_URL: - str.append(" 回调"); - break; - case AUTO_START_JOB: - str.append(" 自动重启"); - break; - } - } - str.append("]"); - jobConfigVO.setAlarmStrs(str.toString()); - } + public static void buildAlarm(List jobConfigVOList, + Map> map) { + if (CollectionUtils.isEmpty(map)) { + return; + } + for (JobConfigVO jobConfigVO : jobConfigVOList) { + List list = map.get(jobConfigVO.getId()); + if (CollectionUtil.isNotEmpty(list)) { + StringBuilder str = new StringBuilder("["); + for (AlarmTypeEnum alarmTypeEnum : list) { + switch (alarmTypeEnum) { + case DINGDING: + str.append(" 钉钉"); + break; + case CALLBACK_URL: + str.append(" 回调"); + break; + case AUTO_START_JOB: + str.append(" 自动重启"); + break; + default: + + } } - + str.append("]"); + jobConfigVO.setAlarmStrs(str.toString()); + } } + + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobRunLogVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobRunLogVO.java index f3f61d03..26eb1bc4 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobRunLogVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/JobRunLogVO.java @@ -21,109 +21,109 @@ @Data public class JobRunLogVO implements Serializable { - private static final long serialVersionUID = 1L; - - private Long id; - - private Long jobConfigId; - - /** - * 任务名称 - */ - private String jobName; - - /** - * 提交模式: standalone 、yarn 、yarn-session - */ - private String deployMode; - - /** - * 运行后的任务id - */ - private String jobId; - - /** - * 远程日志url的地址 - */ - private String remoteLogUrl; - - /** - * 启动时间 - */ - private Date startTime; - - /** - * 结束时间 - */ - private Date endTime; - - /** - * 任务状态 - */ - private String jobStatus; - - /** - * 创建时间 - */ - private String createTime; - - /** - * 修改时间 - */ - private String editTime; - - - /** - * 启动时本地日志 - */ - private String localLog; - - /** - * 本地客户端日志 - */ - private String clinetJobUrl; - - - public static JobRunLogVO toVO(JobRunLogDTO jobRunLogDTO, boolean isLocalLog,Integer port) { - if (jobRunLogDTO == null) { - return null; - } - JobRunLogVO jobRunLogVO = new JobRunLogVO(); - jobRunLogVO.setId(jobRunLogDTO.getId()); - jobRunLogVO.setJobConfigId(jobRunLogDTO.getJobConfigId()); - jobRunLogVO.setJobName(jobRunLogDTO.getJobName()); - jobRunLogVO.setDeployMode(jobRunLogDTO.getDeployMode()); - jobRunLogVO.setJobId(jobRunLogDTO.getJobId()); - jobRunLogVO.setRemoteLogUrl(jobRunLogDTO.getRemoteLogUrl()); - jobRunLogVO.setStartTime(jobRunLogDTO.getStartTime()); - jobRunLogVO.setEndTime(jobRunLogDTO.getEndTime()); - jobRunLogVO.setJobStatus(JobStatusEnum.getJobStatusEnum(jobRunLogDTO.getJobStatus()).getDesc()); - jobRunLogVO.setCreateTime(DateFormatUtils.toFormatString(jobRunLogDTO.getCreateTime())); - jobRunLogVO.setEditTime(DateFormatUtils.toFormatString(jobRunLogDTO.getEditTime())); - if (isLocalLog) { - jobRunLogVO.setLocalLog(jobRunLogDTO.getLocalLog()); - } - if (port!=null && StringUtils.isNotEmpty(jobRunLogDTO.getRunIp())){ - jobRunLogVO.setClinetJobUrl(String.format("http://%s:%s/log/getFlinkLocalJobLog", - jobRunLogDTO.getRunIp(),port)); - } - - return jobRunLogVO; - } + private static final long serialVersionUID = 1L; + + private Long id; + + private Long jobConfigId; + + /** + * 任务名称 + */ + private String jobName; + + /** + * 提交模式: standalone 、yarn 、yarn-session + */ + private String deployMode; + + /** + * 运行后的任务id + */ + private String jobId; + + /** + * 远程日志url的地址 + */ + private String remoteLogUrl; + + /** + * 启动时间 + */ + private Date startTime; + + /** + * 结束时间 + */ + private Date endTime; + + /** + * 任务状态 + */ + private String jobStatus; + + /** + * 创建时间 + */ + private String createTime; - public static List toListVO(List jobRunLogList, boolean isLocalLog) { - if (CollectionUtils.isEmpty(jobRunLogList)) { - return Collections.emptyList(); - } - List list = new ArrayList<>(); + /** + * 修改时间 + */ + private String editTime; - for (JobRunLogDTO jobRunLog : jobRunLogList) { - list.add(JobRunLogVO.toVO(jobRunLog, isLocalLog,null)); - } - return list; + /** + * 启动时本地日志 + */ + private String localLog; + /** + * 本地客户端日志 + */ + private String clinetJobUrl; + + + public static JobRunLogVO toVO(JobRunLogDTO jobRunLogDTO, boolean isLocalLog, Integer port) { + if (jobRunLogDTO == null) { + return null; + } + JobRunLogVO jobRunLogVO = new JobRunLogVO(); + jobRunLogVO.setId(jobRunLogDTO.getId()); + jobRunLogVO.setJobConfigId(jobRunLogDTO.getJobConfigId()); + jobRunLogVO.setJobName(jobRunLogDTO.getJobName()); + jobRunLogVO.setDeployMode(jobRunLogDTO.getDeployMode()); + jobRunLogVO.setJobId(jobRunLogDTO.getJobId()); + jobRunLogVO.setRemoteLogUrl(jobRunLogDTO.getRemoteLogUrl()); + jobRunLogVO.setStartTime(jobRunLogDTO.getStartTime()); + jobRunLogVO.setEndTime(jobRunLogDTO.getEndTime()); + jobRunLogVO.setJobStatus(JobStatusEnum.getJobStatusEnum(jobRunLogDTO.getJobStatus()).getDesc()); + jobRunLogVO.setCreateTime(DateFormatUtils.toFormatString(jobRunLogDTO.getCreateTime())); + jobRunLogVO.setEditTime(DateFormatUtils.toFormatString(jobRunLogDTO.getEditTime())); + if (isLocalLog) { + jobRunLogVO.setLocalLog(jobRunLogDTO.getLocalLog()); } + if (port != null && StringUtils.isNotEmpty(jobRunLogDTO.getRunIp())) { + jobRunLogVO.setClinetJobUrl(String.format("http://%s:%s/log/getFlinkLocalJobLog", + jobRunLogDTO.getRunIp(), port)); + } + + return jobRunLogVO; + } + + public static List toListVO(List jobRunLogList, boolean isLocalLog) { + if (CollectionUtils.isEmpty(jobRunLogList)) { + return Collections.emptyList(); + } + List list = new ArrayList<>(); + + for (JobRunLogDTO jobRunLog : jobRunLogList) { + list.add(JobRunLogVO.toVO(jobRunLog, isLocalLog, null)); + } + return list; + + + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/PageVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/PageVO.java index 05ac0120..c64e3a6a 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/PageVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/PageVO.java @@ -11,26 +11,26 @@ @Data public class PageVO { - /** - * 当前页码 - */ - private int pageNum; + /** + * 当前页码 + */ + private int pageNum; - /** - * 每页数量 - */ - private int pageSize; + /** + * 每页数量 + */ + private int pageSize; - /** - * 页码 - */ - private int pages; + /** + * 页码 + */ + private int pages; - /** - * 总条数 - */ - private long total; + /** + * 总条数 + */ + private long total; - private T data; + private T data; } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SavepointBackupVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SavepointBackupVO.java index c4e5e404..9c600df0 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SavepointBackupVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SavepointBackupVO.java @@ -17,36 +17,37 @@ public class SavepointBackupVO { - private Long id; - /** - * backup地址 - */ - private String savepointPath; + private Long id; + /** + * backup地址 + */ + private String savepointPath; - private String backupTime; + private String backupTime; - public static SavepointBackupVO toDTO(SavepointBackupDTO savepointBackupDTO) { - if (savepointBackupDTO == null) { - return null; - } - SavepointBackupVO savepointBackupVO = new SavepointBackupVO(); - savepointBackupVO.setId(savepointBackupDTO.getId()); - savepointBackupVO.setSavepointPath(savepointBackupDTO.getSavepointPath()); - savepointBackupVO.setBackupTime(DateFormatUtils.toFormatString(savepointBackupDTO.getBackupTime())); - return savepointBackupVO; + public static SavepointBackupVO toDTO(SavepointBackupDTO savepointBackupDTO) { + if (savepointBackupDTO == null) { + return null; } - - public static List toDTOList(List savepointBackupList) { - if (CollectionUtil.isEmpty(savepointBackupList)) { - return Collections.emptyList(); - } - List list = CollectionUtil.newArrayList(); - for (SavepointBackupDTO savepointBackupDTO : savepointBackupList) { - list.add(toDTO(savepointBackupDTO)); - } - return list; + SavepointBackupVO savepointBackupVO = new SavepointBackupVO(); + savepointBackupVO.setId(savepointBackupDTO.getId()); + savepointBackupVO.setSavepointPath(savepointBackupDTO.getSavepointPath()); + savepointBackupVO + .setBackupTime(DateFormatUtils.toFormatString(savepointBackupDTO.getBackupTime())); + return savepointBackupVO; + } + + public static List toDTOList(List savepointBackupList) { + if (CollectionUtil.isEmpty(savepointBackupList)) { + return Collections.emptyList(); + } + List list = CollectionUtil.newArrayList(); + for (SavepointBackupDTO savepointBackupDTO : savepointBackupList) { + list.add(toDTO(savepointBackupDTO)); } + return list; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SysConfigVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SysConfigVO.java index 68c4ceb6..4551639c 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SysConfigVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SysConfigVO.java @@ -11,12 +11,12 @@ @Data public class SysConfigVO { - private String key; + private String key; - private String desc; + private String desc; - public SysConfigVO(String key, String desc) { - this.key = key; - this.desc = desc; - } + public SysConfigVO(String key, String desc) { + this.key = key; + this.desc = desc; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SystemConfigVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SystemConfigVO.java index 9cdffeb6..f69d7c6a 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SystemConfigVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/SystemConfigVO.java @@ -18,39 +18,39 @@ public class SystemConfigVO { - private Long id; + private Long id; - private String desc; + private String desc; - private String key; + private String key; - private String val; + private String val; - public static SystemConfigVO toVO(SystemConfigDTO systemConfigDTO) { - if (systemConfigDTO == null) { - return null; - } - SystemConfigVO systemConfigVO = new SystemConfigVO(); - systemConfigVO.setId(systemConfigDTO.getId()); - if (SysConfigEnum.getSysConfigEnum(systemConfigDTO.getKey())!=null){ - systemConfigVO.setDesc(SysConfigEnum.getSysConfigEnum(systemConfigDTO.getKey()).getDesc()); - } - systemConfigVO.setKey(systemConfigDTO.getKey()); - systemConfigVO.setVal(systemConfigDTO.getVal()); - return systemConfigVO; + public static SystemConfigVO toVO(SystemConfigDTO systemConfigDTO) { + if (systemConfigDTO == null) { + return null; } - - public static List toListVO(List systemConfigDTOList) { - if (CollectionUtils.isEmpty(systemConfigDTOList)) { - return Collections.emptyList(); - } - List list = new ArrayList<>(); - for (SystemConfigDTO systemConfigDTO : systemConfigDTOList) { - list.add(toVO(systemConfigDTO)); - } - return list; + SystemConfigVO systemConfigVO = new SystemConfigVO(); + systemConfigVO.setId(systemConfigDTO.getId()); + if (SysConfigEnum.getSysConfigEnum(systemConfigDTO.getKey()) != null) { + systemConfigVO.setDesc(SysConfigEnum.getSysConfigEnum(systemConfigDTO.getKey()).getDesc()); + } + systemConfigVO.setKey(systemConfigDTO.getKey()); + systemConfigVO.setVal(systemConfigDTO.getVal()); + return systemConfigVO; + } + + public static List toListVO(List systemConfigDTOList) { + if (CollectionUtils.isEmpty(systemConfigDTOList)) { + return Collections.emptyList(); + } + List list = new ArrayList<>(); + for (SystemConfigDTO systemConfigDTO : systemConfigDTOList) { + list.add(toVO(systemConfigDTO)); } + return list; + } } diff --git a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/UserVO.java b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/UserVO.java index 1504f345..281f7e2c 100644 --- a/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/UserVO.java +++ b/flink-streaming-web-common/src/main/java/com/flink/streaming/web/model/vo/UserVO.java @@ -18,74 +18,73 @@ @Data public class UserVO { - /** - * 用户编号 - */ - private Integer id; - - /** - * 用户帐号 - */ - private String username; - - /** - * 用户名称 - */ - private String name; - - /** - * @see UserStatusEnum - * 1:启用 0: 停用 - */ - private Integer status; - - - /** - * 状态描述 - */ - private String statusDesc; - - - /** - * 创建时间 - */ - private String createTimeStr; - - /** - * 修改时间 - */ - private String editTimeStr; - - - public static UserVO toVO(UserDTO userDTO) { - if (userDTO == null) { - return null; - } - UserVO userVO = new UserVO(); - userVO.setId(userDTO.getId()); - userVO.setUsername(userDTO.getUsername()); - userVO.setName(userDTO.getName()); - userVO.setStatus(userDTO.getStatus()); - userVO.setStatusDesc(UserStatusEnum.getStatus(userDTO.getStatus()).getDesc()); - userVO.setCreateTimeStr(DateFormatUtils.toFormatString(userDTO.getCreateTime())); - userVO.setEditTimeStr(DateFormatUtils.toFormatString(userDTO.getEditTime())); - return userVO; + /** + * 用户编号 + */ + private Integer id; + + /** + * 用户帐号 + */ + private String username; + + /** + * 用户名称 + */ + private String name; + + /** + * @see UserStatusEnum 1:启用 0: 停用 + */ + private Integer status; + + + /** + * 状态描述 + */ + private String statusDesc; + + + /** + * 创建时间 + */ + private String createTimeStr; + + /** + * 修改时间 + */ + private String editTimeStr; + + + public static UserVO toVO(UserDTO userDTO) { + if (userDTO == null) { + return null; + } + UserVO userVO = new UserVO(); + userVO.setId(userDTO.getId()); + userVO.setUsername(userDTO.getUsername()); + userVO.setName(userDTO.getName()); + userVO.setStatus(userDTO.getStatus()); + userVO.setStatusDesc(UserStatusEnum.getStatus(userDTO.getStatus()).getDesc()); + userVO.setCreateTimeStr(DateFormatUtils.toFormatString(userDTO.getCreateTime())); + userVO.setEditTimeStr(DateFormatUtils.toFormatString(userDTO.getEditTime())); + return userVO; + } + + public static List toListVO(List userDTOList) { + if (CollectionUtil.isEmpty(userDTOList)) { + return Collections.EMPTY_LIST; } + List list = CollectionUtil.newArrayList(); - public static List toListVO(List userDTOList) { - if (CollectionUtil.isEmpty(userDTOList)) { - return Collections.EMPTY_LIST; - } - List list = CollectionUtil.newArrayList(); - - for (UserDTO userDTO : userDTOList) { - if (userDTO == null) { - continue; - } - list.add(UserVO.toVO(userDTO)); - } - return list; + for (UserDTO userDTO : userDTOList) { + if (userDTO == null) { + continue; + } + list.add(UserVO.toVO(userDTO)); } + return list; + } } diff --git a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/AlarmPoolConfig.java b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/AlarmPoolConfig.java index beb3bc8f..ebd9f861 100644 --- a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/AlarmPoolConfig.java +++ b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/AlarmPoolConfig.java @@ -8,9 +8,8 @@ import java.util.concurrent.TimeUnit; /** + * 核心线程10个 最大线程100 队列100 公平策略 告警线程池 * - * 核心线程10个 最大线程100 队列100 公平策略 - * 告警线程池 * @author zhuhuipei * @Description: * @date 2018/9/6 @@ -18,37 +17,38 @@ */ @Slf4j -public class AlarmPoolConfig { +public final class AlarmPoolConfig { - private static int corePoolSize = 10; + private static int corePoolSize = 10; - private static int maximumPoolSize = 30; + private static int maximumPoolSize = 30; - private static long keepAliveTime = 10; + private static long keepAliveTime = 10; - private static ThreadPoolExecutor threadPoolExecutor; + private static ThreadPoolExecutor threadPoolExecutor; - private static AlarmPoolConfig alarmPoolConfig; + private static AlarmPoolConfig alarmPoolConfig; - private AlarmPoolConfig() { - BlockingQueue workQueue = new ArrayBlockingQueue<>(100, true); - threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.MINUTES, workQueue); - } + private AlarmPoolConfig() { + BlockingQueue workQueue = new ArrayBlockingQueue<>(100, true); + threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, + TimeUnit.MINUTES, workQueue); + } - public static synchronized AlarmPoolConfig getInstance() { + public static synchronized AlarmPoolConfig getInstance() { + if (null == alarmPoolConfig) { + synchronized (AlarmPoolConfig.class) { if (null == alarmPoolConfig) { - synchronized (AlarmPoolConfig.class) { - if (null == alarmPoolConfig) { - alarmPoolConfig = new AlarmPoolConfig(); - } - } + alarmPoolConfig = new AlarmPoolConfig(); } - log.info("AlarmPoolConfig threadPoolExecutor={}", threadPoolExecutor); - return alarmPoolConfig; + } } + log.info("AlarmPoolConfig threadPoolExecutor={}", threadPoolExecutor); + return alarmPoolConfig; + } - public synchronized ThreadPoolExecutor getThreadPoolExecutor() { - return threadPoolExecutor; - } + public synchronized ThreadPoolExecutor getThreadPoolExecutor() { + return threadPoolExecutor; + } } diff --git a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/CustomConfig.java b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/CustomConfig.java index 926756dc..bd59e0a8 100644 --- a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/CustomConfig.java +++ b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/CustomConfig.java @@ -15,6 +15,6 @@ public class CustomConfig { - @Value("${server.port}") - private Integer webPort; + @Value("${server.port}") + private Integer webPort; } diff --git a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/JobThreadPool.java b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/JobThreadPool.java index 6db3fbbc..5d102329 100644 --- a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/JobThreadPool.java +++ b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/JobThreadPool.java @@ -8,7 +8,6 @@ import java.util.concurrent.TimeUnit; /** - * * 核心线程10个 最大线程100 队列200 公平策略 * * @author zhuhuipei @@ -17,39 +16,40 @@ * @time 00:16 */ @Slf4j -public class JobThreadPool { +public final class JobThreadPool { - private static int corePoolSize = 10; + private static int corePoolSize = 10; - private static int maximumPoolSize = 100; + private static int maximumPoolSize = 100; - private static long keepAliveTime = 10; + private static long keepAliveTime = 10; - private static ThreadPoolExecutor threadPoolExecutor; + private static ThreadPoolExecutor threadPoolExecutor; - private static JobThreadPool asyncThreadPool; + private static JobThreadPool asyncThreadPool; - private JobThreadPool() { - BlockingQueue workQueue = new ArrayBlockingQueue<>(200, true); - threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.MINUTES, workQueue); - } + private JobThreadPool() { + BlockingQueue workQueue = new ArrayBlockingQueue<>(200, true); + threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, + TimeUnit.MINUTES, workQueue); + } - public static synchronized JobThreadPool getInstance() { + public static synchronized JobThreadPool getInstance() { + if (null == asyncThreadPool) { + synchronized (JobThreadPool.class) { if (null == asyncThreadPool) { - synchronized (JobThreadPool.class) { - if (null == asyncThreadPool) { - asyncThreadPool = new JobThreadPool(); - } - } + asyncThreadPool = new JobThreadPool(); } - log.info("JobThreadPool threadPoolExecutor={}", threadPoolExecutor); - return asyncThreadPool; + } } + log.info("JobThreadPool threadPoolExecutor={}", threadPoolExecutor); + return asyncThreadPool; + } - public synchronized ThreadPoolExecutor getThreadPoolExecutor() { - return threadPoolExecutor; - } + public synchronized ThreadPoolExecutor getThreadPoolExecutor() { + return threadPoolExecutor; + } } diff --git a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/SavePointThreadPool.java b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/SavePointThreadPool.java index 74363de8..dd891e04 100644 --- a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/SavePointThreadPool.java +++ b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/SavePointThreadPool.java @@ -8,7 +8,6 @@ import java.util.concurrent.TimeUnit; /** - * * 核心线程10个 最大线程100 队列200 公平策略 * * @author zhuhuipei @@ -17,39 +16,40 @@ * @time 00:16 */ @Slf4j -public class SavePointThreadPool { +public final class SavePointThreadPool { - private static int corePoolSize = 10; + private static int corePoolSize = 10; - private static int maximumPoolSize = 100; + private static int maximumPoolSize = 100; - private static long keepAliveTime = 10; + private static long keepAliveTime = 10; - private static ThreadPoolExecutor threadPoolExecutor; + private static ThreadPoolExecutor threadPoolExecutor; - private static SavePointThreadPool asyncThreadPool; + private static SavePointThreadPool asyncThreadPool; - private SavePointThreadPool() { - BlockingQueue workQueue = new ArrayBlockingQueue<>(400, true); - threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.MINUTES, workQueue); - } + private SavePointThreadPool() { + BlockingQueue workQueue = new ArrayBlockingQueue<>(400, true); + threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, + TimeUnit.MINUTES, workQueue); + } - public static synchronized SavePointThreadPool getInstance() { + public static synchronized SavePointThreadPool getInstance() { + if (null == asyncThreadPool) { + synchronized (SavePointThreadPool.class) { if (null == asyncThreadPool) { - synchronized (SavePointThreadPool.class) { - if (null == asyncThreadPool) { - asyncThreadPool = new SavePointThreadPool(); - } - } + asyncThreadPool = new SavePointThreadPool(); } - log.info("JobThreadPool threadPoolExecutor={}", threadPoolExecutor); - return asyncThreadPool; + } } + log.info("JobThreadPool threadPoolExecutor={}", threadPoolExecutor); + return asyncThreadPool; + } - public synchronized ThreadPoolExecutor getThreadPoolExecutor() { - return threadPoolExecutor; - } + public synchronized ThreadPoolExecutor getThreadPoolExecutor() { + return threadPoolExecutor; + } } diff --git a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/TaskPoolConfig.java b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/TaskPoolConfig.java index bcaab7c2..1fef1330 100644 --- a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/TaskPoolConfig.java +++ b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/TaskPoolConfig.java @@ -9,6 +9,7 @@ /** * SchedulerTask 线程池 + * * @author zhuhuipei * @Description: * @date 2018/9/6 @@ -18,19 +19,19 @@ @EnableAsync public class TaskPoolConfig { - private int corePoolSize = 25; + private int corePoolSize = 25; - private int maxPoolSize = 50; + private int maxPoolSize = 50; - private int queueCapacity = 10; + private int queueCapacity = 10; - @Bean - public Executor taskExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(corePoolSize); - executor.setMaxPoolSize(maxPoolSize); - executor.setQueueCapacity(queueCapacity); - executor.initialize(); - return executor; - } + @Bean + public Executor taskExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(corePoolSize); + executor.setMaxPoolSize(maxPoolSize); + executor.setQueueCapacity(queueCapacity); + executor.initialize(); + return executor; + } } diff --git a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/WaitForPoolConfig.java b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/WaitForPoolConfig.java index 52821aac..b8e7a713 100644 --- a/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/WaitForPoolConfig.java +++ b/flink-streaming-web-config/src/main/java/com/flink/streaming/web/config/WaitForPoolConfig.java @@ -15,38 +15,39 @@ */ @Slf4j -public class WaitForPoolConfig { +public final class WaitForPoolConfig { - private static int corePoolSize = 20; + private static int corePoolSize = 20; - private static int maximumPoolSize = 400; + private static int maximumPoolSize = 400; - private static long keepAliveTime = 10; + private static long keepAliveTime = 10; - private static ThreadPoolExecutor threadPoolExecutor; + private static ThreadPoolExecutor threadPoolExecutor; - private static WaitForPoolConfig alarmPoolConfig; + private static WaitForPoolConfig alarmPoolConfig; - private WaitForPoolConfig() { - BlockingQueue workQueue = new ArrayBlockingQueue<>(100, true); - threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.MINUTES, - workQueue, new ThreadPoolExecutor.AbortPolicy()); - } + private WaitForPoolConfig() { + BlockingQueue workQueue = new ArrayBlockingQueue<>(100, true); + threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, + TimeUnit.MINUTES, + workQueue, new ThreadPoolExecutor.AbortPolicy()); + } - public static synchronized WaitForPoolConfig getInstance() { + public static synchronized WaitForPoolConfig getInstance() { + if (null == alarmPoolConfig) { + synchronized (WaitForPoolConfig.class) { if (null == alarmPoolConfig) { - synchronized (WaitForPoolConfig.class) { - if (null == alarmPoolConfig) { - alarmPoolConfig = new WaitForPoolConfig(); - } - } + alarmPoolConfig = new WaitForPoolConfig(); } - log.info("WaitForPoolConfig threadPoolExecutor={}", threadPoolExecutor); - return alarmPoolConfig; + } } + log.info("WaitForPoolConfig threadPoolExecutor={}", threadPoolExecutor); + return alarmPoolConfig; + } - public synchronized ThreadPoolExecutor getThreadPoolExecutor() { - return threadPoolExecutor; - } + public synchronized ThreadPoolExecutor getThreadPoolExecutor() { + return threadPoolExecutor; + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/AlarmServiceAO.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/AlarmServiceAO.java index 1bbff18d..5543f452 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/AlarmServiceAO.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/AlarmServiceAO.java @@ -10,22 +10,22 @@ */ public interface AlarmServiceAO { - /** - * 发送钉钉告警消息 - * - * @author zhuhuipei - * @date 2020-09-25 - * @time 19:53 - */ - boolean sendForDingding(String url, String content, Long jobConfigId); + /** + * 发送钉钉告警消息 + * + * @author zhuhuipei + * @date 2020-09-25 + * @time 19:53 + */ + boolean sendForDingding(String url, String content, Long jobConfigId); - /** - * 发送http请求回调 - * - * @author zhuhuipei - * @date 2021/2/21 - * @time 11:31 - */ - boolean sendForHttp(String url,CallbackDTO callbackDTO); + /** + * 发送http请求回调 + * + * @author zhuhuipei + * @date 2021/2/21 + * @time 11:31 + */ + boolean sendForHttp(String url, CallbackDTO callbackDTO); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/DingDingService.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/DingDingService.java index 40ff4610..3f2c54f0 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/DingDingService.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/DingDingService.java @@ -5,22 +5,24 @@ /** * 钉钉服务 + * * @author wxj - * @date 2022年1月5日 下午3:00:49 * @version V1.0 + * @date 2022年1月5日 下午3:00:49 */ public interface DingDingService { - - /** - * 定制化告警通知 - * - * @param cusContent - * @param jobConfigDTO - * @param deployModeEnum - * @author wxj - * @date 2022年1月5日 上午10:51:19 - * @version V1.0 - */ - public void doAlarmNotify(String cusContent, JobConfigDTO jobConfigDTO, DeployModeEnum deployModeEnum); + + /** + * 定制化告警通知 + * + * @param cusContent + * @param jobConfigDTO + * @param deployModeEnum + * @author wxj + * @date 2022年1月5日 上午10:51:19 + * @version V1.0 + */ + void doAlarmNotify(String cusContent, JobConfigDTO jobConfigDTO, + DeployModeEnum deployModeEnum); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobBaseServiceAO.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobBaseServiceAO.java index 8ac4c2a8..c624333a 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobBaseServiceAO.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobBaseServiceAO.java @@ -11,60 +11,60 @@ */ public interface JobBaseServiceAO { - /** - * 提交任务前校验数据 - * - * @author zhuhuipei - * @date 2021/3/28 - * @time 10:12 - */ - void checkStart(JobConfigDTO jobConfigDTO); + /** + * 提交任务前校验数据 + * + * @author zhuhuipei + * @date 2021/3/28 + * @time 10:12 + */ + void checkStart(JobConfigDTO jobConfigDTO); - /** - * Savepoint前校验数据 - * - * @author zhuhuipei - * @date 2021/3/31 - * @time 19:54 - */ - void checkSavepoint(JobConfigDTO jobConfigDTO); + /** + * Savepoint前校验数据 + * + * @author zhuhuipei + * @date 2021/3/31 + * @time 19:54 + */ + void checkSavepoint(JobConfigDTO jobConfigDTO); - /** - * 管配置检查 - * - * @author zhuhuipei - * @date 2021/3/31 - * @time 20:06 - */ - void checkClose(JobConfigDTO jobConfigDTO); + /** + * 管配置检查 + * + * @author zhuhuipei + * @date 2021/3/31 + * @time 20:06 + */ + void checkClose(JobConfigDTO jobConfigDTO); - /** - * @author zhuhuipei - * @date 2021/3/28 - * @time 10:12 - */ - Long insertJobRunLog(JobConfigDTO jobConfigDTO, String userName); + /** + * @author zhuhuipei + * @date 2021/3/28 + * @time 10:12 + */ + Long insertJobRunLog(JobConfigDTO jobConfigDTO, String userName); - /** - * 将配置的sql 写入文件并且返回运行所需参数 - * - * @author zhuhuipei - * @date 2021/3/28 - * @time 10:37 - */ - JobRunParamDTO writeSqlToFile(JobConfigDTO jobConfigDTO); + /** + * 将配置的sql 写入文件并且返回运行所需参数 + * + * @author zhuhuipei + * @date 2021/3/28 + * @time 10:37 + */ + JobRunParamDTO writeSqlToFile(JobConfigDTO jobConfigDTO); - /** - * 异步执行任务 - * - * @author zhuhuipei - * @date 2021/3/28 - * @time 10:55 - */ - void aSyncExecJob(final JobRunParamDTO jobRunParamDTO, final JobConfigDTO jobConfig, - final Long jobRunLogId, final String savepointPath); + /** + * 异步执行任务 + * + * @author zhuhuipei + * @date 2021/3/28 + * @time 10:55 + */ + void aSyncExecJob(final JobRunParamDTO jobRunParamDTO, final JobConfigDTO jobConfig, + final Long jobRunLogId, final String savepointPath); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobConfigAO.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobConfigAO.java index cacf9586..6d0080b4 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobConfigAO.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobConfigAO.java @@ -10,22 +10,22 @@ */ public interface JobConfigAO { - /** - * 新增 - * - * @author zhuhuipei - * @date 2021/2/28 - * @time 11:26 - */ - void addJobConfig(JobConfigDTO jobConfigDTO); + /** + * 新增 + * + * @author zhuhuipei + * @date 2021/2/28 + * @time 11:26 + */ + void addJobConfig(JobConfigDTO jobConfigDTO); - /** - * 修改参数 - * - * @author zhuhuipei - * @date 2021/2/28 - * @time 11:26 - */ - void updateJobConfigById(JobConfigDTO jobConfigDTO); + /** + * 修改参数 + * + * @author zhuhuipei + * @date 2021/2/28 + * @time 11:26 + */ + void updateJobConfigById(JobConfigDTO jobConfigDTO); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobServerAO.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobServerAO.java index 39869e7c..4f7d3c46 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobServerAO.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/JobServerAO.java @@ -8,51 +8,51 @@ */ public interface JobServerAO { - /** - * 启动任务 - * - * @author zhuhuipei - * @date 2020-07-20 - * @time 23:12 - */ - void start(Long id, Long savepointId, String userName); - - - /** - * 关闭任务 - * - * @author zhuhuipei - * @date 2020-07-20 - * @time 23:12 - */ - void stop(Long id, String userName); - - - /** - * 执行savepoint - * - * @author zhuhuipei - * @date 2020-09-21 - * @time 00:41 - */ - void savepoint(Long id); - - - /** - * 开启配置 - * - * @author zhuhuipei - * @date 2020-08-12 - * @time 21:14 - */ - void open(Long id, String userName); - - /** - * 关闭配置 - * - * @author zhuhuipei - * @date 2020-08-12 - * @time 21:14 - */ - void close(Long id, String userName); + /** + * 启动任务 + * + * @author zhuhuipei + * @date 2020-07-20 + * @time 23:12 + */ + void start(Long id, Long savepointId, String userName); + + + /** + * 关闭任务 + * + * @author zhuhuipei + * @date 2020-07-20 + * @time 23:12 + */ + void stop(Long id, String userName); + + + /** + * 执行savepoint + * + * @author zhuhuipei + * @date 2020-09-21 + * @time 00:41 + */ + void savepoint(Long id); + + + /** + * 开启配置 + * + * @author zhuhuipei + * @date 2020-08-12 + * @time 21:14 + */ + void open(Long id, String userName); + + /** + * 关闭配置 + * + * @author zhuhuipei + * @date 2020-08-12 + * @time 21:14 + */ + void close(Long id, String userName); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/TaskServiceAO.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/TaskServiceAO.java index 840b24b6..03826e0f 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/TaskServiceAO.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/TaskServiceAO.java @@ -8,37 +8,37 @@ */ public interface TaskServiceAO { - /** - * 检查任务状态一致性问题(任务是不是挂掉) - *

- * 如:数据库里面任务状态是运行中,实际任务在集群上已经挂掉啦 - * - * @author zhuhuipei - * @date 2020-09-22 - * @time 23:00 - */ - void checkJobStatus(); - - - /** - * 检查yarn上任务存在 但是状态已经停止,这个时候停止Yarn任务 - * - * @author zhuhuipei - * @date 2020-10-25 - * @time 17:15 - */ - @Deprecated - void checkYarnJobByStop(); - - - /** - * 针对在线运行任务进行自动SavePoint - * - * @author zhuhuipei - * @date 2020-09-22 - * @time 23:25 - */ - void autoSavePoint(); + /** + * 检查任务状态一致性问题(任务是不是挂掉) + *

+ * 如:数据库里面任务状态是运行中,实际任务在集群上已经挂掉啦 + * + * @author zhuhuipei + * @date 2020-09-22 + * @time 23:00 + */ + void checkJobStatus(); + + + /** + * 检查yarn上任务存在 但是状态已经停止,这个时候停止Yarn任务 + * + * @author zhuhuipei + * @date 2020-10-25 + * @time 17:15 + */ + @Deprecated + void checkYarnJobByStop(); + + + /** + * 针对在线运行任务进行自动SavePoint + * + * @author zhuhuipei + * @date 2020-09-22 + * @time 23:25 + */ + void autoSavePoint(); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/AlarmServiceAOImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/AlarmServiceAOImpl.java index 240b88b7..3c00e653 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/AlarmServiceAOImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/AlarmServiceAOImpl.java @@ -26,73 +26,73 @@ public class AlarmServiceAOImpl implements AlarmServiceAO { - @Autowired - private AlartLogService alartLogService; + @Autowired + private AlartLogService alartLogService; - @Autowired - private JobRunLogService jobRunLogService; + @Autowired + private JobRunLogService jobRunLogService; - @Autowired - private DingDingAlarm dingDingAlarm; + @Autowired + private DingDingAlarm dingDingAlarm; - @Autowired - private HttpAlarm httpAlarm; + @Autowired + private HttpAlarm httpAlarm; - @Override - public boolean sendForDingding(String url, String content, Long jobConfigId) { + @Override + public boolean sendForDingding(String url, String content, Long jobConfigId) { - boolean isSuccess = false; - String failLog = ""; - try { - isSuccess = dingDingAlarm.send(url, content); - } catch (Exception e) { - log.error("dingDingAlarm.send is error", e); - failLog = e.getMessage(); - } - this.insertLog(isSuccess, jobConfigId, failLog, content, AlarmLogTypeEnum.DINGDING); - - return isSuccess; - } - - @Override - public boolean sendForHttp(String url, CallbackDTO callbackDTO) { - - boolean isSuccess = false; - String failLog = ""; - try { - isSuccess = httpAlarm.send(url, callbackDTO); - } catch (Exception e) { - log.error("dingDingAlarm.send is error", e); - failLog = e.getMessage(); - } - this.insertLog(isSuccess, callbackDTO.getJobConfigId(), failLog, JSON.toJSONString(callbackDTO), - AlarmLogTypeEnum.CALLBACK_URL); - - return isSuccess; + boolean isSuccess = false; + String failLog = ""; + try { + isSuccess = dingDingAlarm.send(url, content); + } catch (Exception e) { + log.error("dingDingAlarm.send is error", e); + failLog = e.getMessage(); } + this.insertLog(isSuccess, jobConfigId, failLog, content, AlarmLogTypeEnum.DINGDING); + return isSuccess; + } - private void insertLog(boolean isSuccess, Long jobConfigId, String failLog, String content, - AlarmLogTypeEnum alarMLogTypeEnum) { - JobRunLogDTO jobRunLogDTO = jobRunLogService.getDetailLogById(jobConfigId); - AlartLogDTO alartLogDTO = new AlartLogDTO(); - alartLogDTO.setJobConfigId(jobConfigId); - alartLogDTO.setAlarMLogTypeEnum(alarMLogTypeEnum); - alartLogDTO.setMessage(content); - if (jobRunLogDTO != null) { - alartLogDTO.setJobName(jobRunLogDTO.getJobName()); - } else { - alartLogDTO.setJobName("测试"); - } - if (isSuccess) { - alartLogDTO.setAlarmLogStatusEnum(AlarmLogStatusEnum.SUCCESS); - } else { - alartLogDTO.setAlarmLogStatusEnum(AlarmLogStatusEnum.FAIL); - alartLogDTO.setFailLog(failLog); - } - alartLogService.addAlartLog(alartLogDTO); + @Override + public boolean sendForHttp(String url, CallbackDTO callbackDTO) { + boolean isSuccess = false; + String failLog = ""; + try { + isSuccess = httpAlarm.send(url, callbackDTO); + } catch (Exception e) { + log.error("dingDingAlarm.send is error", e); + failLog = e.getMessage(); } + this.insertLog(isSuccess, callbackDTO.getJobConfigId(), failLog, JSON.toJSONString(callbackDTO), + AlarmLogTypeEnum.CALLBACK_URL); + + return isSuccess; + } + + + private void insertLog(boolean isSuccess, Long jobConfigId, String failLog, String content, + AlarmLogTypeEnum alarMLogTypeEnum) { + JobRunLogDTO jobRunLogDTO = jobRunLogService.getDetailLogById(jobConfigId); + AlartLogDTO alartLogDTO = new AlartLogDTO(); + alartLogDTO.setJobConfigId(jobConfigId); + alartLogDTO.setAlarMLogTypeEnum(alarMLogTypeEnum); + alartLogDTO.setMessage(content); + if (jobRunLogDTO != null) { + alartLogDTO.setJobName(jobRunLogDTO.getJobName()); + } else { + alartLogDTO.setJobName("测试"); + } + if (isSuccess) { + alartLogDTO.setAlarmLogStatusEnum(AlarmLogStatusEnum.SUCCESS); + } else { + alartLogDTO.setAlarmLogStatusEnum(AlarmLogStatusEnum.FAIL); + alartLogDTO.setFailLog(failLog); + } + alartLogService.addAlartLog(alartLogDTO); + + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/DingDingServiceImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/DingDingServiceImpl.java index 52cb1123..a62008de 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/DingDingServiceImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/DingDingServiceImpl.java @@ -30,256 +30,280 @@ import lombok.extern.slf4j.Slf4j; /** - * * @author wxj - * @date 2022年1月5日 下午3:02:00 * @version V1.0 + * @date 2022年1月5日 下午3:02:00 */ @Component @Slf4j public class DingDingServiceImpl implements DingDingService { - - @Autowired - private AlartLogService alartLogService; - @Autowired - private JobRunLogService jobRunLogService; + @Autowired + private AlartLogService alartLogService; - @Override - public void doAlarmNotify(String cusContent, JobConfigDTO jobConfigDTO, DeployModeEnum deployModeEnum) { - Long id = jobConfigDTO.getId(); - if (StringUtils.isNotBlank(this.ALARM_DINGTALK_TELEPHONE)) { - if (this.alarmDingTalkTasks.contains(id)) { - String content = "大数据实时计算告警," + cusContent; - this.sendTelephoeNotify(id, this.ALARM_DINGTALK_TELEPHONE, this.DINGTALK_TEMPLATE_ID, 3, content); - } - } - String un = this.ALARM_DINGMSG_USER; - if (StringUtils.isNotBlank(un)) { - if (this.alarmDingMsgTasks.contains(id)) { - String content = "【大数据实时计算告警】\n" + cusContent + "\n通知时间:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"); - if (un.indexOf(",") > 0) { - for (String str : un.split(",")) { - if (StringUtils.isNotBlank(str)) { - this.sendDingDingMsg(id, str, content); - } - } - } else { - this.sendDingDingMsg(id, this.ALARM_DINGMSG_USER, content); - } + @Autowired + private JobRunLogService jobRunLogService; + + @Override + public void doAlarmNotify(String cusContent, JobConfigDTO jobConfigDTO, + DeployModeEnum deployModeEnum) { + Long id = jobConfigDTO.getId(); + if (StringUtils.isNotBlank(this.alarmDingtalkTelephone)) { + if (this.alarmDingTalkTasks.contains(id)) { + String content = "大数据实时计算告警," + cusContent; + this.sendTelephoeNotify(id, this.alarmDingtalkTelephone, this.dingtalkTemplateId, 3, + content); + } + } + String un = this.alarmDingmsgUser; + if (StringUtils.isNotBlank(un)) { + if (this.alarmDingMsgTasks.contains(id)) { + String content = "【大数据实时计算告警】\n" + cusContent + "\n通知时间:" + DateFormatUtils + .format(new Date(), "yyyy-MM-dd HH:mm:ss"); + if (un.indexOf(",") > 0) { + for (String str : un.split(",")) { + if (StringUtils.isNotBlank(str)) { + this.sendDingDingMsg(id, str, content); } + } + } else { + this.sendDingDingMsg(id, this.alarmDingmsgUser, content); } + } } + } - @NacosValue(value = "${DINGTALK_URL:}", autoRefreshed = true) - private String DINGTALK_URL; + @NacosValue(value = "${DINGTALK_URL:}", autoRefreshed = true) + private String dingtalkUrl; - @NacosValue(value = "${DINGTALK_TEMPLATE_ID:}", autoRefreshed = true) - private String DINGTALK_TEMPLATE_ID; + @NacosValue(value = "${DINGTALK_TEMPLATE_ID:}", autoRefreshed = true) + private String dingtalkTemplateId; - @NacosValue(value = "${DINGTALK_APPKEY:}", autoRefreshed = true) - private String DINGTALK_APPKEY; + @NacosValue(value = "${DINGTALK_APPKEY:}", autoRefreshed = true) + private String dingtalkAppkey; - @NacosValue(value = "${DINGMSG_NOTIFY_URL:}", autoRefreshed = true) - private String DINGMSG_NOTIFY_URL; + @NacosValue(value = "${DINGMSG_NOTIFY_URL:}", autoRefreshed = true) + private String dingmsgNotifyUrl; - @NacosValue(value = "${DINGMSG_APP_ID:}", autoRefreshed = true) - private String DINGMSG_APP_ID; + @NacosValue(value = "${DINGMSG_APP_ID:}", autoRefreshed = true) + private String dingmsgAppId; - @NacosValue(value = "${DINGMSG_APP_KEY:}", autoRefreshed = true) - private String DINGMSG_APP_KEY; + @NacosValue(value = "${DINGMSG_APP_KEY:}", autoRefreshed = true) + private String dingmsgAppKey; - private Set alarmDingTalkTasks = new HashSet(); + private Set alarmDingTalkTasks = new HashSet(); - private Set alarmDingMsgTasks = new HashSet(); + private Set alarmDingMsgTasks = new HashSet(); - @NacosValue(value = "${ALARM_DINGTALK_TASKS:}", autoRefreshed = true) - public void setAlarmDingTalkTasks(String alarmDingTalkTasks) { - this.alarmDingTalkTasks.clear(); - if (org.apache.commons.lang3.StringUtils.isBlank(alarmDingTalkTasks)) { - return; - } - String[] ids = alarmDingTalkTasks.split(","); - for (String id : ids) { - if (isNumeric(id)) { - this.alarmDingTalkTasks.add(Long.valueOf(id)); - } - } + @NacosValue(value = "${ALARM_DINGTALK_TASKS:}", autoRefreshed = true) + public void setAlarmDingTalkTasks(String alarmDingTalkTasks) { + this.alarmDingTalkTasks.clear(); + if (org.apache.commons.lang3.StringUtils.isBlank(alarmDingTalkTasks)) { + return; } - - @NacosValue(value = "${ALARM_DINGMSG_TASKS:}", autoRefreshed = true) - public void setAlarmDingMsgTasks(String alarmDingMsgTasks) { - this.alarmDingMsgTasks.clear(); - if (org.apache.commons.lang3.StringUtils.isBlank(alarmDingMsgTasks)) { - return; - } - String[] ids = alarmDingMsgTasks.split(","); - for (String id : ids) { - if (isNumeric(id)) { - this.alarmDingMsgTasks.add(Long.valueOf(id)); - } - } + String[] ids = alarmDingTalkTasks.split(","); + for (String id : ids) { + if (isNumeric(id)) { + this.alarmDingTalkTasks.add(Long.valueOf(id)); + } } - - @NacosValue(value = "${ALARM_DINGTALK_TELEPHONE:}", autoRefreshed = true) - private String ALARM_DINGTALK_TELEPHONE; - - @NacosValue(value = "${ALARM_DINGMSG_USER:}", autoRefreshed = true) - private String ALARM_DINGMSG_USER; + } - /** - * 判断是否为数字 - * - * @param str - * @return - * @author wxj - * @date 2022年1月5日 下午3:22:29 - * @version V1.0 - */ - public static boolean isNumeric(String str) { - for (int i = 0; i < str.length(); i++) { - System.out.println(str.charAt(i)); - if (!Character.isDigit(str.charAt(i))) { - return false; - } - } - return true; + @NacosValue(value = "${ALARM_DINGMSG_TASKS:}", autoRefreshed = true) + public void setAlarmDingMsgTasks(String alarmDingMsgTasks) { + this.alarmDingMsgTasks.clear(); + if (org.apache.commons.lang3.StringUtils.isBlank(alarmDingMsgTasks)) { + return; } - - /** - * 计算签名 - * - * @param param - * @param appKey - * @return - * @author wxj - * @date 2022年1月5日 下午3:22:08 - * @version V1.0 - */ - public static String getSign(Map param, String appKey) { - Map treeMap = new TreeMap<>(param); - StringBuilder signBuilder = new StringBuilder(); - for (String key : treeMap.keySet()) { - signBuilder.append("&").append(key).append("=").append(treeMap.get(key)); - } - signBuilder.append(appKey); - String signStr = StringUtils.substring(signBuilder.toString(), 1); // 去掉第一个& - return Md5Utils.MD5(signStr); + String[] ids = alarmDingMsgTasks.split(","); + for (String id : ids) { + if (isNumeric(id)) { + this.alarmDingMsgTasks.add(Long.valueOf(id)); + } } - - /** - * 电话告警 - * - * @param paramMap - * @return - * @author wxj - * @date 2022年1月5日 下午3:13:38 - * @version V1.0 - */ - public JSONObject sendTelephoeNotify(Long jobConfigId, String mobile, String templateId, Integer count, String content) { - Map param = new HashMap<>(); - param.put("mobile", mobile); - param.put("templateId", templateId); - param.put("count", count.toString()); - param.put("param", content); - String url = this.DINGTALK_URL; - String sign = getSign(param, this.DINGTALK_APPKEY); - param.put("sign", sign); - JSONObject result = new JSONObject(); - try { - String ret = HttpClientToolUtils.doPost(url, param, null, 6000); - log.warn("电话告警,任务[{}]请求 {} 参数:mobile={},templateId={},count={},content={} \n返回:{}", - jobConfigId, url, mobile, templateId, count, content, ret); - if (StringUtils.isBlank(ret)) { - result.put("ret", false); - result.put("msg", "接口调用异常,返回为空"); - String failLog = "电话告警,任务["+jobConfigId+"]请求 "+url+" 参数:mobile="+mobile+",templateId="+templateId+",count="+count+",content="+content+" \n返回:" + result.toJSONString(); - this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); - return result; - } - JSONObject retJson = JSON.parseObject(ret); - if (retJson.containsKey("code") && retJson.getInteger("code") != 200) { - result.put("ret", false); - result.put("msg", retJson.getString("msg")); - String failLog = "电话告警,任务["+jobConfigId+"]请求 "+url+" 参数:mobile="+mobile+",templateId="+templateId+",count="+count+",content="+content+" \n返回:" + result.toJSONString(); - this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); - return result; - } - result.put("ret", true); - result.put("msg", "成功"); - String failLog = "电话告警,任务["+jobConfigId+"]请求 "+url+" 参数:mobile="+mobile+",templateId="+templateId+",count="+count+",content="+content+" \n返回:" + result.toJSONString(); - this.insertLog(true, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); - return result; - } catch (Exception e) { - String failLog = "电话告警,任务["+jobConfigId+"]请求 "+url+" 参数:mobile="+mobile+",templateId="+templateId+",count="+count+",content="+content+" \n异常:" + e.getMessage(); - log.error(failLog, e); - result.put("ret", false); - result.put("msg", "接口调用失败"); - this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); - return result; - } + } + + @NacosValue(value = "${ALARM_DINGTALK_TELEPHONE:}", autoRefreshed = true) + private String alarmDingtalkTelephone; + + @NacosValue(value = "${ALARM_DINGMSG_USER:}", autoRefreshed = true) + private String alarmDingmsgUser; + + /** + * 判断是否为数字 + * + * @param str + * @return + * @author wxj + * @date 2022年1月5日 下午3:22:29 + * @version V1.0 + */ + public static boolean isNumeric(String str) { + for (int i = 0; i < str.length(); i++) { + System.out.println(str.charAt(i)); + if (!Character.isDigit(str.charAt(i))) { + return false; + } } - - /** - * 钉钉消息告警 - * - * @param paramMap - * @return - * @author wxj - * @date 2022年1月5日 下午3:13:38 - * @version V1.0 - */ - public JSONObject sendDingDingMsg(Long jobConfigId, String un, String content) { - Map param = new HashMap<>(); - param.put("un", un); - param.put("appid", this.DINGMSG_APP_ID); - param.put("content", content); - String url = this.DINGMSG_NOTIFY_URL; - String sign = getSign(param, this.DINGMSG_APP_KEY); - param.put("sign", sign); - JSONObject result = new JSONObject(); - try { - String ret = HttpClientToolUtils.doPost(url, param, null, 6000); - log.warn("钉钉告警,任务[{}]请求 {} 参数:un={},content={} \n返回:{}", jobConfigId, url, un, content, ret); - if (StringUtils.isBlank(ret)) { - result.put("ret", false); - result.put("msg", "接口调用异常,返回为空"); - String failLog = "钉钉告警,任务["+jobConfigId+"]请求 "+url+" 参数:un="+un+",content="+content+" \n返回:" + result.toJSONString(); - this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); - return result; - } - JSONObject retJson = JSON.parseObject(ret); - if (retJson.containsKey("code") && retJson.getInteger("code") != 200) { - result.put("ret", false); - result.put("msg", retJson.getString("msg")); - String failLog = "钉钉告警,任务["+jobConfigId+"]请求 "+url+" 参数:un="+un+",content="+content+" \n返回:" + result.toJSONString(); - this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); - return result; - } - result.put("ret", true); - result.put("msg", "成功"); - String failLog = "钉钉告警,任务["+jobConfigId+"]请求 "+url+" 参数:un="+un+",content="+content+" \n返回:" + result.toJSONString(); - this.insertLog(true, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); - return result; - } catch (Exception e) { - String failLog = "钉钉告警,任务["+jobConfigId+"]请求 "+url+" 参数:un="+un+",content="+content+" \n异常:" + e.getMessage(); - log.error(failLog, e); - result.put("ret", false); - result.put("msg", "接口调用失败"); - this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); - return result; - } + return true; + } + + /** + * 计算签名 + * + * @param param + * @param appKey + * @return + * @author wxj + * @date 2022年1月5日 下午3:22:08 + * @version V1.0 + */ + public static String getSign(Map param, String appKey) { + Map treeMap = new TreeMap<>(param); + StringBuilder signBuilder = new StringBuilder(); + for (String key : treeMap.keySet()) { + signBuilder.append("&").append(key).append("=").append(treeMap.get(key)); } - - private void insertLog(boolean isSuccess, Long jobConfigId, String failLog, String content, AlarmLogTypeEnum alarMLogTypeEnum) { - JobRunLogDTO jobRunLogDTO = jobRunLogService.getDetailLogById(jobConfigId); - AlartLogDTO alartLogDTO = new AlartLogDTO(); - alartLogDTO.setJobConfigId(jobConfigId); - alartLogDTO.setAlarMLogTypeEnum(alarMLogTypeEnum); - alartLogDTO.setMessage(content); - alartLogDTO.setFailLog(failLog); - alartLogDTO.setJobName(jobRunLogDTO.getJobName()); - alartLogDTO.setAlarmLogStatusEnum(isSuccess ? AlarmLogStatusEnum.SUCCESS : AlarmLogStatusEnum.FAIL); - alartLogService.addAlartLog(alartLogDTO); + signBuilder.append(appKey); + String signStr = StringUtils.substring(signBuilder.toString(), 1); // 去掉第一个& + return Md5Utils.md5(signStr); + } + + /** + * 电话告警 + * + * @param paramMap + * @return + * @author wxj + * @date 2022年1月5日 下午3:13:38 + * @version V1.0 + */ + public JSONObject sendTelephoeNotify(Long jobConfigId, String mobile, String templateId, + Integer count, String content) { + Map param = new HashMap<>(); + param.put("mobile", mobile); + param.put("templateId", templateId); + param.put("count", count.toString()); + param.put("param", content); + String url = this.dingtalkUrl; + String sign = getSign(param, this.dingtalkAppkey); + param.put("sign", sign); + JSONObject result = new JSONObject(); + try { + String ret = HttpClientToolUtils.doPost(url, param, null, 6000); + log.warn("电话告警,任务[{}]请求 {} 参数:mobile={},templateId={},count={},content={} \n返回:{}", + jobConfigId, url, mobile, templateId, count, content, ret); + if (StringUtils.isBlank(ret)) { + result.put("ret", false); + result.put("msg", "接口调用异常,返回为空"); + String failLog = + "电话告警,任务[" + jobConfigId + "]请求 " + url + " 参数:mobile=" + mobile + ",templateId=" + + templateId + ",count=" + count + ",content=" + content + " \n返回:" + result + .toJSONString(); + this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); + return result; + } + JSONObject retJson = JSON.parseObject(ret); + if (retJson.containsKey("code") && retJson.getInteger("code") != 200) { + result.put("ret", false); + result.put("msg", retJson.getString("msg")); + String failLog = + "电话告警,任务[" + jobConfigId + "]请求 " + url + " 参数:mobile=" + mobile + ",templateId=" + + templateId + ",count=" + count + ",content=" + content + " \n返回:" + result + .toJSONString(); + this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); + return result; + } + result.put("ret", true); + result.put("msg", "成功"); + String failLog = + "电话告警,任务[" + jobConfigId + "]请求 " + url + " 参数:mobile=" + mobile + ",templateId=" + + templateId + ",count=" + count + ",content=" + content + " \n返回:" + result + .toJSONString(); + this.insertLog(true, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); + return result; + } catch (Exception e) { + String failLog = + "电话告警,任务[" + jobConfigId + "]请求 " + url + " 参数:mobile=" + mobile + ",templateId=" + + templateId + ",count=" + count + ",content=" + content + " \n异常:" + e.getMessage(); + log.error(failLog, e); + result.put("ret", false); + result.put("msg", "接口调用失败"); + this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); + return result; } + } + + /** + * 钉钉消息告警 + * + * @param paramMap + * @return + * @author wxj + * @date 2022年1月5日 下午3:13:38 + * @version V1.0 + */ + public JSONObject sendDingDingMsg(Long jobConfigId, String un, String content) { + Map param = new HashMap<>(); + param.put("un", un); + param.put("appid", this.dingmsgAppId); + param.put("content", content); + String url = this.dingmsgNotifyUrl; + String sign = getSign(param, this.dingmsgAppKey); + param.put("sign", sign); + JSONObject result = new JSONObject(); + try { + String ret = HttpClientToolUtils.doPost(url, param, null, 6000); + log.warn("钉钉告警,任务[{}]请求 {} 参数:un={},content={} \n返回:{}", jobConfigId, url, un, content, ret); + if (StringUtils.isBlank(ret)) { + result.put("ret", false); + result.put("msg", "接口调用异常,返回为空"); + String failLog = + "钉钉告警,任务[" + jobConfigId + "]请求 " + url + " 参数:un=" + un + ",content=" + content + + " \n返回:" + result.toJSONString(); + this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); + return result; + } + JSONObject retJson = JSON.parseObject(ret); + if (retJson.containsKey("code") && retJson.getInteger("code") != 200) { + result.put("ret", false); + result.put("msg", retJson.getString("msg")); + String failLog = + "钉钉告警,任务[" + jobConfigId + "]请求 " + url + " 参数:un=" + un + ",content=" + content + + " \n返回:" + result.toJSONString(); + this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); + return result; + } + result.put("ret", true); + result.put("msg", "成功"); + String failLog = + "钉钉告警,任务[" + jobConfigId + "]请求 " + url + " 参数:un=" + un + ",content=" + content + + " \n返回:" + result.toJSONString(); + this.insertLog(true, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); + return result; + } catch (Exception e) { + String failLog = + "钉钉告警,任务[" + jobConfigId + "]请求 " + url + " 参数:un=" + un + ",content=" + content + + " \n异常:" + e.getMessage(); + log.error(failLog, e); + result.put("ret", false); + result.put("msg", "接口调用失败"); + this.insertLog(false, jobConfigId, failLog, content, AlarmLogTypeEnum.OTHER); + return result; + } + } + + private void insertLog(boolean isSuccess, Long jobConfigId, String failLog, String content, + AlarmLogTypeEnum alarMLogTypeEnum) { + JobRunLogDTO jobRunLogDTO = jobRunLogService.getDetailLogById(jobConfigId); + AlartLogDTO alartLogDTO = new AlartLogDTO(); + alartLogDTO.setJobConfigId(jobConfigId); + alartLogDTO.setAlarMLogTypeEnum(alarMLogTypeEnum); + alartLogDTO.setMessage(content); + alartLogDTO.setFailLog(failLog); + alartLogDTO.setJobName(jobRunLogDTO.getJobName()); + alartLogDTO + .setAlarmLogStatusEnum(isSuccess ? AlarmLogStatusEnum.SUCCESS : AlarmLogStatusEnum.FAIL); + alartLogService.addAlartLog(alartLogDTO); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobBaseServiceAOImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobBaseServiceAOImpl.java index 3fac1c55..de441c94 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobBaseServiceAOImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobBaseServiceAOImpl.java @@ -50,414 +50,435 @@ @Slf4j public class JobBaseServiceAOImpl implements JobBaseServiceAO { - public static final ThreadLocal threadAppId = new ThreadLocal(); + public static final ThreadLocal THREADAPPID = new ThreadLocal(); - @Autowired - private JobRunLogService jobRunLogService; + @Autowired + private JobRunLogService jobRunLogService; - @Autowired - private YarnRestRpcAdapter yarnRestRpcAdapter; + @Autowired + private YarnRestRpcAdapter yarnRestRpcAdapter; - @Autowired - private SystemConfigService systemConfigService; + @Autowired + private SystemConfigService systemConfigService; - @Autowired - private CommandRpcClinetAdapter commandRpcClinetAdapter; + @Autowired + private CommandRpcClinetAdapter commandRpcClinetAdapter; - @Autowired - private JobConfigService jobConfigService; + @Autowired + private JobConfigService jobConfigService; - @Autowired - private FlinkRestRpcAdapter flinkRestRpcAdapter; + @Autowired + private FlinkRestRpcAdapter flinkRestRpcAdapter; - @NacosInjected - private ConfigService configService; + @NacosInjected + private ConfigService configService; - @NacosValue(value = "${nacos.config.data-id:}", autoRefreshed = true) - private String nacosConfigDataId; + @NacosValue(value = "${nacos.config.data-id:}", autoRefreshed = true) + private String nacosConfigDataId; - @NacosValue(value = "${nacos.config.group:}", autoRefreshed = true) - private String nacosConfigGroup; + @NacosValue(value = "${nacos.config.group:}", autoRefreshed = true) + private String nacosConfigGroup; - @Override - public void checkStart(JobConfigDTO jobConfigDTO) { - if (jobConfigDTO == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); - } - if (JobConfigStatus.RUN.getCode().equals(jobConfigDTO.getStatus().getCode())) { - throw new BizException("任务运行中请先停止任务"); - } - if (jobConfigDTO.getStatus().equals(JobConfigStatus.STARTING)) { - throw new BizException("任务正在启动中 请稍等.."); - } - if (jobConfigDTO.getIsOpen().intValue() == YN.N.getValue()) { - throw new BizException("请先开启任务"); - } - switch (jobConfigDTO.getDeployModeEnum()) { - case YARN_PER: - this.checYarnQueue(jobConfigDTO); - RestResult restResult = CliConfigUtil.checkFlinkRunConfigForYarn(jobConfigDTO.getFlinkRunConfig()); - if (restResult != null && !restResult.isSuccess()) { - throw new BizException("启动参数校验没有通过:" + restResult.getMessage()); - } - break; + @Override + public void checkStart(JobConfigDTO jobConfigDTO) { + if (jobConfigDTO == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); + } + if (JobConfigStatus.RUN.getCode().equals(jobConfigDTO.getStatus().getCode())) { + throw new BizException("任务运行中请先停止任务"); + } + if (jobConfigDTO.getStatus().equals(JobConfigStatus.STARTING)) { + throw new BizException("任务正在启动中 请稍等.."); + } + if (jobConfigDTO.getIsOpen().intValue() == YN.N.getValue()) { + throw new BizException("请先开启任务"); + } + switch (jobConfigDTO.getDeployModeEnum()) { + case YARN_PER: + this.checYarnQueue(jobConfigDTO); + RestResult restResult = CliConfigUtil + .checkFlinkRunConfigForYarn(jobConfigDTO.getFlinkRunConfig()); + if (restResult != null && !restResult.isSuccess()) { + throw new BizException("启动参数校验没有通过:" + restResult.getMessage()); } + break; + //TODO + default: - Map systemConfigMap = SystemConfigDTO.toMap(systemConfigService.getSystemConfig(SysConfigEnumType.SYS)); - this.checkSysConfig(systemConfigMap, jobConfigDTO.getDeployModeEnum()); + } + Map systemConfigMap = SystemConfigDTO + .toMap(systemConfigService.getSystemConfig(SysConfigEnumType.SYS)); + this.checkSysConfig(systemConfigMap, jobConfigDTO.getDeployModeEnum()); - } - @Override - public void checkSavepoint(JobConfigDTO jobConfigDTO) { - if (jobConfigDTO == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); - } + } + + @Override + public void checkSavepoint(JobConfigDTO jobConfigDTO) { + if (jobConfigDTO == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); + } // if (JobTypeEnum.JAR.equals(jobConfigDTO.getJobTypeEnum())) { // log.warn(MessageConstants.MESSAGE_006, jobConfigDTO.getJobName()); // throw new BizException(MessageConstants.MESSAGE_006); // } - if (JobTypeEnum.SQL_BATCH.equals(jobConfigDTO.getJobTypeEnum())) { - log.warn(MessageConstants.MESSAGE_010, jobConfigDTO.getJobName()); - throw new BizException(MessageConstants.MESSAGE_010); - } - - if (StringUtils.isEmpty(jobConfigDTO.getFlinkCheckpointConfig()) && - DeployModeEnum.STANDALONE.equals(jobConfigDTO.getDeployModeEnum())) { - log.error(MessageConstants.MESSAGE_004, jobConfigDTO); - throw new BizException(MessageConstants.MESSAGE_004); - } - if (StringUtils.isEmpty(jobConfigDTO.getJobId())) { - log.warn(MessageConstants.MESSAGE_005, jobConfigDTO.getJobName()); - throw new BizException(MessageConstants.MESSAGE_005); - } - - + if (JobTypeEnum.SQL_BATCH.equals(jobConfigDTO.getJobTypeEnum())) { + log.warn(MessageConstants.MESSAGE_010, jobConfigDTO.getJobName()); + throw new BizException(MessageConstants.MESSAGE_010); } - @Override - public void checkClose(JobConfigDTO jobConfigDTO) { - - if (jobConfigDTO.getStatus().equals(JobConfigStatus.RUN)) { - throw new BizException(MessageConstants.MESSAGE_002); - } - if (jobConfigDTO.getStatus().equals(JobConfigStatus.STARTING)) { - throw new BizException(MessageConstants.MESSAGE_003); - } + if (StringUtils.isEmpty(jobConfigDTO.getFlinkCheckpointConfig()) + && DeployModeEnum.STANDALONE.equals(jobConfigDTO.getDeployModeEnum())) { + log.error(MessageConstants.MESSAGE_004, jobConfigDTO); + throw new BizException(MessageConstants.MESSAGE_004); } - - @Override - public Long insertJobRunLog(JobConfigDTO jobConfigDTO, String userName) { - JobRunLogDTO jobRunLogDTO = new JobRunLogDTO(); - jobRunLogDTO.setDeployMode(jobConfigDTO.getDeployModeEnum().name()); - jobRunLogDTO.setLocalLog(MessageConstants.MESSAGE_001); - jobRunLogDTO.setJobConfigId(jobConfigDTO.getId()); - jobRunLogDTO.setStartTime(new Date()); - jobRunLogDTO.setJobName(jobConfigDTO.getJobName()); - jobRunLogDTO.setJobId(jobConfigDTO.getJobId()); - jobRunLogDTO.setJobStatus(JobStatusEnum.STARTING.name()); - jobRunLogDTO.setCreator(userName); - jobRunLogDTO.setEditor(userName); - jobRunLogDTO.setRunIp(IpUtil.getInstance().getLocalIP()); - return jobRunLogService.insertJobRunLog(jobRunLogDTO); + if (StringUtils.isEmpty(jobConfigDTO.getJobId())) { + log.warn(MessageConstants.MESSAGE_005, jobConfigDTO.getJobName()); + throw new BizException(MessageConstants.MESSAGE_005); } - @Override - public JobRunParamDTO writeSqlToFile(JobConfigDTO jobConfigDTO) { - if (configService != null && StringUtils.isNotEmpty(nacosConfigDataId) - && StringUtils.isNotEmpty(nacosConfigGroup)) { - replaceNacosParameters(jobConfigDTO); - } - Map systemConfigMap = SystemConfigDTO.toMap(systemConfigService.getSystemConfig(SysConfigEnumType.SYS)); - String sqlPath = FileUtils.getSqlHome(systemConfigMap.get(SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey())) - + FileUtils.createFileName(String.valueOf(jobConfigDTO.getId())); - FileUtils.writeText(sqlPath, jobConfigDTO.getFlinkSql(), Boolean.FALSE); + } - return JobRunParamDTO.buildJobRunParam(systemConfigMap, jobConfigDTO, sqlPath); - } + @Override + public void checkClose(JobConfigDTO jobConfigDTO) { - @Override - public void aSyncExecJob(JobRunParamDTO jobRunParamDTO, JobConfigDTO jobConfigDTO, - Long jobRunLogId, String savepointPath) { - if (configService != null && StringUtils.isNotEmpty(nacosConfigDataId) - && StringUtils.isNotEmpty(nacosConfigGroup)) { - replaceNacosParameters(jobConfigDTO); + if (jobConfigDTO.getStatus().equals(JobConfigStatus.RUN)) { + throw new BizException(MessageConstants.MESSAGE_002); + } + if (jobConfigDTO.getStatus().equals(JobConfigStatus.STARTING)) { + throw new BizException(MessageConstants.MESSAGE_003); + } + } + + @Override + public Long insertJobRunLog(JobConfigDTO jobConfigDTO, String userName) { + JobRunLogDTO jobRunLogDTO = new JobRunLogDTO(); + jobRunLogDTO.setDeployMode(jobConfigDTO.getDeployModeEnum().name()); + jobRunLogDTO.setLocalLog(MessageConstants.MESSAGE_001); + jobRunLogDTO.setJobConfigId(jobConfigDTO.getId()); + jobRunLogDTO.setStartTime(new Date()); + jobRunLogDTO.setJobName(jobConfigDTO.getJobName()); + jobRunLogDTO.setJobId(jobConfigDTO.getJobId()); + jobRunLogDTO.setJobStatus(JobStatusEnum.STARTING.name()); + jobRunLogDTO.setCreator(userName); + jobRunLogDTO.setEditor(userName); + jobRunLogDTO.setRunIp(IpUtil.getInstance().getLocalIP()); + return jobRunLogService.insertJobRunLog(jobRunLogDTO); + } + + @Override + public JobRunParamDTO writeSqlToFile(JobConfigDTO jobConfigDTO) { + if (configService != null && StringUtils.isNotEmpty(nacosConfigDataId) + && StringUtils.isNotEmpty(nacosConfigGroup)) { + replaceNacosParameters(jobConfigDTO); + } + Map systemConfigMap = SystemConfigDTO + .toMap(systemConfigService.getSystemConfig(SysConfigEnumType.SYS)); + + String sqlPath = FileUtils + .getSqlHome(systemConfigMap.get(SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey())) + + FileUtils.createFileName(String.valueOf(jobConfigDTO.getId())); + FileUtils.writeText(sqlPath, jobConfigDTO.getFlinkSql(), Boolean.FALSE); + + return JobRunParamDTO.buildJobRunParam(systemConfigMap, jobConfigDTO, sqlPath); + } + + //CHECKSTYLE:OFF + @Override + public void aSyncExecJob(JobRunParamDTO jobRunParamDTO, JobConfigDTO jobConfigDTO, + Long jobRunLogId, String savepointPath) { + if (configService != null && StringUtils.isNotEmpty(nacosConfigDataId) + && StringUtils.isNotEmpty(nacosConfigGroup)) { + replaceNacosParameters(jobConfigDTO); + } + ThreadPoolExecutor threadPoolExecutor = JobThreadPool.getInstance().getThreadPoolExecutor(); + threadPoolExecutor.execute(new Runnable() { + @Override + public void run() { + String jobStatus = JobStatusEnum.SUCCESS.name(); + String appId = ""; + THREADAPPID.set(appId); + boolean success = true; + StringBuilder localLog = new StringBuilder() + .append("开始提交任务:") + .append(DateUtil.now()).append(SystemConstant.LINE_FEED) + .append("三方jar: ").append(SystemConstant.LINE_FEED); + if (jobConfigDTO.getExtJarPath() != null) { + localLog.append(jobConfigDTO.getExtJarPath()); } - ThreadPoolExecutor threadPoolExecutor = JobThreadPool.getInstance().getThreadPoolExecutor(); - threadPoolExecutor.execute(new Runnable() { - @Override - public void run() { - String jobStatus = JobStatusEnum.SUCCESS.name(); - String appId = ""; - threadAppId.set(appId); - boolean success = true; - StringBuilder localLog = new StringBuilder() - .append("开始提交任务:") - .append(DateUtil.now()).append(SystemConstant.LINE_FEED) - .append("三方jar: ").append(SystemConstant.LINE_FEED); - if(jobConfigDTO.getExtJarPath()!=null){ - localLog.append(jobConfigDTO.getExtJarPath()); - } - - localLog.append(SystemConstant.LINE_FEED) - .append("客户端IP:").append(IpUtil.getInstance().getLocalIP()) - .append(SystemConstant.LINE_FEED); - try { - String command = ""; - - //如果是自定义提交jar模式下载文件到本地 - this.downJar(jobRunParamDTO, jobConfigDTO); - switch (jobConfigDTO.getDeployModeEnum()) { - case YARN_PER: - //localLog.append("HADOOP_CLASSPATH=").append(System.getProperty("HADOOP_CLASSPATH")).append(SystemConstant.LINE_FEED); - //1、构建执行命令 - command = CommandUtil.buildRunCommandForYarnCluster(jobRunParamDTO, - jobConfigDTO, savepointPath); - //2、提交任务 - appId = this.submitJobForYarn(command, jobConfigDTO, localLog); - break; - case LOCAL: - case STANDALONE: - //1、构建执行命令 - command = CommandUtil.buildRunCommandForCluster(jobRunParamDTO, jobConfigDTO, savepointPath); - //2、提交任务 - appId = this.submitJobForStandalone(command, jobConfigDTO, localLog); - break; - } - } catch (Exception e) { - log.error("任务[" + jobConfigDTO.getId() + "]执行有异常!", e); - localLog.append(e).append(errorInfoDir()); - success = false; - jobStatus = JobStatusEnum.FAIL.name(); - } finally { - localLog.append("\n启动结束时间: ").append(DateUtil.now()).append(SystemConstant.LINE_FEED); - if (success) { - localLog.append("######客户端提交任务 成功 (客户端提交成功不代表任务在集群运行成功,具体请查看集群任务)############################## "); - } else { - localLog.append("######启动结果是 失败############################## "); - } - if (StringUtils.isBlank(appId)) { // 解决任务异常,但已经生成了appID,但没有传递给上层调用方法的问题 - appId = threadAppId.get(); - log.info("任务[{}]执行有异常情况,appid = {}", jobConfigDTO.getId(), appId); - } - this.updateStatusAndLog(jobConfigDTO, jobRunLogId, jobStatus, localLog.toString(), appId); - } - } + localLog.append(SystemConstant.LINE_FEED) + .append("客户端IP:").append(IpUtil.getInstance().getLocalIP()) + .append(SystemConstant.LINE_FEED); + try { + String command = ""; - /** - *下载文件到本地并且setMainJarPath - * @author zhuhuipei - * @date 2021/3/28 - * @time 14:58 - */ - private void downJar(JobRunParamDTO jobRunParamDTO, JobConfigDTO jobConfigDTO) { - if (JobTypeEnum.JAR.getCode() == jobConfigDTO.getJobTypeEnum().getCode()) { - String savePath = jobRunParamDTO.getSysHome() + "tmp/udf_jar/"; - try { - String pathName = UrlUtil.downLoadFromUrl(jobConfigDTO.getCustomJarUrl(), savePath); - jobRunParamDTO.setMainJarPath(pathName); - } catch (Exception e) { - log.error("文件下载失败 {}", jobConfigDTO.getCustomJarUrl(), e); - throw new BizException("文件下载失败"); - } - } - } - - /** - *错误日志目录提示 - * @author zhuhuipei - * @date 2020-10-19 - * @time 21:47 - */ - private String errorInfoDir() { - StringBuilder errorTips = new StringBuilder(SystemConstant.LINE_FEED) - .append(SystemConstant.LINE_FEED) - .append("(重要)请登陆服务器分别查看下面两个目录下的错误日志") - .append(IpUtil.getInstance().getLocalIP()).append(SystemConstant.LINE_FEED) - .append("web系统日志目录(web日志):") - .append(systemConfigService - .getSystemConfigByKey(SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey())) - .append("logs/error.log").append(SystemConstant.LINE_FEED) - .append("flink提交日志目录(flink客户端日志:") - .append(systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_HOME.getKey())) - .append("log/)").append(SystemConstant.LINE_FEED) - .append(SystemConstant.LINE_FEED) - .append(SystemConstant.LINE_FEED); - return errorTips.toString(); + //如果是自定义提交jar模式下载文件到本地 + this.downJar(jobRunParamDTO, jobConfigDTO); + switch (jobConfigDTO.getDeployModeEnum()) { + case YARN_PER: + //localLog.append("HADOOP_CLASSPATH=").append(System.getProperty("HADOOP_CLASSPATH")).append(SystemConstant.LINE_FEED); + //1、构建执行命令 + command = CommandUtil.buildRunCommandForYarnCluster(jobRunParamDTO, + jobConfigDTO, savepointPath); + //2、提交任务 + appId = this.submitJobForYarn(command, jobConfigDTO, localLog); + break; + case LOCAL: + case STANDALONE: + //1、构建执行命令 + command = CommandUtil + .buildRunCommandForCluster(jobRunParamDTO, jobConfigDTO, savepointPath); + //2、提交任务 + appId = this.submitJobForStandalone(command, jobConfigDTO, localLog); + break; + default: + log.warn("不支持的模式 {}", jobConfigDTO.getDeployModeEnum()); + } + } catch (Exception e) { + log.error("任务[" + jobConfigDTO.getId() + "]执行有异常!", e); + localLog.append(e).append(errorInfoDir()); + success = false; + jobStatus = JobStatusEnum.FAIL.name(); + } finally { + localLog.append("\n启动结束时间: ").append(DateUtil.now()).append(SystemConstant.LINE_FEED); + if (success) { + localLog.append( + "######客户端提交任务 成功 (客户端提交成功不代表任务在集群运行成功,具体请查看集群任务)############################## "); + } else { + localLog.append("######启动结果是 失败############################## "); + } + if (StringUtils.isBlank(appId)) { // 解决任务异常,但已经生成了appID,但没有传递给上层调用方法的问题 + appId = THREADAPPID.get(); + log.info("任务[{}]执行有异常情况,appid = {}", jobConfigDTO.getId(), appId); + } + this.updateStatusAndLog(jobConfigDTO, jobRunLogId, jobStatus, localLog.toString(), appId); + } + } + + + /** + *下载文件到本地并且setMainJarPath + * @author zhuhuipei + * @date 2021/3/28 + * @time 14:58 + */ + private void downJar(JobRunParamDTO jobRunParamDTO, JobConfigDTO jobConfigDTO) { + if (JobTypeEnum.JAR.getCode() == jobConfigDTO.getJobTypeEnum().getCode()) { + String savePath = jobRunParamDTO.getSysHome() + "tmp/udf_jar/"; + try { + String pathName = UrlUtil.downLoadFromUrl(jobConfigDTO.getCustomJarUrl(), savePath); + jobRunParamDTO.setMainJarPath(pathName); + } catch (Exception e) { + log.error("文件下载失败 {}", jobConfigDTO.getCustomJarUrl(), e); + throw new BizException("文件下载失败"); + } + } + } + + /** + *错误日志目录提示 + * @author zhuhuipei + * @date 2020-10-19 + * @time 21:47 + */ + private String errorInfoDir() { + StringBuilder errorTips = new StringBuilder(SystemConstant.LINE_FEED) + .append(SystemConstant.LINE_FEED) + .append("(重要)请登陆服务器分别查看下面两个目录下的错误日志") + .append(IpUtil.getInstance().getLocalIP()).append(SystemConstant.LINE_FEED) + .append("web系统日志目录(web日志):") + .append(systemConfigService + .getSystemConfigByKey(SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey())) + .append("logs/error.log").append(SystemConstant.LINE_FEED) + .append("flink提交日志目录(flink客户端日志:") + .append(systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_HOME.getKey())) + .append("log/)").append(SystemConstant.LINE_FEED) + .append(SystemConstant.LINE_FEED) + .append(SystemConstant.LINE_FEED); + return errorTips.toString(); + } + + + /** + * 更新日志、更新配置信息 + * @param jobConfig + * @param jobRunLogId + * @param jobStatus + * @param localLog + * @param appId + */ + private void updateStatusAndLog(JobConfigDTO jobConfig, Long jobRunLogId, + String jobStatus, String localLog, String appId) { + try { + JobConfigDTO jobConfigDTO = new JobConfigDTO(); + jobConfigDTO.setId(jobConfig.getId()); + jobConfigDTO.setJobId(appId); + JobRunLogDTO jobRunLogDTO = new JobRunLogDTO(); + jobRunLogDTO.setId(jobRunLogId); + jobRunLogDTO.setJobId(appId); + if (JobStatusEnum.SUCCESS.name().equals(jobStatus) && !StringUtils.isEmpty(appId)) { + + //批任务提交完成后算成功 + if (JobTypeEnum.SQL_BATCH.equals(jobConfig.getJobTypeEnum())) { + jobConfigDTO.setStatus(JobConfigStatus.SUCCESS); + } else { + jobConfigDTO.setStatus(JobConfigStatus.RUN); } - - /** - * 更新日志、更新配置信息 - * @param jobConfig - * @param jobRunLogId - * @param jobStatus - * @param localLog - * @param appId - */ - private void updateStatusAndLog(JobConfigDTO jobConfig, Long jobRunLogId, - String jobStatus, String localLog, String appId) { - try { - JobConfigDTO jobConfigDTO = new JobConfigDTO(); - jobConfigDTO.setId(jobConfig.getId()); - jobConfigDTO.setJobId(appId); - JobRunLogDTO jobRunLogDTO = new JobRunLogDTO(); - jobRunLogDTO.setId(jobRunLogId); - jobRunLogDTO.setJobId(appId); - if (JobStatusEnum.SUCCESS.name().equals(jobStatus) && !StringUtils.isEmpty(appId)) { - - //批任务提交完成后算成功 - if (JobTypeEnum.SQL_BATCH.equals(jobConfig.getJobTypeEnum())) { - jobConfigDTO.setStatus(JobConfigStatus.SUCCESS); - } else { - jobConfigDTO.setStatus(JobConfigStatus.RUN); - } - - jobConfigDTO.setLastStartTime(new Date()); - if (DeployModeEnum.LOCAL.equals(jobConfig.getDeployModeEnum()) || - DeployModeEnum.STANDALONE.equals(jobConfig.getDeployModeEnum())) { - jobRunLogDTO.setRemoteLogUrl(systemConfigService.getFlinkHttpAddress(jobConfig.getDeployModeEnum()) - + SystemConstants.HTTP_STANDALONE_APPS + jobConfigDTO.getJobId()); - } - if (DeployModeEnum.YARN_PER.equals(jobConfig.getDeployModeEnum())) { - jobRunLogDTO.setRemoteLogUrl(systemConfigService.getYarnRmHttpAddress() - + SystemConstants.HTTP_YARN_CLUSTER_APPS + jobConfigDTO.getJobId()); - } - - } else { - jobConfigDTO.setStatus(JobConfigStatus.FAIL); - } - jobConfigService.updateJobConfigById(jobConfigDTO); - - jobRunLogDTO.setJobStatus(jobStatus); - jobRunLogDTO.setLocalLog(localLog); - jobRunLogService.updateJobRunLogById(jobRunLogDTO); - - //最后更新一次日志 (更新日志和更新信息分开 防止日志更新失败导致相关状态更新也失败) - jobRunLogService.updateLogById(localLog, jobRunLogId); - } catch (Exception e) { - log.error(" localLog.length={} 异步更新数据失败:", localLog.length(), e); - } + jobConfigDTO.setLastStartTime(new Date()); + if (DeployModeEnum.LOCAL.equals(jobConfig.getDeployModeEnum()) + || DeployModeEnum.STANDALONE.equals(jobConfig.getDeployModeEnum())) { + jobRunLogDTO.setRemoteLogUrl( + systemConfigService.getFlinkHttpAddress(jobConfig.getDeployModeEnum()) + + SystemConstants.HTTP_STANDALONE_APPS + jobConfigDTO.getJobId()); } - - private String submitJobForStandalone(String command, JobConfigDTO jobConfig, StringBuilder localLog) - throws Exception { - String appId = commandRpcClinetAdapter.submitJob(command, localLog, jobRunLogId, jobConfig.getDeployModeEnum()); - JobStandaloneInfo jobStandaloneInfo = flinkRestRpcAdapter.getJobInfoForStandaloneByAppId(appId, - jobConfig.getDeployModeEnum()); - - if (jobStandaloneInfo == null || StringUtils.isNotEmpty(jobStandaloneInfo.getErrors())) { - log.error("[submitJobForStandalone] is error jobStandaloneInfo={}", jobStandaloneInfo); - localLog.append("\n 任务失败 appId=" + appId); - throw new BizException("任务失败"); - } else { - if (!SystemConstants.STATUS_RUNNING.equals(jobStandaloneInfo.getState()) - && !SystemConstants.STATUS_FINISHED.equals(jobStandaloneInfo.getState())) { - localLog.append("\n 任务失败 appId=" + appId).append("状态是:" + jobStandaloneInfo.getState()); - throw new BizException("[submitJobForStandalone]任务失败"); - } - } - return appId; + if (DeployModeEnum.YARN_PER.equals(jobConfig.getDeployModeEnum())) { + jobRunLogDTO.setRemoteLogUrl(systemConfigService.getYarnRmHttpAddress() + + SystemConstants.HTTP_YARN_CLUSTER_APPS + jobConfigDTO.getJobId()); } - private String submitJobForYarn(String command, JobConfigDTO jobConfigDTO, StringBuilder localLog) - throws Exception { - commandRpcClinetAdapter.submitJob(command, localLog, jobRunLogId, jobConfigDTO.getDeployModeEnum()); - return yarnRestRpcAdapter.getAppIdByYarn(jobConfigDTO.getJobName(), - YarnUtil.getQueueName(jobConfigDTO.getFlinkRunConfig())); - } + } else { + jobConfigDTO.setStatus(JobConfigStatus.FAIL); + } + jobConfigService.updateJobConfigById(jobConfigDTO); - }); - } + jobRunLogDTO.setJobStatus(jobStatus); + jobRunLogDTO.setLocalLog(localLog); + jobRunLogService.updateJobRunLogById(jobRunLogDTO); - private void checYarnQueue(JobConfigDTO jobConfigDTO) { - try { - String queueName = YarnUtil.getQueueName(jobConfigDTO.getFlinkRunConfig()); - if (StringUtils.isEmpty(queueName)) { - throw new BizException("无法获取队列名称,请检查你的 flink运行配置参数"); - } - String appId = yarnRestRpcAdapter.getAppIdByYarn(jobConfigDTO.getJobName(), queueName); - if (StringUtils.isNotEmpty(appId)) { - throw new BizException("该任务在yarn上有运行,请到集群上取消任务后再运行 任务名称是:" + - jobConfigDTO.getJobName() + " 队列名称是:" + queueName + TipsConstants.TIPS_1); - } - } catch (BizException e) { - if (SysErrorEnum.YARN_CODE.getCode().equals(e.getCode())) { - log.info(e.getErrorMsg()); - } else { - throw e; - } + //最后更新一次日志 (更新日志和更新信息分开 防止日志更新失败导致相关状态更新也失败) + jobRunLogService.updateLogById(localLog, jobRunLogId); } catch (Exception e) { - throw new BizException(e.getMessage()); + log.error(" localLog.length={} 异步更新数据失败:", localLog.length(), e); } - } - - private void checkSysConfig(Map systemConfigMap, DeployModeEnum deployModeEnum) { - if (systemConfigMap == null) { - throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL); - } - if (!systemConfigMap.containsKey(SysConfigEnum.FLINK_HOME.getKey())) { - throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_FLINK_HOME); + } + + private String submitJobForStandalone(String command, JobConfigDTO jobConfig, + StringBuilder localLog) + throws Exception { + String appId = commandRpcClinetAdapter + .submitJob(command, localLog, jobRunLogId, jobConfig.getDeployModeEnum()); + JobStandaloneInfo jobStandaloneInfo = flinkRestRpcAdapter + .getJobInfoForStandaloneByAppId(appId, + jobConfig.getDeployModeEnum()); + + if (jobStandaloneInfo == null || StringUtils.isNotEmpty(jobStandaloneInfo.getErrors())) { + log.error("[submitJobForStandalone] is error jobStandaloneInfo={}", jobStandaloneInfo); + localLog.append("\n 任务失败 appId=" + appId); + throw new BizException("任务失败"); + } else { + if (!SystemConstants.STATUS_RUNNING.equals(jobStandaloneInfo.getState()) + && !SystemConstants.STATUS_FINISHED.equals(jobStandaloneInfo.getState())) { + localLog.append("\n 任务失败 appId=" + appId).append("状态是:" + jobStandaloneInfo.getState()); + throw new BizException("[submitJobForStandalone]任务失败"); + } } + return appId; + } + + private String submitJobForYarn(String command, JobConfigDTO jobConfigDTO, + StringBuilder localLog) + throws Exception { + commandRpcClinetAdapter + .submitJob(command, localLog, jobRunLogId, jobConfigDTO.getDeployModeEnum()); + return yarnRestRpcAdapter.getAppIdByYarn(jobConfigDTO.getJobName(), + YarnUtil.getQueueName(jobConfigDTO.getFlinkRunConfig())); + } + + }); + } + //CHECKSTYLE:ON + + private void checYarnQueue(JobConfigDTO jobConfigDTO) { + try { + String queueName = YarnUtil.getQueueName(jobConfigDTO.getFlinkRunConfig()); + if (StringUtils.isEmpty(queueName)) { + throw new BizException("无法获取队列名称,请检查你的 flink运行配置参数"); + } + String appId = yarnRestRpcAdapter.getAppIdByYarn(jobConfigDTO.getJobName(), queueName); + if (StringUtils.isNotEmpty(appId)) { + throw new BizException("该任务在yarn上有运行,请到集群上取消任务后再运行 任务名称是:" + + jobConfigDTO.getJobName() + " 队列名称是:" + queueName + TipsConstants.TIPS_1); + } + } catch (BizException e) { + if (SysErrorEnum.YARN_CODE.getCode().equals(e.getCode())) { + log.info(e.getErrorMsg()); + } else { + throw e; + } + } catch (Exception e) { + throw new BizException(e.getMessage()); + } + } - if (DeployModeEnum.YARN_PER.equals(deployModeEnum)) { - if (!systemConfigMap.containsKey(SysConfigEnum.YARN_RM_HTTP_ADDRESS.getKey())) { - throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_YARN_RM_HTTP_ADDRESS); - } - } - if (!systemConfigMap.containsKey(SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey())) { - throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_FLINK_STREAMING_PLATFORM_WEB_HOME); - } + private void checkSysConfig(Map systemConfigMap, DeployModeEnum deployModeEnum) { + if (systemConfigMap == null) { + throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL); + } + if (!systemConfigMap.containsKey(SysConfigEnum.FLINK_HOME.getKey())) { + throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_FLINK_HOME); } - /** - * 正则表达式,区配参数:${xxxx} - */ - private static Pattern param_pattern = Pattern.compile("\\$\\{[\\w.-]+\\}"); - - /** - * 使用Nacos配置替换脚本中的参数 - * - * @param jobConfigDTO - * @author wxj - * @date 2021年12月29日 下午3:02:46 - * @version V1.0 - */ - private void replaceNacosParameters(JobConfigDTO jobConfigDTO) { - try { - String configInfo = configService.getConfig(nacosConfigDataId, nacosConfigGroup, 3000); - Properties properties = new Properties(); - properties.load(new StringReader(configInfo)); - jobConfigDTO.setFlinkRunConfig(replaceParamter(properties, jobConfigDTO.getFlinkRunConfig())); - jobConfigDTO.setFlinkCheckpointConfig(replaceParamter(properties, jobConfigDTO.getFlinkCheckpointConfig())); - jobConfigDTO.setExtJarPath(replaceParamter(properties, jobConfigDTO.getExtJarPath())); - jobConfigDTO.setFlinkSql(replaceParamter(properties, jobConfigDTO.getFlinkSql())); - jobConfigDTO.setCustomArgs(replaceParamter(properties, jobConfigDTO.getCustomArgs())); - jobConfigDTO.setCustomMainClass(replaceParamter(properties, jobConfigDTO.getCustomMainClass())); - jobConfigDTO.setCustomJarUrl(replaceParamter(properties, jobConfigDTO.getCustomJarUrl())); - } catch (Exception e) { - throw new RuntimeException(e); - } + if (DeployModeEnum.YARN_PER.equals(deployModeEnum)) { + if (!systemConfigMap.containsKey(SysConfigEnum.YARN_RM_HTTP_ADDRESS.getKey())) { + throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_YARN_RM_HTTP_ADDRESS); + } + } + if (!systemConfigMap.containsKey(SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey())) { + throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_FLINK_STREAMING_PLATFORM_WEB_HOME); + } + } + + /** + * 正则表达式,区配参数:${xxxx} + */ + private static final Pattern PARAM_PATTERN = Pattern.compile("\\$\\{[\\w.-]+\\}"); + + /** + * 使用Nacos配置替换脚本中的参数 + * + * @param jobConfigDTO + * @author wxj + * @date 2021年12月29日 下午3:02:46 + * @version V1.0 + */ + private void replaceNacosParameters(JobConfigDTO jobConfigDTO) { + try { + String configInfo = configService.getConfig(nacosConfigDataId, nacosConfigGroup, 3000); + Properties properties = new Properties(); + properties.load(new StringReader(configInfo)); + jobConfigDTO.setFlinkRunConfig(replaceParamter(properties, jobConfigDTO.getFlinkRunConfig())); + jobConfigDTO.setFlinkCheckpointConfig( + replaceParamter(properties, jobConfigDTO.getFlinkCheckpointConfig())); + jobConfigDTO.setExtJarPath(replaceParamter(properties, jobConfigDTO.getExtJarPath())); + jobConfigDTO.setFlinkSql(replaceParamter(properties, jobConfigDTO.getFlinkSql())); + jobConfigDTO.setCustomArgs(replaceParamter(properties, jobConfigDTO.getCustomArgs())); + jobConfigDTO + .setCustomMainClass(replaceParamter(properties, jobConfigDTO.getCustomMainClass())); + jobConfigDTO.setCustomJarUrl(replaceParamter(properties, jobConfigDTO.getCustomJarUrl())); + } catch (Exception e) { + throw new RuntimeException(e); } + } - private String replaceParamter(Properties properties, String text) { - if (text == null) { - return null; - } - Matcher m = param_pattern.matcher(text); - while (m.find()) { - String param = m.group(); - String key = param.substring(2, param.length() - 1); - String value = (String)properties.get(key); - if (value != null) { - text = text.replace(param, value); - } - } - return text; + private String replaceParamter(Properties properties, String text) { + if (text == null) { + return null; + } + Matcher m = PARAM_PATTERN.matcher(text); + while (m.find()) { + String param = m.group(); + String key = param.substring(2, param.length() - 1); + String value = (String) properties.get(key); + if (value != null) { + text = text.replace(param, value); + } } + return text; + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobConfigAOImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobConfigAOImpl.java index bab23988..c20f8a43 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobConfigAOImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobConfigAOImpl.java @@ -19,23 +19,25 @@ @Slf4j public class JobConfigAOImpl implements JobConfigAO { - @Autowired - private JobConfigService jobConfigService; + @Autowired + private JobConfigService jobConfigService; - @Autowired - private JobAlarmConfigService jobAlarmConfigService; + @Autowired + private JobAlarmConfigService jobAlarmConfigService; - @Override - @Transactional(rollbackFor = Exception.class) - public void addJobConfig(JobConfigDTO jobConfigDTO) { - Long jobConfigId = jobConfigService.addJobConfig(jobConfigDTO); - jobAlarmConfigService.upSertBatchJobAlarmConfig(jobConfigDTO.getAlarmTypeEnumList(), jobConfigId); - } + @Override + @Transactional(rollbackFor = Exception.class) + public void addJobConfig(JobConfigDTO jobConfigDTO) { + Long jobConfigId = jobConfigService.addJobConfig(jobConfigDTO); + jobAlarmConfigService + .upSertBatchJobAlarmConfig(jobConfigDTO.getAlarmTypeEnumList(), jobConfigId); + } - @Override - @Transactional(rollbackFor = Exception.class) - public void updateJobConfigById(JobConfigDTO jobConfigDTO) { - jobConfigService.updateJobConfigByIdWithWriteHistory(jobConfigDTO); - jobAlarmConfigService.upSertBatchJobAlarmConfig(jobConfigDTO.getAlarmTypeEnumList(), jobConfigDTO.getId()); - } + @Override + @Transactional(rollbackFor = Exception.class) + public void updateJobConfigById(JobConfigDTO jobConfigDTO) { + jobConfigService.updateJobConfigByIdWithWriteHistory(jobConfigDTO); + jobAlarmConfigService + .upSertBatchJobAlarmConfig(jobConfigDTO.getAlarmTypeEnumList(), jobConfigDTO.getId()); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobStandaloneServerAOImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobStandaloneServerAOImpl.java index b87032ec..0e2d12ec 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobStandaloneServerAOImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobStandaloneServerAOImpl.java @@ -34,161 +34,170 @@ public class JobStandaloneServerAOImpl implements JobServerAO { - @Autowired - private JobConfigService jobConfigService; + @Autowired + private JobConfigService jobConfigService; - @Autowired - private SavepointBackupService savepointBackupService; + @Autowired + private SavepointBackupService savepointBackupService; - @Autowired - private CommandRpcClinetAdapter commandRpcClinetAdapter; + @Autowired + private CommandRpcClinetAdapter commandRpcClinetAdapter; - @Autowired - private FlinkRestRpcAdapter flinkRestRpcAdapter; + @Autowired + private FlinkRestRpcAdapter flinkRestRpcAdapter; - @Autowired - private JobBaseServiceAO jobBaseServiceAO; + @Autowired + private JobBaseServiceAO jobBaseServiceAO; - @Override - @Transactional(rollbackFor = Exception.class) - public void start(Long id, Long savepointId, String userName) { + @Override + @Transactional(rollbackFor = Exception.class) + public void start(Long id, Long savepointId, String userName) { - JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); - - if (StringUtils.isNotBlank(jobConfigDTO.getJobId())) { - if (!jobConfigDTO.getJobTypeEnum().equals(JobTypeEnum.SQL_BATCH)){ - JobStandaloneInfo jobstatus = flinkRestRpcAdapter.getJobInfoForStandaloneByAppId(jobConfigDTO.getJobId(), jobConfigDTO.getDeployModeEnum()); - if (!("CANCELED".equals(jobstatus.getState()) || "FAILED".equals(jobstatus.getState())) - && StringUtils.isNotBlank(jobstatus.getState())) { - throw new BizException("请检查Flink任务列表,任务ID=[" + jobConfigDTO.getJobId() + "]处于[ "+jobstatus.getState()+"]状态,不能重复启动任务!") ; - } - } + JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); + if (StringUtils.isNotBlank(jobConfigDTO.getJobId())) { + if (!jobConfigDTO.getJobTypeEnum().equals(JobTypeEnum.SQL_BATCH)) { + JobStandaloneInfo jobstatus = flinkRestRpcAdapter + .getJobInfoForStandaloneByAppId(jobConfigDTO.getJobId(), + jobConfigDTO.getDeployModeEnum()); + if (!("CANCELED".equals(jobstatus.getState()) || "FAILED".equals(jobstatus.getState())) + && StringUtils.isNotBlank(jobstatus.getState())) { + throw new BizException( + "请检查Flink任务列表,任务ID=[" + jobConfigDTO.getJobId() + "]处于[ " + jobstatus.getState() + + "]状态,不能重复启动任务!"); } + } - //1、检查jobConfigDTO 状态等参数 - jobBaseServiceAO.checkStart(jobConfigDTO); + } - // TODO 要不要检查集群上任务是否存在 + //1、检查jobConfigDTO 状态等参数 + jobBaseServiceAO.checkStart(jobConfigDTO); - //2、将配置的sql 写入本地文件并且返回运行所需参数 - JobRunParamDTO jobRunParamDTO = jobBaseServiceAO.writeSqlToFile(jobConfigDTO); + // TODO 要不要检查集群上任务是否存在 - //3、插一条运行日志数据 - Long jobRunLogId = jobBaseServiceAO.insertJobRunLog(jobConfigDTO, userName); + //2、将配置的sql 写入本地文件并且返回运行所需参数 + JobRunParamDTO jobRunParamDTO = jobBaseServiceAO.writeSqlToFile(jobConfigDTO); - //4、变更任务状态(变更为:启动中) 有乐观锁 防止重复提交 - jobConfigService.updateStatusByStart(jobConfigDTO.getId(), userName, jobRunLogId, jobConfigDTO.getVersion()); + //3、插一条运行日志数据 + Long jobRunLogId = jobBaseServiceAO.insertJobRunLog(jobConfigDTO, userName); - String savepointPath = savepointBackupService.getSavepointPathById(id, savepointId); + //4、变更任务状态(变更为:启动中) 有乐观锁 防止重复提交 + jobConfigService.updateStatusByStart(jobConfigDTO.getId(), userName, jobRunLogId, + jobConfigDTO.getVersion()); - //异步提交任务 - jobBaseServiceAO.aSyncExecJob(jobRunParamDTO, jobConfigDTO, jobRunLogId, savepointPath); + String savepointPath = savepointBackupService.getSavepointPathById(id, savepointId); - } + //异步提交任务 + jobBaseServiceAO.aSyncExecJob(jobRunParamDTO, jobConfigDTO, jobRunLogId, savepointPath); + } - @Override - public void stop(Long id, String userName) { - log.info("[{}]开始停止任务[{}]", userName, id); - JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); - if (jobConfigDTO == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); - } - JobStandaloneInfo jobStandaloneInfo = flinkRestRpcAdapter.getJobInfoForStandaloneByAppId(jobConfigDTO.getJobId(), jobConfigDTO.getDeployModeEnum()); - log.info("任务[{}]当前状态为:{}", id, jobStandaloneInfo); - if (jobStandaloneInfo == null || StringUtils.isNotEmpty(jobStandaloneInfo.getErrors())) { - log.warn("开始停止任务[{}],getJobInfoForStandaloneByAppId is error jobStandaloneInfo={}", id, jobStandaloneInfo); - } else { - // 停止前先savepoint - if (StringUtils.isNotBlank(jobConfigDTO.getFlinkCheckpointConfig()) - && jobConfigDTO.getJobTypeEnum() != JobTypeEnum.SQL_BATCH - && SystemConstants.STATUS_RUNNING.equals(jobStandaloneInfo.getState())) { - log.info("开始保存任务[{}]的状态-savepoint", id); - this.savepoint(id); - } - //停止任务 - if (SystemConstants.STATUS_RUNNING.equals(jobStandaloneInfo.getState()) || SystemConstants.STATUS_RESTARTING.equals(jobStandaloneInfo.getState())) { - flinkRestRpcAdapter.cancelJobForFlinkByAppId(jobConfigDTO.getJobId(), jobConfigDTO.getDeployModeEnum()); - } - } - JobConfigDTO jobConfig = new JobConfigDTO(); - jobConfig.setStatus(JobConfigStatus.STOP); - jobConfig.setEditor(userName); - jobConfig.setId(id); - jobConfig.setJobId(""); - //变更状态 - jobConfigService.updateJobConfigById(jobConfig); + + @Override + public void stop(Long id, String userName) { + log.info("[{}]开始停止任务[{}]", userName, id); + JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); + if (jobConfigDTO == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); + } + JobStandaloneInfo jobStandaloneInfo = flinkRestRpcAdapter + .getJobInfoForStandaloneByAppId(jobConfigDTO.getJobId(), jobConfigDTO.getDeployModeEnum()); + log.info("任务[{}]当前状态为:{}", id, jobStandaloneInfo); + if (jobStandaloneInfo == null || StringUtils.isNotEmpty(jobStandaloneInfo.getErrors())) { + log.warn("开始停止任务[{}],getJobInfoForStandaloneByAppId is error jobStandaloneInfo={}", id, + jobStandaloneInfo); + } else { + // 停止前先savepoint + if (StringUtils.isNotBlank(jobConfigDTO.getFlinkCheckpointConfig()) + && jobConfigDTO.getJobTypeEnum() != JobTypeEnum.SQL_BATCH + && SystemConstants.STATUS_RUNNING.equals(jobStandaloneInfo.getState())) { + log.info("开始保存任务[{}]的状态-savepoint", id); + this.savepoint(id); + } + //停止任务 + if (SystemConstants.STATUS_RUNNING.equals(jobStandaloneInfo.getState()) + || SystemConstants.STATUS_RESTARTING.equals(jobStandaloneInfo.getState())) { + flinkRestRpcAdapter + .cancelJobForFlinkByAppId(jobConfigDTO.getJobId(), jobConfigDTO.getDeployModeEnum()); + } + } + JobConfigDTO jobConfig = new JobConfigDTO(); + jobConfig.setStatus(JobConfigStatus.STOP); + jobConfig.setEditor(userName); + jobConfig.setId(id); + jobConfig.setJobId(""); + //变更状态 + jobConfigService.updateJobConfigById(jobConfig); + } + + @Override + public void savepoint(Long id) { + JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); + + jobBaseServiceAO.checkSavepoint(jobConfigDTO); + + JobStandaloneInfo jobStandaloneInfo = flinkRestRpcAdapter + .getJobInfoForStandaloneByAppId(jobConfigDTO.getJobId(), jobConfigDTO.getDeployModeEnum()); + if (jobStandaloneInfo == null || StringUtils.isNotEmpty(jobStandaloneInfo.getErrors()) + || !SystemConstants.STATUS_RUNNING.equals(jobStandaloneInfo.getState())) { + log.warn(MessageConstants.MESSAGE_007, jobConfigDTO.getJobName()); + throw new BizException(MessageConstants.MESSAGE_007); } - @Override - public void savepoint(Long id) { - JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); + //1、 执行savepoint + try { + //yarn模式下和集群模式下统一目录是hdfs:///flink/savepoint/flink-streaming-platform-web/ + //LOCAL模式本地模式下保存在flink根目录下 + String targetDirectory = SystemConstants.DEFAULT_SAVEPOINT_ROOT_PATH + id; + if (DeployModeEnum.LOCAL.equals(jobConfigDTO.getDeployModeEnum())) { + targetDirectory = "savepoint/" + id; + } + + commandRpcClinetAdapter.savepointForPerCluster(jobConfigDTO.getJobId(), targetDirectory); + } catch (Exception e) { + log.error(MessageConstants.MESSAGE_008, e); + throw new BizException(MessageConstants.MESSAGE_008); + } - jobBaseServiceAO.checkSavepoint(jobConfigDTO); + String savepointPath = flinkRestRpcAdapter.savepointPath(jobConfigDTO.getJobId(), + jobConfigDTO.getDeployModeEnum()); + if (StringUtils.isEmpty(savepointPath)) { + log.warn(MessageConstants.MESSAGE_009, jobConfigDTO); + throw new BizException(MessageConstants.MESSAGE_009); + } + //2、 执行保存Savepoint到本地数据库 + savepointBackupService.insertSavepoint(id, savepointPath, new Date()); + } - JobStandaloneInfo jobStandaloneInfo = flinkRestRpcAdapter.getJobInfoForStandaloneByAppId(jobConfigDTO.getJobId() - , jobConfigDTO.getDeployModeEnum()); - if (jobStandaloneInfo == null || StringUtils.isNotEmpty(jobStandaloneInfo.getErrors()) - || !SystemConstants.STATUS_RUNNING.equals(jobStandaloneInfo.getState())) { - log.warn(MessageConstants.MESSAGE_007, jobConfigDTO.getJobName()); - throw new BizException(MessageConstants.MESSAGE_007); - } - //1、 执行savepoint - try { - //yarn模式下和集群模式下统一目录是hdfs:///flink/savepoint/flink-streaming-platform-web/ - //LOCAL模式本地模式下保存在flink根目录下 - String targetDirectory = SystemConstants.DEFAULT_SAVEPOINT_ROOT_PATH + id; - if (DeployModeEnum.LOCAL.equals(jobConfigDTO.getDeployModeEnum())) { - targetDirectory = "savepoint/" + id; - } - - commandRpcClinetAdapter.savepointForPerCluster(jobConfigDTO.getJobId(), targetDirectory); - } catch (Exception e) { - log.error(MessageConstants.MESSAGE_008, e); - throw new BizException(MessageConstants.MESSAGE_008); - } + @Override + public void open(Long id, String userName) { + jobConfigService.openOrClose(id, YN.Y, userName); + } - String savepointPath = flinkRestRpcAdapter.savepointPath(jobConfigDTO.getJobId(), - jobConfigDTO.getDeployModeEnum()); - if (StringUtils.isEmpty(savepointPath)) { - log.warn(MessageConstants.MESSAGE_009, jobConfigDTO); - throw new BizException(MessageConstants.MESSAGE_009); - } - //2、 执行保存Savepoint到本地数据库 - savepointBackupService.insertSavepoint(id, savepointPath, new Date()); - } + @Override + public void close(Long id, String userName) { + jobBaseServiceAO.checkClose(jobConfigService.getJobConfigById(id)); + jobConfigService.openOrClose(id, YN.N, userName); + } - @Override - public void open(Long id, String userName) { - jobConfigService.openOrClose(id, YN.Y, userName); + private void checkSysConfig(Map systemConfigMap, DeployModeEnum deployModeEnum) { + if (systemConfigMap == null) { + throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL); } - - @Override - public void close(Long id, String userName) { - jobBaseServiceAO.checkClose(jobConfigService.getJobConfigById(id)); - jobConfigService.openOrClose(id, YN.N, userName); + if (!systemConfigMap.containsKey(SysConfigEnum.FLINK_HOME.getKey())) { + throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_FLINK_HOME); } + if (DeployModeEnum.LOCAL == deployModeEnum + && !systemConfigMap.containsKey(SysConfigEnum.FLINK_REST_HTTP_ADDRESS.getKey())) { + throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_FLINK_REST_HTTP_ADDRESS); + } - private void checkSysConfig(Map systemConfigMap, DeployModeEnum deployModeEnum) { - if (systemConfigMap == null) { - throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL); - } - if (!systemConfigMap.containsKey(SysConfigEnum.FLINK_HOME.getKey())) { - throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_FLINK_HOME); - } - - if (DeployModeEnum.LOCAL == deployModeEnum - && !systemConfigMap.containsKey(SysConfigEnum.FLINK_REST_HTTP_ADDRESS.getKey())) { - throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_FLINK_REST_HTTP_ADDRESS); - } - - if (DeployModeEnum.STANDALONE == deployModeEnum - && !systemConfigMap.containsKey(SysConfigEnum.FLINK_REST_HA_HTTP_ADDRESS.getKey())) { - throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_FLINK_REST_HA_HTTP_ADDRESS); - } + if (DeployModeEnum.STANDALONE == deployModeEnum + && !systemConfigMap.containsKey(SysConfigEnum.FLINK_REST_HA_HTTP_ADDRESS.getKey())) { + throw new BizException(SysErrorEnum.SYSTEM_CONFIG_IS_NULL_FLINK_REST_HA_HTTP_ADDRESS); } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobYarnServerAOImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobYarnServerAOImpl.java index 77e90f07..99084f8a 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobYarnServerAOImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/JobYarnServerAOImpl.java @@ -33,136 +33,139 @@ @Slf4j public class JobYarnServerAOImpl implements JobServerAO { - //最大重试次数 - private static final Integer TRY_TIMES = 2; + //最大重试次数 + private static final Integer TRY_TIMES = 2; - @Autowired - private JobConfigService jobConfigService; + @Autowired + private JobConfigService jobConfigService; - @Autowired - private YarnRestRpcAdapter yarnRestRpcAdapter; + @Autowired + private YarnRestRpcAdapter yarnRestRpcAdapter; - @Autowired - private CommandRpcClinetAdapter commandRpcClinetAdapter; + @Autowired + private CommandRpcClinetAdapter commandRpcClinetAdapter; - @Autowired - private SavepointBackupService savepointBackupService; + @Autowired + private SavepointBackupService savepointBackupService; - @Autowired - private JobBaseServiceAO jobBaseServiceAO; + @Autowired + private JobBaseServiceAO jobBaseServiceAO; - @Override - @Transactional(rollbackFor = Exception.class) - public void start(Long id, Long savepointId, String userName) { + @Override + @Transactional(rollbackFor = Exception.class) + public void start(Long id, Long savepointId, String userName) { - JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); + JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); - //1、检查jobConfigDTO 状态等参数 - jobBaseServiceAO.checkStart(jobConfigDTO); + //1、检查jobConfigDTO 状态等参数 + jobBaseServiceAO.checkStart(jobConfigDTO); - if (StringUtils.isNotEmpty(jobConfigDTO.getJobId())) { - this.stop(jobConfigDTO); - } + if (StringUtils.isNotEmpty(jobConfigDTO.getJobId())) { + this.stop(jobConfigDTO); + } - //2、将配置的sql 写入本地文件并且返回运行所需参数 - JobRunParamDTO jobRunParamDTO = jobBaseServiceAO.writeSqlToFile(jobConfigDTO); + //2、将配置的sql 写入本地文件并且返回运行所需参数 + JobRunParamDTO jobRunParamDTO = jobBaseServiceAO.writeSqlToFile(jobConfigDTO); - //3、插一条运行日志数据 - Long jobRunLogId = jobBaseServiceAO.insertJobRunLog(jobConfigDTO, userName); + //3、插一条运行日志数据 + Long jobRunLogId = jobBaseServiceAO.insertJobRunLog(jobConfigDTO, userName); - //4、变更任务状态(变更为:启动中) 有乐观锁 防止重复提交 - jobConfigService.updateStatusByStart(jobConfigDTO.getId(), userName, jobRunLogId, jobConfigDTO.getVersion()); + //4、变更任务状态(变更为:启动中) 有乐观锁 防止重复提交 + jobConfigService.updateStatusByStart(jobConfigDTO.getId(), userName, jobRunLogId, + jobConfigDTO.getVersion()); - String savepointPath = savepointBackupService.getSavepointPathById(id, savepointId); + String savepointPath = savepointBackupService.getSavepointPathById(id, savepointId); - //异步提交任务 - jobBaseServiceAO.aSyncExecJob(jobRunParamDTO, jobConfigDTO, jobRunLogId, savepointPath); + //异步提交任务 + jobBaseServiceAO.aSyncExecJob(jobRunParamDTO, jobConfigDTO, jobRunLogId, savepointPath); - } + } - @Override - public void stop(Long id, String userName) { - log.info("[{}]开始停止任务[{}]", userName, id); - JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); - if (jobConfigDTO == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); - } - //1、停止前做一次savepoint操作 - try { - this.savepoint(id); - } catch (Exception e) { - log.error(MessageConstants.MESSAGE_008, e); - } - //2、停止任务 - this.stop(jobConfigDTO); - JobConfigDTO jobConfig = new JobConfigDTO(); - jobConfig.setStatus(JobConfigStatus.STOP); - jobConfig.setEditor(userName); - jobConfig.setId(id); - jobConfig.setJobId(""); - //3、变更状态 - jobConfigService.updateJobConfigById(jobConfig); + @Override + public void stop(Long id, String userName) { + log.info("[{}]开始停止任务[{}]", userName, id); + JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); + if (jobConfigDTO == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); } - - @Override - public void savepoint(Long id) { - JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); - - jobBaseServiceAO.checkSavepoint(jobConfigDTO); - - JobInfo jobInfo = yarnRestRpcAdapter.getJobInfoForPerYarnByAppId(jobConfigDTO.getJobId()); - if (jobInfo == null) { - log.warn(MessageConstants.MESSAGE_007, jobConfigDTO.getJobName()); - throw new BizException(MessageConstants.MESSAGE_007); - } - //1、 执行savepoint - try { - commandRpcClinetAdapter.savepointForPerYarn(jobInfo.getId(), - SystemConstants.DEFAULT_SAVEPOINT_ROOT_PATH + id, jobConfigDTO.getJobId()); - } catch (Exception e) { - log.error(MessageConstants.MESSAGE_008, e); - throw new BizException(MessageConstants.MESSAGE_008); - } - - String savepointPath = yarnRestRpcAdapter.getSavepointPath(jobConfigDTO.getJobId(), jobInfo.getId()); - if (StringUtils.isEmpty(savepointPath)) { - log.warn(MessageConstants.MESSAGE_009, jobConfigDTO); - throw new BizException(MessageConstants.MESSAGE_009); - } - //2、 执行保存Savepoint到本地数据库 - savepointBackupService.insertSavepoint(id, savepointPath, new Date()); + //1、停止前做一次savepoint操作 + try { + this.savepoint(id); + } catch (Exception e) { + log.error(MessageConstants.MESSAGE_008, e); } - - - @Override - public void open(Long id, String userName) { - jobConfigService.openOrClose(id, YN.Y, userName); + //2、停止任务 + this.stop(jobConfigDTO); + JobConfigDTO jobConfig = new JobConfigDTO(); + jobConfig.setStatus(JobConfigStatus.STOP); + jobConfig.setEditor(userName); + jobConfig.setId(id); + jobConfig.setJobId(""); + //3、变更状态 + jobConfigService.updateJobConfigById(jobConfig); + } + + @Override + public void savepoint(Long id) { + JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); + + jobBaseServiceAO.checkSavepoint(jobConfigDTO); + + JobInfo jobInfo = yarnRestRpcAdapter.getJobInfoForPerYarnByAppId(jobConfigDTO.getJobId()); + if (jobInfo == null) { + log.warn(MessageConstants.MESSAGE_007, jobConfigDTO.getJobName()); + throw new BizException(MessageConstants.MESSAGE_007); } - - @Override - public void close(Long id, String userName) { - jobBaseServiceAO.checkClose(jobConfigService.getJobConfigById(id)); - - jobConfigService.openOrClose(id, YN.N, userName); + //1、 执行savepoint + try { + commandRpcClinetAdapter.savepointForPerYarn(jobInfo.getId(), + SystemConstants.DEFAULT_SAVEPOINT_ROOT_PATH + id, jobConfigDTO.getJobId()); + } catch (Exception e) { + log.error(MessageConstants.MESSAGE_008, e); + throw new BizException(MessageConstants.MESSAGE_008); } - - private void stop(JobConfigDTO jobConfigDTO) { - Integer retryNum = 1; - while (retryNum <= TRY_TIMES) { - JobInfo jobInfo = yarnRestRpcAdapter.getJobInfoForPerYarnByAppId(jobConfigDTO.getJobId()); - log.info("任务[{}]当前状态为:{}", jobConfigDTO.getId(), jobInfo); - if (jobInfo != null && SystemConstants.STATUS_RUNNING.equals(jobInfo.getStatus())) { - log.info("执行停止操作 jobYarnInfo={} retryNum={} id={}", jobInfo, retryNum, jobConfigDTO.getJobId()); - yarnRestRpcAdapter.cancelJobForYarnByAppId(jobConfigDTO.getJobId(), jobInfo.getId()); - } else { - log.info("任务已经停止 jobYarnInfo={} id={}", jobInfo, jobConfigDTO.getJobId()); - break; - } - retryNum++; - } + String savepointPath = yarnRestRpcAdapter + .getSavepointPath(jobConfigDTO.getJobId(), jobInfo.getId()); + if (StringUtils.isEmpty(savepointPath)) { + log.warn(MessageConstants.MESSAGE_009, jobConfigDTO); + throw new BizException(MessageConstants.MESSAGE_009); + } + //2、 执行保存Savepoint到本地数据库 + savepointBackupService.insertSavepoint(id, savepointPath, new Date()); + } + + + @Override + public void open(Long id, String userName) { + jobConfigService.openOrClose(id, YN.Y, userName); + } + + @Override + public void close(Long id, String userName) { + jobBaseServiceAO.checkClose(jobConfigService.getJobConfigById(id)); + + jobConfigService.openOrClose(id, YN.N, userName); + } + + + private void stop(JobConfigDTO jobConfigDTO) { + Integer retryNum = 1; + while (retryNum <= TRY_TIMES) { + JobInfo jobInfo = yarnRestRpcAdapter.getJobInfoForPerYarnByAppId(jobConfigDTO.getJobId()); + log.info("任务[{}]当前状态为:{}", jobConfigDTO.getId(), jobInfo); + if (jobInfo != null && SystemConstants.STATUS_RUNNING.equals(jobInfo.getStatus())) { + log.info("执行停止操作 jobYarnInfo={} retryNum={} id={}", jobInfo, retryNum, + jobConfigDTO.getJobId()); + yarnRestRpcAdapter.cancelJobForYarnByAppId(jobConfigDTO.getJobId(), jobInfo.getId()); + } else { + log.info("任务已经停止 jobYarnInfo={} id={}", jobInfo, jobConfigDTO.getJobId()); + break; + } + retryNum++; } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/TaskServiceAOImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/TaskServiceAOImpl.java index 1d5f2253..c2f0c1c6 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/TaskServiceAOImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/ao/impl/TaskServiceAOImpl.java @@ -41,288 +41,310 @@ @Slf4j public class TaskServiceAOImpl implements TaskServiceAO { - @Autowired - private JobConfigService jobConfigService; + @Autowired + private JobConfigService jobConfigService; - @Autowired - private FlinkRestRpcAdapter flinkRestRpcAdapter; + @Autowired + private FlinkRestRpcAdapter flinkRestRpcAdapter; - @Autowired - private YarnRestRpcAdapter yarnRestRpcAdapter; + @Autowired + private YarnRestRpcAdapter yarnRestRpcAdapter; - @Autowired - private AlarmServiceAO alarmServiceAO; + @Autowired + private AlarmServiceAO alarmServiceAO; - @Autowired - private JobServerAO jobYarnServerAO; + @Autowired + private JobServerAO jobYarnServerAO; - @Autowired - private JobServerAO jobStandaloneServerAO; + @Autowired + private JobServerAO jobStandaloneServerAO; - @Autowired - private SystemConfigService systemConfigService; + @Autowired + private SystemConfigService systemConfigService; - @Autowired - private JobAlarmConfigService jobAlarmConfigService; - - @Autowired - private DingDingService dingDingService; + @Autowired + private JobAlarmConfigService jobAlarmConfigService; - private ThreadPoolExecutor threadPoolExecutor = AlarmPoolConfig.getInstance().getThreadPoolExecutor(); + @Autowired + private DingDingService dingDingService; - @Override - public void checkJobStatus() { - List jobConfigDTOList = jobConfigService.findJobConfigByStatus(JobConfigStatus.RUN.getCode()); - if (CollectionUtils.isEmpty(jobConfigDTOList)) { - log.warn("当前配置中没有运行的任务"); - return; - } - for (JobConfigDTO jobConfigDTO : jobConfigDTOList) { - if (JobTypeEnum.SQL_BATCH.equals(jobConfigDTO.getJobTypeEnum())){ - log.warn("批任务不需要状态校验"); - return; - } - List alarmTypeEnumList = jobAlarmConfigService.findByJobId(jobConfigDTO.getId()); - switch (jobConfigDTO.getDeployModeEnum()) { - case YARN_PER: - this.checkYarn(jobConfigDTO, alarmTypeEnumList); - this.sleep(); - break; - case LOCAL: - case STANDALONE: - this.checkStandalone(jobConfigDTO, alarmTypeEnumList); - this.sleep(); - break; - default: - break; - } - } + private ThreadPoolExecutor threadPoolExecutor = AlarmPoolConfig.getInstance() + .getThreadPoolExecutor(); + + @Override + public void checkJobStatus() { + List jobConfigDTOList = jobConfigService + .findJobConfigByStatus(JobConfigStatus.RUN.getCode()); + if (CollectionUtils.isEmpty(jobConfigDTOList)) { + log.warn("当前配置中没有运行的任务"); + return; + } + for (JobConfigDTO jobConfigDTO : jobConfigDTOList) { + if (JobTypeEnum.SQL_BATCH.equals(jobConfigDTO.getJobTypeEnum())) { + log.warn("批任务不需要状态校验"); + return; + } + List alarmTypeEnumList = jobAlarmConfigService + .findByJobId(jobConfigDTO.getId()); + switch (jobConfigDTO.getDeployModeEnum()) { + case YARN_PER: + this.checkYarn(jobConfigDTO, alarmTypeEnumList); + this.sleep(); + break; + case LOCAL: + case STANDALONE: + this.checkStandalone(jobConfigDTO, alarmTypeEnumList); + this.sleep(); + break; + default: + break; + } } + } - @Override - @Deprecated - public void checkYarnJobByStop() { - List jobConfigDTOList = jobConfigService.findJobConfigByStatus(JobConfigStatus.STOP.getCode()); - if (CollectionUtils.isEmpty(jobConfigDTOList)) { - return; - } - for (JobConfigDTO jobConfigDTO : jobConfigDTOList) { - if (jobConfigDTO.getIsOpen().intValue() == YN.N.getValue()) { - continue; + @Override + @Deprecated + public void checkYarnJobByStop() { + List jobConfigDTOList = jobConfigService + .findJobConfigByStatus(JobConfigStatus.STOP.getCode()); + if (CollectionUtils.isEmpty(jobConfigDTOList)) { + return; + } + for (JobConfigDTO jobConfigDTO : jobConfigDTOList) { + if (jobConfigDTO.getIsOpen().intValue() == YN.N.getValue()) { + continue; + } + if (JobTypeEnum.SQL_BATCH.equals(jobConfigDTO.getJobTypeEnum())) { + log.warn("批任务不需要状态校验"); + return; + } + switch (jobConfigDTO.getDeployModeEnum()) { + case YARN_PER: + String appId = null; + try { + String queueName = YarnUtil.getQueueName(jobConfigDTO.getFlinkRunConfig()); + if (StringUtils.isEmpty(queueName)) { + continue; } - if (JobTypeEnum.SQL_BATCH.equals(jobConfigDTO.getJobTypeEnum())){ - log.warn("批任务不需要状态校验"); - return; + log.info("check job getJobName={} queueName={}", jobConfigDTO.getJobName(), queueName); + appId = yarnRestRpcAdapter.getAppIdByYarn(jobConfigDTO.getJobName(), queueName); + } catch (BizException be) { + if (SysErrorEnum.YARN_CODE.getCode().equals(be.getCode())) { + continue; } - switch (jobConfigDTO.getDeployModeEnum()) { - case YARN_PER: - String appId = null; - try { - String queueName = YarnUtil.getQueueName(jobConfigDTO.getFlinkRunConfig()); - if (StringUtils.isEmpty(queueName)) { - continue; - } - log.info("check job getJobName={} queueName={}", jobConfigDTO.getJobName(), queueName); - appId = yarnRestRpcAdapter.getAppIdByYarn(jobConfigDTO.getJobName(), queueName); - } catch (BizException be) { - if (SysErrorEnum.YARN_CODE.getCode().equals(be.getCode())) { - continue; - } - log.error("[BizException]getAppIdByYarn is error ", be); - } catch (Exception e) { - log.error("[Exception]getAppIdByYarn is error ", e); - continue; - } - if (!StringUtils.isEmpty(appId)) { - JobInfo jobInfo = yarnRestRpcAdapter.getJobInfoForPerYarnByAppId(appId); - if (jobInfo != null && SystemConstants.STATUS_RUNNING.equals(jobInfo.getStatus())) { - log.warn("执行停止操作 jobYarnInfo={} id={}", jobInfo, appId); - yarnRestRpcAdapter.cancelJobForYarnByAppId(appId, jobInfo.getId()); - } - } - break; - default: - break; + log.error("[BizException]getAppIdByYarn is error ", be); + } catch (Exception e) { + log.error("[Exception]getAppIdByYarn is error ", e); + continue; + } + if (!StringUtils.isEmpty(appId)) { + JobInfo jobInfo = yarnRestRpcAdapter.getJobInfoForPerYarnByAppId(appId); + if (jobInfo != null && SystemConstants.STATUS_RUNNING.equals(jobInfo.getStatus())) { + log.warn("执行停止操作 jobYarnInfo={} id={}", jobInfo, appId); + yarnRestRpcAdapter.cancelJobForYarnByAppId(appId, jobInfo.getId()); } - } + } + break; + default: + break; + } } + } - @Override - public void autoSavePoint() { - List jobConfigDTOList = jobConfigService.findJobConfigByStatus(JobConfigStatus.RUN.getCode()); - if (CollectionUtils.isEmpty(jobConfigDTOList)) { - log.warn("autoSavePoint is null 没有找到运行中的任务 "); - return; - } - for (JobConfigDTO jobConfigDTO : jobConfigDTOList) { + @Override + public void autoSavePoint() { + List jobConfigDTOList = jobConfigService + .findJobConfigByStatus(JobConfigStatus.RUN.getCode()); + if (CollectionUtils.isEmpty(jobConfigDTOList)) { + log.warn("autoSavePoint is null 没有找到运行中的任务 "); + return; + } + for (JobConfigDTO jobConfigDTO : jobConfigDTOList) { - //sql、jar 流任务才执行SavePoint - if (JobTypeEnum.SQL_STREAMING.equals(jobConfigDTO.getJobTypeEnum())|| - JobTypeEnum.JAR.equals(jobConfigDTO.getJobTypeEnum())) { - SavePointThreadPool.getInstance().getThreadPoolExecutor().execute(new SavePoint(jobConfigDTO)); - sleep(); - } + //sql、jar 流任务才执行SavePoint + if (JobTypeEnum.SQL_STREAMING.equals(jobConfigDTO.getJobTypeEnum()) + || JobTypeEnum.JAR.equals(jobConfigDTO.getJobTypeEnum())) { + SavePointThreadPool.getInstance().getThreadPoolExecutor() + .execute(new SavePoint(jobConfigDTO)); + sleep(); + } - } } + } - /** - * 执行SavePoint - */ - class SavePoint implements Runnable { - - private JobConfigDTO jobConfigDTO; + /** + * 执行SavePoint + */ + class SavePoint implements Runnable { - public SavePoint(JobConfigDTO jobConfigDTO) { - this.jobConfigDTO = jobConfigDTO; - } + private JobConfigDTO jobConfigDTO; - @Override - public void run() { - try { - switch (jobConfigDTO.getDeployModeEnum()) { - case YARN_PER: - jobYarnServerAO.savepoint(jobConfigDTO.getId()); - break; - case LOCAL: - case STANDALONE: - jobStandaloneServerAO.savepoint(jobConfigDTO.getId()); - break; - } + SavePoint(JobConfigDTO jobConfigDTO) { + this.jobConfigDTO = jobConfigDTO; + } - } catch (Exception e) { - log.error("执行savepoint 异常", e); - } + @Override + public void run() { + try { + switch (jobConfigDTO.getDeployModeEnum()) { + case YARN_PER: + jobYarnServerAO.savepoint(jobConfigDTO.getId()); + break; + case LOCAL: + case STANDALONE: + jobStandaloneServerAO.savepoint(jobConfigDTO.getId()); + break; + default: } + + } catch (Exception e) { + log.error("执行savepoint 异常", e); + } } + } - private void sleep() { - try { - Thread.sleep(4000); - } catch (InterruptedException e) { - } + private void sleep() { + try { + Thread.sleep(4000); + } catch (InterruptedException e) { } + } - private void checkYarn(JobConfigDTO jobConfigDTO, List alarmTypeEnumList) { - if (StringUtils.isEmpty(jobConfigDTO.getJobId())) { - log.error("任务[{}]配置不存在", jobConfigDTO.getId()); - return; - } - //查询任务状态 - JobInfo jobInfo = yarnRestRpcAdapter.getJobInfoForPerYarnByAppId(jobConfigDTO.getJobId()); - if (jobInfo != null && SystemConstants.STATUS_RUNNING.equals(jobInfo.getStatus())) { - return; - } - //变更任务状态 - log.error("发现本地任务[{}]状态和yarn上不一致,准备自动修复本地web任务状态, {}", jobConfigDTO.getId(), jobConfigDTO); - JobConfigDTO jobConfig = JobConfigDTO.bulidStop(jobConfigDTO.getId()); - jobConfigService.updateJobConfigById(jobConfig); - //发送告警并且自动拉起任务 - this.alermAndAutoJob(alarmTypeEnumList, SystemConstants.buildDingdingMessage("检测到任务[" + jobConfigDTO.getId() + "]停止运行,任务名称:" + - jobConfigDTO.getJobName()), jobConfigDTO, DeployModeEnum.YARN_PER); + private void checkYarn(JobConfigDTO jobConfigDTO, List alarmTypeEnumList) { + if (StringUtils.isEmpty(jobConfigDTO.getJobId())) { + log.error("任务[{}]配置不存在", jobConfigDTO.getId()); + return; + } + //查询任务状态 + JobInfo jobInfo = yarnRestRpcAdapter.getJobInfoForPerYarnByAppId(jobConfigDTO.getJobId()); + if (jobInfo != null && SystemConstants.STATUS_RUNNING.equals(jobInfo.getStatus())) { + return; } + //变更任务状态 + log.error("发现本地任务[{}]状态和yarn上不一致,准备自动修复本地web任务状态, {}", + jobConfigDTO.getId(), jobConfigDTO); + JobConfigDTO jobConfig = JobConfigDTO.bulidStop(jobConfigDTO.getId()); + jobConfigService.updateJobConfigById(jobConfig); + //发送告警并且自动拉起任务 + this.alermAndAutoJob(alarmTypeEnumList, + SystemConstants.buildDingdingMessage("检测到任务[" + jobConfigDTO.getId() + + "]停止运行,任务名称:" + jobConfigDTO.getJobName()), jobConfigDTO, DeployModeEnum.YARN_PER); + } - private void checkStandalone(JobConfigDTO jobConfigDTO, List alarmTypeEnumList) { - if (StringUtils.isEmpty(jobConfigDTO.getJobId())) { - String message = SystemConstants.buildDingdingMessage("检测到任务jobId异常任务[" + jobConfigDTO.getId() +"]名称:" + jobConfigDTO.getJobName()); - log.error(message); - return; - } - //查询任务状态 - JobStandaloneInfo jobStandaloneInfo = flinkRestRpcAdapter.getJobInfoForStandaloneByAppId(jobConfigDTO.getJobId(), jobConfigDTO.getDeployModeEnum()); - if (jobStandaloneInfo != null && SystemConstants.STATUS_RUNNING.equals(jobStandaloneInfo.getState())) { - return; - } - //变更任务状态 - log.error("发现本地任务[{}]状态和yarn上不一致,准备自动修复任务状态,jobStandaloneInfo={}", jobConfigDTO.getId(), jobStandaloneInfo); - JobConfigDTO jobConfig = JobConfigDTO.bulidStop(jobConfigDTO.getId()); - jobConfigService.updateJobConfigById(jobConfig); - //发送告警并且自动拉起任务 - this.alermAndAutoJob(alarmTypeEnumList, SystemConstants.buildDingdingMessage("检测到任务[" + jobConfigDTO.getId() + "]停止运行,任务名称:" + - jobConfigDTO.getJobName()), jobConfigDTO, DeployModeEnum.STANDALONE); + private void checkStandalone(JobConfigDTO jobConfigDTO, List alarmTypeEnumList) { + if (StringUtils.isEmpty(jobConfigDTO.getJobId())) { + String message = SystemConstants.buildDingdingMessage( + "检测到任务jobId异常任务[" + jobConfigDTO.getId() + "]名称:" + jobConfigDTO.getJobName()); + log.error(message); + return; + } + //查询任务状态 + JobStandaloneInfo jobStandaloneInfo = flinkRestRpcAdapter + .getJobInfoForStandaloneByAppId(jobConfigDTO.getJobId(), jobConfigDTO.getDeployModeEnum()); + if (jobStandaloneInfo != null && SystemConstants.STATUS_RUNNING + .equals(jobStandaloneInfo.getState())) { + return; } + //变更任务状态 + log.error("发现本地任务[{}]状态和yarn上不一致,准备自动修复任务状态,jobStandaloneInfo={}", jobConfigDTO.getId(), + jobStandaloneInfo); + JobConfigDTO jobConfig = JobConfigDTO.bulidStop(jobConfigDTO.getId()); + jobConfigService.updateJobConfigById(jobConfig); + //发送告警并且自动拉起任务 + this.alermAndAutoJob(alarmTypeEnumList, + SystemConstants.buildDingdingMessage("检测到任务[" + jobConfigDTO.getId() + + "]停止运行,任务名称:" + jobConfigDTO.getJobName()), jobConfigDTO, + DeployModeEnum.STANDALONE); + } - /** - * 告警并且拉起任务, - * //TODO 如果拉起失败下次将不能拉起 - * - * @author zhuhuipei - * @date 2021/2/28 - * @time 19:50 - */ - private void alermAndAutoJob(List alarmTypeEnumList, String cusContent, - JobConfigDTO jobConfigDTO, DeployModeEnum deployModeEnum) { - threadPoolExecutor.execute(new Runnable() { - @Override - public void run() { - dingDingService.doAlarmNotify(cusContent, jobConfigDTO, deployModeEnum); - } - }); - if (CollectionUtils.isEmpty(alarmTypeEnumList)) { - log.warn("任务[{}-{}]没有配置告警,无法进行告警,并且任务将会被停止!!!", jobConfigDTO.getId(), jobConfigDTO.getJobName()); - return; - } - CallbackDTO callbackDTO = CallbackDTO.to(jobConfigDTO); - //告警 - for (AlarmTypeEnum alarmTypeEnum : alarmTypeEnumList) { - switch (alarmTypeEnum) { - case DINGDING: - this.dingdingAlarm(cusContent, callbackDTO.getJobConfigId()); - break; - case CALLBACK_URL: - this.httpAlarm(callbackDTO); - break; - } - } - //自动拉起 - if (alarmTypeEnumList.contains(AlarmTypeEnum.AUTO_START_JOB)) { - log.info("校验任务不存在,开始自动拉起 JobConfigId={}", callbackDTO.getJobConfigId()); - try { - switch (deployModeEnum) { - case YARN_PER: - jobYarnServerAO.start(callbackDTO.getJobConfigId(), null, SystemConstants.USER_NAME_TASK_AUTO); - break; - case STANDALONE: - jobStandaloneServerAO.start(callbackDTO.getJobConfigId(), null, SystemConstants.USER_NAME_TASK_AUTO); - break; - } - } catch (Exception e) { - log.error("自动重启任务失败 JobConfigId={}", callbackDTO.getJobConfigId(), e); - } + /** + * 告警并且拉起任务, //TODO 如果拉起失败下次将不能拉起 + * + * @author zhuhuipei + * @date 2021/2/28 + * @time 19:50 + */ + private void alermAndAutoJob(List alarmTypeEnumList, String cusContent, + JobConfigDTO jobConfigDTO, DeployModeEnum deployModeEnum) { + threadPoolExecutor.execute(new Runnable() { + @Override + public void run() { + dingDingService.doAlarmNotify(cusContent, jobConfigDTO, deployModeEnum); + } + }); + if (CollectionUtils.isEmpty(alarmTypeEnumList)) { + log.warn("任务[{}-{}]没有配置告警,无法进行告警,并且任务将会被停止!!!", jobConfigDTO.getId(), + jobConfigDTO.getJobName()); + return; + } + CallbackDTO callbackDTO = CallbackDTO.to(jobConfigDTO); + //告警 + for (AlarmTypeEnum alarmTypeEnum : alarmTypeEnumList) { + switch (alarmTypeEnum) { + case DINGDING: + this.dingdingAlarm(cusContent, callbackDTO.getJobConfigId()); + break; + case CALLBACK_URL: + this.httpAlarm(callbackDTO); + break; + default: + } + } + //自动拉起 + if (alarmTypeEnumList.contains(AlarmTypeEnum.AUTO_START_JOB)) { + log.info("校验任务不存在,开始自动拉起 JobConfigId={}", callbackDTO.getJobConfigId()); + try { + switch (deployModeEnum) { + case YARN_PER: + jobYarnServerAO + .start(callbackDTO.getJobConfigId(), null, SystemConstants.USER_NAME_TASK_AUTO); + break; + case STANDALONE: + jobStandaloneServerAO + .start(callbackDTO.getJobConfigId(), null, SystemConstants.USER_NAME_TASK_AUTO); + break; + default: } + } catch (Exception e) { + log.error("自动重启任务失败 JobConfigId={}", callbackDTO.getJobConfigId(), e); + } } + } - /** - * 钉钉告警 - * - * @author zhuhuipei - * @date 2021/2/28 - * @time 19:56 - */ - private void dingdingAlarm(String content, Long jobConfigId) { - String alartUrl = systemConfigService.getSystemConfigByKey(SysConfigEnum.DINGDING_ALARM_URL.getKey()); - if (StringUtils.isEmpty(alartUrl)) { - log.warn("##### 钉钉告警url没有设置,任务[{}]无法告警 #####", jobConfigId); - return; - } - threadPoolExecutor.execute(new AlarmDingdingThread(alarmServiceAO, content, jobConfigId, alartUrl)); + /** + * 钉钉告警 + * + * @author zhuhuipei + * @date 2021/2/28 + * @time 19:56 + */ + private void dingdingAlarm(String content, Long jobConfigId) { + String alartUrl = systemConfigService + .getSystemConfigByKey(SysConfigEnum.DINGDING_ALARM_URL.getKey()); + if (StringUtils.isEmpty(alartUrl)) { + log.warn("##### 钉钉告警url没有设置,任务[{}]无法告警 #####", jobConfigId); + return; } + threadPoolExecutor + .execute(new AlarmDingdingThread(alarmServiceAO, content, jobConfigId, alartUrl)); + } - /** - * 回调函数自定义告警 - * - * @author zhuhuipei - * @date 2021/2/28 - * @time 19:56 - */ - private void httpAlarm(CallbackDTO callbackDTO) { - String alartUrl = systemConfigService.getSystemConfigByKey(SysConfigEnum.CALLBACK_ALARM_URL.getKey()); - if (StringUtils.isEmpty(alartUrl)) { - log.warn("##### 回调告警url没有设置,任务[{}]无法告警 #####", callbackDTO.getJobConfigId()); - return; - } - threadPoolExecutor.execute(new AlarmHttpThread(alarmServiceAO, callbackDTO, alartUrl)); + /** + * 回调函数自定义告警 + * + * @author zhuhuipei + * @date 2021/2/28 + * @time 19:56 + */ + private void httpAlarm(CallbackDTO callbackDTO) { + String alartUrl = systemConfigService + .getSystemConfigByKey(SysConfigEnum.CALLBACK_ALARM_URL.getKey()); + if (StringUtils.isEmpty(alartUrl)) { + log.warn("##### 回调告警url没有设置,任务[{}]无法告警 #####", callbackDTO.getJobConfigId()); + return; } + threadPoolExecutor.execute(new AlarmHttpThread(alarmServiceAO, callbackDTO, alartUrl)); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/AlartApiController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/AlartApiController.java index 4d0951f0..88c336a4 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/AlartApiController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/AlartApiController.java @@ -36,129 +36,132 @@ public class AlartApiController extends BaseController { - @Autowired - private AlarmServiceAO alarmServiceAO; - - @Autowired - private SystemConfigService systemConfigService; - - @Autowired - private AlartLogService alartLogService; - - /** - * 查询告警日志列表 - * - * @param modelMap - * @param alartLogParam - * @return - * @author wxj - * @date 2021年12月16日 下午4:11:09 - * @version V1.0 - */ - @RequestMapping(value = "/alartLogList") - public RestResult queryAlartLogList(ModelMap modelMap, AlartLogParam alartLogParam) { - if (alartLogParam == null){ - alartLogParam = new AlartLogParam(); - } - PageModel pageModel = alartLogService.queryAlartLog(alartLogParam); - PageVO> pageVO = new PageVO>(); - pageVO.setPageNum(pageModel.getPageNum()); - pageVO.setPages(pageModel.getPages()); - pageVO.setPageSize(pageModel.getPageSize()); - pageVO.setTotal(pageModel.getTotal()); - pageVO.setData(pageModel); - return RestResult.success(pageVO); + @Autowired + private AlarmServiceAO alarmServiceAO; + + @Autowired + private SystemConfigService systemConfigService; + + @Autowired + private AlartLogService alartLogService; + + /** + * 查询告警日志列表 + * + * @param modelMap + * @param alartLogParam + * @return + * @author wxj + * @date 2021年12月16日 下午4:11:09 + * @version V1.0 + */ + @RequestMapping(value = "/alartLogList") + public RestResult queryAlartLogList(ModelMap modelMap, AlartLogParam alartLogParam) { + if (alartLogParam == null) { + alartLogParam = new AlartLogParam(); } - - /** - * 查询告警配置 - * - * @param modelMap - * @return - * @author wxj - * @date 2021年12月16日 下午4:11:48 - * @version V1.0 - */ - @RequestMapping(value = "/alartConfig") - public RestResult alartConfig(ModelMap modelMap) { - List list = SystemConfigVO.toListVO(systemConfigService.getSystemConfig(SysConfigEnumType.ALART)); - return RestResult.success(list); + PageModel pageModel = alartLogService.queryAlartLog(alartLogParam); + PageVO> pageVO = new PageVO>(); + pageVO.setPageNum(pageModel.getPageNum()); + pageVO.setPages(pageModel.getPages()); + pageVO.setPageSize(pageModel.getPageSize()); + pageVO.setTotal(pageModel.getTotal()); + pageVO.setData(pageModel); + return RestResult.success(pageVO); + } + + /** + * 查询告警配置 + * + * @param modelMap + * @return + * @author wxj + * @date 2021年12月16日 下午4:11:48 + * @version V1.0 + */ + @RequestMapping(value = "/alartConfig") + public RestResult alartConfig(ModelMap modelMap) { + List list = SystemConfigVO + .toListVO(systemConfigService.getSystemConfig(SysConfigEnumType.ALART)); + return RestResult.success(list); + } + + /** + * 测试钉钉功能是否正常 + * + * @author zhuhuipei + * @date 2020-09-28 + * @time 19:25 + */ + @RequestMapping("/testDingdingAlert") + public RestResult testDingdingAlert() { + try { + String alartUrl = systemConfigService + .getSystemConfigByKey(SysConfigEnum.DINGDING_ALARM_URL.getKey()); + if (StringUtils.isEmpty(alartUrl)) { + return RestResult.error("钉钉告警地址不存在"); + } + boolean isSuccess = alarmServiceAO.sendForDingding(alartUrl, + SystemConstants.buildDingdingMessage("测试"), 0L); + if (isSuccess) { + return RestResult.success(); + } + } catch (Exception e) { + log.error("testDingdingAlert is fail", e); } - /** - * 测试钉钉功能是否正常 - * - * @author zhuhuipei - * @date 2020-09-28 - * @time 19:25 - */ - @RequestMapping("/testDingdingAlert") - public RestResult testDingdingAlert() { - try { - String alartUrl = systemConfigService.getSystemConfigByKey(SysConfigEnum.DINGDING_ALARM_URL.getKey()); - if (StringUtils.isEmpty(alartUrl)) { - return RestResult.error("钉钉告警地址不存在"); - } - boolean isSuccess = alarmServiceAO.sendForDingding(alartUrl, - SystemConstants.buildDingdingMessage("测试"), 0L); - if (isSuccess) { - return RestResult.success(); - } - } catch (Exception e) { - log.error("testDingdingAlert is fail", e); - } - - return RestResult.error("钉钉告警测试失败"); + return RestResult.error("钉钉告警测试失败"); + } + + + /** + * 测试url回调告警 + * + * @author zhuhuipei + * @date 2021/2/21 + * @time 15:05 + */ + @RequestMapping("/testHttpAlert") + public RestResult testHttpAlert() { + try { + String callbackUrl = systemConfigService + .getSystemConfigByKey(SysConfigEnum.CALLBACK_ALARM_URL.getKey()); + if (StringUtils.isEmpty(callbackUrl)) { + return RestResult.error("回调URL地址不存在"); + } + CallbackDTO callbackDTO = new CallbackDTO(); + callbackDTO.setAppId("测试AppId"); + callbackDTO.setDeployMode("测试DeployMode"); + callbackDTO.setJobName("测试JobName"); + callbackDTO.setJobConfigId(0L); + boolean isSuccess = alarmServiceAO.sendForHttp(callbackUrl, callbackDTO); + if (isSuccess) { + return RestResult.success(); + } + return RestResult.error("测试失败"); + } catch (Exception e) { + log.error("testHttpAlert is fail", e); } - - /** - * 测试url回调告警 - * - * @author zhuhuipei - * @date 2021/2/21 - * @time 15:05 - */ - @RequestMapping("/testHttpAlert") - public RestResult testHttpAlert() { - try { - String callbackUrl = systemConfigService.getSystemConfigByKey(SysConfigEnum.CALLBACK_ALARM_URL.getKey()); - if (StringUtils.isEmpty(callbackUrl)) { - return RestResult.error("回调URL地址不存在"); - } - CallbackDTO callbackDTO = new CallbackDTO(); - callbackDTO.setAppId("测试AppId"); - callbackDTO.setDeployMode("测试DeployMode"); - callbackDTO.setJobName("测试JobName"); - callbackDTO.setJobConfigId(0L); - boolean isSuccess = alarmServiceAO.sendForHttp(callbackUrl, callbackDTO); - if (isSuccess) { - return RestResult.success(); - } - return RestResult.error("测试失败"); - } catch (Exception e) { - log.error("testHttpAlert is fail", e); - } - - return RestResult.error("钉钉告警测试失败"); + return RestResult.error("钉钉告警测试失败"); + } + + + /** + * 错误日志详情 + * + * @author zhuhuipei + * @date 2020-09-28 + * @time 19:25 + */ + @RequestMapping("/logErrorInfo") + public RestResult logErrorInfo(Long id) { + AlartLogDTO alartLogDTO = alartLogService.findLogById(id); + if (alartLogDTO == null || StringUtils.isEmpty(alartLogDTO.getFailLog())) { + return RestResult.error("没有异常数据"); } + return RestResult.success(alartLogDTO.getFailLog()); - - /** - * 错误日志详情 - * - * @author zhuhuipei - * @date 2020-09-28 - * @time 19:25 - */ - @RequestMapping("/logErrorInfo") - public RestResult logErrorInfo(Long id) { - AlartLogDTO alartLogDTO = alartLogService.findLogById(id); - if (alartLogDTO == null || StringUtils.isEmpty(alartLogDTO.getFailLog())) { - return RestResult.error("没有异常数据"); - } - return RestResult.success(alartLogDTO.getFailLog()); - - } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/ApiController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/ApiController.java index 43ca35b0..109d3759 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/ApiController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/ApiController.java @@ -18,18 +18,18 @@ @Slf4j public class ApiController extends BaseController { - @Autowired - private JobServerAO jobYarnServerAO; + @Autowired + private JobServerAO jobYarnServerAO; - @RequestMapping("/ok") - public RestResult ok() { - return RestResult.success(); - } + @RequestMapping("/ok") + public RestResult ok() { + return RestResult.success(); + } - @RequestMapping("/alarmCallback") - public RestResult alarmCallback(String appId, String jobName, String deployMode) { - log.info("测试回调 appId={} jobName={} deployMode={}", appId, jobName, deployMode); - return RestResult.success(); - } + @RequestMapping("/alarmCallback") + public RestResult alarmCallback(String appId, String jobName, String deployMode) { + log.info("测试回调 appId={} jobName={} deployMode={}", appId, jobName, deployMode); + return RestResult.success(); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/ConfigApiController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/ConfigApiController.java index b562fe55..110ee06e 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/ConfigApiController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/ConfigApiController.java @@ -28,51 +28,52 @@ public class ConfigApiController extends BaseController { - @Autowired - private SystemConfigService systemConfigService; + @Autowired + private SystemConfigService systemConfigService; - @RequestMapping(value = "/upsertSynConfig", method = RequestMethod.POST) - public RestResult upsertSynConfig(String key, String val) { - try { - systemConfigService.addOrUpdateConfigByKey(key, val.trim()); - } catch (BizException biz) { - log.warn("upsertSynConfig is error ", biz); - return RestResult.error(biz.getMessage()); - } catch (Exception e) { - log.error("upsertSynConfig is error", e); - return RestResult.error(e.getMessage()); - } - return RestResult.success(); + @RequestMapping(value = "/upsertSynConfig", method = RequestMethod.POST) + public RestResult upsertSynConfig(String key, String val) { + try { + systemConfigService.addOrUpdateConfigByKey(key, val.trim()); + } catch (BizException biz) { + log.warn("upsertSynConfig is error ", biz); + return RestResult.error(biz.getMessage()); + } catch (Exception e) { + log.error("upsertSynConfig is error", e); + return RestResult.error(e.getMessage()); } + return RestResult.success(); + } - @RequestMapping(value = "/deleteConfig", method = RequestMethod.POST) - public RestResult deleteConfig(String key) { - try { - systemConfigService.deleteConfigByKey(key); - } catch (BizException biz) { - log.warn("upsertSynConfig is error ", biz); - return RestResult.error(biz.getMessage()); - } catch (Exception e) { - log.error("upsertSynConfig is error", e); - return RestResult.error(e.getMessage()); - } - return RestResult.success(); - } - - /** - * 查询系统配置列表 - * - * @param modelMap - * @return - * @author wxj - * @date 2021年12月16日 下午5:19:53 - * @version V1.0 - */ - @RequestMapping(value = "/sysConfig") - public RestResult sysConfig(ModelMap modelMap) { - List list = SystemConfigVO.toListVO(systemConfigService.getSystemConfig(SysConfigEnumType.SYS)); - return RestResult.success(list); + @RequestMapping(value = "/deleteConfig", method = RequestMethod.POST) + public RestResult deleteConfig(String key) { + try { + systemConfigService.deleteConfigByKey(key); + } catch (BizException biz) { + log.warn("upsertSynConfig is error ", biz); + return RestResult.error(biz.getMessage()); + } catch (Exception e) { + log.error("upsertSynConfig is error", e); + return RestResult.error(e.getMessage()); } + return RestResult.success(); + } + + /** + * 查询系统配置列表 + * + * @param modelMap + * @return + * @author wxj + * @date 2021年12月16日 下午5:19:53 + * @version V1.0 + */ + @RequestMapping(value = "/sysConfig") + public RestResult sysConfig(ModelMap modelMap) { + List list = SystemConfigVO + .toListVO(systemConfigService.getSystemConfig(SysConfigEnumType.SYS)); + return RestResult.success(list); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/FlinkLogApiController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/FlinkLogApiController.java index 025b73da..b1d61da9 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/FlinkLogApiController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/FlinkLogApiController.java @@ -23,34 +23,36 @@ @Slf4j public class FlinkLogApiController { - @Autowired - public SystemConfigService systemConfigService; + @Autowired + private SystemConfigService systemConfigService; - @RequestMapping(value = "/getFlinkLocalJobLog") - public String getFlinkLocalJobLog(HttpServletResponse response){ - try { - String fileName=String.format("flink-%s-client-%s.log", LinuxInfoUtil.loginName(), IpUtil.getHostName()); - String flinkName=systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_HOME.getKey()); - String logPath=flinkName+"log/"+fileName; - log.info("日志文件地址 logPath={}",logPath); - File file = new File(logPath); - InputStream fis = new BufferedInputStream(new FileInputStream(file)); - byte[] buffer = new byte[fis.available()]; - fis.read(buffer); - fis.close(); - response.reset(); - response.addHeader("Content-Length", "" + file.length()); - response.setContentType("text/plain; charset=utf-8"); - OutputStream toClient = new BufferedOutputStream(response.getOutputStream(),2048); - toClient.write(buffer); - toClient.flush(); - toClient.close(); - } catch (Exception ex) { - log.error("[getFlinkLocalJobLog is error]",ex); - return ex.getMessage(); - } - return "ok"; + @RequestMapping(value = "/getFlinkLocalJobLog") + public String getFlinkLocalJobLog(HttpServletResponse response) { + try { + String fileName = String + .format("flink-%s-client-%s.log", LinuxInfoUtil.loginName(), IpUtil.getHostName()); + String flinkName = systemConfigService + .getSystemConfigByKey(SysConfigEnum.FLINK_HOME.getKey()); + String logPath = flinkName + "log/" + fileName; + log.info("日志文件地址 logPath={}", logPath); + File file = new File(logPath); + InputStream fis = new BufferedInputStream(new FileInputStream(file)); + byte[] buffer = new byte[fis.available()]; + fis.read(buffer); + fis.close(); + response.reset(); + response.addHeader("Content-Length", "" + file.length()); + response.setContentType("text/plain; charset=utf-8"); + OutputStream toClient = new BufferedOutputStream(response.getOutputStream(), 2048); + toClient.write(buffer); + toClient.flush(); + toClient.close(); + } catch (Exception ex) { + log.error("[getFlinkLocalJobLog is error]", ex); + return ex.getMessage(); } + return "ok"; + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/JobConfigApiController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/JobConfigApiController.java index b3255402..2c3df6a4 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/JobConfigApiController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/JobConfigApiController.java @@ -62,626 +62,667 @@ @Slf4j public class JobConfigApiController extends BaseController { - @Autowired - private JobServerAO jobYarnServerAO; - - @Autowired - private JobServerAO jobStandaloneServerAO; - - @Autowired - private JobConfigService jobConfigService; - - @Autowired - private JobConfigAO jobConfigAO; - - @Autowired - private JobConfigHistoryService jobConfigHistoryService; - - @Autowired - private SystemConfigService systemConfigService; - - @Autowired - public JobAlarmConfigService jobAlarmConfigService; - - @Autowired - private SavepointBackupService savepointBackupService; - - @RequestMapping("/start") - public RestResult start(Long id, Long savepointId) { - try { - this.getJobServerAO(id).start(id, savepointId, this.getUserName()); - } catch (BizException e) { - log.error("启动失败 id={}", id, e); - return RestResult.error(e.getCode(), e.getErrorMsg()); - } catch (Exception e) { - log.error("启动失败 id={}", id, e); - return RestResult.error(SysErrorEnum.START_JOB_FAIL); - } - return RestResult.success(); - } - - @RequestMapping("/stop") - public RestResult stop(Long id) { - try { - this.getJobServerAO(id).stop(id, this.getUserName()); - } catch (BizException e) { - log.warn("停止失败 id={}", id, e); - return RestResult.error(e.getCode(), e.getErrorMsg()); - } catch (Exception e) { - log.error("停止失败 id={}", id, e); - return RestResult.error(SysErrorEnum.STOP_JOB_FAIL); - } - return RestResult.success(); - } + @Autowired + private JobServerAO jobYarnServerAO; - @RequestMapping("/close") - public RestResult close(Long id) { - try { - this.getJobServerAO(id).close(id, this.getUserName()); - } catch (BizException e) { - log.warn("关闭失败 id={}", id, e); - return RestResult.error(e.getCode(), e.getErrorMsg()); - } catch (Exception e) { - log.error("关闭失败 id={}", id, e); - return RestResult.error(SysErrorEnum.START_JOB_FAIL); - } - return RestResult.success(); - } - - @RequestMapping("/open") - public RestResult open(Long id) { - try { - this.getJobServerAO(id).open(id, this.getUserName()); - } catch (BizException e) { - log.warn("开始失败 id={}", id, e); - return RestResult.error(e.getCode(), e.getErrorMsg()); - } catch (Exception e) { - log.error("开始失败 id={}", id, e); - return RestResult.error(SysErrorEnum.START_JOB_FAIL); - } - return RestResult.success(); - } + @Autowired + private JobServerAO jobStandaloneServerAO; - @RequestMapping("/delete") - public RestResult delete(Long id) { - try { - jobConfigService.deleteJobConfigById(id, this.getUserName()); - } catch (BizException e) { - log.warn("删除失败 id={}", id, e); - return RestResult.error(e.getCode(), e.getErrorMsg()); - } catch (Exception e) { - log.error("删除失败 id={}", id, e); - return RestResult.error(SysErrorEnum.START_JOB_FAIL); - } - return RestResult.success(); - } + @Autowired + private JobConfigService jobConfigService; - @RequestMapping("/savepoint") - public RestResult savepoint(Long id) { - try { - this.getJobServerAO(id).savepoint(id); - } catch (BizException e) { - log.warn("savepoint is error id={}", id, e); - return RestResult.error(e.getCode(), e.getErrorMsg()); - } catch (Exception e) { - log.error("savepoint is error id={}", id, e); - return RestResult.error(SysErrorEnum.SAVEPOINT_JOB_FAIL); - } - return RestResult.success(); - } + @Autowired + private JobConfigAO jobConfigAO; - @RequestMapping(value = "/addConfig", method = { RequestMethod.POST }) - public RestResult addConfig(UpsertJobConfigParam upsertJobConfigParam) { + @Autowired + private JobConfigHistoryService jobConfigHistoryService; - try { - RestResult restResult = checkUpsertJobConfigParam(upsertJobConfigParam); - if (restResult != null) { - return restResult; - } - jobConfigAO.addJobConfig(UpsertJobConfigParam.toDTO(upsertJobConfigParam)); - } catch (BizException biz) { - log.warn("addJobConfig is error ", biz); - return RestResult.error(biz.getErrorMsg()); - } catch (Exception e) { - log.error("addJobConfig is error", e); - return RestResult.error(e.getMessage()); - } - return RestResult.success(); - } + @Autowired + private SystemConfigService systemConfigService; - @RequestMapping(value = "/editConfig", method = { RequestMethod.POST }) - public RestResult editConfig(UpsertJobConfigParam upsertJobConfigParam) { - try { - RestResult restResult = checkUpsertJobConfigParam(upsertJobConfigParam); - if (restResult != null) { - return restResult; - } - JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(upsertJobConfigParam.getId()); - if (jobConfigDTO == null) { - return RestResult.error("数据不存在"); - } + @Autowired + private JobAlarmConfigService jobAlarmConfigService; - completeJObConfigDTO(jobConfigDTO); + @Autowired + private SavepointBackupService savepointBackupService; - if (YN.getYNByValue(jobConfigDTO.getIsOpen()).getCode()) { - return RestResult.error(SysErrorEnum.JOB_CONFIG_JOB_IS_OPEN.getErrorMsg()); - } - JobConfigDTO jobConfigNew = UpsertJobConfigParam.toDTO(upsertJobConfigParam); -// if (!checkJobConfigChanged(jobConfigDTO, jobConfigNew)) { -// throw new BizException("没有产生任何修改,不需要保存!"); -// } - jobConfigAO.updateJobConfigById(jobConfigNew); - } catch (BizException biz) { - log.warn("updateJobConfigById is error ", biz); - return RestResult.error(biz.getErrorMsg()); - } catch (Exception e) { - log.error("updateJobConfigById is error", e); - return RestResult.error(e.getMessage()); - } - return RestResult.success(); + @RequestMapping("/start") + public RestResult start(Long id, Long savepointId) { + try { + this.getJobServerAO(id).start(id, savepointId, this.getUserName()); + } catch (BizException e) { + log.error("启动失败 id={}", id, e); + return RestResult.error(e.getCode(), e.getErrorMsg()); + } catch (Exception e) { + log.error("启动失败 id={}", id, e); + return RestResult.error(SysErrorEnum.START_JOB_FAIL); } - - @RequestMapping(value = "/copyConfig", method = { RequestMethod.POST }) - public RestResult copyConfig(UpsertJobConfigParam upsertJobConfigParam) { - try { - JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(upsertJobConfigParam.getId()); - if (jobConfigDTO == null) { - return RestResult.error("原始拷贝数据不存在"); - } - /* - * copy job conf 默认将id去除 - * 默认在任务名称后面copy_随机字符_${jobConfigDTO.getJobName()}字符 状态默认重置为停止 开启配置 - * isOpen 0 - */ - jobConfigDTO.setId(null); - jobConfigDTO.setJobName( - String.format("copy_%s_%s", StringUtils.lowerCase(RandomStringUtils.randomAlphanumeric(4)), jobConfigDTO.getJobName())); - jobConfigDTO.setStatus(JobConfigStatus.STOP); - jobConfigDTO.setIsOpen(YN.N.getValue()); - jobConfigDTO.setJobId(null); - jobConfigDTO.setLastRunLogId(null); - jobConfigDTO.setVersion(0); - jobConfigDTO.setLastStartTime(null); - jobConfigDTO.setLastRunLogId(null); - - jobConfigAO.addJobConfig(jobConfigDTO); - - } catch (BizException biz) { - log.warn("copyJobConfigById is error ", biz); - return RestResult.error(biz.getErrorMsg()); - } catch (Exception e) { - log.error("copyJobConfigById is error", e); - return RestResult.error(e.getMessage()); - } - return RestResult.success(); + return RestResult.success(); + } + + @RequestMapping("/stop") + public RestResult stop(Long id) { + try { + this.getJobServerAO(id).stop(id, this.getUserName()); + } catch (BizException e) { + log.warn("停止失败 id={}", id, e); + return RestResult.error(e.getCode(), e.getErrorMsg()); + } catch (Exception e) { + log.error("停止失败 id={}", id, e); + return RestResult.error(SysErrorEnum.STOP_JOB_FAIL); } - - /** - * 查询作业列表 - * - * @param jobConfigParam - * @return - * @author wxj - * @date 2021年12月1日 下午5:09:06 - * @version V1.0 - */ - @RequestMapping(value = "/listTask", method = {RequestMethod.POST}) - public RestResult listTask(ModelMap modelMap, JobConfigParam jobConfigParam) { - if (jobConfigParam==null){ - jobConfigParam=new JobConfigParam(); - } - PageModel pageModel = jobConfigService.queryJobConfig(jobConfigParam); - completeJObConfigDTO(pageModel); - PageVO pageVO = new PageVO(); - pageVO.setPageNum(pageModel.getPageNum()); - pageVO.setPages(pageModel.getPages()); - pageVO.setPageSize(pageModel.getPageSize()); - pageVO.setTotal(pageModel.getTotal()); - pageVO.setData(pageModel); - return RestResult.success(pageVO); + return RestResult.success(); + } + + @RequestMapping("/close") + public RestResult close(Long id) { + try { + this.getJobServerAO(id).close(id, this.getUserName()); + } catch (BizException e) { + log.warn("关闭失败 id={}", id, e); + return RestResult.error(e.getCode(), e.getErrorMsg()); + } catch (Exception e) { + log.error("关闭失败 id={}", id, e); + return RestResult.error(SysErrorEnum.START_JOB_FAIL); } - - /** - * 查询历史版本 - * - * @param modelMap - * @param jobConfigId - * @return - * @author wxj - * @date 2021年12月20日 上午11:07:22 - * @version V1.0 - */ - @RequestMapping(value = "/jobConfigHistoryPage") - public RestResult listPage(ModelMap modelMap, JobConfigHisotryParam jobConfigParam) { - PageModel pageModel = jobConfigHistoryService.queryJobConfigHistory(jobConfigParam); - PageVO pageVO = new PageVO(); - pageVO.setPageNum(pageModel.getPageNum()); - pageVO.setPages(pageModel.getPages()); - pageVO.setPageSize(pageModel.getPageSize()); - pageVO.setTotal(pageModel.getTotal()); - pageVO.setData(pageModel); - return RestResult.success(pageVO); + return RestResult.success(); + } + + @RequestMapping("/open") + public RestResult open(Long id) { + try { + this.getJobServerAO(id).open(id, this.getUserName()); + } catch (BizException e) { + log.warn("开始失败 id={}", id, e); + return RestResult.error(e.getCode(), e.getErrorMsg()); + } catch (Exception e) { + log.error("开始失败 id={}", id, e); + return RestResult.error(SysErrorEnum.START_JOB_FAIL); } - - /** - * 查询历史版本详情 - * - * @param modelMap - * @param id - * @return - * @author wxj - * @date 2021年12月20日 下午2:13:50 - * @version V1.0 - */ - @RequestMapping("/jobConfigHistoryDetail") - public RestResult detailPage(ModelMap modelMap, Long id) { - JobConfigHistoryDTO jobConfigHistoryDTO= jobConfigHistoryService.getJobConfigHistoryById(id); - return RestResult.success(jobConfigHistoryDTO); + return RestResult.success(); + } + + @RequestMapping("/delete") + public RestResult delete(Long id) { + try { + jobConfigService.deleteJobConfigById(id, this.getUserName()); + } catch (BizException e) { + log.warn("删除失败 id={}", id, e); + return RestResult.error(e.getCode(), e.getErrorMsg()); + } catch (Exception e) { + log.error("删除失败 id={}", id, e); + return RestResult.error(SysErrorEnum.START_JOB_FAIL); } - - /** - * 从代码库中发布代码到Flink管理平台 - * - * @param deployConfigFile 配置文件 - * @param deployPath 发布代码根路径 - * @param deployUser 发布用户 - * @param versionDesc 发布版本说明 - * @return - * @author wxj - * @date 2021年12月27日 下午4:11:34 - * @version V1.0 - * @throws Exception - */ - @RequestMapping("/deployFlinkTask") - public RestResult deployFlinkTask(String deployConfigFile, String deployPath, String deployUser, String versionDesc) throws Exception { - Yaml yaml = new Yaml(); - try (InputStream in = new FileInputStream(deployConfigFile)) { - DeployFlinkVO deploy = yaml.loadAs(in, DeployFlinkVO.class); - int count = 0; - for (FlinkTask task : deploy.getTaskList()) { - if (task.getId() == null) { - continue; - } - count++; - String jobDesc = (StringUtils.isBlank(task.getJobDesc()) ? "" : task.getJobDesc() + "-") + versionDesc; - if (jobDesc.length() > 100) { - jobDesc = jobDesc.substring(0, 100); - } - JobTypeEnum jobType = task.getJobType() == null ? JobTypeEnum.SQL_STREAMING : task.getJobType(); - DeployModeEnum deployMode = task.getDeployMode() == null ? DeployModeEnum.STANDALONE : task.getDeployMode(); - String flinkSql = StringUtils.isBlank(task.getSqlFile()) ? null : this.readTextFile(deployPath + "/" + task.getSqlFile()); - String alarmTypes = getAlarmTypes(task.getAlarmTypes()); - String flinkRunConfig = task.getFlinkRunConfig(); - UpsertJobConfigParam jobConfigParam = new UpsertJobConfigParam(); - jobConfigParam.setId(task.getId()); - jobConfigParam.setJobType(jobType.getCode()); - jobConfigParam.setJobName(task.getJobName()); - jobConfigParam.setJobDesc(jobDesc); - jobConfigParam.setDeployMode(deployMode.name()); - jobConfigParam.setFlinkRunConfig(flinkRunConfig); - jobConfigParam.setFlinkCheckpointConfig(task.getFlinkCheckpointConfig()); - jobConfigParam.setFlinkSql(flinkSql); - jobConfigParam.setAlarmTypes(alarmTypes); - jobConfigParam.setExtJarPath(task.getExtJarPath()); - jobConfigParam.setCustomArgs(task.getCustomArgs()); - jobConfigParam.setCustomMainClass(task.getCustomMainClass()); - jobConfigParam.setCustomJarUrl(task.getCustomJarUrl()); - - JobConfigDTO job = jobConfigService.getJobConfigByIdContainDelete(task.getId()); - if (job != null) { // 更新 - if (jobType != job.getJobTypeEnum()) { - throw new BizException("不能变更编号为[" + task.getId() +"]的任务类型!"); - } - jobConfigParam.setIsOpen(job.getIsOpen()); - jobConfigParam.setStatus(job.getStatus().getCode()); - JobConfigDTO updateJobConfig = UpsertJobConfigParam.toDTO(jobConfigParam); - if (job.getIsDeleted() == 1) { // 已经打删除标记的任务重新启用 - jobConfigService.recoveryDeleteJobConfigById(job.getId(), deployUser); - } - jobConfigAO.updateJobConfigById(updateJobConfig); - } else { // 新增 - jobConfigParam.setIsOpen(1); - jobConfigParam.setStatus(JobConfigStatus.SUCCESS.getCode()); - jobConfigParam.setFlinkRunConfig(flinkRunConfig == null ? "" : flinkRunConfig); - JobConfigDTO addJobConfig = UpsertJobConfigParam.toDTO(jobConfigParam); - jobConfigAO.addJobConfig(addJobConfig); - } - log.info("[{}]发布任务:[{}]{},{}", deployUser, jobConfigParam.getId(), jobConfigParam.getJobName(), versionDesc); - } - // 重新启动任务 - for (FlinkTask task : deploy.getTaskList()) { - if (task.getId() == null) { - continue; - } - if (task.getDeployStartFlag() != null && task.getDeployStartFlag() == false) { - continue; - } - JobConfigDTO job = jobConfigService.getJobConfigById(task.getId()); - if (job.getIsOpen() != 1) { - continue; - } - // 停止任务 - if (StringUtils.isNotBlank(job.getJobId())) { - this.getJobServerAO(job.getId()).stop(job.getId(), deployUser); - } - // 查询最近一次的SavePoint,恢复运行 - List savepointBackupDTOList = savepointBackupService.lasterHistory10(job.getId()); - Long savepointId = (savepointBackupDTOList != null && savepointBackupDTOList.size() > 0) ? savepointBackupDTOList.get(0).getId() : null; - this.getJobServerAO(job.getId()).start(job.getId(), savepointId, deployUser); - } - return RestResult.success("成功发布" + count + "个任务!"); - } catch (Exception e) { - log.error("发布失败!", e); - return RestResult.error(e.getMessage()); - } + return RestResult.success(); + } + + @RequestMapping("/savepoint") + public RestResult savepoint(Long id) { + try { + this.getJobServerAO(id).savepoint(id); + } catch (BizException e) { + log.warn("savepoint is error id={}", id, e); + return RestResult.error(e.getCode(), e.getErrorMsg()); + } catch (Exception e) { + log.error("savepoint is error id={}", id, e); + return RestResult.error(SysErrorEnum.SAVEPOINT_JOB_FAIL); + } + return RestResult.success(); + } + + @RequestMapping(value = "/addConfig", method = {RequestMethod.POST}) + public RestResult addConfig(UpsertJobConfigParam upsertJobConfigParam) { + + try { + RestResult restResult = checkUpsertJobConfigParam(upsertJobConfigParam); + if (restResult != null) { + return restResult; + } + jobConfigAO.addJobConfig(UpsertJobConfigParam.toDTO(upsertJobConfigParam)); + } catch (BizException biz) { + log.warn("addJobConfig is error ", biz); + return RestResult.error(biz.getErrorMsg()); + } catch (Exception e) { + log.error("addJobConfig is error", e); + return RestResult.error(e.getMessage()); } - - private String getAlarmTypes(List list) { - if (list == null || list.size() == 0) { - return null; + return RestResult.success(); + } + + @RequestMapping(value = "/editConfig", method = {RequestMethod.POST}) + public RestResult editConfig(UpsertJobConfigParam upsertJobConfigParam) { + try { + RestResult restResult = checkUpsertJobConfigParam(upsertJobConfigParam); + if (restResult != null) { + return restResult; + } + JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(upsertJobConfigParam.getId()); + if (jobConfigDTO == null) { + return RestResult.error("数据不存在"); + } + + completeJObConfigDTO(jobConfigDTO); + + if (YN.getYNByValue(jobConfigDTO.getIsOpen()).getCode()) { + return RestResult.error(SysErrorEnum.JOB_CONFIG_JOB_IS_OPEN.getErrorMsg()); + } + JobConfigDTO jobConfigNew = UpsertJobConfigParam.toDTO(upsertJobConfigParam); + + jobConfigAO.updateJobConfigById(jobConfigNew); + } catch (BizException biz) { + log.warn("updateJobConfigById is error ", biz); + return RestResult.error(biz.getErrorMsg()); + } catch (Exception e) { + log.error("updateJobConfigById is error", e); + return RestResult.error(e.getMessage()); + } + return RestResult.success(); + } + + @RequestMapping(value = "/copyConfig", method = {RequestMethod.POST}) + public RestResult copyConfig(UpsertJobConfigParam upsertJobConfigParam) { + try { + JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(upsertJobConfigParam.getId()); + if (jobConfigDTO == null) { + return RestResult.error("原始拷贝数据不存在"); + } + /* + * copy job conf 默认将id去除 + * 默认在任务名称后面copy_随机字符_${jobConfigDTO.getJobName()}字符 状态默认重置为停止 开启配置 + * isOpen 0 + */ + jobConfigDTO.setId(null); + jobConfigDTO.setJobName( + String + .format("copy_%s_%s", StringUtils.lowerCase(RandomStringUtils.randomAlphanumeric(4)), + jobConfigDTO.getJobName())); + jobConfigDTO.setStatus(JobConfigStatus.STOP); + jobConfigDTO.setIsOpen(YN.N.getValue()); + jobConfigDTO.setJobId(null); + jobConfigDTO.setLastRunLogId(null); + jobConfigDTO.setVersion(0); + jobConfigDTO.setLastStartTime(null); + jobConfigDTO.setLastRunLogId(null); + + jobConfigAO.addJobConfig(jobConfigDTO); + + } catch (BizException biz) { + log.warn("copyJobConfigById is error ", biz); + return RestResult.error(biz.getErrorMsg()); + } catch (Exception e) { + log.error("copyJobConfigById is error", e); + return RestResult.error(e.getMessage()); + } + return RestResult.success(); + } + + /** + * 查询作业列表 + * + * @param jobConfigParam + * @return + * @author wxj + * @date 2021年12月1日 下午5:09:06 + * @version V1.0 + */ + @RequestMapping(value = "/listTask", method = {RequestMethod.POST}) + public RestResult listTask(ModelMap modelMap, JobConfigParam jobConfigParam) { + if (jobConfigParam == null) { + jobConfigParam = new JobConfigParam(); + } + PageModel pageModel = jobConfigService.queryJobConfig(jobConfigParam); + completeJObConfigDTO(pageModel); + PageVO pageVO = new PageVO(); + pageVO.setPageNum(pageModel.getPageNum()); + pageVO.setPages(pageModel.getPages()); + pageVO.setPageSize(pageModel.getPageSize()); + pageVO.setTotal(pageModel.getTotal()); + pageVO.setData(pageModel); + return RestResult.success(pageVO); + } + + /** + * 查询历史版本 + * + * @param modelMap + * @param jobConfigId + * @return + * @author wxj + * @date 2021年12月20日 上午11:07:22 + * @version V1.0 + */ + @RequestMapping(value = "/jobConfigHistoryPage") + public RestResult listPage(ModelMap modelMap, JobConfigHisotryParam jobConfigParam) { + PageModel pageModel = jobConfigHistoryService + .queryJobConfigHistory(jobConfigParam); + PageVO pageVO = new PageVO(); + pageVO.setPageNum(pageModel.getPageNum()); + pageVO.setPages(pageModel.getPages()); + pageVO.setPageSize(pageModel.getPageSize()); + pageVO.setTotal(pageModel.getTotal()); + pageVO.setData(pageModel); + return RestResult.success(pageVO); + } + + /** + * 查询历史版本详情 + * + * @param modelMap + * @param id + * @return + * @author wxj + * @date 2021年12月20日 下午2:13:50 + * @version V1.0 + */ + @RequestMapping("/jobConfigHistoryDetail") + public RestResult detailPage(ModelMap modelMap, Long id) { + JobConfigHistoryDTO jobConfigHistoryDTO = jobConfigHistoryService.getJobConfigHistoryById(id); + return RestResult.success(jobConfigHistoryDTO); + } + + /** + * 从代码库中发布代码到Flink管理平台 + * + * @param deployConfigFile 配置文件 + * @param deployPath 发布代码根路径 + * @param deployUser 发布用户 + * @param versionDesc 发布版本说明 + * @return + * @throws Exception + * @author wxj + * @date 2021年12月27日 下午4:11:34 + * @version V1.0 + */ + @RequestMapping("/deployFlinkTask") + public RestResult deployFlinkTask(String deployConfigFile, String deployPath, + String deployUser, String versionDesc) throws Exception { + Yaml yaml = new Yaml(); + try (InputStream in = new FileInputStream(deployConfigFile)) { + DeployFlinkVO deploy = yaml.loadAs(in, DeployFlinkVO.class); + int count = 0; + for (FlinkTask task : deploy.getTaskList()) { + if (task.getId() == null) { + continue; } - String result = ""; - for (AlarmTypeEnum alarmTypeEnum : list) { - result += (result.length() > 0 ? "," : "") + alarmTypeEnum.getCode(); + count++; + String jobDesc = + (StringUtils.isBlank(task.getJobDesc()) ? "" : task.getJobDesc() + "-") + versionDesc; + if (jobDesc.length() > 100) { + jobDesc = jobDesc.substring(0, 100); } - return result; - } - - private String readTextFile(String fileName) { - try (InputStream fin = new FileInputStream(fileName);) { - byte[] buffer = new byte[fin.available()]; - fin.read(buffer); - fin.close(); - String result = new String(buffer, "utf-8"); - return result; - } catch (Exception e) { - log.error("读取文件[" + fileName + "]失败!", e); + JobTypeEnum jobType = + task.getJobType() == null ? JobTypeEnum.SQL_STREAMING : task.getJobType(); + DeployModeEnum deployMode = + task.getDeployMode() == null ? DeployModeEnum.STANDALONE : task.getDeployMode(); + String flinkSql = StringUtils.isBlank(task.getSqlFile()) ? null + : this.readTextFile(deployPath + "/" + task.getSqlFile()); + String alarmTypes = getAlarmTypes(task.getAlarmTypes()); + String flinkRunConfig = task.getFlinkRunConfig(); + UpsertJobConfigParam jobConfigParam = new UpsertJobConfigParam(); + jobConfigParam.setId(task.getId()); + jobConfigParam.setJobType(jobType.getCode()); + jobConfigParam.setJobName(task.getJobName()); + jobConfigParam.setJobDesc(jobDesc); + jobConfigParam.setDeployMode(deployMode.name()); + jobConfigParam.setFlinkRunConfig(flinkRunConfig); + jobConfigParam.setFlinkCheckpointConfig(task.getFlinkCheckpointConfig()); + jobConfigParam.setFlinkSql(flinkSql); + jobConfigParam.setAlarmTypes(alarmTypes); + jobConfigParam.setExtJarPath(task.getExtJarPath()); + jobConfigParam.setCustomArgs(task.getCustomArgs()); + jobConfigParam.setCustomMainClass(task.getCustomMainClass()); + jobConfigParam.setCustomJarUrl(task.getCustomJarUrl()); + + JobConfigDTO job = jobConfigService.getJobConfigByIdContainDelete(task.getId()); + if (job != null) { // 更新 + if (jobType != job.getJobTypeEnum()) { + throw new BizException("不能变更编号为[" + task.getId() + "]的任务类型!"); + } + jobConfigParam.setIsOpen(job.getIsOpen()); + jobConfigParam.setStatus(job.getStatus().getCode()); + JobConfigDTO updateJobConfig = UpsertJobConfigParam.toDTO(jobConfigParam); + if (job.getIsDeleted() == 1) { // 已经打删除标记的任务重新启用 + jobConfigService.recoveryDeleteJobConfigById(job.getId(), deployUser); + } + jobConfigAO.updateJobConfigById(updateJobConfig); + } else { // 新增 + jobConfigParam.setIsOpen(1); + jobConfigParam.setStatus(JobConfigStatus.SUCCESS.getCode()); + jobConfigParam.setFlinkRunConfig(flinkRunConfig == null ? "" : flinkRunConfig); + JobConfigDTO addJobConfig = UpsertJobConfigParam.toDTO(jobConfigParam); + jobConfigAO.addJobConfig(addJobConfig); } - return null; - } - - private RestResult checkUpsertJobConfigParam(UpsertJobConfigParam upsertJobConfigParam) { - if (upsertJobConfigParam == null) { - return RestResult.error("参数不能空"); + log.info("[{}]发布任务:[{}]{},{}", deployUser, jobConfigParam.getId(), + jobConfigParam.getJobName(), versionDesc); + } + // 重新启动任务 + for (FlinkTask task : deploy.getTaskList()) { + if (task.getId() == null) { + continue; } - if (StringUtils.isEmpty(upsertJobConfigParam.getJobName())) { - return RestResult.error("任务名称不能空"); + if (task.getDeployStartFlag() != null && !task.getDeployStartFlag()) { + continue; } - if (upsertJobConfigParam.getJobName().length() > 50) { - return RestResult.error("任务名称不能超过50个字符"); + JobConfigDTO job = jobConfigService.getJobConfigById(task.getId()); + if (job.getIsOpen() != 1) { + continue; } - if (!upsertJobConfigParam.getJobName().matches("[0-9A-Za-z_]*")) { - return RestResult.error("任务名称仅能含数字,字母和下划线"); + // 停止任务 + if (StringUtils.isNotBlank(job.getJobId())) { + this.getJobServerAO(job.getId()).stop(job.getId(), deployUser); } + // 查询最近一次的SavePoint,恢复运行 + List savepointBackupDTOList = savepointBackupService + .lasterHistory10(job.getId()); + Long savepointId = (savepointBackupDTOList != null && savepointBackupDTOList.size() > 0) + ? savepointBackupDTOList.get(0).getId() : null; + this.getJobServerAO(job.getId()).start(job.getId(), savepointId, deployUser); + } + return RestResult.success("成功发布" + count + "个任务!"); + } catch (Exception e) { + log.error("发布失败!", e); + return RestResult.error(e.getMessage()); + } + } - // jar需要校验参数 - if (JobTypeEnum.JAR.equals(upsertJobConfigParam.getJobType())) { + private String getAlarmTypes(List list) { + if (list == null || list.size() == 0) { + return null; + } + String result = ""; + for (AlarmTypeEnum alarmTypeEnum : list) { + result += (result.length() > 0 ? "," : "") + alarmTypeEnum.getCode(); + } + return result; + } + + private String readTextFile(String fileName) { + try (InputStream fin = new FileInputStream(fileName);) { + byte[] buffer = new byte[fin.available()]; + fin.read(buffer); + fin.close(); + String result = new String(buffer, "utf-8"); + return result; + } catch (Exception e) { + log.error("读取文件[" + fileName + "]失败!", e); + } + return null; + } - if (StringUtils.isEmpty(upsertJobConfigParam.getCustomMainClass())) { - return RestResult.error("主类不能为空"); - } + //CHECKSTYLE:OFF + private RestResult checkUpsertJobConfigParam(UpsertJobConfigParam upsertJobConfigParam) { + if (upsertJobConfigParam == null) { + return RestResult.error("参数不能空"); + } + if (StringUtils.isEmpty(upsertJobConfigParam.getJobName())) { + return RestResult.error("任务名称不能空"); + } + if (upsertJobConfigParam.getJobName().length() > 50) { + return RestResult.error("任务名称不能超过50个字符"); + } + if (!upsertJobConfigParam.getJobName().matches("[0-9A-Za-z_]*")) { + return RestResult.error("任务名称仅能含数字,字母和下划线"); + } - if (StringUtils.isEmpty(upsertJobConfigParam.getCustomJarUrl())) { - return RestResult.error("主类jar的http地址不能为空"); - } - if (MatcherUtils.isHttpsOrHttp(upsertJobConfigParam.getCustomJarUrl())) { - return RestResult.error("主类jar的http地址 不是http或者https:" + upsertJobConfigParam.getCustomJarUrl()); - } - } - // sql配置需要校验的参数JobType=null是兼容之前配置 - if (JobTypeEnum.SQL_STREAMING.equals(upsertJobConfigParam.getJobType()) || upsertJobConfigParam.getJobType() == null - || JobTypeEnum.SQL_STREAMING.getCode() == upsertJobConfigParam.getJobType().intValue()) { - if (StringUtils.isEmpty(upsertJobConfigParam.getFlinkSql())) { - return RestResult.error("sql语句不能为空"); - } - if (StringUtils.isNotEmpty(upsertJobConfigParam.getExtJarPath())) { - String[] urls = upsertJobConfigParam.getExtJarPath().split(SystemConstant.LINE_FEED); - for (String url : urls) { - if (StringUtils.isEmpty(url)) { - continue; - } - if (!MatcherUtils.isHttpsOrHttp(url)) { - return RestResult.error("udf地址错误: 非法的http或者是https地址 url=" + url); - } - } - } - } + // jar需要校验参数 + if (JobTypeEnum.JAR.equals(upsertJobConfigParam.getJobType())) { - if (StringUtils.isNotEmpty(upsertJobConfigParam.getFlinkCheckpointConfig())) { - CheckPointParam checkPointParam = CliConfigUtil.checkFlinkCheckPoint(upsertJobConfigParam.getFlinkCheckpointConfig()); - RestResult restResult = this.checkPointParam(checkPointParam); - if (restResult != null && !restResult.isSuccess()) { - return restResult; - } - } + if (StringUtils.isEmpty(upsertJobConfigParam.getCustomMainClass())) { + return RestResult.error("主类不能为空"); + } - if (DeployModeEnum.YARN_PER.name().equals(upsertJobConfigParam.getDeployMode())) { - if (StringUtils.isEmpty(upsertJobConfigParam.getFlinkRunConfig())) { - return RestResult.error("flink运行配置不能为空"); - } - RestResult restResult = CliConfigUtil.checkFlinkRunConfigForYarn(upsertJobConfigParam.getFlinkRunConfig()); - if (restResult != null) { - return restResult; - } + if (StringUtils.isEmpty(upsertJobConfigParam.getCustomJarUrl())) { + return RestResult.error("主类jar的http地址不能为空"); + } + if (MatcherUtils.isHttpsOrHttp(upsertJobConfigParam.getCustomJarUrl())) { + return RestResult + .error("主类jar的http地址 不是http或者https:" + upsertJobConfigParam.getCustomJarUrl()); + } + } + // sql配置需要校验的参数JobType=null是兼容之前配置 + if (JobTypeEnum.SQL_STREAMING.equals(upsertJobConfigParam.getJobType()) + || upsertJobConfigParam.getJobType() == null + || JobTypeEnum.SQL_STREAMING.getCode() == upsertJobConfigParam.getJobType().intValue()) { + if (StringUtils.isEmpty(upsertJobConfigParam.getFlinkSql())) { + return RestResult.error("sql语句不能为空"); + } + if (StringUtils.isNotEmpty(upsertJobConfigParam.getExtJarPath())) { + String[] urls = upsertJobConfigParam.getExtJarPath().split(SystemConstant.LINE_FEED); + for (String url : urls) { + if (StringUtils.isEmpty(url)) { + continue; + } + if (!MatcherUtils.isHttpsOrHttp(url)) { + return RestResult.error("udf地址错误: 非法的http或者是https地址 url=" + url); + } } + } + } - return null; + if (StringUtils.isNotEmpty(upsertJobConfigParam.getFlinkCheckpointConfig())) { + CheckPointParam checkPointParam = CliConfigUtil + .checkFlinkCheckPoint(upsertJobConfigParam.getFlinkCheckpointConfig()); + RestResult restResult = this.checkPointParam(checkPointParam); + if (restResult != null && !restResult.isSuccess()) { + return restResult; + } } - /** - * 获取JobServerAO - * - * @author zhuhuipei - * @date 2020/11/4 - * @time 11:19 - */ - private JobServerAO getJobServerAO(Long id) { - JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); - if (jobConfigDTO == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); - } - DeployModeEnum deployModeEnum = jobConfigDTO.getDeployModeEnum(); - switch (deployModeEnum) { - case LOCAL: - log.info(" 本地模式启动 {}", deployModeEnum); - return jobStandaloneServerAO; - case YARN_PER: - log.info(" yan per 模式启动 {}", deployModeEnum); - return jobYarnServerAO; - case STANDALONE: - log.info(" STANDALONE模式启动 {}", deployModeEnum); - return jobStandaloneServerAO; - default: - throw new RuntimeException("不支持该模式系统"); - } + if (DeployModeEnum.YARN_PER.name().equals(upsertJobConfigParam.getDeployMode())) { + if (StringUtils.isEmpty(upsertJobConfigParam.getFlinkRunConfig())) { + return RestResult.error("flink运行配置不能为空"); + } + RestResult restResult = CliConfigUtil + .checkFlinkRunConfigForYarn(upsertJobConfigParam.getFlinkRunConfig()); + if (restResult != null) { + return restResult; + } } - private RestResult checkPointParam(CheckPointParam checkPointParam) { - if (checkPointParam == null) { - return RestResult.success(); - } - if (StringUtils.isNotEmpty(checkPointParam.getCheckpointingMode())) { - if (!(FlinkConstants.EXACTLY_ONCE.equalsIgnoreCase(checkPointParam.getCheckpointingMode()) - || FlinkConstants.AT_LEAST_ONCE.equalsIgnoreCase(checkPointParam.getCheckpointingMode()))) { - return RestResult.error("checkpointingMode 参数必须是 AT_LEAST_ONCE 或者 EXACTLY_ONCE"); - } - } - if (StringUtils.isNotEmpty(checkPointParam.getExternalizedCheckpointCleanup())) { - if (!(FlinkConstants.DELETE_ON_CANCELLATION.equalsIgnoreCase(checkPointParam.getExternalizedCheckpointCleanup()) - || FlinkConstants.RETAIN_ON_CANCELLATION.equalsIgnoreCase(checkPointParam.getExternalizedCheckpointCleanup()))) { - return RestResult.error("externalizedCheckpointCleanup 参数必须是DELETE_ON_CANCELLATION 或者 RETAIN_ON_CANCELLATION"); - } + return null; + } +//CHECKSTYLE:ON + + /** + * 获取JobServerAO + * + * @author zhuhuipei + * @date 2020/11/4 + * @time 11:19 + */ + private JobServerAO getJobServerAO(Long id) { + JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(id); + if (jobConfigDTO == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); + } + DeployModeEnum deployModeEnum = jobConfigDTO.getDeployModeEnum(); + switch (deployModeEnum) { + case LOCAL: + log.info(" 本地模式启动 {}", deployModeEnum); + return jobStandaloneServerAO; + case YARN_PER: + log.info(" yan per 模式启动 {}", deployModeEnum); + return jobYarnServerAO; + case STANDALONE: + log.info(" STANDALONE模式启动 {}", deployModeEnum); + return jobStandaloneServerAO; + default: + throw new RuntimeException("不支持该模式系统"); + } + } + + private RestResult checkPointParam(CheckPointParam checkPointParam) { + if (checkPointParam == null) { + return RestResult.success(); + } + if (StringUtils.isNotEmpty(checkPointParam.getCheckpointingMode())) { + if (!(FlinkConstants.EXACTLY_ONCE.equalsIgnoreCase(checkPointParam.getCheckpointingMode()) + || FlinkConstants.AT_LEAST_ONCE + .equalsIgnoreCase(checkPointParam.getCheckpointingMode()))) { + return RestResult.error("checkpointingMode 参数必须是 AT_LEAST_ONCE 或者 EXACTLY_ONCE"); + } + } + if (StringUtils.isNotEmpty(checkPointParam.getExternalizedCheckpointCleanup())) { + if (!(FlinkConstants.DELETE_ON_CANCELLATION + .equalsIgnoreCase(checkPointParam.getExternalizedCheckpointCleanup()) + || FlinkConstants.RETAIN_ON_CANCELLATION + .equalsIgnoreCase(checkPointParam.getExternalizedCheckpointCleanup()))) { + return RestResult.error( + "externalizedCheckpointCleanup 参数必须是DELETE_ON_CANCELLATION 或者 RETAIN_ON_CANCELLATION"); + } + } + return RestResult.success(); + } + + + /** + * 补充字段信息 + * + * @author wxj + * @date 2021年12月21日 下午5:01:47 + * @version V1.0 + */ + private void completeJObConfigDTO(JobConfigDTO jobConfigDTO) { + Map domainKey = new HashMap<>(); + domainKey.put(DeployModeEnum.YARN_PER, + systemConfigService.getSystemConfigByKey(SysConfigEnum.YARN_RM_HTTP_ADDRESS.getKey())); + domainKey.put(DeployModeEnum.LOCAL, + systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_REST_HTTP_ADDRESS.getKey())); + domainKey.put(DeployModeEnum.STANDALONE, systemConfigService + .getSystemConfigByKey(SysConfigEnum.FLINK_REST_HA_HTTP_ADDRESS.getKey())); + // 补充FlinkRunUrl字段 + String domain = domainKey.get(jobConfigDTO.getDeployModeEnum()); + if (StringUtils.isNotEmpty(domain)) { + if (DeployModeEnum.YARN_PER.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils + .isEmpty(jobConfigDTO.getJobId())) { + jobConfigDTO.setFlinkRunUrl(HttpUtil.buildUrl(domain, + FlinkYarnRestUriConstants.getUriOverviewForYarn(jobConfigDTO.getJobId()))); + } + if (DeployModeEnum.LOCAL.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils + .isEmpty(jobConfigDTO.getJobId())) { + jobConfigDTO.setFlinkRunUrl(domain + String + .format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, jobConfigDTO.getJobId())); + } + if (DeployModeEnum.STANDALONE.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils + .isEmpty(jobConfigDTO.getJobId())) { + String[] urls = domain.split(";"); + for (String url : urls) { + if (HttpServiceCheckerUtil.checkUrlConnect(url)) { + jobConfigDTO.setFlinkRunUrl(url.trim() + String + .format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, jobConfigDTO.getJobId())); + break; + } } - return RestResult.success(); + } } - - - /** - * 补充字段信息 - * - * @author wxj - * @date 2021年12月21日 下午5:01:47 - * @version V1.0 - */ - private void completeJObConfigDTO(JobConfigDTO jobConfigDTO) { - Map domainKey = new HashMap<>(); - domainKey.put(DeployModeEnum.YARN_PER, systemConfigService.getSystemConfigByKey(SysConfigEnum.YARN_RM_HTTP_ADDRESS.getKey())); - domainKey.put(DeployModeEnum.LOCAL, systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_REST_HTTP_ADDRESS.getKey())); - domainKey.put(DeployModeEnum.STANDALONE, systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_REST_HA_HTTP_ADDRESS.getKey())); - // 补充FlinkRunUrl字段 - String domain = domainKey.get(jobConfigDTO.getDeployModeEnum()); - if (StringUtils.isNotEmpty(domain)) { - if (DeployModeEnum.YARN_PER.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { - jobConfigDTO.setFlinkRunUrl(HttpUtil.buildUrl(domain , FlinkYarnRestUriConstants.getUriOverviewForYarn(jobConfigDTO.getJobId()))); - } - if (DeployModeEnum.LOCAL.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { - jobConfigDTO.setFlinkRunUrl(domain + String.format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, jobConfigDTO.getJobId())); - } - if (DeployModeEnum.STANDALONE.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { - String[] urls = domain.split(";"); - for (String url : urls) { - if (HttpServiceCheckerUtil.checkUrlConnect(url)) { - jobConfigDTO.setFlinkRunUrl(url.trim() + String.format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, jobConfigDTO.getJobId())); - break; - } - } - } + // 补充AlarmStrs字段 + List list = jobAlarmConfigService.findByJobId(jobConfigDTO.getId()); + if (CollectionUtil.isNotEmpty(list)) { + List alarmTypes = new ArrayList(); + StringBuilder str = new StringBuilder("["); + for (AlarmTypeEnum alarmTypeEnum : list) { + alarmTypes.add(alarmTypeEnum.getCode()); + if (str.length() > 1) { + str.append(" "); } - // 补充AlarmStrs字段 - List list = jobAlarmConfigService.findByJobId(jobConfigDTO.getId()); - if (CollectionUtil.isNotEmpty(list)) { - List alarmTypes = new ArrayList(); - StringBuilder str = new StringBuilder("["); - for (AlarmTypeEnum alarmTypeEnum : list) { - alarmTypes.add(alarmTypeEnum.getCode()); - if (str.length() > 1) { - str.append(" "); - } - switch (alarmTypeEnum) { - case DINGDING: - str.append("钉钉"); - break; - case CALLBACK_URL: - str.append("回调"); - break; - case AUTO_START_JOB: - str.append("自动重启"); - break; - } - } - str.append("]"); - jobConfigDTO.setAlarmStrs(str.toString()); - jobConfigDTO.setAlarmTypes(alarmTypes); - jobConfigDTO.setAlarmTypeEnumList(list); + switch (alarmTypeEnum) { + case DINGDING: + str.append("钉钉"); + break; + case CALLBACK_URL: + str.append("回调"); + break; + case AUTO_START_JOB: + str.append("自动重启"); + break; + default: } + } + str.append("]"); + jobConfigDTO.setAlarmStrs(str.toString()); + jobConfigDTO.setAlarmTypes(alarmTypes); + jobConfigDTO.setAlarmTypeEnumList(list); + } + } + + /** + * 补充字段信息 + * + * @param pageModel + * @author wxj + * @date 2021年12月21日 下午5:01:47 + * @version V1.0 + */ + private void completeJObConfigDTO(PageModel pageModel) { + if (pageModel == null || pageModel.size() == 0) { + return; } - - /** - * 补充字段信息 - * - * @param pageModel - * @author wxj - * @date 2021年12月21日 下午5:01:47 - * @version V1.0 - */ - private void completeJObConfigDTO(PageModel pageModel) { - if (pageModel == null || pageModel.size() == 0) { - return; + List jobIdList = pageModel.stream().map(jobConfigVO -> jobConfigVO.getId()) + .collect(Collectors.toList()); + Map> map = jobAlarmConfigService.findByJobIdList(jobIdList); + Map domainKey = new HashMap<>(); + domainKey.put(DeployModeEnum.YARN_PER, + systemConfigService.getSystemConfigByKey(SysConfigEnum.YARN_RM_HTTP_ADDRESS.getKey())); + domainKey.put(DeployModeEnum.LOCAL, + systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_REST_HTTP_ADDRESS.getKey())); + domainKey.put(DeployModeEnum.STANDALONE, systemConfigService + .getSystemConfigByKey(SysConfigEnum.FLINK_REST_HA_HTTP_ADDRESS.getKey())); + for (JobConfigDTO jobConfigDTO : pageModel) { + // 补充FlinkRunUrl字段 + String domain = domainKey.get(jobConfigDTO.getDeployModeEnum()); + if (StringUtils.isNotEmpty(domain)) { + if (DeployModeEnum.YARN_PER.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils + .isEmpty(jobConfigDTO.getJobId())) { + jobConfigDTO.setFlinkRunUrl(HttpUtil.buildUrl(domain, + FlinkYarnRestUriConstants.getUriOverviewForYarn(jobConfigDTO.getJobId()))); } - List jobIdList= pageModel.stream().map(jobConfigVO ->jobConfigVO.getId() ).collect(Collectors.toList()); - Map> map = jobAlarmConfigService.findByJobIdList(jobIdList); - Map domainKey = new HashMap<>(); - domainKey.put(DeployModeEnum.YARN_PER, systemConfigService.getSystemConfigByKey(SysConfigEnum.YARN_RM_HTTP_ADDRESS.getKey())); - domainKey.put(DeployModeEnum.LOCAL, systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_REST_HTTP_ADDRESS.getKey())); - domainKey.put(DeployModeEnum.STANDALONE, systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_REST_HA_HTTP_ADDRESS.getKey())); - for (JobConfigDTO jobConfigDTO : pageModel) { - // 补充FlinkRunUrl字段 - String domain = domainKey.get(jobConfigDTO.getDeployModeEnum()); - if (StringUtils.isNotEmpty(domain)) { - if (DeployModeEnum.YARN_PER.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { - jobConfigDTO.setFlinkRunUrl(HttpUtil.buildUrl(domain , FlinkYarnRestUriConstants.getUriOverviewForYarn(jobConfigDTO.getJobId()))); - } - if (DeployModeEnum.LOCAL.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { - jobConfigDTO.setFlinkRunUrl(domain + String.format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, jobConfigDTO.getJobId())); - } - if (DeployModeEnum.STANDALONE.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils.isEmpty(jobConfigDTO.getJobId())) { - String[] urls = domain.split(";"); - for (String url : urls) { - if (HttpServiceCheckerUtil.checkUrlConnect(url)) { - jobConfigDTO.setFlinkRunUrl(url.trim() + String.format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, jobConfigDTO.getJobId())); - break; - } - } - } - } - // 补充AlarmStrs字段 - List list = map.get(jobConfigDTO.getId()); - if (CollectionUtil.isNotEmpty(list)) { - List alarmTypes = new ArrayList(); - StringBuilder str = new StringBuilder("["); - for (AlarmTypeEnum alarmTypeEnum : list) { - alarmTypes.add(alarmTypeEnum.getCode()); - if (str.length() > 1) { - str.append(" "); - } - switch (alarmTypeEnum) { - case DINGDING: - str.append("钉钉"); - break; - case CALLBACK_URL: - str.append("回调"); - break; - case AUTO_START_JOB: - str.append("自动重启"); - break; - } - } - str.append("]"); - jobConfigDTO.setAlarmStrs(str.toString()); - jobConfigDTO.setAlarmTypes(alarmTypes); - jobConfigDTO.setAlarmTypeEnumList(list); + if (DeployModeEnum.LOCAL.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils + .isEmpty(jobConfigDTO.getJobId())) { + jobConfigDTO.setFlinkRunUrl(domain + String + .format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, jobConfigDTO.getJobId())); + } + if (DeployModeEnum.STANDALONE.equals(jobConfigDTO.getDeployModeEnum()) && !StringUtils + .isEmpty(jobConfigDTO.getJobId())) { + String[] urls = domain.split(";"); + for (String url : urls) { + if (HttpServiceCheckerUtil.checkUrlConnect(url)) { + jobConfigDTO.setFlinkRunUrl(url.trim() + String + .format(FlinkYarnRestUriConstants.URI_YARN_JOB_OVERVIEW, + jobConfigDTO.getJobId())); + break; } + } + } + } + // 补充AlarmStrs字段 + List list = map.get(jobConfigDTO.getId()); + if (CollectionUtil.isNotEmpty(list)) { + List alarmTypes = new ArrayList(); + StringBuilder str = new StringBuilder("["); + for (AlarmTypeEnum alarmTypeEnum : list) { + alarmTypes.add(alarmTypeEnum.getCode()); + if (str.length() > 1) { + str.append(" "); + } + switch (alarmTypeEnum) { + case DINGDING: + str.append("钉钉"); + break; + case CALLBACK_URL: + str.append("回调"); + break; + case AUTO_START_JOB: + str.append("自动重启"); + break; + default: + } } + str.append("]"); + jobConfigDTO.setAlarmStrs(str.toString()); + jobConfigDTO.setAlarmTypes(alarmTypes); + jobConfigDTO.setAlarmTypeEnumList(list); + } } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/JobLogApiController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/JobLogApiController.java index 4218af65..75829525 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/JobLogApiController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/JobLogApiController.java @@ -19,55 +19,57 @@ /** * 日志API + * * @author wxj - * @date 2021年12月13日 下午4:16:29 * @version V1.0 + * @date 2021年12月13日 下午4:16:29 */ @RestController @RequestMapping("/api") public class JobLogApiController extends BaseController { - @Autowired - private JobRunLogService jobRunLogService; - - @Autowired - private CustomConfig customConfig; + @Autowired + private JobRunLogService jobRunLogService; - - /** - * 查询作业列表 - * - * @param jobConfigParam - * @return - * @author wxj - * @date 2021年12月1日 下午5:09:06 - * @version V1.0 - */ - @RequestMapping(value = "/logList", method = {RequestMethod.POST}) - public RestResult listTask(JobRunLogParam jobRunLogParam) { - PageModel pageModel = jobRunLogService.queryJobRunLog(jobRunLogParam); - PageVO> pageVO = new PageVO>(); - pageVO.setPageNum(pageModel.getPageNum()); - pageVO.setPages(pageModel.getPages()); - pageVO.setPageSize(pageModel.getPageSize()); - pageVO.setTotal(pageModel.getTotal()); - pageVO.setData(pageModel); - return RestResult.success(pageVO); - } - - /** - * 查询日志详情 - * - * @param modelMap - * @param id - * @return - * @author wxj - * @date 2021年12月14日 上午9:35:20 - * @version V1.0 - */ - @RequestMapping(value = "/logDetail", method = {RequestMethod.POST}) - public RestResult sysConfig(ModelMap modelMap, Long logid) { - JobRunLogVO vo = JobRunLogVO.toVO(jobRunLogService.getDetailLogById(logid), YN.Y.getCode(),customConfig.getWebPort()); - return RestResult.success(vo); - } + @Autowired + private CustomConfig customConfig; + + + /** + * 查询作业列表 + * + * @param jobConfigParam + * @return + * @author wxj + * @date 2021年12月1日 下午5:09:06 + * @version V1.0 + */ + @RequestMapping(value = "/logList", method = {RequestMethod.POST}) + public RestResult listTask(JobRunLogParam jobRunLogParam) { + PageModel pageModel = jobRunLogService.queryJobRunLog(jobRunLogParam); + PageVO> pageVO = new PageVO>(); + pageVO.setPageNum(pageModel.getPageNum()); + pageVO.setPages(pageModel.getPages()); + pageVO.setPageSize(pageModel.getPageSize()); + pageVO.setTotal(pageModel.getTotal()); + pageVO.setData(pageModel); + return RestResult.success(pageVO); + } + + /** + * 查询日志详情 + * + * @param modelMap + * @param id + * @return + * @author wxj + * @date 2021年12月14日 上午9:35:20 + * @version V1.0 + */ + @RequestMapping(value = "/logDetail", method = {RequestMethod.POST}) + public RestResult sysConfig(ModelMap modelMap, Long logid) { + JobRunLogVO vo = JobRunLogVO + .toVO(jobRunLogService.getDetailLogById(logid), YN.Y.getCode(), customConfig.getWebPort()); + return RestResult.success(vo); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/SavepointApiController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/SavepointApiController.java index 131c0a7a..f7a0455a 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/SavepointApiController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/SavepointApiController.java @@ -32,63 +32,68 @@ @Slf4j public class SavepointApiController { - @Autowired - private SavepointBackupService savepointBackupService; - - @Autowired - private JobConfigService jobConfigService; + @Autowired + private SavepointBackupService savepointBackupService; - @RequestMapping(value = "/addSavepoint") - public RestResult addSavepoint(Long jobConfigId, String savepointPath) { - try { - if (StringUtils.isBlank(savepointPath)) { - throw new BizException("SavePoint地址不能为空!"); - } - JobConfigDTO jobdto = jobConfigService.getJobConfigById(jobConfigId); - if (jobdto == null) { - throw new BizException("查找不到编号为[" + jobConfigId + "]的任务!"); - } - savepointPath = savepointPath.trim(); - List savepointBackupDTOList = savepointBackupService.lasterHistory10(jobConfigId); - for (SavepointBackupDTO savepointBackupDTO : savepointBackupDTOList) { - if (savepointPath.equals(savepointBackupDTO.getSavepointPath())) { - throw new BizException("SavePoint地址[" + savepointPath + "]已经存在!"); - } - } - savepointBackupService.insertSavepoint(jobConfigId, savepointPath, new Date()); - } catch (BizException e) { - log.error("addSavepoint is error jobConfigId={},savepointPath={}", jobConfigId, savepointPath, e); - return RestResult.error(e.getCode(), e.getErrorMsg()); - } catch (Exception e) { - log.error("addSavepoint error jobConfigId={},savepointPath={}", jobConfigId, savepointPath, e); - return RestResult.error(SysErrorEnum.ADD_SAVEPOINT_ERROR); + @Autowired + private JobConfigService jobConfigService; + + @RequestMapping(value = "/addSavepoint") + public RestResult addSavepoint(Long jobConfigId, String savepointPath) { + try { + if (StringUtils.isBlank(savepointPath)) { + throw new BizException("SavePoint地址不能为空!"); + } + JobConfigDTO jobdto = jobConfigService.getJobConfigById(jobConfigId); + if (jobdto == null) { + throw new BizException("查找不到编号为[" + jobConfigId + "]的任务!"); + } + savepointPath = savepointPath.trim(); + List savepointBackupDTOList = savepointBackupService + .lasterHistory10(jobConfigId); + for (SavepointBackupDTO savepointBackupDTO : savepointBackupDTOList) { + if (savepointPath.equals(savepointBackupDTO.getSavepointPath())) { + throw new BizException("SavePoint地址[" + savepointPath + "]已经存在!"); } - return RestResult.success(); + } + savepointBackupService.insertSavepoint(jobConfigId, savepointPath, new Date()); + } catch (BizException e) { + log.error("addSavepoint is error jobConfigId={},savepointPath={}", jobConfigId, savepointPath, + e); + return RestResult.error(e.getCode(), e.getErrorMsg()); + } catch (Exception e) { + log.error("addSavepoint error jobConfigId={},savepointPath={}", jobConfigId, savepointPath, + e); + return RestResult.error(SysErrorEnum.ADD_SAVEPOINT_ERROR); } + return RestResult.success(); + } - /** - * 获取SavePoint保存历史信息 - * - * @param modelMap - * @param jobConfigId - * @return - * @author wxj - * @date 2021年12月3日 上午10:01:42 - * @version V1.0 - */ - @RequestMapping(value = "/querySavePointList10") - public RestResult querySavePointList10(Long taskid) { - List savepointBackupDTOList = savepointBackupService.lasterHistory10(taskid); - ModelMap modelMap = new ModelMap(); - modelMap.put("data", SavepointBackupVO.toDTOList(savepointBackupDTOList)); - JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(taskid); - if (jobConfigDTO != null && JobConfigStatus.RUN.getCode().intValue() != jobConfigDTO.getStatus().getCode().intValue() - && YN.getYNByValue(jobConfigDTO.getIsOpen()).getCode()) { - modelMap.put("enable", true); - } else { - modelMap.put("enable", false); - } - modelMap.put("taskId", taskid); - return RestResult.success(modelMap); + /** + * 获取SavePoint保存历史信息 + * + * @param modelMap + * @param jobConfigId + * @return + * @author wxj + * @date 2021年12月3日 上午10:01:42 + * @version V1.0 + */ + @RequestMapping(value = "/querySavePointList10") + public RestResult querySavePointList10(Long taskid) { + List savepointBackupDTOList = savepointBackupService + .lasterHistory10(taskid); + ModelMap modelMap = new ModelMap(); + modelMap.put("data", SavepointBackupVO.toDTOList(savepointBackupDTOList)); + JobConfigDTO jobConfigDTO = jobConfigService.getJobConfigById(taskid); + if (jobConfigDTO != null && JobConfigStatus.RUN.getCode().intValue() != jobConfigDTO.getStatus() + .getCode().intValue() + && YN.getYNByValue(jobConfigDTO.getIsOpen()).getCode()) { + modelMap.put("enable", true); + } else { + modelMap.put("enable", false); } + modelMap.put("taskId", taskid); + return RestResult.success(modelMap); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/SqlValidationController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/SqlValidationController.java index 5f605d9a..35dcc180 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/SqlValidationController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/SqlValidationController.java @@ -22,27 +22,27 @@ @Slf4j public class SqlValidationController extends BaseController { - @RequestMapping("/checkfSql") - public RestResult checkfSql(String flinkSql) { - if (StringUtils.isEmpty(flinkSql)) { - return RestResult.error("flinkSql 参数不能为空"); - } - - try { - List listSql = SqlValidation.toSqlList(flinkSql); - if (CollectionUtils.isEmpty(listSql)) { - return RestResult.error("没有检测到有效sql语句,是否缺少了 ; 分隔符"); - } - - //SqlValidation.preCheckSql(listSql); - SqlValidation.explainStmt(SqlFileParser.parserSql(listSql)); - } catch (Exception e) { - log.warn("校验失败flinkSql={} errorMessage= {} ", flinkSql, e.getMessage()); - return RestResult.error(e.getMessage()); - } - - return RestResult.success(); + @RequestMapping("/checkfSql") + public RestResult checkfSql(String flinkSql) { + if (StringUtils.isEmpty(flinkSql)) { + return RestResult.error("flinkSql 参数不能为空"); } + try { + List listSql = SqlValidation.toSqlList(flinkSql); + if (CollectionUtils.isEmpty(listSql)) { + return RestResult.error("没有检测到有效sql语句,是否缺少了 ; 分隔符"); + } + + //SqlValidation.preCheckSql(listSql); + SqlValidation.explainStmt(SqlFileParser.parserSql(listSql)); + } catch (Exception e) { + log.warn("校验失败flinkSql={} errorMessage= {} ", flinkSql, e.getMessage()); + return RestResult.error(e.getMessage()); + } + + return RestResult.success(); + } + } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/UserApiController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/UserApiController.java index b499d1e4..b3620729 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/UserApiController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/api/UserApiController.java @@ -3,8 +3,9 @@ import com.flink.streaming.web.common.RestResult; import com.flink.streaming.web.common.SystemConstants; import com.flink.streaming.web.common.util.UserSessionUtil; +import com.flink.streaming.web.controller.web.BaseController; +import com.flink.streaming.web.enums.UserStatusEnum; import com.flink.streaming.web.exceptions.BizException; -import com.flink.streaming.web.model.dto.JobRunLogDTO; import com.flink.streaming.web.model.dto.PageModel; import com.flink.streaming.web.model.dto.UserDTO; import com.flink.streaming.web.model.dto.UserSession; @@ -12,9 +13,11 @@ import com.flink.streaming.web.model.vo.Constant; import com.flink.streaming.web.model.vo.PageVO; import com.flink.streaming.web.model.vo.UserVO; -import com.flink.streaming.web.controller.web.BaseController; -import com.flink.streaming.web.enums.UserStatusEnum; import com.flink.streaming.web.service.UserService; +import java.util.List; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -23,12 +26,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -import java.util.List; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - /** * @author zhuhuipei * @Description: @@ -40,215 +37,218 @@ @Slf4j public class UserApiController extends BaseController { - @Autowired - private UserService userService; - - - @RequestMapping("/login") - public RestResult login(ModelMap modelMap, HttpServletResponse response, String name, String password) { - try { - String cookieId = userService.login(name, password); - if (StringUtils.isEmpty(cookieId)) { - return RestResult.error("登录失败,请联系查看日志"); - } - Cookie cookie = new Cookie(SystemConstants.COOKIE_NAME_SESSION_ID, cookieId); - //24小时有效 - cookie.setMaxAge(24 * 60 * 60); - //全局有效 - cookie.setPath("/"); - response.addCookie(cookie); - log.info("cookieId={},name={}", cookieId, name); - } catch (Exception e) { - log.warn("login is error ", e); - return RestResult.error(e.getMessage()); - } - UserDTO user = userService.qyeryByUserName(name); - return RestResult.newInstance(Constant.RESPONE_STATUS_SUCCESS, "登录成功!", UserVO.toVO(user)); + @Autowired + private UserService userService; + + + @RequestMapping("/login") + public RestResult login(ModelMap modelMap, HttpServletResponse response, String name, + String password) { + try { + String cookieId = userService.login(name, password); + if (StringUtils.isEmpty(cookieId)) { + return RestResult.error("登录失败,请联系查看日志"); + } + Cookie cookie = new Cookie(SystemConstants.COOKIE_NAME_SESSION_ID, cookieId); + //24小时有效 + cookie.setMaxAge(24 * 60 * 60); + //全局有效 + cookie.setPath("/"); + response.addCookie(cookie); + log.info("cookieId={},name={}", cookieId, name); + } catch (Exception e) { + log.warn("login is error ", e); + return RestResult.error(e.getMessage()); } - - @RequestMapping("/logout") - public RestResult logout(HttpServletRequest request, HttpServletResponse response) { - try { - UserSession userSession = UserSessionUtil.userSession(request); - boolean nologin = (userSession == null) || (!userService.checkLogin(userSession)); - if (nologin) { - RestResult.newInstance(Constant.RESPONE_STATUS_SUCCESS, "没有登录或找不到用户信息!", null); - } - UserDTO user = userService.qyeryByUserName(userSession.getName()); - //清除Cookies信息 - Cookie cookies[] = request.getCookies(); - for (Cookie cookie : cookies) { - Cookie clear_cookie = new Cookie(cookie.getName(), null); - clear_cookie.setMaxAge(0); - clear_cookie.setPath(cookie.getPath()); - response.addCookie(cookie); - } - return RestResult.newInstance(Constant.RESPONE_STATUS_SUCCESS, "退出成功!", UserVO.toVO(user)); - } catch (Exception e) { - log.warn("login is error ", e); - return RestResult.error(e.getMessage()); - } + UserDTO user = userService.qyeryByUserName(name); + return RestResult.newInstance(Constant.RESPONE_STATUS_SUCCESS, "登录成功!", UserVO.toVO(user)); + } + + @RequestMapping("/logout") + public RestResult logout(HttpServletRequest request, HttpServletResponse response) { + try { + UserSession userSession = UserSessionUtil.userSession(request); + boolean nologin = (userSession == null) || (!userService.checkLogin(userSession)); + if (nologin) { + RestResult.newInstance(Constant.RESPONE_STATUS_SUCCESS, "没有登录或找不到用户信息!", null); + } + UserDTO user = userService.qyeryByUserName(userSession.getName()); + //清除Cookies信息 + Cookie cookies[] = request.getCookies(); + for (Cookie cookie : cookies) { + Cookie clearCookie = new Cookie(cookie.getName(), null); + clearCookie.setMaxAge(0); + clearCookie.setPath(cookie.getPath()); + response.addCookie(cookie); + } + return RestResult.newInstance(Constant.RESPONE_STATUS_SUCCESS, "退出成功!", UserVO.toVO(user)); + } catch (Exception e) { + log.warn("login is error ", e); + return RestResult.error(e.getMessage()); } - - /** - * 分页查询所有用户列表 - * - * @param modelMap - * @param pageparam - * @return - * @author wxj - * @date 2021年12月14日 下午4:21:15 - * @version V1.0 - */ - @RequestMapping("/userList") - public RestResult userList(ModelMap modelMap, PageParam pageparam) { - if (pageparam == null) { - pageparam = new PageParam(); - } - PageModel list = userService.queryAllByPage(pageparam); - List vlist = UserVO.toListVO(list); - PageVO pageVO = new PageVO(); - pageVO.setPageNum(list.getPageNum()); - pageVO.setPages(list.getPages()); - pageVO.setPageSize(list.getPageSize()); - pageVO.setTotal(list.getTotal()); - pageVO.setData(vlist); - return RestResult.success(pageVO); + } + + /** + * 分页查询所有用户列表 + * + * @param modelMap + * @param pageparam + * @return + * @author wxj + * @date 2021年12月14日 下午4:21:15 + * @version V1.0 + */ + @RequestMapping("/userList") + public RestResult userList(ModelMap modelMap, PageParam pageparam) { + if (pageparam == null) { + pageparam = new PageParam(); } + PageModel list = userService.queryAllByPage(pageparam); + List vlist = UserVO.toListVO(list); + PageVO pageVO = new PageVO(); + pageVO.setPageNum(list.getPageNum()); + pageVO.setPages(list.getPages()); + pageVO.setPageSize(list.getPageSize()); + pageVO.setTotal(list.getTotal()); + pageVO.setData(vlist); + return RestResult.success(pageVO); + } - /** - * 获取当前用户信息 - * - * @param request - * @return - * @author wxj - * @date 2021年11月30日 下午3:22:00 - * @version V1.0 - */ - @RequestMapping("/getUserInfo") - public RestResult getUserInfo(HttpServletRequest request) { - try { - UserSession userSession = UserSessionUtil.userSession(request); - boolean nologin = (userSession == null) || (!userService.checkLogin(userSession)); - if (nologin) { - return RestResult.error("登录失败,请联系查看日志"); - } - UserDTO user = userService.qyeryByUserName(userSession.getName()); - return RestResult.newInstance(Constant.RESPONE_STATUS_SUCCESS, "登录成功!", UserVO.toVO(user)); - } catch (Exception e) { - log.warn("login is error ", e); - return RestResult.error(e.getMessage()); - } + /** + * 获取当前用户信息 + * + * @param request + * @return + * @author wxj + * @date 2021年11月30日 下午3:22:00 + * @version V1.0 + */ + @RequestMapping("/getUserInfo") + public RestResult getUserInfo(HttpServletRequest request) { + try { + UserSession userSession = UserSessionUtil.userSession(request); + boolean nologin = (userSession == null) || (!userService.checkLogin(userSession)); + if (nologin) { + return RestResult.error("登录失败,请联系查看日志"); + } + UserDTO user = userService.qyeryByUserName(userSession.getName()); + return RestResult.newInstance(Constant.RESPONE_STATUS_SUCCESS, "登录成功!", UserVO.toVO(user)); + } catch (Exception e) { + log.warn("login is error ", e); + return RestResult.error(e.getMessage()); } + } - @RequestMapping(value = "/addUser", method = RequestMethod.POST) - public RestResult addUser(String name, String fullname, String pwd1, String pwd2) { - try { - this.check(name, pwd1, pwd2); - userService.addUser(name, fullname, pwd1, this.getUserName()); - } catch (Exception e) { - log.warn("新增账号失败", e); - return RestResult.error(e.getMessage()); - } - return RestResult.success(); + @RequestMapping(value = "/addUser", method = RequestMethod.POST) + public RestResult addUser(String name, String fullname, String pwd1, String pwd2) { + try { + this.check(name, pwd1, pwd2); + userService.addUser(name, fullname, pwd1, this.getUserName()); + } catch (Exception e) { + log.warn("新增账号失败", e); + return RestResult.error(e.getMessage()); } + return RestResult.success(); + } - @RequestMapping(value = "/updatePassword", method = RequestMethod.POST) - public RestResult updatePassword(String name, String fullname, String oldPwd, String pwd1, String pwd2) { - try { - this.check(name, pwd1, pwd2); - userService.updatePassword(name, oldPwd, pwd1, this.getUserName()); - } catch (Exception e) { - log.warn("修改密码失败", e); - return RestResult.error(e.getMessage()); - } - return RestResult.success(); + @RequestMapping(value = "/updatePassword", method = RequestMethod.POST) + public RestResult updatePassword(String name, String fullname, String oldPwd, String pwd1, + String pwd2) { + try { + this.check(name, pwd1, pwd2); + userService.updatePassword(name, oldPwd, pwd1, this.getUserName()); + } catch (Exception e) { + log.warn("修改密码失败", e); + return RestResult.error(e.getMessage()); } + return RestResult.success(); + } - /** - * 修改当前用户密码 - * - * @param request - * @param userid - * @param password - * @return - * @author wxj - * @date 2021年12月1日 下午2:09:34 - * @version V1.0 - */ - @RequestMapping(value = "/updateCurrentUserPassword", method = RequestMethod.POST) - public RestResult updateCurrentUserPassword(HttpServletRequest request, Integer userid, String password) { - try { - UserSession userSession = UserSessionUtil.userSession(request); - boolean nologin = (userSession == null) || (!userService.checkLogin(userSession)); - if (nologin) { - RestResult.newInstance(Constant.RESPONE_STATUS_SUCCESS, "没有登录或找不到用户信息!", null); - } - this.check(userSession.getName(), password, password); - UserDTO user = userService.qyeryByUserId(userid); - if (user.getId() != userSession.getUserid()) { - return RestResult.error("不能修改非当前登录用户的密码!"); - } - userService.updatePassword(userid, password, this.getUserName()); - } catch (Exception e) { - log.warn("修改密码失败", e); - return RestResult.error(e.getMessage()); - } - return RestResult.success(); + /** + * 修改当前用户密码 + * + * @param request + * @param userid + * @param password + * @return + * @author wxj + * @date 2021年12月1日 下午2:09:34 + * @version V1.0 + */ + @RequestMapping(value = "/updateCurrentUserPassword", method = RequestMethod.POST) + public RestResult updateCurrentUserPassword(HttpServletRequest request, Integer userid, + String password) { + try { + UserSession userSession = UserSessionUtil.userSession(request); + boolean nologin = (userSession == null) || (!userService.checkLogin(userSession)); + if (nologin) { + RestResult.newInstance(Constant.RESPONE_STATUS_SUCCESS, "没有登录或找不到用户信息!", null); + } + this.check(userSession.getName(), password, password); + UserDTO user = userService.qyeryByUserId(userid); + if (user.getId() != userSession.getUserid()) { + return RestResult.error("不能修改非当前登录用户的密码!"); + } + userService.updatePassword(userid, password, this.getUserName()); + } catch (Exception e) { + log.warn("修改密码失败", e); + return RestResult.error(e.getMessage()); } - - /** - * 修改用户信息 - * - * @param username - * @param name - * @return - * @author wxj - * @date 2021年12月1日 上午10:19:56 - * @version V1.0 - */ - @RequestMapping(value = "/updateUserInfo", method = RequestMethod.POST) - public RestResult updateUserInfo(Integer userid, String fullname) { - try { - userService.updateFullName(userid, fullname, this.getUserName()); - } catch (Exception e) { - log.warn("修改用户信息失败", e); - return RestResult.error(e.getMessage()); - } - return RestResult.success(); + return RestResult.success(); + } + + /** + * 修改用户信息 + * + * @param username + * @param name + * @return + * @author wxj + * @date 2021年12月1日 上午10:19:56 + * @version V1.0 + */ + @RequestMapping(value = "/updateUserInfo", method = RequestMethod.POST) + public RestResult updateUserInfo(Integer userid, String fullname) { + try { + userService.updateFullName(userid, fullname, this.getUserName()); + } catch (Exception e) { + log.warn("修改用户信息失败", e); + return RestResult.error(e.getMessage()); } + return RestResult.success(); + } - @RequestMapping(value = "/stopOrOpen", method = RequestMethod.POST) - public RestResult stopOrOpen(String name, Integer code) { - try { - userService.stopOrOpen(name, UserStatusEnum.getStatus(code), this.getUserName()); - } catch (Exception e) { - log.warn("操作失败联系管理员", e); - return RestResult.error(e.getMessage()); - } - return RestResult.success(); + @RequestMapping(value = "/stopOrOpen", method = RequestMethod.POST) + public RestResult stopOrOpen(String name, Integer code) { + try { + userService.stopOrOpen(name, UserStatusEnum.getStatus(code), this.getUserName()); + } catch (Exception e) { + log.warn("操作失败联系管理员", e); + return RestResult.error(e.getMessage()); } + return RestResult.success(); + } - private void check(String name, String pwd1, String pwd2) { - if (StringUtils.isEmpty(name)) { - throw new BizException("账号不能为空"); - } - if (name.length() < 4) { - throw new BizException("名称长度不能少于4位"); - } - if (StringUtils.isEmpty(pwd1) || StringUtils.isEmpty(pwd2)) { - throw new BizException("密码和确认密码都不能为空"); - } - if (!pwd1.equals(pwd2)) { - throw new BizException("二次密码输入不一致"); - } - if (pwd1.length() < 6) { - throw new BizException("密码长度不能少于6位"); - } - if (!name.matches("[a-zA-Z0-9]+")) { - throw new BizException("账号只能是英文字母或数字"); - } + private void check(String name, String pwd1, String pwd2) { + if (StringUtils.isEmpty(name)) { + throw new BizException("账号不能为空"); + } + if (name.length() < 4) { + throw new BizException("名称长度不能少于4位"); + } + if (StringUtils.isEmpty(pwd1) || StringUtils.isEmpty(pwd2)) { + throw new BizException("密码和确认密码都不能为空"); + } + if (!pwd1.equals(pwd2)) { + throw new BizException("二次密码输入不一致"); + } + if (pwd1.length() < 6) { + throw new BizException("密码长度不能少于6位"); + } + if (!name.matches("[a-zA-Z0-9]+")) { + throw new BizException("账号只能是英文字母或数字"); } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/web/BaseController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/web/BaseController.java index c4ce5b85..6930a186 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/web/BaseController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/web/BaseController.java @@ -15,25 +15,26 @@ */ public class BaseController { - /** - * 取得HttpServletRequest对象. - * - * @return HttpServletRequest对象. - */ - protected HttpServletRequest getServletRequest() { - - ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - HttpServletRequest request = attrs.getRequest(); - return request; - } - - - public String getUserName() { - UserSession userSession = UserSessionUtil.userSession(getServletRequest()); - if (userSession == null) { - return ""; - } - return userSession.getName(); + /** + * 取得HttpServletRequest对象. + * + * @return HttpServletRequest对象. + */ + protected HttpServletRequest getServletRequest() { + + ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder + .getRequestAttributes(); + HttpServletRequest request = attrs.getRequest(); + return request; + } + + + public String getUserName() { + UserSession userSession = UserSessionUtil.userSession(getServletRequest()); + if (userSession == null) { + return ""; } + return userSession.getName(); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/web/DefaultController.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/web/DefaultController.java index 2010cf25..1608453f 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/web/DefaultController.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/controller/web/DefaultController.java @@ -14,9 +14,10 @@ @Controller @Slf4j public class DefaultController { - @RequestMapping("/") - public String defaultUrl(ModelMap modelMap) { - return "forward:/admin/listPage"; - } + + @RequestMapping("/") + public String defaultUrl(ModelMap modelMap) { + return "forward:/admin/listPage"; + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/interceptor/InterceptorConfig.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/interceptor/InterceptorConfig.java index 71bdfe14..7f1d7971 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/interceptor/InterceptorConfig.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/interceptor/InterceptorConfig.java @@ -16,19 +16,19 @@ public class InterceptorConfig implements WebMvcConfigurer { - @Autowired - private LoginInterceptor loginInterceptor; + @Autowired + private LoginInterceptor loginInterceptor; - @Override - public void addInterceptors(InterceptorRegistry registry) { - //注册loginInterceptor拦截器 - InterceptorRegistration registration = registry.addInterceptor(loginInterceptor); - //所有路径都被拦截 - registration.addPathPatterns("/**"); - //添加不拦截路径 - registration.excludePathPatterns("/static/**", "/static/*", "/admin/index", - "/admin/qrcode", "/api/login", "/api/logout", - "/ok","/alarmCallback","/log/*","/favicon.ico"); - } + @Override + public void addInterceptors(InterceptorRegistry registry) { + //注册loginInterceptor拦截器 + InterceptorRegistration registration = registry.addInterceptor(loginInterceptor); + //所有路径都被拦截 + registration.addPathPatterns("/**"); + //添加不拦截路径 + registration.excludePathPatterns("/static/**", "/static/*", "/admin/index", + "/admin/qrcode", "/api/login", "/api/logout", + "/ok", "/alarmCallback", "/log/*", "/favicon.ico"); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/interceptor/LoginInterceptor.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/interceptor/LoginInterceptor.java index 87f4402b..5cb2ad55 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/interceptor/LoginInterceptor.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/interceptor/LoginInterceptor.java @@ -27,47 +27,49 @@ public class LoginInterceptor implements HandlerInterceptor { - @Autowired - private UserService userService; + @Autowired + private UserService userService; - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) - throws Exception { - log.debug("进入LoginInterceptor拦截器 {}", request.getRequestURI()); - if ("/".equals(request.getRequestURI())) { - response.sendRedirect("/static/ui/index.html"); - return false; - } - UserSession userSession = UserSessionUtil.userSession(request); - - // ajax请求 - if (WebUtil.isAjaxRequest(request)) { - boolean nologin = (userSession == null) || (!userService.checkLogin(userSession)); - if (nologin) { - RestResult respdata = RestResult.newInstance(Constant.RESPONE_STATUS_UNAUTH, "未登录认证!", null); - WebUtil.restResponseWithFlush(response, respdata); - return false; - } - return true; - } - log.debug("未知请求={}", request.getRequestURI()); - return true; + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + log.debug("进入LoginInterceptor拦截器 {}", request.getRequestURI()); + if ("/".equals(request.getRequestURI())) { + response.sendRedirect("/static/ui/index.html"); + return false; } + UserSession userSession = UserSessionUtil.userSession(request); - @Override - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { - UserSession userSession = UserSessionUtil.userSession(request); - if (modelAndView != null && userSession != null) { - modelAndView.addObject("user", userSession.getName()); - } + // ajax请求 + if (WebUtil.isAjaxRequest(request)) { + boolean nologin = (userSession == null) || (!userService.checkLogin(userSession)); + if (nologin) { + RestResult respdata = RestResult + .newInstance(Constant.RESPONE_STATUS_UNAUTH, "未登录认证!", null); + WebUtil.restResponseWithFlush(response, respdata); + return false; + } + return true; + } + log.debug("未知请求={}", request.getRequestURI()); + return true; + } + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, + ModelAndView modelAndView) { + UserSession userSession = UserSessionUtil.userSession(request); + if (modelAndView != null && userSession != null) { + modelAndView.addObject("user", userSession.getName()); } - @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { + } + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, + Object handler, Exception ex) { - } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/listener/ApplicationStopListener.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/listener/ApplicationStopListener.java index 94410fff..6fb33e41 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/listener/ApplicationStopListener.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/listener/ApplicationStopListener.java @@ -17,23 +17,23 @@ @Slf4j public class ApplicationStopListener implements ApplicationListener { - @Autowired - private IpStatusService ipStatusService; + @Autowired + private IpStatusService ipStatusService; - @Override - public void onApplicationEvent(ContextClosedEvent event) { - try { - log.warn("## sart the ApplicationStopListener start 。。。。。"); + @Override + public void onApplicationEvent(ContextClosedEvent event) { + try { + log.warn("## sart the ApplicationStopListener start 。。。。。"); - ipStatusService.cancelIp(); + ipStatusService.cancelIp(); - log.warn("## stop the ApplicationStopListener end 。。。。。"); + log.warn("## stop the ApplicationStopListener end 。。。。。"); - } catch (Throwable e) { - log.warn("##something goes wrong when stopping ApplicationStopListener:", e); + } catch (Throwable e) { + log.warn("##something goes wrong when stopping ApplicationStopListener:", e); - } finally { - log.info("## ApplicationStopListener client is down."); - } + } finally { + log.info("## ApplicationStopListener client is down."); } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/AlarmLogMapper.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/AlarmLogMapper.java index f2b050f0..ed24cb8e 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/AlarmLogMapper.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/AlarmLogMapper.java @@ -10,13 +10,13 @@ public interface AlarmLogMapper { - int insert(AlartLog alartLog); + int insert(AlartLog alartLog); - AlartLog selectByPrimaryKey(@Param("id") Long id); + AlartLog selectByPrimaryKey(@Param("id") Long id); - Page selectByParam(AlartLogParam alartLogParam); + Page selectByParam(AlartLogParam alartLogParam); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/IpStatusMapper.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/IpStatusMapper.java index 287aad82..bfae1f3e 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/IpStatusMapper.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/IpStatusMapper.java @@ -10,26 +10,26 @@ public interface IpStatusMapper { - int updateStatusByIp(IpStatus ipStatus); + int updateStatusByIp(IpStatus ipStatus); - int insert(IpStatus ipStatus); + int insert(IpStatus ipStatus); - IpStatus selectByIp(@Param("ip") String ip); + IpStatus selectByIp(@Param("ip") String ip); - List selectAll(); + List selectAll(); - /** - * 排序后获得id最的一条记录并且 - * where is_deleted = 0 AND STATUS = 1 and last_time >= DATE_ADD(NOW(),INTERVAL -61 SECOND) - * - * @author zhuhuipei - * @date 2020-09-22 - * @time 19:50 - */ - IpStatus selectLastIp(); + /** + * 排序后获得id最的一条记录并且 where is_deleted = 0 AND STATUS = 1 and last_time >= DATE_ADD(NOW(),INTERVAL + * -61 SECOND) + * + * @author zhuhuipei + * @date 2020-09-22 + * @time 19:50 + */ + IpStatus selectLastIp(); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobAlarmConfigMapper.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobAlarmConfigMapper.java index d609a848..a77e4cae 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobAlarmConfigMapper.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobAlarmConfigMapper.java @@ -9,13 +9,13 @@ @Repository public interface JobAlarmConfigMapper { - int insertBatch(@Param("list") List list); + int insertBatch(@Param("list") List list); - List selectByJobId(@Param("jobId")Long jobId); + List selectByJobId(@Param("jobId") Long jobId); - List selectByJobIdList(@Param("jobIdList")List jobIdList); + List selectByJobIdList(@Param("jobIdList") List jobIdList); - int deleteByJobId(@Param("jobId")Long jobId); + int deleteByJobId(@Param("jobId") Long jobId); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobConfigHistoryMapper.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobConfigHistoryMapper.java index f6dcf9a4..9bf3e3aa 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobConfigHistoryMapper.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobConfigHistoryMapper.java @@ -12,11 +12,11 @@ @Repository public interface JobConfigHistoryMapper { - int insert(JobConfigHistory record); + int insert(JobConfigHistory record); - List selectByJobConfigId(@Param("jobConfigId") Long jobConfigId); + List selectByJobConfigId(@Param("jobConfigId") Long jobConfigId); - JobConfigHistory selectById(@Param("id") Long id); - - Page findJobConfigHistory(JobConfigHisotryParam jobConfigParam); + JobConfigHistory selectById(@Param("id") Long id); + + Page findJobConfigHistory(JobConfigHisotryParam jobConfigParam); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobConfigMapper.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobConfigMapper.java index 6b72edd9..dca6512b 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobConfigMapper.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobConfigMapper.java @@ -11,27 +11,28 @@ @Repository public interface JobConfigMapper { - int insert(JobConfig record); - - int insertWithId(JobConfig record); + int insert(JobConfig record); - long selectCountByJobName(@Param("jobName") String jobName, @Param("id") Long id); + int insertWithId(JobConfig record); - JobConfig selectByPrimaryKey(Long id); - - JobConfig selectByPrimaryKeyContainDelete(Long id); + long selectCountByJobName(@Param("jobName") String jobName, @Param("id") Long id); - int updateByPrimaryKeySelective(JobConfig record); + JobConfig selectByPrimaryKey(Long id); + JobConfig selectByPrimaryKeyContainDelete(Long id); - int updateStatusByStart(@Param("id") Long id, @Param("status") Integer status, @Param("userName") String userName, - @Param("jobRunLogId") Long jobRunLogId, @Param("oldVersion") Integer oldVersion); + int updateByPrimaryKeySelective(JobConfig record); - Page findJobConfig(JobConfigParam jobConfigParam); - int deleteById(@Param("id") Long id, @Param("userName") String userName); - - int recoveryDeleteJobConfigById(@Param("id") Long id, @Param("userName") String userName); + int updateStatusByStart(@Param("id") Long id, @Param("status") Integer status, + @Param("userName") String userName, + @Param("jobRunLogId") Long jobRunLogId, @Param("oldVersion") Integer oldVersion); - List findJobConfigByStatus(@Param("statusList") List statusList); + Page findJobConfig(JobConfigParam jobConfigParam); + + int deleteById(@Param("id") Long id, @Param("userName") String userName); + + int recoveryDeleteJobConfigById(@Param("id") Long id, @Param("userName") String userName); + + List findJobConfigByStatus(@Param("statusList") List statusList); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobRunLogMapper.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobRunLogMapper.java index 34259069..af4c49e1 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobRunLogMapper.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/JobRunLogMapper.java @@ -9,16 +9,16 @@ @Repository public interface JobRunLogMapper { - int insert(JobRunLog record); + int insert(JobRunLog record); - int update(JobRunLog record); + int update(JobRunLog record); - JobRunLog selectById(@Param("id") Long id); + JobRunLog selectById(@Param("id") Long id); - Page selectByParam(JobRunLogParam jobRunLogParam); + Page selectByParam(JobRunLogParam jobRunLogParam); - int deleteByJobConfigId(@Param("jobConfigId") Long jobConfigId); + int deleteByJobConfigId(@Param("jobConfigId") Long jobConfigId); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/SavepointBackupMapper.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/SavepointBackupMapper.java index 88d32a21..cf5166fd 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/SavepointBackupMapper.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/SavepointBackupMapper.java @@ -9,12 +9,13 @@ @Repository public interface SavepointBackupMapper { - int insert(SavepointBackup savepointBackup); + int insert(SavepointBackup savepointBackup); - List selectByLimt10(@Param("jobConfigId") Long jobConfigId); + List selectByLimt10(@Param("jobConfigId") Long jobConfigId); - SavepointBackup getSavepointBackupById(@Param("jobConfigId") Long jobConfigId, @Param("id") Long id); + SavepointBackup getSavepointBackupById(@Param("jobConfigId") Long jobConfigId, + @Param("id") Long id); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/SystemConfigMapper.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/SystemConfigMapper.java index a2226786..def2cce0 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/SystemConfigMapper.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/SystemConfigMapper.java @@ -10,17 +10,17 @@ public interface SystemConfigMapper { - int insert(SystemConfig systemConfig); + int insert(SystemConfig systemConfig); - List selectAllConfig(@Param("type") String type); + List selectAllConfig(@Param("type") String type); - SystemConfig selectConfigByKey(@Param("key") String key); + SystemConfig selectConfigByKey(@Param("key") String key); - int deleteByKey(@Param("key") String key); + int deleteByKey(@Param("key") String key); - int updateByKey(SystemConfig systemConfig); + int updateByKey(SystemConfig systemConfig); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/UserMapper.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/UserMapper.java index 173721d5..1172e0d4 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/UserMapper.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/mapper/UserMapper.java @@ -12,18 +12,18 @@ @Repository public interface UserMapper { - User selectByUsername(@Param("username") String username); + User selectByUsername(@Param("username") String username); - User selectByUserId(@Param("userid") Integer userid); + User selectByUserId(@Param("userid") Integer userid); - int insert(User user); + int insert(User user); - int updateByPrimaryKeySelective(User user); - - int updateByUserIdSelective(User user); + int updateByPrimaryKeySelective(User user); - List findAll(); - - Page queryAllByPage(PageParam pageparam); + int updateByUserIdSelective(User user); + + List findAll(); + + Page queryAllByPage(PageParam pageparam); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/CommandRpcClinetAdapter.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/CommandRpcClinetAdapter.java index d63d77b2..e5985ff8 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/CommandRpcClinetAdapter.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/CommandRpcClinetAdapter.java @@ -11,36 +11,37 @@ public interface CommandRpcClinetAdapter { - /** - * 提交服务 - * - * @author zhuhuipei - * @date 2021/3/26 - * @time 17:31 - */ - String submitJob(String command, StringBuilder localLog, Long jobRunLogId, DeployModeEnum deployModeEnum) - throws Exception; - - - /** - * yarn per模式执行savepoint - *

- * 默认savepoint保存的地址是:hdfs:///flink/savepoint/flink-streaming-platform-web/ - * - * @author zhuhuipei - * @date 2020-09-21 - * @time 23:14 - */ - void savepointForPerYarn(String jobId, String targetDirectory, String yarnAppId) throws Exception; - - /** - * 集群模式下执行savepoint - * - * @author zhuhuipei - * @date 2021/3/31 - * @time 19:39 - */ - void savepointForPerCluster(String jobId, String targetDirectory) throws Exception; + /** + * 提交服务 + * + * @author zhuhuipei + * @date 2021/3/26 + * @time 17:31 + */ + String submitJob(String command, StringBuilder localLog, Long jobRunLogId, + DeployModeEnum deployModeEnum) + throws Exception; + + + /** + * yarn per模式执行savepoint + *

+ * 默认savepoint保存的地址是:hdfs:///flink/savepoint/flink-streaming-platform-web/ + * + * @author zhuhuipei + * @date 2020-09-21 + * @time 23:14 + */ + void savepointForPerYarn(String jobId, String targetDirectory, String yarnAppId) throws Exception; + + /** + * 集群模式下执行savepoint + * + * @author zhuhuipei + * @date 2021/3/31 + * @time 19:39 + */ + void savepointForPerCluster(String jobId, String targetDirectory) throws Exception; } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/FlinkRestRpcAdapter.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/FlinkRestRpcAdapter.java index 0aea699b..ac06cd47 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/FlinkRestRpcAdapter.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/FlinkRestRpcAdapter.java @@ -12,34 +12,34 @@ public interface FlinkRestRpcAdapter { - /** - * Standalone 模式下获取状态 - * - * @author zhuhuipei - * @date 2020/11/3 - * @time 23:47 - */ - JobStandaloneInfo getJobInfoForStandaloneByAppId(String appId, DeployModeEnum deployModeEnum); - - - /** - * 基于flink rest API取消任务 - * - * @author zhuhuipei - * @date 2020/11/3 - * @time 22:50 - */ - void cancelJobForFlinkByAppId(String jobId, DeployModeEnum deployModeEnum); - - - /** - * 获取savepoint路径 - * - * @author zhuhuipei - * @date 2021/3/31 - * @time 22:01 - */ - String savepointPath(String jobId, DeployModeEnum deployModeEnum); + /** + * Standalone 模式下获取状态 + * + * @author zhuhuipei + * @date 2020/11/3 + * @time 23:47 + */ + JobStandaloneInfo getJobInfoForStandaloneByAppId(String appId, DeployModeEnum deployModeEnum); + + + /** + * 基于flink rest API取消任务 + * + * @author zhuhuipei + * @date 2020/11/3 + * @time 22:50 + */ + void cancelJobForFlinkByAppId(String jobId, DeployModeEnum deployModeEnum); + + + /** + * 获取savepoint路径 + * + * @author zhuhuipei + * @date 2021/3/31 + * @time 22:01 + */ + String savepointPath(String jobId, DeployModeEnum deployModeEnum); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/YarnRestRpcAdapter.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/YarnRestRpcAdapter.java index 12bcdab2..80edfcf5 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/YarnRestRpcAdapter.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/YarnRestRpcAdapter.java @@ -11,68 +11,67 @@ */ public interface YarnRestRpcAdapter { - /** - * 通过任务名称获取yarn 的appId - * - * @author zhuhuipei - * @date 2020-08-06 - * @time 20:18 - */ - String getAppIdByYarn(String jobName, String queueName); + /** + * 通过任务名称获取yarn 的appId + * + * @author zhuhuipei + * @date 2020-08-06 + * @time 20:18 + */ + String getAppIdByYarn(String jobName, String queueName); - /** - * 通过http杀掉一个任务 - * - * @author zhuhuipei - * @date 2020-08-06 - * @time 20:50 - */ - void stopJobByJobId(String appId); + /** + * 通过http杀掉一个任务 + * + * @author zhuhuipei + * @date 2020-08-06 + * @time 20:50 + */ + void stopJobByJobId(String appId); - /** - * 查询yarn 上某任务状态 - * - * @author zhuhuipei - * @date 2020-08-07 - * @time 21:36 - */ - YarnStateEnum getJobStateByJobId(String appId); + /** + * 查询yarn 上某任务状态 + * + * @author zhuhuipei + * @date 2020-08-07 + * @time 21:36 + */ + YarnStateEnum getJobStateByJobId(String appId); - /** - * per yarn 模式下获取任务新状态 - * - * @author zhuhuipei - * @date 2020-09-18 - * @time 01:15 - */ - JobInfo getJobInfoForPerYarnByAppId(String appId); + /** + * per yarn 模式下获取任务新状态 + * + * @author zhuhuipei + * @date 2020-09-18 + * @time 01:15 + */ + JobInfo getJobInfoForPerYarnByAppId(String appId); + /** + * per yarn 模式下 取消任务 + * + * @param appId (yarn上的appId) + * @param jobId (flink上的id) + * @author zhuhuipei + * @date 2020-09-18 + * @time 00:01 + */ + void cancelJobForYarnByAppId(String appId, String jobId); - /** - * per yarn 模式下 取消任务 - * - * @param appId (yarn上的appId) - * @param jobId (flink上的id) - * @author zhuhuipei - * @date 2020-09-18 - * @time 00:01 - */ - void cancelJobForYarnByAppId(String appId, String jobId); - - /** - * per yarn 模式下 获取SavepointPath 地址 - *

- * 通过checkpoint 接口获取Savepoint地址 - * - * @author zhuhuipei - * @date 2020-09-21 - * @time 02:44 - */ - String getSavepointPath(String appId, String jobId); + /** + * per yarn 模式下 获取SavepointPath 地址 + *

+ * 通过checkpoint 接口获取Savepoint地址 + * + * @author zhuhuipei + * @date 2020-09-21 + * @time 02:44 + */ + String getSavepointPath(String appId, String jobId); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/CommandRpcClinetAdapterImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/CommandRpcClinetAdapterImpl.java index 24f53ba8..d172800a 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/CommandRpcClinetAdapterImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/CommandRpcClinetAdapterImpl.java @@ -34,182 +34,187 @@ public class CommandRpcClinetAdapterImpl implements CommandRpcClinetAdapter { - private static long INTERVAL_TIME_TWO = 1000 * 2; + private static final long INTERVAL_TIME_TWO = 1000 * 2; - @Autowired - private JobRunLogService jobRunLogService; + @Autowired + private JobRunLogService jobRunLogService; - @Autowired - private SystemConfigService systemConfigService; + @Autowired + private SystemConfigService systemConfigService; - @Override - public String submitJob(String command, StringBuilder localLog, Long jobRunLogId, - DeployModeEnum deployModeEnum) throws Exception { - log.info(" command ={} ", command); - localLog.append("启动命令:").append(command).append(SystemConstant.LINE_FEED); - Process pcs = Runtime.getRuntime().exec(command); + @Override + public String submitJob(String command, StringBuilder localLog, Long jobRunLogId, + DeployModeEnum deployModeEnum) throws Exception { + log.info(" command ={} ", command); + localLog.append("启动命令:").append(command).append(SystemConstant.LINE_FEED); + Process pcs = Runtime.getRuntime().exec(command); - //清理错误日志 - this.clearLogStream(pcs.getErrorStream(), String.format("%s#startForLocal-error#%s", DateUtil.now(), + //清理错误日志 + this.clearLogStream(pcs.getErrorStream(), + String.format("%s#startForLocal-error#%s", DateUtil.now(), deployModeEnum.name())); - String appId = this.clearInfoLogStream(pcs.getInputStream(), localLog, jobRunLogId); - int rs = pcs.waitFor(); - localLog.append("rs=").append(rs).append(SystemConstant.LINE_FEED); - jobRunLogService.updateLogById(localLog.toString(), jobRunLogId); - if (rs != 0) { - localLog.append(" 执行异常 rs=").append(rs).append(" appId=").append(appId); - throw new RuntimeException("执行异常 is error rs=" + rs); - } - if (StringUtils.isEmpty(appId)) { - localLog.append("appId无法获 ").append(TipsConstants.TIPS_1); - throw new RuntimeException("appId无法获取"); - } - return appId; + String appId = this.clearInfoLogStream(pcs.getInputStream(), localLog, jobRunLogId); + int rs = pcs.waitFor(); + localLog.append("rs=").append(rs).append(SystemConstant.LINE_FEED); + jobRunLogService.updateLogById(localLog.toString(), jobRunLogId); + if (rs != 0) { + localLog.append(" 执行异常 rs=").append(rs).append(" appId=").append(appId); + throw new RuntimeException("执行异常 is error rs=" + rs); + } + if (StringUtils.isEmpty(appId)) { + localLog.append("appId无法获 ").append(TipsConstants.TIPS_1); + throw new RuntimeException("appId无法获取"); } + return appId; + } - @Override - public void savepointForPerYarn(String jobId, String targetDirectory, String yarnAppId) throws Exception { + @Override + public void savepointForPerYarn(String jobId, String targetDirectory, String yarnAppId) + throws Exception { - String command = CommandUtil.buildSavepointCommandForYarn(jobId, targetDirectory, yarnAppId, - systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_HOME.getKey())); - log.info("[savepointForPerYarn] command={}", command); - this.execSavepoint(command); + String command = CommandUtil.buildSavepointCommandForYarn(jobId, targetDirectory, yarnAppId, + systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_HOME.getKey())); + log.info("[savepointForPerYarn] command={}", command); + this.execSavepoint(command); - } + } - @Override - public void savepointForPerCluster(String jobId, String targetDirectory) throws Exception { - String command = CommandUtil.buildSavepointCommandForCluster(jobId, targetDirectory, - systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_HOME.getKey())); - log.info("[savepointForPerCluster] command={}", command); - this.execSavepoint(command); - } + @Override + public void savepointForPerCluster(String jobId, String targetDirectory) throws Exception { + String command = CommandUtil.buildSavepointCommandForCluster(jobId, targetDirectory, + systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_HOME.getKey())); + log.info("[savepointForPerCluster] command={}", command); + this.execSavepoint(command); + } - private void execSavepoint(String command) throws Exception { - Process pcs = Runtime.getRuntime().exec(command); - //消费正常日志 - this.clearLogStream(pcs.getInputStream(), String.format("%s-savepoint-success", DateUtil.now())); - //消费错误日志 - this.clearLogStream(pcs.getErrorStream(), String.format("%s-savepoint-error", DateUtil.now())); + private void execSavepoint(String command) throws Exception { + Process pcs = Runtime.getRuntime().exec(command); + //消费正常日志 + this.clearLogStream(pcs.getInputStream(), + String.format("%s-savepoint-success", DateUtil.now())); + //消费错误日志 + this.clearLogStream(pcs.getErrorStream(), String.format("%s-savepoint-error", DateUtil.now())); - int rs = pcs.waitFor(); - if (rs != 0) { - throw new Exception("[savepointForPerYarn]执行savepoint失败 is error rs=" + rs); - } + int rs = pcs.waitFor(); + if (rs != 0) { + throw new Exception("[savepointForPerYarn]执行savepoint失败 is error rs=" + rs); } - - /** - * 清理pcs.waitFor()日志防止死锁 - * - * @author zhuhuipei - * @date 2021/3/28 - * @time 11:15 - */ - private void clearLogStream(InputStream stream, final String threadName) { - WaitForPoolConfig.getInstance().getThreadPoolExecutor().execute(() -> { - BufferedReader reader = null; - try { - Thread.currentThread().setName(threadName); - String result = null; - reader = new BufferedReader(new InputStreamReader(stream, SystemConstants.CODE_UTF_8)); - //按行读取 - while ((result = reader.readLine()) != null) { - log.info(result); - } - } catch (Exception e) { - log.error("threadName={}", threadName); - } finally { - this.close(reader, stream, "clearLogStream"); - } - } - ); - } - - /** - * 启动日志输出并且从日志中获取成功后的jobId - * - * @author zhuhuipei - * @date 2021/3/28 - * @time 11:15 - */ - private String clearInfoLogStream(InputStream stream, StringBuilder localLog, Long jobRunLogId) { - - String appId = null; - BufferedReader reader = null; - try { - long lastTime = System.currentTimeMillis(); + } + + /** + * 清理pcs.waitFor()日志防止死锁 + * + * @author zhuhuipei + * @date 2021/3/28 + * @time 11:15 + */ + private void clearLogStream(InputStream stream, final String threadName) { + WaitForPoolConfig.getInstance().getThreadPoolExecutor().execute(() -> { + BufferedReader reader = null; + try { + Thread.currentThread().setName(threadName); String result = null; reader = new BufferedReader(new InputStreamReader(stream, SystemConstants.CODE_UTF_8)); //按行读取 while ((result = reader.readLine()) != null) { - log.info("read={}", result); - if (StringUtils.isEmpty(appId) && result.contains(SystemConstant.QUERY_JOBID_KEY_WORD)) { - appId = result.replace(SystemConstant.QUERY_JOBID_KEY_WORD, SystemConstant.SPACE).trim(); - log.info("[job-submitted-success] 解析得到的appId是 {} 原始数据 :{}", appId, result); - localLog.append("[job-submitted-success] 解析得到的appId是:") - .append(appId).append(SystemConstant.LINE_FEED); - } - if (StringUtils.isEmpty(appId) && result.contains(SystemConstant.QUERY_JOBID_KEY_WORD_BACKUP)) { - appId = result.replace(SystemConstant.QUERY_JOBID_KEY_WORD_BACKUP, SystemConstant.SPACE).trim(); - log.info("[Job has been submitted with JobID] 解析得到的appId是 {} 原始数据 :{}", appId, result); - localLog.append("[Job has been submitted with JobID] 解析得到的appId是:") - .append(appId).append(SystemConstant.LINE_FEED); - } - localLog.append(result).append(SystemConstant.LINE_FEED); - //每隔2s更新日志 - if (System.currentTimeMillis() >= lastTime + INTERVAL_TIME_TWO) { - jobRunLogService.updateLogById(localLog.toString(), jobRunLogId); - lastTime = System.currentTimeMillis(); - } - } - if (appId == null || appId.length() != 32) { - log.error("解析appID异常 appId:{}", appId); - throw new BizException("解析appId异常"); + log.info(result); } - JobBaseServiceAOImpl.threadAppId.set(appId); - log.info("获取到的appId是 {}", appId); - return appId; - } catch (BizException e) { - throw e; - } catch (Exception e) { - log.error("[clearInfoLogStream] is error", e); - throw new RuntimeException("clearInfoLogStream is error"); - } finally { - this.close(reader, stream, "clearInfoLogStream"); - + } catch (Exception e) { + log.error("threadName={}", threadName); + } finally { + this.close(reader, stream, "clearLogStream"); + } } - } - - - /** - * 关闭流 - * - * @author zhuhuipei - * @date 2021/3/28 - * @time 12:53 - */ - private void close(BufferedReader reader, InputStream stream, String typeName) { - if (reader != null) { - try { - reader.close(); - log.info("[{}]关闭reader ", typeName); - } catch (IOException e) { - log.error("[{}] 关闭reader流失败 ", typeName, e); - } + ); + } + + /** + * 启动日志输出并且从日志中获取成功后的jobId + * + * @author zhuhuipei + * @date 2021/3/28 + * @time 11:15 + */ + private String clearInfoLogStream(InputStream stream, StringBuilder localLog, Long jobRunLogId) { + + String appId = null; + BufferedReader reader = null; + try { + long lastTime = System.currentTimeMillis(); + String result = null; + reader = new BufferedReader(new InputStreamReader(stream, SystemConstants.CODE_UTF_8)); + //按行读取 + while ((result = reader.readLine()) != null) { + log.info("read={}", result); + if (StringUtils.isEmpty(appId) && result.contains(SystemConstant.QUERY_JOBID_KEY_WORD)) { + appId = result.replace(SystemConstant.QUERY_JOBID_KEY_WORD, SystemConstant.SPACE).trim(); + log.info("[job-submitted-success] 解析得到的appId是 {} 原始数据 :{}", appId, result); + localLog.append("[job-submitted-success] 解析得到的appId是:") + .append(appId).append(SystemConstant.LINE_FEED); } - if (stream != null) { - try { - log.info("[{}]关闭stream ", typeName); - stream.close(); - } catch (IOException e) { - log.error("[{}] 关闭stream流失败 ", typeName, e); - } + if (StringUtils.isEmpty(appId) && result + .contains(SystemConstant.QUERY_JOBID_KEY_WORD_BACKUP)) { + appId = result.replace(SystemConstant.QUERY_JOBID_KEY_WORD_BACKUP, SystemConstant.SPACE) + .trim(); + log.info("[Job has been submitted with JobID] 解析得到的appId是 {} 原始数据 :{}", appId, result); + localLog.append("[Job has been submitted with JobID] 解析得到的appId是:") + .append(appId).append(SystemConstant.LINE_FEED); + } + localLog.append(result).append(SystemConstant.LINE_FEED); + //每隔2s更新日志 + if (System.currentTimeMillis() >= lastTime + INTERVAL_TIME_TWO) { + jobRunLogService.updateLogById(localLog.toString(), jobRunLogId); + lastTime = System.currentTimeMillis(); } - log.info("线程池状态: {}", WaitForPoolConfig.getInstance().getThreadPoolExecutor()); + } + if (appId == null || appId.length() != 32) { + log.error("解析appID异常 appId:{}", appId); + throw new BizException("解析appId异常"); + } + JobBaseServiceAOImpl.THREADAPPID.set(appId); + log.info("获取到的appId是 {}", appId); + return appId; + } catch (BizException e) { + throw e; + } catch (Exception e) { + log.error("[clearInfoLogStream] is error", e); + throw new RuntimeException("clearInfoLogStream is error"); + } finally { + this.close(reader, stream, "clearInfoLogStream"); + + } + } + + + /** + * 关闭流 + * + * @author zhuhuipei + * @date 2021/3/28 + * @time 12:53 + */ + private void close(BufferedReader reader, InputStream stream, String typeName) { + if (reader != null) { + try { + reader.close(); + log.info("[{}]关闭reader ", typeName); + } catch (IOException e) { + log.error("[{}] 关闭reader流失败 ", typeName, e); + } + } + if (stream != null) { + try { + log.info("[{}]关闭stream ", typeName); + stream.close(); + } catch (IOException e) { + log.error("[{}] 关闭stream流失败 ", typeName, e); + } } + log.info("线程池状态: {}", WaitForPoolConfig.getInstance().getThreadPoolExecutor()); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/FlinkRestRpcAdapterImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/FlinkRestRpcAdapterImpl.java index 26f17eb8..54764f18 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/FlinkRestRpcAdapterImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/FlinkRestRpcAdapterImpl.java @@ -25,67 +25,70 @@ @Slf4j public class FlinkRestRpcAdapterImpl implements FlinkRestRpcAdapter { - @Autowired - private SystemConfigService systemConfigService; + @Autowired + private SystemConfigService systemConfigService; - @Override - public JobStandaloneInfo getJobInfoForStandaloneByAppId(String appId, DeployModeEnum deployModeEnum) { - if (StringUtils.isEmpty(appId)) { - throw new BizException(SysErrorEnum.HTTP_REQUEST_IS_NULL); - } - String res = null; - JobStandaloneInfo jobStandaloneInfo = null; - try { - String url = HttpUtil.buildUrl(systemConfigService.getFlinkHttpAddress(deployModeEnum), - FlinkYarnRestUriConstants.getUriJobsForStandalone(appId)); - log.info("请求参数:jobId={}, url={}", appId, url); - res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M).getForObject(url, String.class); - log.info("请求参数:jobId={}, url={}, result={}", appId, url, res); - if (StringUtils.isEmpty(res)) { - return null; - } - jobStandaloneInfo = JSON.parseObject(res, JobStandaloneInfo.class); - return jobStandaloneInfo; - } catch (HttpClientErrorException e) { - jobStandaloneInfo = new JobStandaloneInfo(); - jobStandaloneInfo.setErrors(e.getMessage()); - log.error("json 异常 res={}", res, e); - } catch (Exception e) { - log.error("json 异常 res={}", res, e); - } - return jobStandaloneInfo; + @Override + public JobStandaloneInfo getJobInfoForStandaloneByAppId(String appId, + DeployModeEnum deployModeEnum) { + if (StringUtils.isEmpty(appId)) { + throw new BizException(SysErrorEnum.HTTP_REQUEST_IS_NULL); } + String res = null; + JobStandaloneInfo jobStandaloneInfo = null; + try { + String url = HttpUtil.buildUrl(systemConfigService.getFlinkHttpAddress(deployModeEnum), + FlinkYarnRestUriConstants.getUriJobsForStandalone(appId)); + log.info("请求参数:jobId={}, url={}", appId, url); + res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M).getForObject(url, String.class); + log.info("请求参数:jobId={}, url={}, result={}", appId, url, res); + if (StringUtils.isEmpty(res)) { + return null; + } + jobStandaloneInfo = JSON.parseObject(res, JobStandaloneInfo.class); + return jobStandaloneInfo; + } catch (HttpClientErrorException e) { + jobStandaloneInfo = new JobStandaloneInfo(); + jobStandaloneInfo.setErrors(e.getMessage()); + log.error("json 异常 res={}", res, e); + } catch (Exception e) { + log.error("json 异常 res={}", res, e); + } + return jobStandaloneInfo; + } - @Override - public void cancelJobForFlinkByAppId(String jobId, DeployModeEnum deployModeEnum) { - if (StringUtils.isEmpty(jobId)) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - String url = HttpUtil.buildUrl(systemConfigService.getFlinkHttpAddress(deployModeEnum), - FlinkYarnRestUriConstants.getUriCancelForStandalone(jobId)); - log.info("请求参数:jobId={}, url={}", jobId, url); - String res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M).getForObject(url, String.class); - log.info("请求参数:jobId={}, url={}, result={}", jobId, url, res); + @Override + public void cancelJobForFlinkByAppId(String jobId, DeployModeEnum deployModeEnum) { + if (StringUtils.isEmpty(jobId)) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL); } + String url = HttpUtil.buildUrl(systemConfigService.getFlinkHttpAddress(deployModeEnum), + FlinkYarnRestUriConstants.getUriCancelForStandalone(jobId)); + log.info("请求参数:jobId={}, url={}", jobId, url); + String res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M).getForObject(url, String.class); + log.info("请求参数:jobId={}, url={}, result={}", jobId, url, res); + } - @Override - public String savepointPath(String jobId, DeployModeEnum deployModeEnum) { - if (StringUtils.isEmpty(jobId)) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - try { - Thread.sleep(HttpUtil.TIME_OUT_3_S); - String url = HttpUtil.buildUrl(systemConfigService.getFlinkHttpAddress(deployModeEnum), - FlinkYarnRestUriConstants.getUriCheckpoints(jobId)); - log.info("请求参数:jobId={}, url={}", jobId, url); - String res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M).getForObject(url, String.class); - if (StringUtils.isEmpty(res)) { - return null; - } - return JSON.parseObject(res).getJSONObject("latest").getJSONObject("savepoint").getString("external_path"); - } catch (Exception e) { - log.error("savepointPath is error", e); - } + @Override + public String savepointPath(String jobId, DeployModeEnum deployModeEnum) { + if (StringUtils.isEmpty(jobId)) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL); + } + try { + Thread.sleep(HttpUtil.TIME_OUT_3_S); + String url = HttpUtil.buildUrl(systemConfigService.getFlinkHttpAddress(deployModeEnum), + FlinkYarnRestUriConstants.getUriCheckpoints(jobId)); + log.info("请求参数:jobId={}, url={}", jobId, url); + String res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M) + .getForObject(url, String.class); + if (StringUtils.isEmpty(res)) { return null; + } + return JSON.parseObject(res).getJSONObject("latest").getJSONObject("savepoint") + .getString("external_path"); + } catch (Exception e) { + log.error("savepointPath is error", e); } + return null; + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/YarnRestRpcAdapterImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/YarnRestRpcAdapterImpl.java index 5f2f542e..2c7ca90d 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/YarnRestRpcAdapterImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/impl/YarnRestRpcAdapterImpl.java @@ -34,158 +34,159 @@ @Slf4j public class YarnRestRpcAdapterImpl implements YarnRestRpcAdapter { - private final String BODY_HTTP_KILL = "{\"state\":\"KILLED\"}"; + private static final String BODY_HTTP_KILL = "{\"state\":\"KILLED\"}"; - @Autowired - private SystemConfigService systemConfigService; + @Autowired + private SystemConfigService systemConfigService; - //TODO 设个方法设计不好 需要改造 - @Override - public String getAppIdByYarn(String jobName, String queueName) { - if (StringUtils.isEmpty(jobName)) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - String url = systemConfigService.getYarnRmHttpAddress() + SystemConstants.buildHttpQuery(queueName); - RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M); - log.info("请求参数 url={}", url); - String res = restTemplate.getForObject(url, String.class); - - YarnAppInfo yarnAppInfo = JSON.parseObject(res, YarnAppInfo.class); - - this.check(yarnAppInfo, queueName, jobName, url); - - for (AppTO appTO : yarnAppInfo.getApps().getApp()) { - if (JobConfigDTO.buildRunName(jobName).equals(appTO.getName())) { - if (SystemConstants.STATUS_RUNNING.equals(appTO.getState())) { - log.info("任务信息 appTO={}", appTO); - return appTO.getId(); - } else { - log.error("任务运行状态失败 状态是 {}", appTO.getState()); - } - } + //TODO 设个方法设计不好 需要改造 + @Override + public String getAppIdByYarn(String jobName, String queueName) { + if (StringUtils.isEmpty(jobName)) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL); + } + String url = + systemConfigService.getYarnRmHttpAddress() + SystemConstants.buildHttpQuery(queueName); + RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M); + log.info("请求参数 url={}", url); + String res = restTemplate.getForObject(url, String.class); + + YarnAppInfo yarnAppInfo = JSON.parseObject(res, YarnAppInfo.class); + + this.check(yarnAppInfo, queueName, jobName, url); + + for (AppTO appTO : yarnAppInfo.getApps().getApp()) { + if (JobConfigDTO.buildRunName(jobName).equals(appTO.getName())) { + if (SystemConstants.STATUS_RUNNING.equals(appTO.getState())) { + log.info("任务信息 appTO={}", appTO); + return appTO.getId(); + } else { + log.error("任务运行状态失败 状态是 {}", appTO.getState()); } - throw new BizException("yarn队列" + queueName + "中没有找到运行的任务 name=" + - JobConfigDTO.buildRunName(jobName), SysErrorEnum.YARN_CODE.getCode()); + } } + throw new BizException("yarn队列" + queueName + "中没有找到运行的任务 name=" + + JobConfigDTO.buildRunName(jobName), SysErrorEnum.YARN_CODE.getCode()); + } - @Override - public void stopJobByJobId(String appId) { - log.info("执行stopJobByJobId appId={}", appId); - if (StringUtils.isEmpty(appId)) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL_YARN_APPID); - } - String url = HttpUtil.buildUrl(systemConfigService.getYarnRmHttpAddress(), - SystemConstants.HTTP_YARN_APPS + appId + "/state"); - log.info("请求关闭 URL ={}", url); - - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - HttpEntity httpEntity = new HttpEntity(BODY_HTTP_KILL, headers); - RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M); - restTemplate.put(url, httpEntity); + @Override + public void stopJobByJobId(String appId) { + log.info("执行stopJobByJobId appId={}", appId); + if (StringUtils.isEmpty(appId)) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL_YARN_APPID); + } + String url = HttpUtil.buildUrl(systemConfigService.getYarnRmHttpAddress(), + SystemConstants.HTTP_YARN_APPS + appId + "/state"); + log.info("请求关闭 URL ={}", url); + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity httpEntity = new HttpEntity(BODY_HTTP_KILL, headers); + RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M); + restTemplate.put(url, httpEntity); + } + + @Override + public YarnStateEnum getJobStateByJobId(String appId) { + if (StringUtils.isEmpty(appId)) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL_YARN_APPID); } - @Override - public YarnStateEnum getJobStateByJobId(String appId) { - if (StringUtils.isEmpty(appId)) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL_YARN_APPID); - } - - String url = HttpUtil.buildUrl(systemConfigService.getYarnRmHttpAddress(), - SystemConstants.HTTP_YARN_APPS + appId + "/state"); - RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M); - String res = restTemplate.getForObject(url, String.class); - if (StringUtils.isEmpty(res)) { - log.error("请求失败:返回结果为空 url={}", url); - throw new BizException(SysErrorEnum.HTTP_REQUEST_IS_NULL); - } - return YarnStateEnum.getYarnStateEnum(String.valueOf(JSON.parseObject(res).get("state"))); + String url = HttpUtil.buildUrl(systemConfigService.getYarnRmHttpAddress(), + SystemConstants.HTTP_YARN_APPS + appId + "/state"); + RestTemplate restTemplate = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M); + String res = restTemplate.getForObject(url, String.class); + if (StringUtils.isEmpty(res)) { + log.error("请求失败:返回结果为空 url={}", url); + throw new BizException(SysErrorEnum.HTTP_REQUEST_IS_NULL); } + return YarnStateEnum.getYarnStateEnum(String.valueOf(JSON.parseObject(res).get("state"))); + } - @Override - public JobInfo getJobInfoForPerYarnByAppId(String appId) { - if (StringUtils.isEmpty(appId)) { - throw new BizException(SysErrorEnum.HTTP_REQUEST_IS_NULL); - } - String res = null; - try { - String url = HttpUtil.buildUrl(systemConfigService.getYarnRmHttpAddress(), - FlinkYarnRestUriConstants.getUriJobsForYarn(appId)); - log.info("[getJobInfoForPerYarnByAppId]请求参数 appId={} url={}", appId, url); - res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M).getForObject(url, String.class); - if (StringUtils.isEmpty(res)) { - return null; - } - JSONArray jsonArray = (JSONArray) JSON.parseObject(res).get("jobs"); - JSONObject jsonObject = (JSONObject) jsonArray.get(0); - JobInfo jobInfo = new JobInfo(); - jobInfo.setId((String) jsonObject.get("id")); - jobInfo.setStatus((String) jsonObject.get("status")); - return jobInfo; - } catch (Exception e) { - log.error("[getJobInfoForPerYarnByAppId] 错误 ", e); - } + @Override + public JobInfo getJobInfoForPerYarnByAppId(String appId) { + if (StringUtils.isEmpty(appId)) { + throw new BizException(SysErrorEnum.HTTP_REQUEST_IS_NULL); + } + String res = null; + try { + String url = HttpUtil.buildUrl(systemConfigService.getYarnRmHttpAddress(), + FlinkYarnRestUriConstants.getUriJobsForYarn(appId)); + log.info("[getJobInfoForPerYarnByAppId]请求参数 appId={} url={}", appId, url); + res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M).getForObject(url, String.class); + if (StringUtils.isEmpty(res)) { return null; + } + JSONArray jsonArray = (JSONArray) JSON.parseObject(res).get("jobs"); + JSONObject jsonObject = (JSONObject) jsonArray.get(0); + JobInfo jobInfo = new JobInfo(); + jobInfo.setId((String) jsonObject.get("id")); + jobInfo.setStatus((String) jsonObject.get("status")); + return jobInfo; + } catch (Exception e) { + log.error("[getJobInfoForPerYarnByAppId] 错误 ", e); } + return null; + } - @Override - public void cancelJobForYarnByAppId(String appId, String jobId) { - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(jobId)) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - String url = HttpUtil.buildUrl(systemConfigService.getYarnRmHttpAddress(), - FlinkYarnRestUriConstants.getUriCancelForYarn(appId, jobId)); - log.info("[cancelJobByAppId]请求参数 appId={} jobId={} url={}", appId, jobId, url); - String res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M).getForObject(url, String.class); - log.info("[cancelJobByAppId]请求参数结果: res={}", res); + @Override + public void cancelJobForYarnByAppId(String appId, String jobId) { + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(jobId)) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL); } + String url = HttpUtil.buildUrl(systemConfigService.getYarnRmHttpAddress(), + FlinkYarnRestUriConstants.getUriCancelForYarn(appId, jobId)); + log.info("[cancelJobByAppId]请求参数 appId={} jobId={} url={}", appId, jobId, url); + String res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_1_M).getForObject(url, String.class); + log.info("[cancelJobByAppId]请求参数结果: res={}", res); + } - @Override - public String getSavepointPath(String appId, String jobId) { - - if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(jobId)) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - String url = HttpUtil.buildUrl(systemConfigService.getYarnRmHttpAddress(), - FlinkYarnRestUriConstants.getUriCheckpointForYarn(appId, jobId)); - log.info("[getSavepointPath]请求参数 appId={} jobId={} url={}", appId, jobId, url); - String res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_5_M).getForObject(url, String.class); - log.info("[getSavepointPath]请求参数结果: res={}", res); - if (StringUtils.isEmpty(res)) { - return null; - } - try { - JSONObject jsonObject = (JSONObject) JSON.parseObject(res).get("latest"); - JSONObject savepoint = (JSONObject) jsonObject.get("savepoint"); - if (savepoint == null) { - return null; - } - return (String) savepoint.get("external_path"); - } catch (Exception e) { - log.error("json 异常 res={}", res, e); - } + @Override + public String getSavepointPath(String appId, String jobId) { + if (StringUtils.isEmpty(appId) || StringUtils.isEmpty(jobId)) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL); + } + String url = HttpUtil.buildUrl(systemConfigService.getYarnRmHttpAddress(), + FlinkYarnRestUriConstants.getUriCheckpointForYarn(appId, jobId)); + log.info("[getSavepointPath]请求参数 appId={} jobId={} url={}", appId, jobId, url); + String res = HttpUtil.buildRestTemplate(HttpUtil.TIME_OUT_5_M).getForObject(url, String.class); + log.info("[getSavepointPath]请求参数结果: res={}", res); + if (StringUtils.isEmpty(res)) { + return null; + } + try { + JSONObject jsonObject = (JSONObject) JSON.parseObject(res).get("latest"); + JSONObject savepoint = (JSONObject) jsonObject.get("savepoint"); + if (savepoint == null) { return null; + } + return (String) savepoint.get("external_path"); + } catch (Exception e) { + log.error("json 异常 res={}", res, e); } - private void check(YarnAppInfo yarnAppInfo, String queueName, String jobName, String url) { - if (yarnAppInfo == null) { - log.error("在队列" + queueName + "没有找到任何yarn上的任务 url={}", url); - throw new BizException("yarn队列" + queueName + "中没有找到运行的任务 name=" + - JobConfigDTO.buildRunName(jobName), SysErrorEnum.YARN_CODE.getCode()); - } - if (yarnAppInfo.getApps() == null) { - log.error("yarnAppInfo.getApps() is null", yarnAppInfo); - throw new BizException("yarn队列" + queueName + "中没有找到运行的任务 name=" + - JobConfigDTO.buildRunName(jobName), SysErrorEnum.YARN_CODE.getCode()); - } - if (yarnAppInfo.getApps().getApp() == null || yarnAppInfo.getApps().getApp().size() <= 0) { - log.error("yarnAppInfo.getApps().getApp() is null", yarnAppInfo); - throw new BizException("yarn队列" + queueName + "中没有找到运行的任务 name=" + - JobConfigDTO.buildRunName(jobName), SysErrorEnum.YARN_CODE.getCode()); - } + return null; + } + + private void check(YarnAppInfo yarnAppInfo, String queueName, String jobName, String url) { + if (yarnAppInfo == null) { + log.error("在队列" + queueName + "没有找到任何yarn上的任务 url={}", url); + throw new BizException("yarn队列" + queueName + "中没有找到运行的任务 name=" + + JobConfigDTO.buildRunName(jobName), SysErrorEnum.YARN_CODE.getCode()); + } + if (yarnAppInfo.getApps() == null) { + log.error("yarnAppInfo.getApps() is null", yarnAppInfo); + throw new BizException("yarn队列" + queueName + "中没有找到运行的任务 name=" + + JobConfigDTO.buildRunName(jobName), SysErrorEnum.YARN_CODE.getCode()); + } + if (yarnAppInfo.getApps().getApp() == null || yarnAppInfo.getApps().getApp().size() <= 0) { + log.error("yarnAppInfo.getApps().getApp() is null", yarnAppInfo); + throw new BizException("yarn队列" + queueName + "中没有找到运行的任务 name=" + + JobConfigDTO.buildRunName(jobName), SysErrorEnum.YARN_CODE.getCode()); } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/model/JobInfo.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/model/JobInfo.java index f13b96c4..44cc86f3 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/model/JobInfo.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/model/JobInfo.java @@ -11,9 +11,9 @@ @Data public class JobInfo { - private String id; + private String id; - private String status; + private String status; } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/model/JobStandaloneInfo.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/model/JobStandaloneInfo.java index e1a20b15..d1d82b4d 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/model/JobStandaloneInfo.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/rpc/model/JobStandaloneInfo.java @@ -11,11 +11,11 @@ @Data public class JobStandaloneInfo { - private String jid; + private String jid; - private String state; + private String state; - private String errors; + private String errors; } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/runner/ApplicationRunner.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/runner/ApplicationRunner.java index c5f454b1..170563f6 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/runner/ApplicationRunner.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/runner/ApplicationRunner.java @@ -23,14 +23,14 @@ public class ApplicationRunner implements org.springframework.boot.ApplicationRunner { - @Autowired - private IpStatusService ipStatusService; + @Autowired + private IpStatusService ipStatusService; - @Override - public void run(ApplicationArguments args) throws Exception { - ipStatusService.registerIp(); - } + @Override + public void run(ApplicationArguments args) throws Exception { + ipStatusService.registerIp(); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/scheduler/SchedulerTask.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/scheduler/SchedulerTask.java index c49fd099..430ac10b 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/scheduler/SchedulerTask.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/scheduler/SchedulerTask.java @@ -26,57 +26,56 @@ public class SchedulerTask { - @Autowired - private IpStatusService ipStatusService; - - - @Autowired - private TaskServiceAO taskServiceAO; - - @Autowired - private SystemConfigService systemConfigService; - - - /** - * 每个1分钟更新一次心跳时间 - * - * @author zhuhuipei - * @date 2020-09-22 - * @time 19:52 - */ - @Async("taskExecutor") - @Scheduled(cron = "0 */1 * * * ?") - public void checkHeartbeat() { - log.debug("#####心跳检查checkHeartbeat#######"); - try { - ipStatusService.updateHeartbeatBylocalIp(); - } catch (Exception e) { - log.error("心跳检查失败", e); - } + @Autowired + private IpStatusService ipStatusService; + + + @Autowired + private TaskServiceAO taskServiceAO; + + @Autowired + private SystemConfigService systemConfigService; + + + /** + * 每个1分钟更新一次心跳时间 + * + * @author zhuhuipei + * @date 2020-09-22 + * @time 19:52 + */ + @Async("taskExecutor") + @Scheduled(cron = "0 */1 * * * ?") + public void checkHeartbeat() { + log.debug("#####心跳检查checkHeartbeat#######"); + try { + ipStatusService.updateHeartbeatBylocalIp(); + } catch (Exception e) { + log.error("心跳检查失败", e); } - - - /** - * 每隔5分钟进行一次一致性校验检查(如果校验失败会进行告警) - * - * @author zhuhuipei - * @date 2020-09-22 - * @time 23:45 - */ - @Async("taskExecutor") - @Scheduled(cron = "0 */5 * * * ?") - public void checkJobStatus() { - if (!ipStatusService.isLeader()) { - return; - } - log.info("#####[task]一致性校验检查#######"); - try { - taskServiceAO.checkJobStatus(); - } catch (Exception e) { - log.error("checkJobStatusByYarn is error", e); - } + } + + + /** + * 每隔5分钟进行一次一致性校验检查(如果校验失败会进行告警) + * + * @author zhuhuipei + * @date 2020-09-22 + * @time 23:45 + */ + @Async("taskExecutor") + @Scheduled(cron = "0 */5 * * * ?") + public void checkJobStatus() { + if (!ipStatusService.isLeader()) { + return; } - + log.info("#####[task]一致性校验检查#######"); + try { + taskServiceAO.checkJobStatus(); + } catch (Exception e) { + log.error("checkJobStatusByYarn is error", e); + } + } // /** // * 每隔20分钟进行一次对停止任务进行是否在yarn上运行的检查 @@ -100,32 +99,32 @@ public void checkJobStatus() { // } - /** - * 每隔1小时进行一次自动savePoint - * - * @author zhuhuipei - * @date 2020-09-22 - * @time 23:45 - */ - @Async("taskExecutor") - @Scheduled(cron = "0 0 */1 * * ?") + /** + * 每隔1小时进行一次自动savePoint + * + * @author zhuhuipei + * @date 2020-09-22 + * @time 23:45 + */ + @Async("taskExecutor") + @Scheduled(cron = "0 0 */1 * * ?") //@Scheduled(cron = "0 */1 * * * ?") - public void autoSavePoint() { - if (!systemConfigService.autoSavepoint()){ - log.info("#####没有开启自动savePoint#######"); - return; - } - - if (!ipStatusService.isLeader()) { - return; - } - log.info("#####[task]开始自动执行savePoint#######"); - try { - taskServiceAO.autoSavePoint(); - } catch (Exception e) { - log.error("autoSavePoint is error", e); - } + public void autoSavePoint() { + if (!systemConfigService.autoSavepoint()) { + log.info("#####没有开启自动savePoint#######"); + return; + } + + if (!ipStatusService.isLeader()) { + return; + } + log.info("#####[task]开始自动执行savePoint#######"); + try { + taskServiceAO.autoSavePoint(); + } catch (Exception e) { + log.error("autoSavePoint is error", e); } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/AlartLogService.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/AlartLogService.java index 8c35c1d8..fcab66a8 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/AlartLogService.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/AlartLogService.java @@ -13,33 +13,33 @@ public interface AlartLogService { - /** - * 新增日志 - * - * @author zhuhuipei - * @date 2020-09-25 - * @time 21:49 - */ - void addAlartLog(AlartLogDTO alartLogDTO); - - - /** - * 按照id查询 - * - * @author zhuhuipei - * @date 2020-09-25 - * @time 21:49 - */ - AlartLogDTO findLogById(Long id); - - - /** - * 按照条件查询 - * - * @author zhuhuipei - * @date 2020-09-25 - * @time 21:51 - */ - PageModel queryAlartLog(AlartLogParam alartLogParam); + /** + * 新增日志 + * + * @author zhuhuipei + * @date 2020-09-25 + * @time 21:49 + */ + void addAlartLog(AlartLogDTO alartLogDTO); + + + /** + * 按照id查询 + * + * @author zhuhuipei + * @date 2020-09-25 + * @time 21:49 + */ + AlartLogDTO findLogById(Long id); + + + /** + * 按照条件查询 + * + * @author zhuhuipei + * @date 2020-09-25 + * @time 21:51 + */ + PageModel queryAlartLog(AlartLogParam alartLogParam); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/IpStatusService.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/IpStatusService.java index 048b5e89..b95cdf28 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/IpStatusService.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/IpStatusService.java @@ -8,42 +8,42 @@ */ public interface IpStatusService { - /** - * 服务启动修改状态 - * - * @author zhuhuipei - * @date 2020-07-20 - * @time 02:27 - */ - void registerIp(); - - - /** - * 服务关闭修改状态 - * - * @author zhuhuipei - * @date 2020-07-20 - * @time 02:27 - */ - void cancelIp(); - - - /** - * 更新最后心跳时间 - * - * @author zhuhuipei - * @date 2020-09-22 - * @time 19:01 - */ - void updateHeartbeatBylocalIp(); - - - /** - * 检查本机是不是leader - * - * @author zhuhuipei - * @date 2020-09-22 - * @time 19:53 - */ - boolean isLeader(); + /** + * 服务启动修改状态 + * + * @author zhuhuipei + * @date 2020-07-20 + * @time 02:27 + */ + void registerIp(); + + + /** + * 服务关闭修改状态 + * + * @author zhuhuipei + * @date 2020-07-20 + * @time 02:27 + */ + void cancelIp(); + + + /** + * 更新最后心跳时间 + * + * @author zhuhuipei + * @date 2020-09-22 + * @time 19:01 + */ + void updateHeartbeatBylocalIp(); + + + /** + * 检查本机是不是leader + * + * @author zhuhuipei + * @date 2020-09-22 + * @time 19:53 + */ + boolean isLeader(); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobAlarmConfigService.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobAlarmConfigService.java index b4284dd2..23d40891 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobAlarmConfigService.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobAlarmConfigService.java @@ -13,31 +13,30 @@ */ public interface JobAlarmConfigService { - /** - * 批量新增/修改 - * - * @author zhuhuipei - * @date 2021/2/27 - * @time 17:49 - */ - void upSertBatchJobAlarmConfig(List alarmTypeEnumList, Long jobId); - - - /** - * 按jobId查询 - * - * @author zhuhuipei - * @date 2021/2/27 - * @time 17:53 - */ - List findByJobId(Long jobId); - - - /** - * - * @author zhuhuipei - */ - Map> findByJobIdList(List jobIdList); + /** + * 批量新增/修改 + * + * @author zhuhuipei + * @date 2021/2/27 + * @time 17:49 + */ + void upSertBatchJobAlarmConfig(List alarmTypeEnumList, Long jobId); + + + /** + * 按jobId查询 + * + * @author zhuhuipei + * @date 2021/2/27 + * @time 17:53 + */ + List findByJobId(Long jobId); + + + /** + * @author zhuhuipei + */ + Map> findByJobIdList(List jobIdList); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobConfigHistoryService.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobConfigHistoryService.java index c214064f..2acee3c3 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobConfigHistoryService.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobConfigHistoryService.java @@ -14,44 +14,44 @@ */ public interface JobConfigHistoryService { - /** - * 新增记录 - * - * @author zhuhuipei - * @date 2021/5/5 - * @time 20:13 - */ - void insertJobConfigHistory(JobConfigHistoryDTO jobConfigHistoryDTO); - - - /** - * 查询历史记录 - * - * @author zhuhuipei - * @date 2021/5/5 - * @time 20:13 - */ - List getJobConfigHistoryByJobConfigId(Long jobConfigId); - - - /** - * 详情 - * - * @author zhuhuipei - * @date 2021/5/5 - * @time 20:14 - */ - JobConfigHistoryDTO getJobConfigHistoryById(Long id); - - /** - * 分页查询 - * - * @param jobConfigParam - * @return - * @author wxj - * @date 2021年12月20日 上午11:11:56 - * @version V1.0 - */ - PageModel queryJobConfigHistory(JobConfigHisotryParam jobConfigParam); + /** + * 新增记录 + * + * @author zhuhuipei + * @date 2021/5/5 + * @time 20:13 + */ + void insertJobConfigHistory(JobConfigHistoryDTO jobConfigHistoryDTO); + + + /** + * 查询历史记录 + * + * @author zhuhuipei + * @date 2021/5/5 + * @time 20:13 + */ + List getJobConfigHistoryByJobConfigId(Long jobConfigId); + + + /** + * 详情 + * + * @author zhuhuipei + * @date 2021/5/5 + * @time 20:14 + */ + JobConfigHistoryDTO getJobConfigHistoryById(Long id); + + /** + * 分页查询 + * + * @param jobConfigParam + * @return + * @author wxj + * @date 2021年12月20日 上午11:11:56 + * @version V1.0 + */ + PageModel queryJobConfigHistory(JobConfigHisotryParam jobConfigParam); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobConfigService.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobConfigService.java index 349d1557..00cdc1fa 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobConfigService.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobConfigService.java @@ -16,121 +16,121 @@ */ public interface JobConfigService { - /** - * 新增配置 - * 返回主键Id - * - * @author zhuhuipei - * @date 2020-07-14 - * @time 19:26 - */ - Long addJobConfig(JobConfigDTO jobConfigDTO); - - - /** - * 修改配置 - * - * @author zhuhuipei - * @date 2020-07-14 - * @time 19:26 - */ - void updateJobConfigById(JobConfigDTO jobConfigDTO); - - /** - * 修改配置(记录历史信息) - * - * @param jobConfigDTO - * @author wxj - * @date 2021年12月30日 下午2:33:31 - * @version V1.0 - */ - void updateJobConfigByIdWithWriteHistory(JobConfigDTO jobConfigDTO); - - - /** - * @author zhuhuipei - * @date 2020-08-18 - * @time 19:01 - */ - void updateJobConfigStatusById(Long id, JobConfigStatus jobConfigStatus); - - - /** - * 启动状态更新 有乐观锁 - * @author zhuhuipei - * @date 2021/2/28 - * @time 17:57 - */ - void updateStatusByStart(Long id, String userName, Long jobRunLogId, Integer version); - - /** - * 单个查询任务详情 - * - * @author zhuhuipei - * @date 2020-07-14 - * @time 23:05 - */ - JobConfigDTO getJobConfigById(Long id); - - /** - * 单个查询任务详情(包括删除) - * - * @param id - * @return - * @author wxj - * @date 2021年12月28日 下午1:48:07 - * @version V1.0 - */ - JobConfigDTO getJobConfigByIdContainDelete(Long id); - - /** - * 开启或者配置 - * - * @author zhuhuipei - * @date 2020-07-14 - * @time 19:27 - */ - void openOrClose(Long id, YN yn, String userName); - - - /** - * 删除任务 - * - * @author zhuhuipei - * @date 2020-07-14 - * @time 23:03 - */ - void deleteJobConfigById(Long id, String userName); - - /** - * 恢复删除任务 - * - * @param id - * @param userName - * @author wxj - * @date 2021年12月28日 下午2:07:31 - * @version V1.0 - */ - int recoveryDeleteJobConfigById(Long id, String userName); - - /** - * 分页查询 - * - * @author zhuhuipei - * @date 2020-07-15 - * @time 02:04 - */ - PageModel queryJobConfig(JobConfigParam jobConfigParam); - - - /** - * 按状态获取任务 - * - * @author zhuhuipei - * @date 2020-09-22 - * @time 23:04 - */ - List findJobConfigByStatus(Integer... status); + /** + * 新增配置 返回主键Id + * + * @author zhuhuipei + * @date 2020-07-14 + * @time 19:26 + */ + Long addJobConfig(JobConfigDTO jobConfigDTO); + + + /** + * 修改配置 + * + * @author zhuhuipei + * @date 2020-07-14 + * @time 19:26 + */ + void updateJobConfigById(JobConfigDTO jobConfigDTO); + + /** + * 修改配置(记录历史信息) + * + * @param jobConfigDTO + * @author wxj + * @date 2021年12月30日 下午2:33:31 + * @version V1.0 + */ + void updateJobConfigByIdWithWriteHistory(JobConfigDTO jobConfigDTO); + + + /** + * @author zhuhuipei + * @date 2020-08-18 + * @time 19:01 + */ + void updateJobConfigStatusById(Long id, JobConfigStatus jobConfigStatus); + + + /** + * 启动状态更新 有乐观锁 + * + * @author zhuhuipei + * @date 2021/2/28 + * @time 17:57 + */ + void updateStatusByStart(Long id, String userName, Long jobRunLogId, Integer version); + + /** + * 单个查询任务详情 + * + * @author zhuhuipei + * @date 2020-07-14 + * @time 23:05 + */ + JobConfigDTO getJobConfigById(Long id); + + /** + * 单个查询任务详情(包括删除) + * + * @param id + * @return + * @author wxj + * @date 2021年12月28日 下午1:48:07 + * @version V1.0 + */ + JobConfigDTO getJobConfigByIdContainDelete(Long id); + + /** + * 开启或者配置 + * + * @author zhuhuipei + * @date 2020-07-14 + * @time 19:27 + */ + void openOrClose(Long id, YN yn, String userName); + + + /** + * 删除任务 + * + * @author zhuhuipei + * @date 2020-07-14 + * @time 23:03 + */ + void deleteJobConfigById(Long id, String userName); + + /** + * 恢复删除任务 + * + * @param id + * @param userName + * @author wxj + * @date 2021年12月28日 下午2:07:31 + * @version V1.0 + */ + int recoveryDeleteJobConfigById(Long id, String userName); + + /** + * 分页查询 + * + * @author zhuhuipei + * @date 2020-07-15 + * @time 02:04 + */ + PageModel queryJobConfig(JobConfigParam jobConfigParam); + + + /** + * 按状态获取任务 + * + * @author zhuhuipei + * @date 2020-09-22 + * @time 23:04 + */ + List findJobConfigByStatus(Integer... status); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobRunLogService.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobRunLogService.java index ce771eb3..4491f976 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobRunLogService.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/JobRunLogService.java @@ -12,62 +12,62 @@ */ public interface JobRunLogService { - /** - * 新增任务 返回主键 - * - * @author zhuhuipei - * @date 2020-08-17 - * @time 00:33 - */ - Long insertJobRunLog(JobRunLogDTO jobRunLogDTO); + /** + * 新增任务 返回主键 + * + * @author zhuhuipei + * @date 2020-08-17 + * @time 00:33 + */ + Long insertJobRunLog(JobRunLogDTO jobRunLogDTO); - /** - * 日志更新 - * - * @author zhuhuipei - * @date 2020-08-24 - * @time 21:08 - */ - void updateLogById(String log, Long id); + /** + * 日志更新 + * + * @author zhuhuipei + * @date 2020-08-24 + * @time 21:08 + */ + void updateLogById(String log, Long id); - /** - * 更新 - * - * @author zhuhuipei - * @date 2020-08-18 - * @time 19:17 - */ - void updateJobRunLogById(JobRunLogDTO jobRunLogDTO); + /** + * 更新 + * + * @author zhuhuipei + * @date 2020-08-18 + * @time 19:17 + */ + void updateJobRunLogById(JobRunLogDTO jobRunLogDTO); - /** - * 日志功能查询 - * - * @author zhuhuipei - * @date 2020-08-17 - * @time 20:45 - */ - PageModel queryJobRunLog(JobRunLogParam jobRunLogParam); + /** + * 日志功能查询 + * + * @author zhuhuipei + * @date 2020-08-17 + * @time 20:45 + */ + PageModel queryJobRunLog(JobRunLogParam jobRunLogParam); - /** - * 单个日志详情 - * - * @author zhuhuipei - * @date 2020-08-17 - * @time 19:49 - */ - JobRunLogDTO getDetailLogById(Long id); + /** + * 单个日志详情 + * + * @author zhuhuipei + * @date 2020-08-17 + * @time 19:49 + */ + JobRunLogDTO getDetailLogById(Long id); - /** - * 删除日志 - * - * @author zhuhuipei - * @date 2020-08-30 - * @time 23:44 - */ - void deleteLogByJobConfigId(Long jobConfigId); + /** + * 删除日志 + * + * @author zhuhuipei + * @date 2020-08-30 + * @time 23:44 + */ + void deleteLogByJobConfigId(Long jobConfigId); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/SavepointBackupService.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/SavepointBackupService.java index 7e49a66a..06d6d241 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/SavepointBackupService.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/SavepointBackupService.java @@ -13,33 +13,33 @@ */ public interface SavepointBackupService { - /** - * 新增 - * - * @author zhuhuipei - * @date 2020-09-17 - * @time 20:34 - */ - void insertSavepoint(Long jobConfigId, String savepointPath, Date backupTime); - - - /** - * 最近5条 - * - * @author zhuhuipei - * @date 2020-09-17 - * @time 20:34 - */ - List lasterHistory10(Long jobConfigId); - - - /** - * 获取SavepointPath详细地址 - * - * @author zhuhuipei - * @date 2020-09-21 - * @time 00:44 - */ - String getSavepointPathById(Long jobConfigId, Long id); + /** + * 新增 + * + * @author zhuhuipei + * @date 2020-09-17 + * @time 20:34 + */ + void insertSavepoint(Long jobConfigId, String savepointPath, Date backupTime); + + + /** + * 最近5条 + * + * @author zhuhuipei + * @date 2020-09-17 + * @time 20:34 + */ + List lasterHistory10(Long jobConfigId); + + + /** + * 获取SavepointPath详细地址 + * + * @author zhuhuipei + * @date 2020-09-21 + * @time 00:44 + */ + String getSavepointPathById(Long jobConfigId, Long id); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/SystemConfigService.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/SystemConfigService.java index cd64e3db..5888bd7e 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/SystemConfigService.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/SystemConfigService.java @@ -15,80 +15,81 @@ public interface SystemConfigService { - /** - * 新增或者修改配置 - * - * @author zhuhuipei - * @date 2020-08-06 - * @time 23:48 - */ - void addOrUpdateConfigByKey(String key, String value); - - - /** - * 查询配置 - * - * @author zhuhuipei - * @date 2020-07-20 - * @time 01:11 - */ - List getSystemConfig(SysConfigEnumType sysConfigEnumType); - - - /** - * 删除一个配置 - * - * @author zhuhuipei - * @date 2020-08-06 - * @time 20:18 - */ - void deleteConfigByKey(String key); - - - /** - * 根据key获取配置的值 - * - * @author zhuhuipei - * @date 2020-08-06 - * @time 20:21 - */ - String getSystemConfigByKey(String key); - - - /** - * 获取yarn的rm Http地址 - * - * @author zhuhuipei - * @date 2020-09-18 - * @time 01:23 - */ - String getYarnRmHttpAddress(); - - - /** - * 获取flink地址 - * - * @author zhuhuipei - * @date 2020/11/4 - * @time 10:52 - */ - String getFlinkHttpAddress(DeployModeEnum deployModeEnum); - - - /** - * 检查配置是否存在 - * - * @author zhuhuipei - * @date 2020-10-14 - * @time 21:41 - */ - boolean isExist(String key); - - - /** - * 是否自动开启savepoint (默认是true) - * @return - */ - boolean autoSavepoint(); + /** + * 新增或者修改配置 + * + * @author zhuhuipei + * @date 2020-08-06 + * @time 23:48 + */ + void addOrUpdateConfigByKey(String key, String value); + + + /** + * 查询配置 + * + * @author zhuhuipei + * @date 2020-07-20 + * @time 01:11 + */ + List getSystemConfig(SysConfigEnumType sysConfigEnumType); + + + /** + * 删除一个配置 + * + * @author zhuhuipei + * @date 2020-08-06 + * @time 20:18 + */ + void deleteConfigByKey(String key); + + + /** + * 根据key获取配置的值 + * + * @author zhuhuipei + * @date 2020-08-06 + * @time 20:21 + */ + String getSystemConfigByKey(String key); + + + /** + * 获取yarn的rm Http地址 + * + * @author zhuhuipei + * @date 2020-09-18 + * @time 01:23 + */ + String getYarnRmHttpAddress(); + + + /** + * 获取flink地址 + * + * @author zhuhuipei + * @date 2020/11/4 + * @time 10:52 + */ + String getFlinkHttpAddress(DeployModeEnum deployModeEnum); + + + /** + * 检查配置是否存在 + * + * @author zhuhuipei + * @date 2020-10-14 + * @time 21:41 + */ + boolean isExist(String key); + + + /** + * 是否自动开启savepoint (默认是true) + * + * @return + */ + boolean autoSavepoint(); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/UserService.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/UserService.java index 2a49e34e..b50a2fa3 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/UserService.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/UserService.java @@ -5,8 +5,6 @@ import com.flink.streaming.web.model.dto.UserDTO; import com.flink.streaming.web.model.dto.UserSession; import com.flink.streaming.web.model.page.PageParam; -import com.github.pagehelper.Page; - import java.util.List; /** @@ -17,118 +15,118 @@ */ public interface UserService { - /** - * 登陆校验,并且返回sessionId - * - * @author zhuhuipei - * @date 2020-07-13 - * @time 21:54 - */ - String login(String userName, String password); - - - /** - * 登陆帐号Session校验 - * - * @author zhuhuipei - * @date 2020-07-13 - * @time 00:11 - */ - boolean checkLogin(UserSession userSession); - - - /** - * 新增用户 - * - * @author zhuhuipei - * @date 2020/11/11 - * @time 22:59 - */ - void addUser(String userName, String fullname, String password, String operator); - - - /** - * 修改密码 - * - * @author zhuhuipei - * @date 2020/11/11 - * @time 23:00 - */ - void updatePassword(String userName, String oldPassword, String newPassword, String operator); - - /** - * 修改密码 - * - * @param userId - * @param password - * @param operator - * @author wxj - * @date 2021年12月1日 下午1:56:14 - * @version V1.0 - */ - void updatePassword(Integer userId, String password, String operator); - - /** - * 修改用户名称 - * - * @param userName - * @param name - * @param operator - * @author wxj - * @date 2021年12月1日 上午10:17:26 - * @version V1.0 - */ - void updateFullName(Integer userid, String fullname, String operator); - - /** - * 开启或者关闭 - * - * @author zhuhuipei - * @date 2020/11/11 - * @time 23:22 - */ - void stopOrOpen(String userName, UserStatusEnum userStatusEnum, String operator); - - - /** - * 获取全部账号 - * - * @author zhuhuipei - * @date 2020/11/11 - * @time 23:31 - */ - List queryAll(); - - /** - * 获取全部账号(分布) - * - * @param pageparam - * @return - * @author wxj - * @date 2021年12月14日 下午4:01:57 - * @version V1.0 - */ - PageModel queryAllByPage(PageParam pageparam); - - /** - * 根据用户名称查询用户 - * - * @param userName - * @return - * @author wxj - * @date 2021年11月30日 上午11:45:36 - * @version V1.0 - */ - UserDTO qyeryByUserName(String userName); - - /** - * 根据用户编号查询用户 - * - * @param userName - * @return - * @author wxj - * @date 2021年11月30日 上午11:45:36 - * @version V1.0 - */ - UserDTO qyeryByUserId(Integer userid); + /** + * 登陆校验,并且返回sessionId + * + * @author zhuhuipei + * @date 2020-07-13 + * @time 21:54 + */ + String login(String userName, String password); + + + /** + * 登陆帐号Session校验 + * + * @author zhuhuipei + * @date 2020-07-13 + * @time 00:11 + */ + boolean checkLogin(UserSession userSession); + + + /** + * 新增用户 + * + * @author zhuhuipei + * @date 2020/11/11 + * @time 22:59 + */ + void addUser(String userName, String fullname, String password, String operator); + + + /** + * 修改密码 + * + * @author zhuhuipei + * @date 2020/11/11 + * @time 23:00 + */ + void updatePassword(String userName, String oldPassword, String newPassword, String operator); + + /** + * 修改密码 + * + * @param userId + * @param password + * @param operator + * @author wxj + * @date 2021年12月1日 下午1:56:14 + * @version V1.0 + */ + void updatePassword(Integer userId, String password, String operator); + + /** + * 修改用户名称 + * + * @param userName + * @param name + * @param operator + * @author wxj + * @date 2021年12月1日 上午10:17:26 + * @version V1.0 + */ + void updateFullName(Integer userid, String fullname, String operator); + + /** + * 开启或者关闭 + * + * @author zhuhuipei + * @date 2020/11/11 + * @time 23:22 + */ + void stopOrOpen(String userName, UserStatusEnum userStatusEnum, String operator); + + + /** + * 获取全部账号 + * + * @author zhuhuipei + * @date 2020/11/11 + * @time 23:31 + */ + List queryAll(); + + /** + * 获取全部账号(分布) + * + * @param pageparam + * @return + * @author wxj + * @date 2021年12月14日 下午4:01:57 + * @version V1.0 + */ + PageModel queryAllByPage(PageParam pageparam); + + /** + * 根据用户名称查询用户 + * + * @param userName + * @return + * @author wxj + * @date 2021年11月30日 上午11:45:36 + * @version V1.0 + */ + UserDTO qyeryByUserName(String userName); + + /** + * 根据用户编号查询用户 + * + * @param userName + * @return + * @author wxj + * @date 2021年11月30日 上午11:45:36 + * @version V1.0 + */ + UserDTO qyeryByUserId(Integer userid); } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/AlartLogServiceImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/AlartLogServiceImpl.java index 8d850caa..c54a860f 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/AlartLogServiceImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/AlartLogServiceImpl.java @@ -24,42 +24,42 @@ public class AlartLogServiceImpl implements AlartLogService { - @Autowired - private AlarmLogMapper alarmLogMapper; + @Autowired + private AlarmLogMapper alarmLogMapper; - @Override - public void addAlartLog(AlartLogDTO alartLogDTO) { - if (alartLogDTO == null) { - return; - } - alarmLogMapper.insert(AlartLogDTO.toEntity(alartLogDTO)); + @Override + public void addAlartLog(AlartLogDTO alartLogDTO) { + if (alartLogDTO == null) { + return; } + alarmLogMapper.insert(AlartLogDTO.toEntity(alartLogDTO)); + } - @Override - public AlartLogDTO findLogById(Long id) { - return AlartLogDTO.toDTO(alarmLogMapper.selectByPrimaryKey(id)); - } - - @Override - public PageModel queryAlartLog(AlartLogParam alartLogParam) { - if (alartLogParam == null) { - alartLogParam = new AlartLogParam(); - } - PageHelper.startPage(alartLogParam.getPageNum(), alartLogParam.getPageSize(), YN.Y.getCode()); + @Override + public AlartLogDTO findLogById(Long id) { + return AlartLogDTO.toDTO(alarmLogMapper.selectByPrimaryKey(id)); + } - //只能查最近30天的 - Page page = alarmLogMapper.selectByParam(alartLogParam); - if (page == null) { - return null; - } - PageModel pageModel = new PageModel<>(); - pageModel.setPageNum(page.getPageNum()); - pageModel.setPages(page.getPages()); - pageModel.setPageSize(page.getPageSize()); - pageModel.setTotal(page.getTotal()); - pageModel.addAll(AlartLogDTO.toListDTO(page.getResult())); - return pageModel; + @Override + public PageModel queryAlartLog(AlartLogParam alartLogParam) { + if (alartLogParam == null) { + alartLogParam = new AlartLogParam(); + } + PageHelper.startPage(alartLogParam.getPageNum(), alartLogParam.getPageSize(), YN.Y.getCode()); + //只能查最近30天的 + Page page = alarmLogMapper.selectByParam(alartLogParam); + if (page == null) { + return null; } + PageModel pageModel = new PageModel<>(); + pageModel.setPageNum(page.getPageNum()); + pageModel.setPages(page.getPages()); + pageModel.setPageSize(page.getPageSize()); + pageModel.setTotal(page.getTotal()); + pageModel.addAll(AlartLogDTO.toListDTO(page.getResult())); + return pageModel; + + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/IpStatusServiceImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/IpStatusServiceImpl.java index 80e9b9db..fcabcede 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/IpStatusServiceImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/IpStatusServiceImpl.java @@ -25,64 +25,64 @@ @Slf4j public class IpStatusServiceImpl implements IpStatusService { - @Autowired - private IpStatusMapper ipStatusMapper; - - @Override - public void registerIp() { - String ip = IpUtil.getInstance().getLocalIP(); - if (StringUtils.isEmpty(ip)) { - log.error(" get ip is null"); - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - IpStatus ipStatus = new IpStatus(); - ipStatus.setIp(ip); - ipStatus.setStatus(IpStatusEnum.START.getCode()); - ipStatus.setLastTime(new Date()); - ipStatus.setIsDeleted(YN.N.getValue()); - - if (ipStatusMapper.selectByIp(ip) == null) { - ipStatusMapper.insert(ipStatus); - } else { - ipStatusMapper.updateStatusByIp(ipStatus); - } + @Autowired + private IpStatusMapper ipStatusMapper; + @Override + public void registerIp() { + String ip = IpUtil.getInstance().getLocalIP(); + if (StringUtils.isEmpty(ip)) { + log.error(" get ip is null"); + throw new BizException(SysErrorEnum.PARAM_IS_NULL); } + IpStatus ipStatus = new IpStatus(); + ipStatus.setIp(ip); + ipStatus.setStatus(IpStatusEnum.START.getCode()); + ipStatus.setLastTime(new Date()); + ipStatus.setIsDeleted(YN.N.getValue()); - @Override - public void cancelIp() { - String ip = IpUtil.getInstance().getLocalIP(); - IpStatus ipStatus = new IpStatus(); - ipStatus.setIp(ip); - ipStatus.setStatus(IpStatusEnum.STOP.getCode()); - ipStatusMapper.updateStatusByIp(ipStatus); + if (ipStatusMapper.selectByIp(ip) == null) { + ipStatusMapper.insert(ipStatus); + } else { + ipStatusMapper.updateStatusByIp(ipStatus); } - @Override - public void updateHeartbeatBylocalIp() { - registerIp(); - } + } - @Override - public boolean isLeader() { + @Override + public void cancelIp() { + String ip = IpUtil.getInstance().getLocalIP(); + IpStatus ipStatus = new IpStatus(); + ipStatus.setIp(ip); + ipStatus.setStatus(IpStatusEnum.STOP.getCode()); + ipStatusMapper.updateStatusByIp(ipStatus); + } - try { - String ip = IpUtil.getInstance().getLocalIP(); - if (StringUtils.isEmpty(ip)) { - return false; - } - IpStatus ipStatus = ipStatusMapper.selectLastIp(); - if (ipStatus == null) { - log.error("selectLastIp is null"); - return false; - } - if (ip.equals(ipStatus.getIp())) { - return true; - } - } catch (Exception e) { - log.error("isLeader is error", e); - } + @Override + public void updateHeartbeatBylocalIp() { + registerIp(); + } + @Override + public boolean isLeader() { + + try { + String ip = IpUtil.getInstance().getLocalIP(); + if (StringUtils.isEmpty(ip)) { + return false; + } + IpStatus ipStatus = ipStatusMapper.selectLastIp(); + if (ipStatus == null) { + log.error("selectLastIp is null"); return false; + } + if (ip.equals(ipStatus.getIp())) { + return true; + } + } catch (Exception e) { + log.error("isLeader is error", e); } + + return false; + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobAlarmConfigServiceImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobAlarmConfigServiceImpl.java index 6fd4a8b2..88f204f1 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobAlarmConfigServiceImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobAlarmConfigServiceImpl.java @@ -26,90 +26,92 @@ @Service public class JobAlarmConfigServiceImpl implements JobAlarmConfigService { - @Autowired - private JobAlarmConfigMapper jobAlarmConfigMapper; - - @Autowired - private SystemConfigService systemConfigService; - - @Override - @Transactional(rollbackFor = Exception.class) - public void upSertBatchJobAlarmConfig(List alarmTypeEnumList, Long jobId) { - if (jobId == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_PARAM_IS_NULL); - } - this.checkSysConfig(alarmTypeEnumList); - jobAlarmConfigMapper.deleteByJobId(jobId); - if (CollectionUtils.isNotEmpty(alarmTypeEnumList)) { - List list = new ArrayList<>(); - for (AlarmTypeEnum alarmTypeEnum : alarmTypeEnumList) { - JobAlarmConfig jobAlarmConfig = new JobAlarmConfig(); - jobAlarmConfig.setJobId(jobId); - jobAlarmConfig.setType(alarmTypeEnum.getCode()); - list.add(jobAlarmConfig); - } - jobAlarmConfigMapper.insertBatch(list); - } + @Autowired + private JobAlarmConfigMapper jobAlarmConfigMapper; + @Autowired + private SystemConfigService systemConfigService; + @Override + @Transactional(rollbackFor = Exception.class) + public void upSertBatchJobAlarmConfig(List alarmTypeEnumList, Long jobId) { + if (jobId == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_PARAM_IS_NULL); } + this.checkSysConfig(alarmTypeEnumList); + jobAlarmConfigMapper.deleteByJobId(jobId); + if (CollectionUtils.isNotEmpty(alarmTypeEnumList)) { + List list = new ArrayList<>(); + for (AlarmTypeEnum alarmTypeEnum : alarmTypeEnumList) { + JobAlarmConfig jobAlarmConfig = new JobAlarmConfig(); + jobAlarmConfig.setJobId(jobId); + jobAlarmConfig.setType(alarmTypeEnum.getCode()); + list.add(jobAlarmConfig); + } + jobAlarmConfigMapper.insertBatch(list); + } + - @Override - public List findByJobId(Long jobId) { + } - List list = jobAlarmConfigMapper.selectByJobId(jobId); - if (CollectionUtils.isEmpty(list)) { - return Collections.emptyList(); - } - List alarmTypeEnumList = new ArrayList<>(); + @Override + public List findByJobId(Long jobId) { - for (JobAlarmConfig jobAlarmConfig : list) { - alarmTypeEnumList.add(AlarmTypeEnum.getAlarmTypeEnum(jobAlarmConfig.getType())); - } + List list = jobAlarmConfigMapper.selectByJobId(jobId); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + List alarmTypeEnumList = new ArrayList<>(); - return alarmTypeEnumList; + for (JobAlarmConfig jobAlarmConfig : list) { + alarmTypeEnumList.add(AlarmTypeEnum.getAlarmTypeEnum(jobAlarmConfig.getType())); } - @Override - public Map> findByJobIdList(List jobIdList) { + return alarmTypeEnumList; + } - List list = jobAlarmConfigMapper.selectByJobIdList(jobIdList); - if (CollectionUtils.isEmpty(list)) { - return Collections.EMPTY_MAP; - } - Map> jobId2List = new HashMap<>(); + @Override + public Map> findByJobIdList(List jobIdList) { - for (JobAlarmConfig jobAlarmConfig : list) { - List alarmTypeEnumList = jobId2List.get(jobAlarmConfig.getJobId()); - if (CollectionUtils.isEmpty(alarmTypeEnumList)) { - alarmTypeEnumList = new ArrayList<>(); - } - alarmTypeEnumList.add(AlarmTypeEnum.getAlarmTypeEnum(jobAlarmConfig.getType())); - jobId2List.put(jobAlarmConfig.getJobId(), alarmTypeEnumList); + List list = jobAlarmConfigMapper.selectByJobIdList(jobIdList); + if (CollectionUtils.isEmpty(list)) { + return Collections.EMPTY_MAP; + } + Map> jobId2List = new HashMap<>(); + + for (JobAlarmConfig jobAlarmConfig : list) { + List alarmTypeEnumList = jobId2List.get(jobAlarmConfig.getJobId()); + if (CollectionUtils.isEmpty(alarmTypeEnumList)) { + alarmTypeEnumList = new ArrayList<>(); + } + alarmTypeEnumList.add(AlarmTypeEnum.getAlarmTypeEnum(jobAlarmConfig.getType())); + jobId2List.put(jobAlarmConfig.getJobId(), alarmTypeEnumList); - } - return jobId2List; } + return jobId2List; + } - private void checkSysConfig(List alarmTypeEnumList) { - if (CollectionUtils.isEmpty(alarmTypeEnumList)) { - return; - } - for (AlarmTypeEnum alarmTypeEnum : alarmTypeEnumList) { - switch (alarmTypeEnum) { - case DINGDING: - if (!systemConfigService.isExist(SysConfigEnum.DINGDING_ALARM_URL.getKey())) { - throw new BizException(SysErrorEnum.ALARM_DINGDING_NULL); - } - break; - case CALLBACK_URL: - if (!systemConfigService.isExist(SysConfigEnum.CALLBACK_ALARM_URL.getKey())) { - throw new BizException(SysErrorEnum.ALARM_HTTP_NULL); - } - break; - } - } + private void checkSysConfig(List alarmTypeEnumList) { + if (CollectionUtils.isEmpty(alarmTypeEnumList)) { + return; + } + for (AlarmTypeEnum alarmTypeEnum : alarmTypeEnumList) { + switch (alarmTypeEnum) { + case DINGDING: + if (!systemConfigService.isExist(SysConfigEnum.DINGDING_ALARM_URL.getKey())) { + throw new BizException(SysErrorEnum.ALARM_DINGDING_NULL); + } + break; + case CALLBACK_URL: + if (!systemConfigService.isExist(SysConfigEnum.CALLBACK_ALARM_URL.getKey())) { + throw new BizException(SysErrorEnum.ALARM_HTTP_NULL); + } + break; + default: + log.warn("不支持的告警模式"); + } } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobConfigHistoryServiceImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobConfigHistoryServiceImpl.java index 4d2ab650..3fbec49f 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobConfigHistoryServiceImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobConfigHistoryServiceImpl.java @@ -26,40 +26,41 @@ @Log public class JobConfigHistoryServiceImpl implements JobConfigHistoryService { - @Autowired - private JobConfigHistoryMapper jobConfigHistoryMapper; + @Autowired + private JobConfigHistoryMapper jobConfigHistoryMapper; - @Override - public void insertJobConfigHistory(JobConfigHistoryDTO jobConfigHistoryDTO) { - jobConfigHistoryMapper.insert(JobConfigHistoryDTO.toEntity(jobConfigHistoryDTO)); - } + @Override + public void insertJobConfigHistory(JobConfigHistoryDTO jobConfigHistoryDTO) { + jobConfigHistoryMapper.insert(JobConfigHistoryDTO.toEntity(jobConfigHistoryDTO)); + } - @Override - public List getJobConfigHistoryByJobConfigId(Long jobConfigId) { - return JobConfigHistoryDTO.toListDTO(jobConfigHistoryMapper.selectByJobConfigId(jobConfigId)); - } + @Override + public List getJobConfigHistoryByJobConfigId(Long jobConfigId) { + return JobConfigHistoryDTO.toListDTO(jobConfigHistoryMapper.selectByJobConfigId(jobConfigId)); + } + + @Override + public JobConfigHistoryDTO getJobConfigHistoryById(Long id) { + return JobConfigHistoryDTO.toDTO(jobConfigHistoryMapper.selectById(id)); + } - @Override - public JobConfigHistoryDTO getJobConfigHistoryById(Long id) { - return JobConfigHistoryDTO.toDTO(jobConfigHistoryMapper.selectById(id)); + @Override + public PageModel queryJobConfigHistory( + JobConfigHisotryParam jobConfigParam) { + if (jobConfigParam == null) { + jobConfigParam = new JobConfigHisotryParam(); } - - @Override - public PageModel queryJobConfigHistory(JobConfigHisotryParam jobConfigParam) { - if (jobConfigParam == null) { - jobConfigParam = new JobConfigHisotryParam(); - } - PageHelper.startPage(jobConfigParam.getPageNum(), jobConfigParam.getPageSize(), YN.Y.getCode()); - Page page = jobConfigHistoryMapper.findJobConfigHistory(jobConfigParam); - if (page == null) { - return null; - } - PageModel pageModel = new PageModel(); - pageModel.setPageNum(page.getPageNum()); - pageModel.setPages(page.getPages()); - pageModel.setPageSize(page.getPageSize()); - pageModel.setTotal(page.getTotal()); - pageModel.addAll(JobConfigHistoryDTO.toListDTO(page.getResult())); - return pageModel; + PageHelper.startPage(jobConfigParam.getPageNum(), jobConfigParam.getPageSize(), YN.Y.getCode()); + Page page = jobConfigHistoryMapper.findJobConfigHistory(jobConfigParam); + if (page == null) { + return null; } + PageModel pageModel = new PageModel(); + pageModel.setPageNum(page.getPageNum()); + pageModel.setPages(page.getPages()); + pageModel.setPageSize(page.getPageSize()); + pageModel.setTotal(page.getTotal()); + pageModel.addAll(JobConfigHistoryDTO.toListDTO(page.getResult())); + return pageModel; + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobConfigServiceImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobConfigServiceImpl.java index 73b22609..fe7ee5e6 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobConfigServiceImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobConfigServiceImpl.java @@ -32,285 +32,286 @@ public class JobConfigServiceImpl implements JobConfigService { - @Autowired - private JobConfigMapper jobConfigMapper; + @Autowired + private JobConfigMapper jobConfigMapper; - @Autowired - private JobRunLogService jobRunLogService; + @Autowired + private JobRunLogService jobRunLogService; - @Autowired - private JobAlarmConfigService jobAlarmConfigService; + @Autowired + private JobAlarmConfigService jobAlarmConfigService; - @Autowired - private SystemConfigService systemConfigService; + @Autowired + private SystemConfigService systemConfigService; - @Autowired - private JobConfigHistoryService jobConfigHistoryService; + @Autowired + private JobConfigHistoryService jobConfigHistoryService; - @Override - public Long addJobConfig(JobConfigDTO jobConfigDTO) { - if (jobConfigDTO == null) { - return null; - } - this.checkJobName(jobConfigDTO.getJobName(), jobConfigDTO.getId()); - this.checkSystemConfig(jobConfigDTO.getDeployModeEnum()); - JobConfig jobConfig = JobConfigDTO.toEntity(jobConfigDTO); - if (jobConfigDTO.getId() == null) { - jobConfigMapper.insert(jobConfig); - } else { - jobConfigMapper.insertWithId(jobConfig); - } - this.insertJobConfigHistory(jobConfig.getId()); - return jobConfig.getId(); + @Override + public Long addJobConfig(JobConfigDTO jobConfigDTO) { + if (jobConfigDTO == null) { + return null; } + this.checkJobName(jobConfigDTO.getJobName(), jobConfigDTO.getId()); + this.checkSystemConfig(jobConfigDTO.getDeployModeEnum()); + JobConfig jobConfig = JobConfigDTO.toEntity(jobConfigDTO); + if (jobConfigDTO.getId() == null) { + jobConfigMapper.insert(jobConfig); + } else { + jobConfigMapper.insertWithId(jobConfig); + } + this.insertJobConfigHistory(jobConfig.getId()); + return jobConfig.getId(); + } - @Override - public void updateJobConfigById(JobConfigDTO jobConfigDTO) { - - if (jobConfigDTO == null || jobConfigDTO.getId() == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_PARAM_IS_NULL); - } - JobConfig jobConfig = jobConfigMapper.selectByPrimaryKey(jobConfigDTO.getId()); - if (jobConfig == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); - } - if (jobConfigDTO.getDeployModeEnum() == null) { - this.checkSystemConfig(DeployModeEnum.valueOf(jobConfig.getDeployMode())); - } else { - this.checkSystemConfig(jobConfigDTO.getDeployModeEnum()); - } - - if (StringUtils.isNotEmpty(jobConfigDTO.getJobName())) { - this.checkJobName(jobConfigDTO.getJobName(), jobConfigDTO.getId()); - } - JobConfig JobConfigUpdate = JobConfigDTO.toEntity(jobConfigDTO); - - jobConfigMapper.updateByPrimaryKeySelective(JobConfigUpdate); + @Override + public void updateJobConfigById(JobConfigDTO jobConfigDTO) { - // this.insertJobConfigHistory(jobConfigDTO.getId()); + if (jobConfigDTO == null || jobConfigDTO.getId() == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_PARAM_IS_NULL); } - - @Override - public void updateJobConfigByIdWithWriteHistory(JobConfigDTO jobConfigDTO) { - if (jobConfigDTO == null || jobConfigDTO.getId() == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_PARAM_IS_NULL); - } - JobConfig jobConfig = jobConfigMapper.selectByPrimaryKey(jobConfigDTO.getId()); - if (jobConfig == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); - } - if (jobConfigDTO.getDeployModeEnum() == null) { - this.checkSystemConfig(DeployModeEnum.valueOf(jobConfig.getDeployMode())); - } else { - this.checkSystemConfig(jobConfigDTO.getDeployModeEnum()); - } - if (StringUtils.isNotEmpty(jobConfigDTO.getJobName())) { - this.checkJobName(jobConfigDTO.getJobName(), jobConfigDTO.getId()); - } - JobConfig JobConfigUpdate = JobConfigDTO.toEntity(jobConfigDTO); - jobConfigMapper.updateByPrimaryKeySelective(JobConfigUpdate); - this.insertJobConfigHistory(jobConfigDTO.getId()); + JobConfig jobConfig = jobConfigMapper.selectByPrimaryKey(jobConfigDTO.getId()); + if (jobConfig == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); } - - @Override - public void updateJobConfigStatusById(Long id, JobConfigStatus jobConfigStatus) { - JobConfig jobConfig = new JobConfig(); - jobConfig.setId(id); - jobConfig.setStatus(jobConfigStatus.getCode()); - jobConfigMapper.updateByPrimaryKeySelective(jobConfig); - + if (jobConfigDTO.getDeployModeEnum() == null) { + this.checkSystemConfig(DeployModeEnum.valueOf(jobConfig.getDeployMode())); + } else { + this.checkSystemConfig(jobConfigDTO.getDeployModeEnum()); } - @Override - public void updateStatusByStart(Long id, String userName, - Long jobRunLogId, Integer version) { - int num = jobConfigMapper.updateStatusByStart(id, JobConfigStatus.STARTING.getCode(), userName, - jobRunLogId, version); - if (num < 1) { - throw new BizException("启动状态更新失败"); - } + if (StringUtils.isNotEmpty(jobConfigDTO.getJobName())) { + this.checkJobName(jobConfigDTO.getJobName(), jobConfigDTO.getId()); } + JobConfig jobConfigUpdate = JobConfigDTO.toEntity(jobConfigDTO); - @Override - public JobConfigDTO getJobConfigById(Long id) { - if (id == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_PARAM_IS_NULL); - } + jobConfigMapper.updateByPrimaryKeySelective(jobConfigUpdate); - JobConfigDTO jobConfigDTO = JobConfigDTO.toDTO(jobConfigMapper.selectByPrimaryKey(id)); + // this.insertJobConfigHistory(jobConfigDTO.getId()); + } - if (jobConfigDTO != null) { - jobConfigDTO.setAlarmTypeEnumList(jobAlarmConfigService.findByJobId(id)); - } - - return jobConfigDTO; + @Override + public void updateJobConfigByIdWithWriteHistory(JobConfigDTO jobConfigDTO) { + if (jobConfigDTO == null || jobConfigDTO.getId() == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_PARAM_IS_NULL); } - - /** - * - * @param id - * @return - * @author wxj - * @date 2021年12月28日 下午1:48:51 - * @version V1.0 - * @see com.flink.streaming.web.service.JobConfigService#getJobConfigByIdContainDelete(java.lang.Long) - */ - @Override - public JobConfigDTO getJobConfigByIdContainDelete(Long id) { - if (id == null) { - return null; - } - JobConfigDTO jobConfigDTO = JobConfigDTO.toDTO(jobConfigMapper.selectByPrimaryKeyContainDelete(id)); - if (jobConfigDTO != null) { - jobConfigDTO.setAlarmTypeEnumList(jobAlarmConfigService.findByJobId(id)); - } - return jobConfigDTO; + JobConfig jobConfig = jobConfigMapper.selectByPrimaryKey(jobConfigDTO.getId()); + if (jobConfig == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_IS_NOT_EXIST); } + if (jobConfigDTO.getDeployModeEnum() == null) { + this.checkSystemConfig(DeployModeEnum.valueOf(jobConfig.getDeployMode())); + } else { + this.checkSystemConfig(jobConfigDTO.getDeployModeEnum()); + } + if (StringUtils.isNotEmpty(jobConfigDTO.getJobName())) { + this.checkJobName(jobConfigDTO.getJobName(), jobConfigDTO.getId()); + } + JobConfig jobConfigUpdate = JobConfigDTO.toEntity(jobConfigDTO); + jobConfigMapper.updateByPrimaryKeySelective(jobConfigUpdate); + this.insertJobConfigHistory(jobConfigDTO.getId()); + } + + @Override + public void updateJobConfigStatusById(Long id, JobConfigStatus jobConfigStatus) { + JobConfig jobConfig = new JobConfig(); + jobConfig.setId(id); + jobConfig.setStatus(jobConfigStatus.getCode()); + jobConfigMapper.updateByPrimaryKeySelective(jobConfig); + + } + + @Override + public void updateStatusByStart(Long id, String userName, + Long jobRunLogId, Integer version) { + int num = jobConfigMapper.updateStatusByStart(id, JobConfigStatus.STARTING.getCode(), userName, + jobRunLogId, version); + if (num < 1) { + throw new BizException("启动状态更新失败"); + } + } - @Override - public void openOrClose(Long id, YN yn, String userName) { - if (id == null) { - throw new BizException(SysErrorEnum.JOB_CONFIG_PARAM_IS_NULL); - } - JobConfig jobConfig = new JobConfig(); - jobConfig.setId(id); - jobConfig.setIsOpen(yn.getValue()); - jobConfig.setEditor(userName); - jobConfigMapper.updateByPrimaryKeySelective(jobConfig); - + @Override + public JobConfigDTO getJobConfigById(Long id) { + if (id == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_PARAM_IS_NULL); } + JobConfigDTO jobConfigDTO = JobConfigDTO.toDTO(jobConfigMapper.selectByPrimaryKey(id)); - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteJobConfigById(Long id, String userName) { - JobConfigDTO jobConfigDTO = this.getJobConfigById(id); - if (jobConfigDTO == null) { - throw new BizException("配置不存在!"); - } - if (JobConfigStatus.RUN.equals(jobConfigDTO.getStatus()) || - JobConfigStatus.STARTING.equals(jobConfigDTO.getStatus())) { - throw new BizException("任务正在启动中或者正在运行,请先停止任务"); - } - if (YN.Y.getValue() == jobConfigDTO.getIsOpen().intValue()) { - throw new BizException("请先关闭配置"); - } - jobConfigMapper.deleteById(id, userName); - jobRunLogService.deleteLogByJobConfigId(id); + if (jobConfigDTO != null) { + jobConfigDTO.setAlarmTypeEnumList(jobAlarmConfigService.findByJobId(id)); + } + + return jobConfigDTO; + } + + /** + * @param id + * @return + * @author wxj + * @date 2021年12月28日 下午1:48:51 + * @version V1.0 + * @see com.flink.streaming.web.service.JobConfigService#getJobConfigByIdContainDelete(java.lang.Long) + */ + @Override + public JobConfigDTO getJobConfigByIdContainDelete(Long id) { + if (id == null) { + return null; } - - @Override - public int recoveryDeleteJobConfigById(Long id, String userName) { - return jobConfigMapper.recoveryDeleteJobConfigById(id, userName); + JobConfigDTO jobConfigDTO = JobConfigDTO + .toDTO(jobConfigMapper.selectByPrimaryKeyContainDelete(id)); + if (jobConfigDTO != null) { + jobConfigDTO.setAlarmTypeEnumList(jobAlarmConfigService.findByJobId(id)); } + return jobConfigDTO; + } - @Override - public PageModel queryJobConfig(JobConfigParam jobConfigParam) { - if (jobConfigParam == null) { - jobConfigParam = new JobConfigParam(); - } + @Override + public void openOrClose(Long id, YN yn, String userName) { + if (id == null) { + throw new BizException(SysErrorEnum.JOB_CONFIG_PARAM_IS_NULL); + } + JobConfig jobConfig = new JobConfig(); + jobConfig.setId(id); + jobConfig.setIsOpen(yn.getValue()); + jobConfig.setEditor(userName); + jobConfigMapper.updateByPrimaryKeySelective(jobConfig); - PageHelper.startPage(jobConfigParam.getPageNum(), jobConfigParam.getPageSize(), YN.Y.getCode()); + } - Page page = jobConfigMapper.findJobConfig(jobConfigParam); - if (page == null) { - return null; - } - PageModel pageModel = new PageModel(); - pageModel.setPageNum(page.getPageNum()); - pageModel.setPages(page.getPages()); - pageModel.setPageSize(page.getPageSize()); - pageModel.setTotal(page.getTotal()); - pageModel.addAll(JobConfigDTO.toListDTO(page.getResult())); - return pageModel; - } - @Override - public List findJobConfigByStatus(Integer... status) { - if (status == null) { - return Collections.emptyList(); - } - List statusList = new ArrayList<>(); - for (Integer s : status) { - statusList.add(s); - } - return JobConfigDTO.toListDTO(jobConfigMapper.findJobConfigByStatus(statusList)); + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteJobConfigById(Long id, String userName) { + JobConfigDTO jobConfigDTO = this.getJobConfigById(id); + if (jobConfigDTO == null) { + throw new BizException("配置不存在!"); + } + if (JobConfigStatus.RUN.equals(jobConfigDTO.getStatus()) + || JobConfigStatus.STARTING.equals(jobConfigDTO.getStatus())) { + throw new BizException("任务正在启动中或者正在运行,请先停止任务"); + } + if (YN.Y.getValue() == jobConfigDTO.getIsOpen().intValue()) { + throw new BizException("请先关闭配置"); + } + jobConfigMapper.deleteById(id, userName); + jobRunLogService.deleteLogByJobConfigId(id); + } + + @Override + public int recoveryDeleteJobConfigById(Long id, String userName) { + return jobConfigMapper.recoveryDeleteJobConfigById(id, userName); + } + + @Override + public PageModel queryJobConfig(JobConfigParam jobConfigParam) { + if (jobConfigParam == null) { + jobConfigParam = new JobConfigParam(); } + PageHelper.startPage(jobConfigParam.getPageNum(), jobConfigParam.getPageSize(), YN.Y.getCode()); - /** - * 检查任务名称是不是重复 - * - * @author zhuhuipei - * @date 2020-07-14 - * @time 13:56 - */ - private void checkJobName(String jobName, Long id) { - long count = jobConfigMapper.selectCountByJobName(jobName, id); - if (count >= 1) { - throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_NAME_IS_EXIST); - } + Page page = jobConfigMapper.findJobConfig(jobConfigParam); + if (page == null) { + return null; } - - /** - * 检查配置文件 - * - * @author zhuhuipei - * @date 2020/11/4 - * @time 22:43 - */ - private void checkSystemConfig(DeployModeEnum deployModeEnum) { - StringBuffer tips = new StringBuffer(); - String flinkHome = systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_HOME.getKey()); - if (StringUtils.isEmpty(flinkHome)) { - tips.append(" flinkHome、"); - } - String webHome = systemConfigService.getSystemConfigByKey( - SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey()); - if (StringUtils.isEmpty(webHome)) { - tips.append(" web应用安装的目录 "); + PageModel pageModel = new PageModel(); + pageModel.setPageNum(page.getPageNum()); + pageModel.setPages(page.getPages()); + pageModel.setPageSize(page.getPageSize()); + pageModel.setTotal(page.getTotal()); + pageModel.addAll(JobConfigDTO.toListDTO(page.getResult())); + return pageModel; + } + + @Override + public List findJobConfigByStatus(Integer... status) { + if (status == null) { + return Collections.emptyList(); + } + List statusList = new ArrayList<>(); + for (Integer s : status) { + statusList.add(s); + } + return JobConfigDTO.toListDTO(jobConfigMapper.findJobConfigByStatus(statusList)); + } + + + /** + * 检查任务名称是不是重复 + * + * @author zhuhuipei + * @date 2020-07-14 + * @time 13:56 + */ + private void checkJobName(String jobName, Long id) { + long count = jobConfigMapper.selectCountByJobName(jobName, id); + if (count >= 1) { + throw new BizException(SysErrorEnum.JOB_CONFIG_JOB_NAME_IS_EXIST); + } + } + + /** + * 检查配置文件 + * + * @author zhuhuipei + * @date 2020/11/4 + * @time 22:43 + */ + private void checkSystemConfig(DeployModeEnum deployModeEnum) { + StringBuffer tips = new StringBuffer(); + String flinkHome = systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_HOME.getKey()); + if (StringUtils.isEmpty(flinkHome)) { + tips.append(" flinkHome、"); + } + String webHome = systemConfigService.getSystemConfigByKey( + SysConfigEnum.FLINK_STREAMING_PLATFORM_WEB_HOME.getKey()); + if (StringUtils.isEmpty(webHome)) { + tips.append(" web应用安装的目录 "); + } + switch (deployModeEnum) { + case YARN_PER: + String yarnHttpAddress = systemConfigService.getSystemConfigByKey( + SysConfigEnum.YARN_RM_HTTP_ADDRESS.getKey()); + if (StringUtils.isEmpty(yarnHttpAddress)) { + tips.append(" yarn_rm_http_address url地址 "); } - switch (deployModeEnum) { - case YARN_PER: - String yarnHttpAddress = systemConfigService.getSystemConfigByKey( - SysConfigEnum.YARN_RM_HTTP_ADDRESS.getKey()); - if (StringUtils.isEmpty(yarnHttpAddress)) { - tips.append(" yarn_rm_http_address url地址 "); - } - break; - case LOCAL: - String flinkHttpAddress = systemConfigService.getSystemConfigByKey( - SysConfigEnum.FLINK_REST_HTTP_ADDRESS.getKey()); - if (StringUtils.isEmpty(flinkHttpAddress)) { - tips.append(" flink_rest_http_address url地址 "); - } - break; - case STANDALONE: - String flinkHaHttpAddress = - systemConfigService.getSystemConfigByKey(SysConfigEnum.FLINK_REST_HA_HTTP_ADDRESS.getKey()); - if (StringUtils.isEmpty(flinkHaHttpAddress)) { - tips.append(" flink_rest_ha_http_address url地址 "); - } - break; - default: - break; + break; + case LOCAL: + String flinkHttpAddress = systemConfigService.getSystemConfigByKey( + SysConfigEnum.FLINK_REST_HTTP_ADDRESS.getKey()); + if (StringUtils.isEmpty(flinkHttpAddress)) { + tips.append(" flink_rest_http_address url地址 "); } - if (StringUtils.isNotEmpty(tips.toString())) { - throw new BizException("请在 系统管理-->系统设置 里面配置 " + tips.toString()); + break; + case STANDALONE: + String flinkHaHttpAddress = + systemConfigService + .getSystemConfigByKey(SysConfigEnum.FLINK_REST_HA_HTTP_ADDRESS.getKey()); + if (StringUtils.isEmpty(flinkHaHttpAddress)) { + tips.append(" flink_rest_ha_http_address url地址 "); } - + break; + default: + break; + } + if (StringUtils.isNotEmpty(tips.toString())) { + throw new BizException("请在 系统管理-->系统设置 里面配置 " + tips.toString()); } - private void insertJobConfigHistory(Long id) { - JobConfig jobConfig = jobConfigMapper.selectByPrimaryKey(id); - if (jobConfig == null) { - log.warn("[insertJobConfigHistory] jobConfig is null id:{} ", id); - return; - } + } + + private void insertJobConfigHistory(Long id) { + JobConfig jobConfig = jobConfigMapper.selectByPrimaryKey(id); + if (jobConfig == null) { + log.warn("[insertJobConfigHistory] jobConfig is null id:{} ", id); + return; + } // if (JobTypeEnum.SQL_STREAMING.getCode() == jobConfig.getJobType().intValue() || // JobTypeEnum.SQL_BATCH.getCode() == jobConfig.getJobType().intValue()) { // jobConfigHistoryService.insertJobConfigHistory(JobConfigHistoryDTO.to(jobConfig)); // } - jobConfigHistoryService.insertJobConfigHistory(JobConfigHistoryDTO.to(jobConfig)); - } + jobConfigHistoryService.insertJobConfigHistory(JobConfigHistoryDTO.to(jobConfig)); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobRunLogServiceImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobRunLogServiceImpl.java index d056f882..23b09176 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobRunLogServiceImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/JobRunLogServiceImpl.java @@ -23,64 +23,64 @@ @Service public class JobRunLogServiceImpl implements JobRunLogService { - @Autowired - private JobRunLogMapper jobRunLogMapper; + @Autowired + private JobRunLogMapper jobRunLogMapper; - @Override - public Long insertJobRunLog(JobRunLogDTO jobRunLogDTO) { - JobRunLog jobRunLog = JobRunLogDTO.toEntity(jobRunLogDTO); - jobRunLogMapper.insert(jobRunLog); - return jobRunLog.getId(); - } - - @Override - public void updateLogById(String localLog, Long id) { - try { - JobRunLog jobRunLog = new JobRunLog(); - jobRunLog.setId(id); - jobRunLog.setLocalLog(localLog); - jobRunLogMapper.update(jobRunLog); - } catch (Exception e) { - log.error("更新日志 失败 id={} ,localLog={}", id, localLog, e); - } + @Override + public Long insertJobRunLog(JobRunLogDTO jobRunLogDTO) { + JobRunLog jobRunLog = JobRunLogDTO.toEntity(jobRunLogDTO); + jobRunLogMapper.insert(jobRunLog); + return jobRunLog.getId(); + } + @Override + public void updateLogById(String localLog, Long id) { + try { + JobRunLog jobRunLog = new JobRunLog(); + jobRunLog.setId(id); + jobRunLog.setLocalLog(localLog); + jobRunLogMapper.update(jobRunLog); + } catch (Exception e) { + log.error("更新日志 失败 id={} ,localLog={}", id, localLog, e); } - @Override - public void updateJobRunLogById(JobRunLogDTO jobRunLogDTO) { - jobRunLogMapper.update(JobRunLogDTO.toEntity(jobRunLogDTO)); - } + } - @Override - public PageModel queryJobRunLog(JobRunLogParam jobRunLogParam) { - if (jobRunLogParam == null) { - jobRunLogParam = new JobRunLogParam(); - } - PageHelper.startPage(jobRunLogParam.getPageNum(), jobRunLogParam.getPageSize(), YN.Y.getCode()); + @Override + public void updateJobRunLogById(JobRunLogDTO jobRunLogDTO) { + jobRunLogMapper.update(JobRunLogDTO.toEntity(jobRunLogDTO)); + } - //只能查最近30天的 - Page page = jobRunLogMapper.selectByParam(jobRunLogParam); - if (page == null) { - return null; - } - PageModel pageModel = new PageModel<>(); - pageModel.setPages(page.getPages()); - pageModel.addAll(JobRunLogDTO.toListDTO(page.getResult())); - pageModel.setPageSize(page.getPageSize()); - pageModel.setTotal(page.getTotal()); - pageModel.setPageNum(page.getPageNum()); - return pageModel; + @Override + public PageModel queryJobRunLog(JobRunLogParam jobRunLogParam) { + if (jobRunLogParam == null) { + jobRunLogParam = new JobRunLogParam(); } + PageHelper.startPage(jobRunLogParam.getPageNum(), jobRunLogParam.getPageSize(), YN.Y.getCode()); - @Override - public JobRunLogDTO getDetailLogById(Long id) { - return JobRunLogDTO.toDTO(jobRunLogMapper.selectById(id)); + //只能查最近30天的 + Page page = jobRunLogMapper.selectByParam(jobRunLogParam); + if (page == null) { + return null; } + PageModel pageModel = new PageModel<>(); + pageModel.setPages(page.getPages()); + pageModel.addAll(JobRunLogDTO.toListDTO(page.getResult())); + pageModel.setPageSize(page.getPageSize()); + pageModel.setTotal(page.getTotal()); + pageModel.setPageNum(page.getPageNum()); + return pageModel; + } - @Override - public void deleteLogByJobConfigId(Long jobConfigId) { - jobRunLogMapper.deleteByJobConfigId(jobConfigId); - } + @Override + public JobRunLogDTO getDetailLogById(Long id) { + return JobRunLogDTO.toDTO(jobRunLogMapper.selectById(id)); + } + + @Override + public void deleteLogByJobConfigId(Long jobConfigId) { + jobRunLogMapper.deleteByJobConfigId(jobConfigId); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/SavepointBackupServiceImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/SavepointBackupServiceImpl.java index 1b7d57f7..377a117a 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/SavepointBackupServiceImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/SavepointBackupServiceImpl.java @@ -19,29 +19,29 @@ @Service public class SavepointBackupServiceImpl implements SavepointBackupService { - @Autowired - private SavepointBackupMapper savepointBackupMapper; + @Autowired + private SavepointBackupMapper savepointBackupMapper; - @Override - public void insertSavepoint(Long jobConfigId, String savepointPath, Date backupTime) { - SavepointBackup savepointBackup = new SavepointBackup(); - savepointBackup.setBackupTime(backupTime); - savepointBackup.setSavepointPath(savepointPath); - savepointBackup.setJobConfigId(jobConfigId); - savepointBackupMapper.insert(savepointBackup); - } + @Override + public void insertSavepoint(Long jobConfigId, String savepointPath, Date backupTime) { + SavepointBackup savepointBackup = new SavepointBackup(); + savepointBackup.setBackupTime(backupTime); + savepointBackup.setSavepointPath(savepointPath); + savepointBackup.setJobConfigId(jobConfigId); + savepointBackupMapper.insert(savepointBackup); + } - @Override - public List lasterHistory10(Long jobConfigId) { - return SavepointBackupDTO.toDTOList(savepointBackupMapper.selectByLimt10(jobConfigId)); - } + @Override + public List lasterHistory10(Long jobConfigId) { + return SavepointBackupDTO.toDTOList(savepointBackupMapper.selectByLimt10(jobConfigId)); + } - @Override - public String getSavepointPathById(Long jobConfigId, Long id) { - SavepointBackup savepointBackup = savepointBackupMapper.getSavepointBackupById(jobConfigId, id); - if (savepointBackup != null) { - return savepointBackup.getSavepointPath(); - } - return null; + @Override + public String getSavepointPathById(Long jobConfigId, Long id) { + SavepointBackup savepointBackup = savepointBackupMapper.getSavepointBackupById(jobConfigId, id); + if (savepointBackup != null) { + return savepointBackup.getSavepointPath(); } + return null; + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/SystemConfigServiceImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/SystemConfigServiceImpl.java index 3b80fdab..4a28d1d2 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/SystemConfigServiceImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/SystemConfigServiceImpl.java @@ -54,8 +54,8 @@ public void addOrUpdateConfigByKey(String key, String value) { @Override public List getSystemConfig(SysConfigEnumType sysConfigEnumType) { - return SystemConfigDTO.toListDTO(systemConfigMapper.selectAllConfig(sysConfigEnumType != null ? - sysConfigEnumType.name() : null)); + return SystemConfigDTO.toListDTO(systemConfigMapper.selectAllConfig(sysConfigEnumType != null + ? sysConfigEnumType.name() : null)); } @Override diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/UserServiceImpl.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/UserServiceImpl.java index b926d190..2f8117ab 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/UserServiceImpl.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/service/impl/UserServiceImpl.java @@ -1,13 +1,12 @@ package com.flink.streaming.web.service.impl; -import com.flink.streaming.web.exceptions.BizException; import com.flink.streaming.web.common.util.Base64Coded; import com.flink.streaming.web.common.util.Md5Utils; import com.flink.streaming.web.enums.SysErrorEnum; import com.flink.streaming.web.enums.UserStatusEnum; import com.flink.streaming.web.enums.YN; +import com.flink.streaming.web.exceptions.BizException; import com.flink.streaming.web.mapper.UserMapper; -import com.flink.streaming.web.model.dto.JobConfigDTO; import com.flink.streaming.web.model.dto.PageModel; import com.flink.streaming.web.model.dto.UserDTO; import com.flink.streaming.web.model.dto.UserSession; @@ -16,14 +15,12 @@ import com.flink.streaming.web.service.UserService; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; - +import java.util.List; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; - /** * @author zhuhuipei * @Description: @@ -34,154 +31,158 @@ @Slf4j public class UserServiceImpl implements UserService { - @Autowired - private UserMapper userMapper; - - @Override - public String login(String userName, String password) { - User user = userMapper.selectByUsername(userName); - if (user == null) { - throw new BizException(SysErrorEnum.USER_IS_NOT_NULL); - } - if (UserStatusEnum.CLOSE.getCode().equals(user.getStatus())) { - throw new BizException(SysErrorEnum.USER_IS_STOP); - } - if (!Md5Utils.getMD5String(password).equalsIgnoreCase(user.getPassword())) { - if (password.equals(user.getPassword())) { //数据库保存的非md5码 - String userSession = UserSession.toJsonString(user.getId(), user.getUsername(), Md5Utils.getMD5String(user.getPassword())); - return Base64Coded.encode(userSession.getBytes()); - } - throw new BizException(SysErrorEnum.USER_PASSWORD_ERROR); - } - String userSession = UserSession.toJsonString(user.getId(), user.getUsername(), user.getPassword()); + @Autowired + private UserMapper userMapper; + + @Override + public String login(String userName, String password) { + User user = userMapper.selectByUsername(userName); + if (user == null) { + throw new BizException(SysErrorEnum.USER_IS_NOT_NULL); + } + if (UserStatusEnum.CLOSE.getCode().equals(user.getStatus())) { + throw new BizException(SysErrorEnum.USER_IS_STOP); + } + if (!Md5Utils.getMD5String(password).equalsIgnoreCase(user.getPassword())) { + if (password.equals(user.getPassword())) { //数据库保存的非md5码 + String userSession = UserSession.toJsonString(user.getId(), user.getUsername(), + Md5Utils.getMD5String(user.getPassword())); return Base64Coded.encode(userSession.getBytes()); + } + throw new BizException(SysErrorEnum.USER_PASSWORD_ERROR); } - - @Override - public boolean checkLogin(UserSession userSession) { - User user = userMapper.selectByUsername(userSession.getName()); - if (user == null) { - return false; - } - if (!userSession.getPassword().equalsIgnoreCase(Md5Utils.getMD5String(user.getPassword()))) { - if (userSession.getPassword().equalsIgnoreCase(Md5Utils.getMD5String(Md5Utils.getMD5String(user.getPassword())))) { //数据库保存的非md5码 - return true; - } - return false; - } - + String userSession = UserSession + .toJsonString(user.getId(), user.getUsername(), user.getPassword()); + return Base64Coded.encode(userSession.getBytes()); + } + + @Override + public boolean checkLogin(UserSession userSession) { + User user = userMapper.selectByUsername(userSession.getName()); + if (user == null) { + return false; + } + if (!userSession.getPassword().equalsIgnoreCase(Md5Utils.getMD5String(user.getPassword()))) { + if (userSession.getPassword().equalsIgnoreCase( + Md5Utils.getMD5String(Md5Utils.getMD5String(user.getPassword())))) { //数据库保存的非md5码 return true; + } + return false; } - @Override - public PageModel queryAllByPage(PageParam pageparam) { - PageHelper.startPage(pageparam.getPageNum(), pageparam.getPageSize(), YN.Y.getCode()); - Page users = userMapper.queryAllByPage(pageparam); - PageModel pageModel = new PageModel(); - pageModel.setPageNum(users.getPageNum()); - pageModel.setPages(users.getPages()); - pageModel.setPageSize(users.getPageSize()); - pageModel.setTotal(users.getTotal()); - pageModel.addAll(UserDTO.toListDTO(users.getResult())); - return pageModel; + return true; + } + + @Override + public PageModel queryAllByPage(PageParam pageparam) { + PageHelper.startPage(pageparam.getPageNum(), pageparam.getPageSize(), YN.Y.getCode()); + Page users = userMapper.queryAllByPage(pageparam); + PageModel pageModel = new PageModel(); + pageModel.setPageNum(users.getPageNum()); + pageModel.setPages(users.getPages()); + pageModel.setPageSize(users.getPageSize()); + pageModel.setTotal(users.getTotal()); + pageModel.addAll(UserDTO.toListDTO(users.getResult())); + return pageModel; + } + + @Override + public void addUser(String userName, String fullname, String password, String operator) { + if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL); } - - @Override - public void addUser(String userName, String fullname, String password, String operator) { - if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - User user = userMapper.selectByUsername(userName); - if (user != null) { - throw new BizException(SysErrorEnum.USER_IS_EXIST); - } - user = new User(); - user.setEditor(operator); - user.setCreator(operator); - user.setUsername(userName); - user.setName(fullname); - //默认开启 - user.setStatus(UserStatusEnum.OPEN.getCode()); - user.setPassword(Md5Utils.getMD5String(password)); - userMapper.insert(user); + User user = userMapper.selectByUsername(userName); + if (user != null) { + throw new BizException(SysErrorEnum.USER_IS_EXIST); } - - @Override - public void updatePassword(String userName, String oldPassword, String password, String operator) { - if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - User userMp = userMapper.selectByUsername(userName); - if (userMp == null) { - throw new BizException(SysErrorEnum.USER_IS_NOT_NULL); - } - if (!userMp.getPassword().equals(Md5Utils.getMD5String(oldPassword))) { - throw new BizException("老的密码不正确"); - } - - User user = new User(); - user.setEditor(operator); - user.setUsername(userName); - user.setPassword(Md5Utils.getMD5String(password)); - userMapper.updateByPrimaryKeySelective(user); + user = new User(); + user.setEditor(operator); + user.setCreator(operator); + user.setUsername(userName); + user.setName(fullname); + //默认开启 + user.setStatus(UserStatusEnum.OPEN.getCode()); + user.setPassword(Md5Utils.getMD5String(password)); + userMapper.insert(user); + } + + @Override + public void updatePassword(String userName, String oldPassword, String password, + String operator) { + if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL); } - - @Override - public void updatePassword(Integer userId, String password, String operator) { - User userMp = userMapper.selectByUserId(userId); - if (userMp == null) { - throw new BizException(SysErrorEnum.USER_IS_NOT_NULL); - } - User user = new User(); - user.setId(userId); - user.setEditor(operator); - user.setPassword(Md5Utils.getMD5String(password)); - userMapper.updateByUserIdSelective(user); + User userMp = userMapper.selectByUsername(userName); + if (userMp == null) { + throw new BizException(SysErrorEnum.USER_IS_NOT_NULL); } - - @Override - public void updateFullName(Integer userid, String fullname, String operator) { - User userMp = userMapper.selectByUserId(userid); - if (userMp == null) { - throw new BizException(SysErrorEnum.USER_IS_NOT_NULL); - } - User user = new User(); - user.setId(userid); - user.setEditor(operator); - user.setName(fullname); - userMapper.updateByUserIdSelective(user); + if (!userMp.getPassword().equals(Md5Utils.getMD5String(oldPassword))) { + throw new BizException("老的密码不正确"); } - @Override - public void stopOrOpen(String userName, UserStatusEnum userStatusEnum, String operator) { - if (StringUtils.isEmpty(userName) || userStatusEnum == null) { - throw new BizException(SysErrorEnum.PARAM_IS_NULL); - } - if (userMapper.selectByUsername(userName) == null) { - throw new BizException(SysErrorEnum.USER_IS_NOT_NULL); - } - User user = new User(); - user.setEditor(operator); - user.setUsername(userName); - user.setStatus(userStatusEnum.getCode()); - userMapper.updateByPrimaryKeySelective(user); + User user = new User(); + user.setEditor(operator); + user.setUsername(userName); + user.setPassword(Md5Utils.getMD5String(password)); + userMapper.updateByPrimaryKeySelective(user); + } + + @Override + public void updatePassword(Integer userId, String password, String operator) { + User userMp = userMapper.selectByUserId(userId); + if (userMp == null) { + throw new BizException(SysErrorEnum.USER_IS_NOT_NULL); } - - @Override - public List queryAll() { - return UserDTO.toListDTO(userMapper.findAll()); + User user = new User(); + user.setId(userId); + user.setEditor(operator); + user.setPassword(Md5Utils.getMD5String(password)); + userMapper.updateByUserIdSelective(user); + } + + @Override + public void updateFullName(Integer userid, String fullname, String operator) { + User userMp = userMapper.selectByUserId(userid); + if (userMp == null) { + throw new BizException(SysErrorEnum.USER_IS_NOT_NULL); } - - @Override - public UserDTO qyeryByUserName(String userName) { - User user = userMapper.selectByUsername(userName); - return UserDTO.toDTO(user); + User user = new User(); + user.setId(userid); + user.setEditor(operator); + user.setName(fullname); + userMapper.updateByUserIdSelective(user); + } + + @Override + public void stopOrOpen(String userName, UserStatusEnum userStatusEnum, String operator) { + if (StringUtils.isEmpty(userName) || userStatusEnum == null) { + throw new BizException(SysErrorEnum.PARAM_IS_NULL); } - - @Override - public UserDTO qyeryByUserId(Integer userid) { - User user = userMapper.selectByUserId(userid); - return UserDTO.toDTO(user); + if (userMapper.selectByUsername(userName) == null) { + throw new BizException(SysErrorEnum.USER_IS_NOT_NULL); } + User user = new User(); + user.setEditor(operator); + user.setUsername(userName); + user.setStatus(userStatusEnum.getCode()); + userMapper.updateByPrimaryKeySelective(user); + } + + @Override + public List queryAll() { + return UserDTO.toListDTO(userMapper.findAll()); + } + + @Override + public UserDTO qyeryByUserName(String userName) { + User user = userMapper.selectByUsername(userName); + return UserDTO.toDTO(user); + } + + @Override + public UserDTO qyeryByUserId(Integer userid) { + User user = userMapper.selectByUserId(userid); + return UserDTO.toDTO(user); + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/thread/AlarmDingdingThread.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/thread/AlarmDingdingThread.java index 8a580d72..15c9a0b3 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/thread/AlarmDingdingThread.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/thread/AlarmDingdingThread.java @@ -13,33 +13,34 @@ @Slf4j public class AlarmDingdingThread implements Runnable { - private AlarmServiceAO alarmServiceAO; - - private String content; - - private Long jobConfigId; - - private String url; - - - public AlarmDingdingThread(AlarmServiceAO alarmServiceAO, String content, Long jobConfigId, String url) { - this.alarmServiceAO = alarmServiceAO; - this.content = content; - this.jobConfigId = jobConfigId; - this.url = url; - } - - @Override - public void run() { - try { - log.info("开始执行钉钉告警 content={} jobConfigId={}",content,jobConfigId); - if (StringUtils.isEmpty(url)) { - log.warn("没有配置钉钉url地址 不发送告警"); - return; - } - alarmServiceAO.sendForDingding(url, content, jobConfigId); - } catch (Exception e) { - log.error("告警失败 is error", e); - } + private AlarmServiceAO alarmServiceAO; + + private String content; + + private Long jobConfigId; + + private String url; + + + public AlarmDingdingThread(AlarmServiceAO alarmServiceAO, String content, Long jobConfigId, + String url) { + this.alarmServiceAO = alarmServiceAO; + this.content = content; + this.jobConfigId = jobConfigId; + this.url = url; + } + + @Override + public void run() { + try { + log.info("开始执行钉钉告警 content={} jobConfigId={}", content, jobConfigId); + if (StringUtils.isEmpty(url)) { + log.warn("没有配置钉钉url地址 不发送告警"); + return; + } + alarmServiceAO.sendForDingding(url, content, jobConfigId); + } catch (Exception e) { + log.error("告警失败 is error", e); } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/thread/AlarmHttpThread.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/thread/AlarmHttpThread.java index 9c765617..1fcd89a0 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/thread/AlarmHttpThread.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/thread/AlarmHttpThread.java @@ -14,29 +14,29 @@ @Slf4j public class AlarmHttpThread implements Runnable { - private AlarmServiceAO alarmServiceAO; + private AlarmServiceAO alarmServiceAO; - private CallbackDTO callbackDTO; + private CallbackDTO callbackDTO; - private String url; + private String url; - public AlarmHttpThread(AlarmServiceAO alarmServiceAO, CallbackDTO callbackDTO, String url) { - this.alarmServiceAO = alarmServiceAO; - this.callbackDTO = callbackDTO; - this.url = url; - } + public AlarmHttpThread(AlarmServiceAO alarmServiceAO, CallbackDTO callbackDTO, String url) { + this.alarmServiceAO = alarmServiceAO; + this.callbackDTO = callbackDTO; + this.url = url; + } - @Override - public void run() { - try { - log.info("开始执行http回调告警 callbackDTO={} url={}", callbackDTO, url); - if (StringUtils.isEmpty(url)) { - log.warn("没有配置http回调地址 不发送告警"); - return; - } - alarmServiceAO.sendForHttp(url, callbackDTO); - } catch (Exception e) { - log.error("告警失败 is error", e); - } + @Override + public void run() { + try { + log.info("开始执行http回调告警 callbackDTO={} url={}", callbackDTO, url); + if (StringUtils.isEmpty(url)) { + log.warn("没有配置http回调地址 不发送告警"); + return; + } + alarmServiceAO.sendForHttp(url, callbackDTO); + } catch (Exception e) { + log.error("告警失败 is error", e); } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/HttpClientToolUtils.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/HttpClientToolUtils.java index b23ae72d..f3a44303 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/HttpClientToolUtils.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/HttpClientToolUtils.java @@ -14,14 +14,13 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; - import javax.net.ssl.SSLContext; import javax.net.ssl.SSLException; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; - +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.http.Header; import org.apache.http.HttpEntity; @@ -53,721 +52,753 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -public class HttpClientToolUtils { - final static Logger logger = LoggerFactory.getLogger(HttpClientToolUtils.class); - - /** - * 绕过验证 - * - * @return - * @throws NoSuchAlgorithmException - * @throws KeyManagementException - */ - public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException { - SSLContext sc = SSLContext.getInstance("TLSv1.2"); - - // 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法 - X509TrustManager trustManager = new X509TrustManager() { - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) - throws CertificateException { - } - - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) - throws CertificateException { - } - - @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - }; - - sc.init(null, new TrustManager[] { trustManager }, null); - return sc; - } - - public static String doPost(String url, Map paramMap, Map headMap) throws IOException { - return doPost(url, paramMap, headMap, null, null, "utf-8"); - } - - public static String doPost(String url, Map paramMap, Map headMap, int connectTimeout) throws IOException { - return doPost(url, paramMap, headMap, null, null, "utf-8", connectTimeout); - } - - public static String doPost(String url, Map paramMap, Map headMap, String body, String mimeType, String charset) - throws IOException { - return doPost(url, paramMap, headMap, body, mimeType, charset, 0); - } - - /** - * 模拟请求 - * - * @param url - * 资源地址 - * @param paramMap - * 参数列表 - * @param headMap - * 请求头列表 - * @param body - * 请求body - * @param mimeType - * MIME type - * @param charset - * 编码 - * @param connectTimeout - * 超时时间 - * @return - * @throws NoSuchAlgorithmException - * @throws KeyManagementException - * @throws IOException - * @throws ClientProtocolException - */ - - public static String doPost(String url, Map paramMap, Map headMap, String body, String mimeType, String charset, - int connectTimeout) throws IOException { - if (StringUtils.isBlank(charset)) { - charset = "utf=8"; - } - String result = ""; - // 采用绕过验证的方式处理https请求 - SSLContext sslcontext = null; - try { - sslcontext = createIgnoreVerifySSL(); - } catch (KeyManagementException | NoSuchAlgorithmException e) { - logger.error(e.getMessage()); - return null; - } - // 设置协议http和https对应的处理socket链接工厂的对象 - Registry socketFactoryRegistry = RegistryBuilder. create() - .register("http", PlainConnectionSocketFactory.INSTANCE).register("https", new SSLConnectionSocketFactory(sslcontext)).build(); - PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); - // HttpClients.custom().setConnectionManager(connManager); - - // 创建自定义的httpclient对象 - // CloseableHttpClient client = - // HttpClients.custom().setConnectionManager(connManager).build(); - if (connectTimeout <= 0) { - connectTimeout = 8000;// 默认设置8秒 - } - // 设置代理 - HttpHost proxy = null; - if (headMap != null && headMap.containsKey("caohua_proxy_ip") && headMap.containsKey("caohua_proxy_port")) { - String proxy_ip = headMap.get("caohua_proxy_ip"); - int proxy_port = Integer.parseInt(headMap.get("caohua_proxy_port")); - proxy = new HttpHost(proxy_ip, proxy_port); - } - RequestConfig defaultRequestConfig = null; - defaultRequestConfig = RequestConfig.custom().setConnectTimeout(connectTimeout).setSocketTimeout(connectTimeout).setProxy(proxy).build(); - - // 创建自定义的httpclient对象 - HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connManager); - builder.setDefaultRequestConfig(defaultRequestConfig); - CloseableHttpClient client = builder.build(); - // 创建post方式请求对象 - HttpPost httpPost = new HttpPost(url); - if (StringUtils.isNotBlank(body)) { - HttpEntity entity = new StringEntity(body, ContentType.create(mimeType, charset)); - httpPost.setEntity(entity); - } - // 装填参数 - if (paramMap != null) { - List nvps = new ArrayList(); - for (Entry entry : paramMap.entrySet()) { - nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); - } - // 设置参数到请求对象中 - try { - httpPost.setEntity(new UrlEncodedFormEntity(nvps, charset)); - } catch (UnsupportedEncodingException e) { - logger.error(e.getMessage()); - return null; - } - } - // 设置header信息 - if (headMap != null) { - for (Entry entry : headMap.entrySet()) { - if (StringUtils.contains(entry.getKey(), "caohua_proxy")) { - continue; - } - httpPost.setHeader(entry.getKey(), entry.getValue()); - } - } - try { - // 执行请求操作,并拿到结果(同步阻塞) - CloseableHttpResponse response = client.execute(httpPost); - // 获取结果实体 - HttpEntity entity = response.getEntity(); - if (entity != null) { - result = EntityUtils.toString(entity, charset);// 按指定编码转换结果实体为String类型 - } - EntityUtils.consume(entity); - response.close();// 释放链接 - } catch (ClientProtocolException e) { - logger.error(e.getMessage()); - } - return result; - } - public static String doGet(String url) throws IOException { - return doGet(url, null, null, "utf-8", 0); +@Slf4j +public class HttpClientToolUtils { + //CHECKSTYLE:OFF + + /** + * 绕过验证 + * + * @return + * @throws NoSuchAlgorithmException + * @throws KeyManagementException + */ + public static SSLContext createIgnoreVerifySSL() + throws NoSuchAlgorithmException, KeyManagementException { + SSLContext sc = SSLContext.getInstance("TLSv1.2"); + + // 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法 + X509TrustManager trustManager = new X509TrustManager() { + @Override + public void checkClientTrusted( + java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) + throws CertificateException { + } + + @Override + public void checkServerTrusted( + java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) + throws CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + }; + + sc.init(null, new TrustManager[]{trustManager}, null); + return sc; + } + + public static String doPost(String url, Map paramMap, Map headMap) + throws IOException { + return doPost(url, paramMap, headMap, null, null, "utf-8"); + } + + public static String doPost(String url, Map paramMap, Map headMap, + int connectTimeout) throws IOException { + return doPost(url, paramMap, headMap, null, null, "utf-8", connectTimeout); + } + + public static String doPost(String url, Map paramMap, Map headMap, + String body, String mimeType, String charset) + throws IOException { + return doPost(url, paramMap, headMap, body, mimeType, charset, 0); + } + + /** + * 模拟请求 + * + * @param url 资源地址 + * @param paramMap 参数列表 + * @param headMap 请求头列表 + * @param body 请求body + * @param mimeType MIME type + * @param charset 编码 + * @param connectTimeout 超时时间 + * @return + * @throws NoSuchAlgorithmException + * @throws KeyManagementException + * @throws IOException + * @throws ClientProtocolException + */ + + public static String doPost(String url, Map paramMap, Map headMap, + String body, String mimeType, String charset, + int connectTimeout) throws IOException { + if (StringUtils.isBlank(charset)) { + charset = "utf=8"; } - - public static String doGet(String url, int connectTimeout) throws IOException { - return doGet(url, null, null, "utf-8", connectTimeout); + String result = ""; + // 采用绕过验证的方式处理https请求 + SSLContext sslcontext = null; + try { + sslcontext = createIgnoreVerifySSL(); + } catch (KeyManagementException | NoSuchAlgorithmException e) { + log.error(e.getMessage()); + return null; } - - public static String doGet(String url, Map paramMap, Map headMap) throws IOException { - return doGet(url, paramMap, headMap, "utf-8", 0); + // 设置协议http和https对应的处理socket链接工厂的对象 + Registry socketFactoryRegistry = RegistryBuilder + .create() + .register("http", PlainConnectionSocketFactory.INSTANCE) + .register("https", new SSLConnectionSocketFactory(sslcontext)).build(); + PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager( + socketFactoryRegistry); + // HttpClients.custom().setConnectionManager(connManager); + + // 创建自定义的httpclient对象 + // CloseableHttpClient client = + // HttpClients.custom().setConnectionManager(connManager).build(); + if (connectTimeout <= 0) { + connectTimeout = 8000; } - - public static String doGet(String url, Map paramMap, Map headMap, int connectTimeout) throws IOException { - return doGet(url, paramMap, headMap, "utf-8", connectTimeout); + // 设置代理 + HttpHost proxy = null; + if (headMap != null && headMap.containsKey("caohua_proxy_ip") && headMap + .containsKey("caohua_proxy_port")) { + String proxyIp = headMap.get("caohua_proxy_ip"); + int proxyPort = Integer.parseInt(headMap.get("caohua_proxy_port")); + proxy = new HttpHost(proxyIp, proxyPort); + } + RequestConfig defaultRequestConfig = null; + defaultRequestConfig = RequestConfig.custom().setConnectTimeout(connectTimeout) + .setSocketTimeout(connectTimeout).setProxy(proxy).build(); + + // 创建自定义的httpclient对象 + HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connManager); + builder.setDefaultRequestConfig(defaultRequestConfig); + CloseableHttpClient client = builder.build(); + // 创建post方式请求对象 + HttpPost httpPost = new HttpPost(url); + if (StringUtils.isNotBlank(body)) { + HttpEntity entity = new StringEntity(body, ContentType.create(mimeType, charset)); + httpPost.setEntity(entity); + } + // 装填参数 + if (paramMap != null) { + List nvps = new ArrayList(); + for (Entry entry : paramMap.entrySet()) { + nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); + } + // 设置参数到请求对象中 + try { + httpPost.setEntity(new UrlEncodedFormEntity(nvps, charset)); + } catch (UnsupportedEncodingException e) { + log.error(e.getMessage()); + return null; + } + } + // 设置header信息 + if (headMap != null) { + for (Entry entry : headMap.entrySet()) { + if (StringUtils.contains(entry.getKey(), "caohua_proxy")) { + continue; + } + httpPost.setHeader(entry.getKey(), entry.getValue()); + } + } + try { + // 执行请求操作,并拿到结果(同步阻塞) + CloseableHttpResponse response = client.execute(httpPost); + // 获取结果实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + result = EntityUtils.toString(entity, charset); + } + EntityUtils.consume(entity); + response.close(); + } catch (ClientProtocolException e) { + log.error(e.getMessage()); + } + return result; + } + + public static String doGet(String url) throws IOException { + return doGet(url, null, null, "utf-8", 0); + } + + public static String doGet(String url, int connectTimeout) throws IOException { + return doGet(url, null, null, "utf-8", connectTimeout); + } + + public static String doGet(String url, Map paramMap, Map headMap) + throws IOException { + return doGet(url, paramMap, headMap, "utf-8", 0); + } + + public static String doGet(String url, Map paramMap, Map headMap, + int connectTimeout) throws IOException { + return doGet(url, paramMap, headMap, "utf-8", connectTimeout); + } + + public static String doGet(String url, Map paramMap, Map headMap, + String charset, int connectTimeout, + String cookieSpec) throws IOException { + String result = ""; + // 采用绕过验证的方式处理https请求 + SSLContext sslcontext = null; + try { + sslcontext = createIgnoreVerifySSL(); + } catch (KeyManagementException | NoSuchAlgorithmException e) { + log.error(e.getMessage()); + return null; } - public static String doGet(String url, Map paramMap, Map headMap, String charset, int connectTimeout, - String cookieSpec) throws IOException { - String result = ""; - // 采用绕过验证的方式处理https请求 - SSLContext sslcontext = null; - try { - sslcontext = createIgnoreVerifySSL(); - } catch (KeyManagementException | NoSuchAlgorithmException e) { - logger.error(e.getMessage()); - return null; - } - - // 设置协议http和https对应的处理socket链接工厂的对象 - Registry socketFactoryRegistry = RegistryBuilder. create() - .register("http", PlainConnectionSocketFactory.INSTANCE).register("https", new SSLConnectionSocketFactory(sslcontext)).build(); - PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); - // HttpClients.custom().setConnectionManager(connManager); + // 设置协议http和https对应的处理socket链接工厂的对象 + Registry socketFactoryRegistry = RegistryBuilder + .create() + .register("http", PlainConnectionSocketFactory.INSTANCE) + .register("https", new SSLConnectionSocketFactory(sslcontext)).build(); + PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager( + socketFactoryRegistry); + // HttpClients.custom().setConnectionManager(connManager); + + if (connectTimeout <= 0) { + connectTimeout = 8000; + } + // 设置代理 + HttpHost proxy = null; + if (headMap != null && headMap.containsKey("caohua_proxy_ip") && headMap + .containsKey("caohua_proxy_port")) { + String proxyIp = headMap.get("caohua_proxy_ip"); + int proxyPort = Integer.parseInt(headMap.get("caohua_proxy_port")); + proxy = new HttpHost(proxyIp, proxyPort); + } + RequestConfig defaultRequestConfig = null; + if (StringUtils.isNotBlank(cookieSpec)) { + defaultRequestConfig = RequestConfig.custom().setSocketTimeout(connectTimeout) + .setConnectTimeout(connectTimeout).setCookieSpec(cookieSpec) + .setProxy(proxy).build(); + } else { + defaultRequestConfig = RequestConfig.custom().setSocketTimeout(connectTimeout) + .setConnectTimeout(connectTimeout).setProxy(proxy).build(); + } // 创建自定义的httpclient对象 + HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connManager); + builder.setDefaultRequestConfig(defaultRequestConfig); + CloseableHttpClient client = builder.build(); + + if (paramMap != null) { + StringBuffer sbf = new StringBuffer(); + sbf.append(url); + if (url.contains("?")) { + sbf.append("&"); + } else { + sbf.append("?"); + } + int n = 0; + for (Entry entry : paramMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + sbf.append(key).append("=").append(value); + if (n < paramMap.size() - 1) { + sbf.append("&"); + } + n++; + } + url = sbf.toString(); + } + // 创建get方式请求对象 + HttpGet httpGet = new HttpGet(url); + // 设置header信息 + if (headMap != null) { + for (Entry entry : headMap.entrySet()) { + if (StringUtils.contains(entry.getKey(), "caohua_proxy")) { + continue; + } + httpGet.setHeader(entry.getKey(), entry.getValue()); + } + } - if (connectTimeout <= 0) { - connectTimeout = 8000;// 默认设置8秒 - } - // 设置代理 - HttpHost proxy = null; - if (headMap != null && headMap.containsKey("caohua_proxy_ip") && headMap.containsKey("caohua_proxy_port")) { - String proxy_ip = headMap.get("caohua_proxy_ip"); - int proxy_port = Integer.parseInt(headMap.get("caohua_proxy_port")); - proxy = new HttpHost(proxy_ip, proxy_port); - } - RequestConfig defaultRequestConfig = null; - if (StringUtils.isNotBlank(cookieSpec)) { - defaultRequestConfig = RequestConfig.custom().setSocketTimeout(connectTimeout).setConnectTimeout(connectTimeout).setCookieSpec(cookieSpec) - .setProxy(proxy).build(); - } else { - defaultRequestConfig = RequestConfig.custom().setSocketTimeout(connectTimeout).setConnectTimeout(connectTimeout).setProxy(proxy).build(); - } // 创建自定义的httpclient对象 - HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connManager); - builder.setDefaultRequestConfig(defaultRequestConfig); - CloseableHttpClient client = builder.build(); - - if (paramMap != null) { - StringBuffer sbf = new StringBuffer(); - sbf.append(url); - if (url.contains("?")) { - sbf.append("&"); - } else { - sbf.append("?"); - } - int n = 0; - for (Entry entry : paramMap.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - sbf.append(key).append("=").append(value); - if (n < paramMap.size() - 1) { - sbf.append("&"); - } - n++; - } - url = sbf.toString(); - } - // 创建get方式请求对象 - HttpGet httpGet = new HttpGet(url); - // 设置header信息 - if (headMap != null) { - for (Entry entry : headMap.entrySet()) { - if (StringUtils.contains(entry.getKey(), "caohua_proxy")) { - continue; - } - httpGet.setHeader(entry.getKey(), entry.getValue()); - } - } + try { + // 执行请求操作,并拿到结果(同步阻塞) + CloseableHttpResponse response = client.execute(httpGet); + // 获取结果实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + result = EntityUtils.toString(entity, charset); + } + EntityUtils.consume(entity); + response.close(); + } catch (ClientProtocolException e) { + e.printStackTrace(); + log.error(e.getMessage()); + } - try { - // 执行请求操作,并拿到结果(同步阻塞) - CloseableHttpResponse response = client.execute(httpGet); - // 获取结果实体 - HttpEntity entity = response.getEntity(); - if (entity != null) { - result = EntityUtils.toString(entity, charset);// 按指定编码转换结果实体为String类型 - } - EntityUtils.consume(entity); - response.close();// 释放链接 - } catch (ClientProtocolException e) { - e.printStackTrace(); - logger.error(e.getMessage()); - } + return result; + } + + public static String doGet(String url, Map paramMap, Map headMap, + String charset, int connectTimeout) + throws IOException { + return doGet(url, paramMap, headMap, "utf-8", connectTimeout, null); + } + + public static Map doGetFull(String url, Map paramMap, + Map headMap, String charset, + int connectTimeout) throws IOException { + charset = StringUtils.isBlank(charset) ? "utf-8" : charset; + Map retMap = new HashMap(); + String result = ""; + // 采用绕过验证的方式处理https请求 + SSLContext sslcontext = null; + try { + sslcontext = createIgnoreVerifySSL(); + } catch (KeyManagementException | NoSuchAlgorithmException e) { + log.error(e.getMessage()); + return null; + } - return result; + // 设置协议http和https对应的处理socket链接工厂的对象 + Registry socketFactoryRegistry = RegistryBuilder + .create() + .register("http", PlainConnectionSocketFactory.INSTANCE) + .register("https", new SSLConnectionSocketFactory(sslcontext)).build(); + PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager( + socketFactoryRegistry); + // HttpClients.custom().setConnectionManager(connManager); + + // setConnectTimeout:设置连接超时时间,单位毫秒。 + // setConnectionRequestTimeout:设置从connect Manager获取Connection + // 超时时间,单位毫秒。这个属性是新加的属性,因为目前版本是可以共享连接池的。 + // setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。 + if (connectTimeout == 0) { + connectTimeout = 8000; + } + // 设置代理 + HttpHost proxy = null; + if (headMap != null && headMap.containsKey("caohua_proxy_ip") && headMap + .containsKey("caohua_proxy_port")) { + String proxyIp = headMap.get("caohua_proxy_ip"); + int proxyPort = Integer.parseInt(headMap.get("caohua_proxy_port")); + proxy = new HttpHost(proxyIp, proxyPort); + } + CookieStore cookieStore = new BasicCookieStore(); + RequestConfig defaultRequestConfig = RequestConfig.custom().setSocketTimeout(connectTimeout) + .setConnectTimeout(connectTimeout).setProxy(proxy) + .build(); + // 创建自定义的httpclient对象 + HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connManager); + builder.setDefaultRequestConfig(defaultRequestConfig); + CloseableHttpClient client = builder.setDefaultCookieStore(cookieStore).build(); + + if (paramMap != null) { + StringBuffer sbf = new StringBuffer(); + sbf.append(url).append("?"); + int n = 0; + for (Entry entry : paramMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + sbf.append(key).append("=").append(value); + if (n < paramMap.size() - 1) { + sbf.append("&"); + } + n++; + } + url = sbf.toString(); + } + // 创建get方式请求对象 + HttpGet httpGet = new HttpGet(url); + // 设置header信息 + if (headMap != null) { + for (Entry entry : headMap.entrySet()) { + if (StringUtils.contains(entry.getKey(), "caohua_proxy")) { + continue; + } + httpGet.setHeader(entry.getKey(), entry.getValue()); + } } - public static String doGet(String url, Map paramMap, Map headMap, String charset, int connectTimeout) - throws IOException { - return doGet(url, paramMap, headMap, "utf-8", connectTimeout, null); + try { + // 执行请求操作,并拿到结果(同步阻塞) + CloseableHttpResponse response = client.execute(httpGet); + // 获取结果实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + result = EntityUtils.toString(entity, charset); + } + EntityUtils.consume(entity); + List cookies = cookieStore.getCookies(); + Header[] headers = response.getAllHeaders(); + retMap.put("cookies", cookies); + retMap.put("headers", headers); + retMap.put("statusLine", response.getStatusLine()); + response.close(); + } catch (ClientProtocolException e) { + log.error(e.getMessage()); + } + retMap.put("result", result); + return retMap; + } + + public static Map doPostFull(String url, Map paramMap, + Map headMap, String body, String mimeType, + String charset) throws IOException { + return doPostFull(url, paramMap, headMap, body, mimeType, charset, 0); + } + + public static Map doPostFull(String url, Map paramMap, + Map headMap, String body, String mimeType, + String charset, int connectTimeout, String cookieSpec) throws IOException { + charset = StringUtils.isBlank(charset) ? "utf-8" : charset; + Map retMap = new HashMap(); + String result = ""; + // 采用绕过验证的方式处理https请求 + SSLContext sslcontext = null; + try { + sslcontext = createIgnoreVerifySSL(); + } catch (KeyManagementException | NoSuchAlgorithmException e) { + log.error(e.getMessage()); + return null; } - public static Map doGetFull(String url, Map paramMap, Map headMap, String charset, - int connectTimeout) throws IOException { - charset = StringUtils.isBlank(charset) ? "utf-8" : charset; - Map retMap = new HashMap(); - String result = ""; - // 采用绕过验证的方式处理https请求 - SSLContext sslcontext = null; - try { - sslcontext = createIgnoreVerifySSL(); - } catch (KeyManagementException | NoSuchAlgorithmException e) { - logger.error(e.getMessage()); - return null; - } + // 设置协议http和https对应的处理socket链接工厂的对象 + Registry socketFactoryRegistry = RegistryBuilder + .create() + .register("http", PlainConnectionSocketFactory.INSTANCE) + .register("https", new SSLConnectionSocketFactory(sslcontext)).build(); + PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager( + socketFactoryRegistry); + // HttpClients.custom().setConnectionManager(connManager); + // setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。 + if (connectTimeout == 0) { + connectTimeout = 8000; + } + // 设置代理 + HttpHost proxy = null; + if (headMap != null && headMap.containsKey("caohua_proxy_ip") && headMap + .containsKey("caohua_proxy_port")) { + String proxyIp = headMap.get("caohua_proxy_ip"); + int proxyPort = Integer.parseInt(headMap.get("caohua_proxy_port")); + proxy = new HttpHost(proxyIp, proxyPort); + } + CookieStore cookieStore = new BasicCookieStore(); + RequestConfig defaultRequestConfig = null; + if (StringUtils.isNotBlank(cookieSpec)) { + defaultRequestConfig = RequestConfig.custom().setSocketTimeout(connectTimeout) + .setCookieSpec(cookieSpec).setProxy(proxy).build(); + } else { + defaultRequestConfig = RequestConfig.custom().setSocketTimeout(connectTimeout).setProxy(proxy) + .build(); + } - // 设置协议http和https对应的处理socket链接工厂的对象 - Registry socketFactoryRegistry = RegistryBuilder. create() - .register("http", PlainConnectionSocketFactory.INSTANCE).register("https", new SSLConnectionSocketFactory(sslcontext)).build(); - PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); - // HttpClients.custom().setConnectionManager(connManager); - - // setConnectTimeout:设置连接超时时间,单位毫秒。 - // setConnectionRequestTimeout:设置从connect Manager获取Connection - // 超时时间,单位毫秒。这个属性是新加的属性,因为目前版本是可以共享连接池的。 - // setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。 - if (connectTimeout == 0) { - connectTimeout = 8000;// 默认设置8秒 - } - // 设置代理 - HttpHost proxy = null; - if (headMap != null && headMap.containsKey("caohua_proxy_ip") && headMap.containsKey("caohua_proxy_port")) { - String proxy_ip = headMap.get("caohua_proxy_ip"); - int proxy_port = Integer.parseInt(headMap.get("caohua_proxy_port")); - proxy = new HttpHost(proxy_ip, proxy_port); - } - CookieStore cookieStore = new BasicCookieStore(); - RequestConfig defaultRequestConfig = RequestConfig.custom().setSocketTimeout(connectTimeout).setConnectTimeout(connectTimeout).setProxy(proxy) - .build(); - // 创建自定义的httpclient对象 - HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connManager); - builder.setDefaultRequestConfig(defaultRequestConfig); - CloseableHttpClient client = builder.setDefaultCookieStore(cookieStore).build(); - - if (paramMap != null) { - StringBuffer sbf = new StringBuffer(); - sbf.append(url).append("?"); - int n = 0; - for (Entry entry : paramMap.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - sbf.append(key).append("=").append(value); - if (n < paramMap.size() - 1) { - sbf.append("&"); - } - n++; - } - url = sbf.toString(); - } - // 创建get方式请求对象 - HttpGet httpGet = new HttpGet(url); - // 设置header信息 - if (headMap != null) { - for (Entry entry : headMap.entrySet()) { - if (StringUtils.contains(entry.getKey(), "caohua_proxy")) { - continue; - } - httpGet.setHeader(entry.getKey(), entry.getValue()); - } - } + // 创建自定义的httpclient对象 + HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connManager); + builder.setDefaultRequestConfig(defaultRequestConfig); + CloseableHttpClient client = builder.setDefaultCookieStore(cookieStore).build(); - try { - // 执行请求操作,并拿到结果(同步阻塞) - CloseableHttpResponse response = client.execute(httpGet); - // 获取结果实体 - HttpEntity entity = response.getEntity(); - if (entity != null) { - result = EntityUtils.toString(entity, charset);// 按指定编码转换结果实体为String类型 - } - EntityUtils.consume(entity); - List cookies = cookieStore.getCookies(); - Header[] headers = response.getAllHeaders(); - retMap.put("cookies", cookies); - retMap.put("headers", headers); - retMap.put("statusLine", response.getStatusLine()); - response.close();// 释放链接 - } catch (ClientProtocolException e) { - logger.error(e.getMessage()); - } - retMap.put("result", result); - return retMap; + // 创建post方式请求对象 + HttpPost httpPost = new HttpPost(url); + if (StringUtils.isNotBlank(body)) { + HttpEntity entity = new StringEntity(body, ContentType.create(mimeType, charset)); + httpPost.setEntity(entity); } - - public static Map doPostFull(String url, Map paramMap, Map headMap, String body, String mimeType, - String charset) throws IOException { - return doPostFull(url, paramMap, headMap, body, mimeType, charset, 0); + // 装填参数 + if (paramMap != null) { + List nvps = new ArrayList(); + for (Entry entry : paramMap.entrySet()) { + nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); + } + // 设置参数到请求对象中 + try { + httpPost.setEntity(new UrlEncodedFormEntity(nvps, charset)); + } catch (UnsupportedEncodingException e) { + log.error(e.getMessage()); + return null; + } + } + // 设置header信息 + if (headMap != null) { + for (Entry entry : headMap.entrySet()) { + if (StringUtils.contains(entry.getKey(), "caohua_proxy")) { + continue; + } + httpPost.setHeader(entry.getKey(), entry.getValue()); + } } + try { + // 执行请求操作,并拿到结果(同步阻塞) + CloseableHttpResponse response = client.execute(httpPost); + // 获取结果实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + result = EntityUtils.toString(entity, charset); + } + EntityUtils.consume(entity); + List cookies = cookieStore.getCookies(); + Header[] headers = response.getAllHeaders(); + retMap.put("cookies", cookies); + retMap.put("headers", headers); + + response.close(); + } catch (ClientProtocolException e) { + log.error(e.getMessage()); + } + retMap.put("result", result); + return retMap; + } - public static Map doPostFull(String url, Map paramMap, Map headMap, String body, String mimeType, - String charset, int connectTimeout, String cookieSpec) throws IOException { - charset = StringUtils.isBlank(charset) ? "utf-8" : charset; - Map retMap = new HashMap(); - String result = ""; - // 采用绕过验证的方式处理https请求 - SSLContext sslcontext = null; - try { - sslcontext = createIgnoreVerifySSL(); - } catch (KeyManagementException | NoSuchAlgorithmException e) { - logger.error(e.getMessage()); - return null; + public static Map doPostFull(String url, Map paramMap, + Map headMap, String body, String mimeType, + String charset, int connectTimeout) throws IOException { + return doPostFull(url, paramMap, headMap, body, mimeType, charset, connectTimeout, null); + } + + /** + * 创建SSL安全连接 + */ + @SuppressWarnings("deprecation") + public static SSLConnectionSocketFactory createSSLConnSocketFactory() { + SSLConnectionSocketFactory sslsf = null; + try { + X509TrustManager xtm = new X509TrustManager() { // 创建TrustManager + public void checkClientTrusted(X509Certificate[] chain, String authType) + throws CertificateException { } - // 设置协议http和https对应的处理socket链接工厂的对象 - Registry socketFactoryRegistry = RegistryBuilder. create() - .register("http", PlainConnectionSocketFactory.INSTANCE).register("https", new SSLConnectionSocketFactory(sslcontext)).build(); - PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); - // HttpClients.custom().setConnectionManager(connManager); - // setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。 - if (connectTimeout == 0) { - connectTimeout = 8000;// 默认设置8秒 + public void checkServerTrusted(X509Certificate[] chain, String authType) + throws CertificateException { } - // 设置代理 - HttpHost proxy = null; - if (headMap != null && headMap.containsKey("caohua_proxy_ip") && headMap.containsKey("caohua_proxy_port")) { - String proxy_ip = headMap.get("caohua_proxy_ip"); - int proxy_port = Integer.parseInt(headMap.get("caohua_proxy_port")); - proxy = new HttpHost(proxy_ip, proxy_port); + + public X509Certificate[] getAcceptedIssuers() { + return null; } - CookieStore cookieStore = new BasicCookieStore(); - RequestConfig defaultRequestConfig = null; - if (StringUtils.isNotBlank(cookieSpec)) { - defaultRequestConfig = RequestConfig.custom().setSocketTimeout(connectTimeout).setCookieSpec(cookieSpec).setProxy(proxy).build(); - } else { - defaultRequestConfig = RequestConfig.custom().setSocketTimeout(connectTimeout).setProxy(proxy).build(); + }; + SSLContext ctx = SSLContext.getInstance("SSL"); + ctx.init(null, new TrustManager[]{xtm}, null); + sslsf = new SSLConnectionSocketFactory(ctx, new X509HostnameVerifier() { + @Override + public boolean verify(String arg0, SSLSession arg1) { + return true; } - // 创建自定义的httpclient对象 - HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connManager); - builder.setDefaultRequestConfig(defaultRequestConfig); - CloseableHttpClient client = builder.setDefaultCookieStore(cookieStore).build(); - - // 创建post方式请求对象 - HttpPost httpPost = new HttpPost(url); - if (StringUtils.isNotBlank(body)) { - HttpEntity entity = new StringEntity(body, ContentType.create(mimeType, charset)); - httpPost.setEntity(entity); + @Override + public void verify(String host, SSLSocket ssl) throws IOException { } - // 装填参数 - if (paramMap != null) { - List nvps = new ArrayList(); - for (Entry entry : paramMap.entrySet()) { - nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); - } - // 设置参数到请求对象中 - try { - httpPost.setEntity(new UrlEncodedFormEntity(nvps, charset)); - } catch (UnsupportedEncodingException e) { - logger.error(e.getMessage()); - return null; - } - } - // 设置header信息 - if (headMap != null) { - for (Entry entry : headMap.entrySet()) { - if (StringUtils.contains(entry.getKey(), "caohua_proxy")) { - continue; - } - httpPost.setHeader(entry.getKey(), entry.getValue()); - } + + @Override + public void verify(String host, X509Certificate cert) throws SSLException { } - try { - // 执行请求操作,并拿到结果(同步阻塞) - CloseableHttpResponse response = client.execute(httpPost); - // 获取结果实体 - HttpEntity entity = response.getEntity(); - if (entity != null) { - result = EntityUtils.toString(entity, charset);// 按指定编码转换结果实体为String类型 - } - EntityUtils.consume(entity); - List cookies = cookieStore.getCookies(); - Header[] headers = response.getAllHeaders(); - retMap.put("cookies", cookies); - retMap.put("headers", headers); - - response.close();// 释放链接 - } catch (ClientProtocolException e) { - logger.error(e.getMessage()); + + @Override + public void verify(String host, String[] cns, String[] subjectAlts) throws SSLException { } - retMap.put("result", result); - return retMap; + }); + } catch (GeneralSecurityException e) { + e.printStackTrace(); } - - public static Map doPostFull(String url, Map paramMap, Map headMap, String body, String mimeType, - String charset, int connectTimeout) throws IOException { - return doPostFull(url, paramMap, headMap, body, mimeType, charset, connectTimeout, null); + return sslsf; + } + + /** + * 创建cookie字符串 + * + * @param cookiemap + * @return + * @author 文香炯 + * @date 2018年1月10日 下午5:09:58 + * @version V1.0 + */ + public static String buildCookie(Map cookiemap) { + if (cookiemap == null) { + return ""; } - - /** - * 创建SSL安全连接 - */ - @SuppressWarnings("deprecation") - public static SSLConnectionSocketFactory createSSLConnSocketFactory() { - SSLConnectionSocketFactory sslsf = null; - try { - X509TrustManager xtm = new X509TrustManager() { // 创建TrustManager - public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { - } - - public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { - } - - public X509Certificate[] getAcceptedIssuers() { - return null; - } - }; - SSLContext ctx = SSLContext.getInstance("SSL"); - ctx.init(null, new TrustManager[] { xtm }, null); - sslsf = new SSLConnectionSocketFactory(ctx, new X509HostnameVerifier() { - @Override - public boolean verify(String arg0, SSLSession arg1) { - return true; - } - - @Override - public void verify(String host, SSLSocket ssl) throws IOException { - } - - @Override - public void verify(String host, X509Certificate cert) throws SSLException { - } - - @Override - public void verify(String host, String[] cns, String[] subjectAlts) throws SSLException { - } - }); - } catch (GeneralSecurityException e) { - e.printStackTrace(); - } - return sslsf; - } - - /** - * 创建cookie字符串 - * - * @param cookiemap - * @return - * @author 文香炯 - * @date 2018年1月10日 下午5:09:58 - * @version V1.0 - */ - public static String buildCookie(Map cookiemap) { - if (cookiemap == null) { - return ""; - } - StringBuffer sb = new StringBuffer(); - for (String key : cookiemap.keySet()) { - sb.append(key).append("=").append(cookiemap.get(key)).append("; "); - } - return sb.toString(); - } - - /** - * 创建cookie字符串 - * - * @param cookiemap - * @return - * @author 文香炯 - * @date 2018年1月10日 下午5:09:58 - * @version V1.0 - */ - public static String buildCookieByMap(Map cookiemap) { - if (cookiemap == null) { - return ""; - } - StringBuffer sb = new StringBuffer(); - for (Cookie cookie : cookiemap.values()) { - sb.append(cookie.getName()).append("=").append(cookie.getValue()).append("; "); - } - return sb.toString(); - } - - /** - * 创建cookie字符串 - * - * @param cookiemap - * @return - * @author 文香炯 - * @date 2018年1月10日 下午5:09:58 - * @version V1.0 - */ - public static String buildCookie(List cookies) { - if (cookies == null) { - return ""; - } - StringBuffer sb = new StringBuffer(); - for (Cookie cookie : cookies) { - sb.append(cookie.getName()).append("=").append(cookie.getValue()).append("; "); - } - return sb.toString(); - } - - /** - * 根据cookie列表创建cookie map - * - * @param cookies - * @return - * @author 文香炯 - * @date 2018年1月12日 上午11:07:18 - * @version V1.0 - */ - public static Map buildCookieMap(List cookies) { - if (cookies == null) { - return null; - } - Map map = new HashMap(); - for (Cookie cookie : cookies) { - map.put(cookie.getName(), cookie); - } - return map; - } - - /** - * 根据创建基于字符串值的cookie map - * - * @param cookies - * @return - * @author 文香炯 - * @date 2018年1月12日 上午11:07:18 - * @version V1.0 - */ - public static Map buildCookieStrMap(Map cookies) { - if (cookies == null) { - return null; - } - Map map = new HashMap(); - for (Cookie cookie : cookies.values()) { - map.put(cookie.getName(), cookie.getValue()); - } - return map; - } - - /** - * 根据创建基于字符串值的cookie map - * - * @param cookies - * @return - * @author 文香炯 - * @date 2018年1月12日 上午11:07:18 - * @version V1.0 - */ - public static Map buildCookieStrMap(List cookies) { - if (cookies == null) { - return null; - } - Map map = new HashMap(); - for (Cookie cookie : cookies) { - map.put(cookie.getName(), cookie.getValue()); - } - return map; - } - - /** - * 根据cookie map创建cookie列表 - * - * @param cookies - * @return - * @author 文香炯 - * @date 2018年1月12日 上午11:07:18 - * @version V1.0 - */ - public static List buildCookieList(Map cookiemap) { - if (cookiemap == null) { - return null; - } - List cookies = new ArrayList(); - for (Cookie cookie : cookiemap.values()) { - cookies.add(cookie); - } - return cookies; + StringBuffer sb = new StringBuffer(); + for (String key : cookiemap.keySet()) { + sb.append(key).append("=").append(cookiemap.get(key)).append("; "); } - - public static String getUrlParamByName(String url, String param) { - Map params = getParamByUrl(url); - return params.get(param); + return sb.toString(); + } + + /** + * 创建cookie字符串 + * + * @param cookiemap + * @return + * @author 文香炯 + * @date 2018年1月10日 下午5:09:58 + * @version V1.0 + */ + public static String buildCookieByMap(Map cookiemap) { + if (cookiemap == null) { + return ""; } - - public static Map getParamByUrl(String url) { - Map map = new HashMap<>(); - List list = null; - if (StringUtils.isBlank(url)) { - return map; - } - try { - list = URLEncodedUtils.parse(new URI(url), "UTF-8"); - } catch (URISyntaxException e) { - logger.error("HttpClientToolUtils.getParamByUrl.error.解析url出错"); - } - for (NameValuePair pair : list) { - map.put(pair.getName(), pair.getValue()); - } - return map; + StringBuffer sb = new StringBuffer(); + for (Cookie cookie : cookiemap.values()) { + sb.append(cookie.getName()).append("=").append(cookie.getValue()).append("; "); + } + return sb.toString(); + } + + /** + * 创建cookie字符串 + * + * @return + * @author 文香炯 + * @date 2018年1月10日 下午5:09:58 + * @version V1.0 + */ + public static String buildCookie(List cookies) { + if (cookies == null) { + return ""; + } + StringBuffer sb = new StringBuffer(); + for (Cookie cookie : cookies) { + sb.append(cookie.getName()).append("=").append(cookie.getValue()).append("; "); + } + return sb.toString(); + } + + /** + * 根据cookie列表创建cookie map + * + * @param cookies + * @return + * @author 文香炯 + * @date 2018年1月12日 上午11:07:18 + * @version V1.0 + */ + public static Map buildCookieMap(List cookies) { + if (cookies == null) { + return null; + } + Map map = new HashMap(); + for (Cookie cookie : cookies) { + map.put(cookie.getName(), cookie); + } + return map; + } + + /** + * 根据创建基于字符串值的cookie map + * + * @param cookies + * @return + * @author 文香炯 + * @date 2018年1月12日 上午11:07:18 + * @version V1.0 + */ + public static Map buildCookieStrMap(Map cookies) { + if (cookies == null) { + return null; + } + Map map = new HashMap(); + for (Cookie cookie : cookies.values()) { + map.put(cookie.getName(), cookie.getValue()); + } + return map; + } + + /** + * 根据创建基于字符串值的cookie map + * + * @param cookies + * @return + * @author 文香炯 + * @date 2018年1月12日 上午11:07:18 + * @version V1.0 + */ + public static Map buildCookieStrMap(List cookies) { + if (cookies == null) { + return null; + } + Map map = new HashMap(); + for (Cookie cookie : cookies) { + map.put(cookie.getName(), cookie.getValue()); + } + return map; + } + + /** + * 根据cookie map创建cookie列表 + * + * @param cookies + * @return + * @author 文香炯 + * @date 2018年1月12日 上午11:07:18 + * @version V1.0 + */ + public static List buildCookieList(Map cookiemap) { + if (cookiemap == null) { + return null; + } + List cookies = new ArrayList(); + for (Cookie cookie : cookiemap.values()) { + cookies.add(cookie); + } + return cookies; + } + + public static String getUrlParamByName(String url, String param) { + Map params = getParamByUrl(url); + return params.get(param); + } + + public static Map getParamByUrl(String url) { + Map map = new HashMap<>(); + List list = null; + if (StringUtils.isBlank(url)) { + return map; + } + try { + list = URLEncodedUtils.parse(new URI(url), "UTF-8"); + } catch (URISyntaxException e) { + log.error("HttpClientToolUtils.getParamByUrl.error.解析url出错"); + } + for (NameValuePair pair : list) { + map.put(pair.getName(), pair.getValue()); + } + return map; + } + + public static String doPut(String url, Map cookieMap, String paramJsonStr) { + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPut httpPut = new HttpPut(url); + RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000) + .setConnectionRequestTimeout(35000).setSocketTimeout(60000).build(); + httpPut.setConfig(requestConfig); + + for (String key : cookieMap.keySet()) { + httpPut.setHeader(key, cookieMap.get(key)); } - public static String doPut(String url, Map cookieMap, String paramJsonStr) { - CloseableHttpClient httpClient = HttpClients.createDefault(); - HttpPut httpPut = new HttpPut(url); - RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000).setConnectionRequestTimeout(35000).setSocketTimeout(60000).build(); - httpPut.setConfig(requestConfig); - - for (String key : cookieMap.keySet()) { - httpPut.setHeader(key,cookieMap.get(key)); + CloseableHttpResponse httpResponse = null; + try { + List list = new ArrayList(); + httpPut.setEntity(new StringEntity(paramJsonStr, ContentType.APPLICATION_JSON)); + httpResponse = httpClient.execute(httpPut, HttpClientContext.create()); + HttpEntity entity = httpResponse.getEntity(); + String result = EntityUtils.toString(entity); + return result; + } catch (ClientProtocolException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (httpResponse != null) { + try { + httpResponse.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - - CloseableHttpResponse httpResponse = null; + } + if (null != httpClient) { try { - Listlist = new ArrayList(); - httpPut.setEntity(new StringEntity(paramJsonStr,ContentType.APPLICATION_JSON)); - httpResponse = httpClient.execute(httpPut,HttpClientContext.create()); - HttpEntity entity = httpResponse.getEntity(); - String result = EntityUtils.toString(entity); - return result; - } catch (ClientProtocolException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + httpClient.close(); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } finally { - if (httpResponse != null) { - try { - httpResponse.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - if (null != httpClient) { - try { - httpClient.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + e.printStackTrace(); } - return null; + } } - + return null; + } +//CHECKSTYLE:ON } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/JacksonUtil.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/JacksonUtil.java index 30d42f58..da6f70ec 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/JacksonUtil.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/JacksonUtil.java @@ -25,290 +25,301 @@ /** * JacksonUtil - * + * * @author 文香炯 - * @date 2017年1月11日 下午2:42:09 * @version V1.0 + * @date 2017年1月11日 下午2:42:09 */ public class JacksonUtil { - private static ObjectMapper mapper = new ObjectMapper(); + private static ObjectMapper mapper = new ObjectMapper(); - /** - * 对象转换成Json字符串 - * - * @param obj - * @return - * @throws JsonProcessingException - * @author 文香炯 - * @date 2017年1月11日 下午2:55:10 - * @version V1.0 - */ - public static String toJsonString(Object obj) { - if (obj == null) { - return null; - } - String json = null; - try { - json = mapper.writeValueAsString(obj); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - return json; + /** + * 对象转换成Json字符串 + * + * @param obj + * @return + * @throws JsonProcessingException + * @author 文香炯 + * @date 2017年1月11日 下午2:55:10 + * @version V1.0 + */ + public static String toJsonString(Object obj) { + if (obj == null) { + return null; } - - /** - * json字符串转换成JsonNode - * - * @param json - * @return - * @throws JsonProcessingException - * @throws IOException - * @author 文香炯 - * @date 2017年1月11日 下午8:31:06 - * @version V1.0 - */ - public static JsonNode parse(String json) { - if (StringUtils.isBlank(json)) { - return null; - } - try { - return mapper.readTree(json); - } catch (IOException e) { - throw new RuntimeException(e); - } + String json = null; + try { + json = mapper.writeValueAsString(obj); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); } + return json; + } - /** - * Json字符串转换成对象 - * - * @param json - * @param clazz - * @return - * @throws JsonParseException - * @throws JsonMappingException - * @throws IOException - * @author 文香炯 - * @date 2017年1月11日 下午4:35:50 - * @version V1.0 - */ - public static Object parse(String json, Class clazz) { - if (StringUtils.isBlank(json)) { - return null; - } - try { - return mapper.readValue(json, clazz); - } catch (Exception e) { - throw new RuntimeException(e); - } + /** + * json字符串转换成JsonNode + * + * @param json + * @return + * @throws JsonProcessingException + * @throws IOException + * @author 文香炯 + * @date 2017年1月11日 下午8:31:06 + * @version V1.0 + */ + public static JsonNode parse(String json) { + if (StringUtils.isBlank(json)) { + return null; } - - /** - * 获取子JsonNode - * - * @param json - * @param fieldName - * @return - * @author 文香炯 - * @date 2017年1月12日 下午8:48:00 - * @version V1.0 - * @throws IOException - * @throws JsonProcessingException - */ - public static JsonNode parseByField(String json, String fieldName) throws JsonProcessingException, IOException { - JsonNode node = mapper.readTree(json); - JsonNode pnode = node.findPath(fieldName); - if (pnode == null || pnode instanceof MissingNode) { - return null; - } - return pnode; + try { + return mapper.readTree(json); + } catch (IOException e) { + throw new RuntimeException(e); } + } - /** - * pojo对象转换成JsonNode - * - * @param json - * @return - * @throws JsonProcessingException - * @throws IOException - * @author 文香炯 - * @date 2017年1月11日 下午8:31:06 - * @version V1.0 - */ - public static JsonNode toJsonNode(Object pojo) { - if (pojo == null) { - return null; - } - return mapper.valueToTree(pojo); + /** + * Json字符串转换成对象 + * + * @param json + * @param clazz + * @return + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + * @author 文香炯 + * @date 2017年1月11日 下午4:35:50 + * @version V1.0 + */ + public static Object parse(String json, Class clazz) { + if (StringUtils.isBlank(json)) { + return null; } - - /** - * 获取子JsonNode - * - * @param json - * @param fieldName - * @return - * @author 文香炯 - * @date 2017年1月12日 下午8:48:00 - * @version V1.0 - */ - public static JsonNode toJsonNodeByField(JsonNode json, String fieldName) { - JsonNode pnode = json.findPath(fieldName); - if (pnode == null || pnode instanceof MissingNode) { - return null; - } - return pnode; + try { + return mapper.readValue(json, clazz); + } catch (Exception e) { + throw new RuntimeException(e); } + } - /** - * JsonNode指定转换成对象 - * - * @param json - * @param paramname - * @param clazz - * @return - * @throws JsonProcessingException - * @throws IOException - * @author 文香炯 - * @date 2017年1月11日 下午8:26:52 - * @version V1.0 - */ - @SuppressWarnings("unchecked") - public static T toObject(JsonNode json, Class clazz) throws JsonProcessingException, IOException { - if (json == null || json instanceof MissingNode) { - return null; - } - if (!(json instanceof TextNode) && clazz.getName().equals(String.class.getName())) { - return (T) json.toString(); - } - return mapper.treeToValue(json, clazz); + /** + * 获取子JsonNode + * + * @param json + * @param fieldName + * @return + * @throws IOException + * @throws JsonProcessingException + * @author 文香炯 + * @date 2017年1月12日 下午8:48:00 + * @version V1.0 + */ + public static JsonNode parseByField(String json, String fieldName) + throws JsonProcessingException, IOException { + JsonNode node = mapper.readTree(json); + JsonNode pnode = node.findPath(fieldName); + if (pnode == null || pnode instanceof MissingNode) { + return null; } + return pnode; + } - public static T toObject(String json, JavaType javatype) throws JsonProcessingException, IOException { - return mapper.readValue(json, javatype); + /** + * pojo对象转换成JsonNode + * + * @param json + * @return + * @throws JsonProcessingException + * @throws IOException + * @author 文香炯 + * @date 2017年1月11日 下午8:31:06 + * @version V1.0 + */ + public static JsonNode toJsonNode(Object pojo) { + if (pojo == null) { + return null; } + return mapper.valueToTree(pojo); + } - public static T toObject(JsonNode json, JavaType javatype) throws JsonProcessingException, IOException { - return mapper.convertValue(json, javatype); + /** + * 获取子JsonNode + * + * @param json + * @param fieldName + * @return + * @author 文香炯 + * @date 2017年1月12日 下午8:48:00 + * @version V1.0 + */ + public static JsonNode toJsonNodeByField(JsonNode json, String fieldName) { + JsonNode pnode = json.findPath(fieldName); + if (pnode == null || pnode instanceof MissingNode) { + return null; } + return pnode; + } - /** - * 指定类(泛型)的转换 - * - * @param json - * @param clazz - * @return - * @throws JsonProcessingException - * @throws IOException - * @author 文香炯 - * @date 2018年8月8日 上午9:47:39 - * @version V1.0 - */ - public static T toObject(String json, Class... clazz) throws JsonProcessingException, IOException { - if (clazz == null || clazz.length == 0) { - return null; - } - Class parametrized = clazz[0]; - Class[] parameterClasses = new Class[clazz.length - 1]; - for (int i = 1; i < clazz.length; i++) { - parameterClasses[i - 1] = clazz[i]; - } - JavaType javatype = mapper.getTypeFactory().constructParametricType(parametrized, parameterClasses); - return mapper.readValue(json, javatype); + /** + * JsonNode指定转换成对象 + * + * @param json + * @param paramname + * @param clazz + * @return + * @throws JsonProcessingException + * @throws IOException + * @author 文香炯 + * @date 2017年1月11日 下午8:26:52 + * @version V1.0 + */ + @SuppressWarnings("unchecked") + public static T toObject(JsonNode json, Class clazz) + throws JsonProcessingException, IOException { + if (json == null || json instanceof MissingNode) { + return null; + } + if (!(json instanceof TextNode) && clazz.getName().equals(String.class.getName())) { + return (T) json.toString(); } + return mapper.treeToValue(json, clazz); + } + + public static T toObject(String json, JavaType javatype) + throws JsonProcessingException, IOException { + return mapper.readValue(json, javatype); + } - /** - * 获取Jackson的JavaType - * - * @param parametrized - * @param parameterClasses - * @return - * @author 文香炯 - * @date 2017年1月12日 下午8:12:28 - * @version V1.0 - */ - public static JavaType getJavaType(Class parametrized, Class[] parameterClasses) { - if (parametrized == null || parameterClasses == null || parameterClasses.length == 0) { - return null; - } - JavaType javatype = mapper.getTypeFactory().constructParametricType(parametrized, parameterClasses); - return javatype; + public static T toObject(JsonNode json, JavaType javatype) + throws JsonProcessingException, IOException { + return mapper.convertValue(json, javatype); + } + + /** + * 指定类(泛型)的转换 + * + * @param json + * @param clazz + * @return + * @throws JsonProcessingException + * @throws IOException + * @author 文香炯 + * @date 2018年8月8日 上午9:47:39 + * @version V1.0 + */ + public static T toObject(String json, Class... clazz) + throws JsonProcessingException, IOException { + if (clazz == null || clazz.length == 0) { + return null; + } + Class parametrized = clazz[0]; + Class[] parameterClasses = new Class[clazz.length - 1]; + for (int i = 1; i < clazz.length; i++) { + parameterClasses[i - 1] = clazz[i]; } + JavaType javatype = mapper.getTypeFactory() + .constructParametricType(parametrized, parameterClasses); + return mapper.readValue(json, javatype); + } - static { - mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); - mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); - mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); - mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); - // 反序列化时忽略多余的字段 - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - // 自定义格式化日期 - mapper.setDateFormat(new MyDateTimeFormat("yyyy-MM-dd HH:mm:ss")); - // 解决时间戳为整数转换的问题 - MyDateDeserializer myDateDeserializer = new MyDateDeserializer(); - SimpleModule newModule = new SimpleModule("MyDateDeserializer", PackageVersion.VERSION); - newModule.addDeserializer(Date.class, myDateDeserializer); - mapper.registerModule(newModule); + /** + * 获取Jackson的JavaType + * + * @param parametrized + * @param parameterClasses + * @return + * @author 文香炯 + * @date 2017年1月12日 下午8:12:28 + * @version V1.0 + */ + public static JavaType getJavaType(Class parametrized, Class[] parameterClasses) { + if (parametrized == null || parameterClasses == null || parameterClasses.length == 0) { + return null; } + JavaType javatype = mapper.getTypeFactory() + .constructParametricType(parametrized, parameterClasses); + return javatype; + } + + static { + mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); + mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); + mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); + mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); + // 反序列化时忽略多余的字段 + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + // 自定义格式化日期 + mapper.setDateFormat(new MyDateTimeFormat("yyyy-MM-dd HH:mm:ss")); + // 解决时间戳为整数转换的问题 + MyDateDeserializer myDateDeserializer = new MyDateDeserializer(); + SimpleModule newModule = new SimpleModule("MyDateDeserializer", PackageVersion.VERSION); + newModule.addDeserializer(Date.class, myDateDeserializer); + mapper.registerModule(newModule); + } - /** - * 自定义格式化日期类 - */ - private static class MyDateTimeFormat extends SimpleDateFormat { - private static final long serialVersionUID = 1899483410257705750L; + /** + * 自定义格式化日期类 + */ + private static class MyDateTimeFormat extends SimpleDateFormat { - public MyDateTimeFormat(String pattern) { - super(pattern); - } + private static final long serialVersionUID = 1899483410257705750L; - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - if (date.getTime() % 1000 > 0) { - SimpleDateFormat format_timstamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - return format_timstamp.format(date, toAppendTo, fieldPosition); - } else { - SimpleDateFormat format_datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - return format_datetime.format(date, toAppendTo, fieldPosition); - } - } + MyDateTimeFormat(String pattern) { + super(pattern); + } + + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + if (date.getTime() % 1000 > 0) { + SimpleDateFormat formatTimstamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + return formatTimstamp.format(date, toAppendTo, fieldPosition); + } else { + SimpleDateFormat formatDatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return formatDatetime.format(date, toAppendTo, fieldPosition); + } + } - @Override - public Date parse(String source, ParsePosition pos) { - if (source == null || source.length() == 0) { - return null; - } - if (StringUtils.isNumeric(source)) { - return new Date(Long.valueOf(source)); - } else if (source.length() <= 10) { - SimpleDateFormat format_date = new SimpleDateFormat("yyyy-MM-dd"); - return format_date.parse(source, pos); - } else if (source.length() <= 19) { - SimpleDateFormat format_datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - return format_datetime.parse(source, pos); - } else if (source.length() == 23) { - SimpleDateFormat format_timstamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - return format_timstamp.parse(source, pos); - } - return super.parse(source, pos); - } + //CHECKSTYLE:OFF + @Override + public Date parse(String source, ParsePosition pos) { + if (source == null || source.length() == 0) { + return null; + } + if (StringUtils.isNumeric(source)) { + return new Date(Long.valueOf(source)); + } else if (source.length() <= 10) { + SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd"); + return formatDate.parse(source, pos); + } else if (source.length() <= 19) { + SimpleDateFormat formatDatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return formatDatetime.parse(source, pos); + } else if (source.length() == 23) { + SimpleDateFormat formatTimstamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + return formatTimstamp.parse(source, pos); + } + return super.parse(source, pos); } + } + //CHECKSTYLE:ON - /** - * 解决时间戳为整数转换的问题 - */ - private static class MyDateDeserializer extends DateDeserializer { + /** + * 解决时间戳为整数转换的问题 + */ + private static class MyDateDeserializer extends DateDeserializer { - private static final long serialVersionUID = -6218693745160760598L; + private static final long serialVersionUID = -6218693745160760598L; - @Override - protected Date _parseDate(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - Date _parseDate = null; - try { - _parseDate = super._parseDate(jp, ctxt); - } catch (Exception ex) { - String dateStr = jp.getText().trim(); - _parseDate = new Date(Long.valueOf(dateStr)); - } - return _parseDate; - } + @Override + protected Date _parseDate(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + Date parseDate = null; + try { + parseDate = super._parseDate(jp, ctxt); + } catch (Exception ex) { + String dateStr = jp.getText().trim(); + parseDate = new Date(Long.valueOf(dateStr)); + } + return parseDate; } + } } diff --git a/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/WebUtil.java b/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/WebUtil.java index 4a425467..a0252714 100644 --- a/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/WebUtil.java +++ b/flink-streaming-web/src/main/java/com/flink/streaming/web/utils/WebUtil.java @@ -1,142 +1,141 @@ package com.flink.streaming.web.utils; +import com.flink.streaming.web.common.RestResult; import java.io.IOException; import java.io.PrintWriter; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j +public class WebUtil { -import com.flink.streaming.web.common.RestResult; -public class WebUtil { - - private static final Logger logger = LoggerFactory.getLogger(WebUtil.class); - - /** - * 判断是否为Ajax请求 - * - * @param request - * @return - * @author wxj - * @date 2020年8月7日 上午10:09:03 - * @version V1.0 - */ - public static boolean isAjaxRequest(HttpServletRequest request) { - return "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With")); - } - - /** - * 响应修改为Restful风格返回Json - * - * @param response - * @param status - * @param message - * @author wxj - * @date 2020年8月7日 上午10:31:45 - * @version V1.0 - */ - public static void restResponse(HttpServletResponse response, String status, String message) { - RestResult respone = RestResult.newInstance(status, message, null); - restResponse(response, respone); - } + /** + * 判断是否为Ajax请求 + * + * @param request + * @return + * @author wxj + * @date 2020年8月7日 上午10:09:03 + * @version V1.0 + */ + public static boolean isAjaxRequest(HttpServletRequest request) { + return "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With")); + } - /** - * 响应修改为Restful风格返回Json - * - * @param response - * @param status - * @param message - * @author wxj - * @date 2020年8月7日 上午10:33:08 - * @version V1.0 - */ - public static void restResponseWithFlush(HttpServletResponse response, String status, String message) { - restResponse(response, status, message); - flush(response); - } - - /** - * 响应修改为Restful风格返回Json - * - * @param response - * @param status - * @param message - * @param data - * @author wxj - * @date 2020年8月7日 上午10:33:12 - * @version V1.0 - */ - public static void restResponse(HttpServletResponse response, String status, String message, Object data) { - RestResult respone = RestResult.newInstance(status, message, data); - restResponse(response, respone); - } - - /** - * 响应修改为Restful风格返回Json - * - * @param response - * @param status - * @param message - * @param data - * @author wxj - * @date 2020年8月7日 上午10:33:16 - * @version V1.0 - */ - public static void restResponseWithFlush(HttpServletResponse response, String status, String message, Object data) { - restResponse(response, status, message, data); - flush(response); - } + /** + * 响应修改为Restful风格返回Json + * + * @param response + * @param status + * @param message + * @author wxj + * @date 2020年8月7日 上午10:31:45 + * @version V1.0 + */ + public static void restResponse(HttpServletResponse response, String status, String message) { + RestResult respone = RestResult.newInstance(status, message, null); + restResponse(response, respone); + } - /** - * 响应修改为Restful风格返回Json - * - * @param response - * @param data - * @author wxj - * @date 2020年8月7日 上午10:33:20 - * @version V1.0 - */ - public static void restResponse(HttpServletResponse response, RestResult data) { - try { - response.setContentType("application/json;charset=utf-8"); - PrintWriter out = response.getWriter(); - out.write(JacksonUtil.toJsonString(data)); - out.flush(); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } - } - - /** - * 响应修改为Restful风格返回Json - * - * @param response - * @param data - * @author wxj - * @date 2020年8月7日 上午10:33:24 - * @version V1.0 - */ - public static void restResponseWithFlush(HttpServletResponse response, RestResult data) { - restResponse(response, data); - flush(response); + /** + * 响应修改为Restful风格返回Json + * + * @param response + * @param status + * @param message + * @author wxj + * @date 2020年8月7日 上午10:33:08 + * @version V1.0 + */ + public static void restResponseWithFlush(HttpServletResponse response, String status, + String message) { + restResponse(response, status, message); + flush(response); + } + + /** + * 响应修改为Restful风格返回Json + * + * @param response + * @param status + * @param message + * @param data + * @author wxj + * @date 2020年8月7日 上午10:33:12 + * @version V1.0 + */ + public static void restResponse(HttpServletResponse response, String status, String message, + Object data) { + RestResult respone = RestResult.newInstance(status, message, data); + restResponse(response, respone); + } + + /** + * 响应修改为Restful风格返回Json + * + * @param response + * @param status + * @param message + * @param data + * @author wxj + * @date 2020年8月7日 上午10:33:16 + * @version V1.0 + */ + public static void restResponseWithFlush(HttpServletResponse response, String status, + String message, Object data) { + restResponse(response, status, message, data); + flush(response); + } + + /** + * 响应修改为Restful风格返回Json + * + * @param response + * @param data + * @author wxj + * @date 2020年8月7日 上午10:33:20 + * @version V1.0 + */ + public static void restResponse(HttpServletResponse response, RestResult data) { + try { + response.setContentType("application/json;charset=utf-8"); + PrintWriter out = response.getWriter(); + out.write(JacksonUtil.toJsonString(data)); + out.flush(); + } catch (IOException e) { + log.error(e.getMessage(), e); } - - /** - * Flush Response,设置完成状态 - * - * @param response - * @author wxj - * @date 2020年8月7日 上午10:33:31 - * @version V1.0 - */ - public static void flush(HttpServletResponse response) { - try { - response.getWriter().flush(); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } + } + + /** + * 响应修改为Restful风格返回Json + * + * @param response + * @param data + * @author wxj + * @date 2020年8月7日 上午10:33:24 + * @version V1.0 + */ + public static void restResponseWithFlush(HttpServletResponse response, RestResult data) { + restResponse(response, data); + flush(response); + } + + /** + * Flush Response,设置完成状态 + * + * @param response + * @author wxj + * @date 2020年8月7日 上午10:33:31 + * @version V1.0 + */ + public static void flush(HttpServletResponse response) { + try { + response.getWriter().flush(); + } catch (IOException e) { + log.error(e.getMessage(), e); } + } } diff --git a/flink-streaming-web/src/main/resources/application-docker.properties b/flink-streaming-web/src/main/resources/application-docker.properties index 0699683d..935d61f9 100644 --- a/flink-streaming-web/src/main/resources/application-docker.properties +++ b/flink-streaming-web/src/main/resources/application-docker.properties @@ -1,8 +1,6 @@ server.port=9084 spring.profiles.active=docker -logging.config= classpath:logging/logback-${spring.profiles.active}.xml -spring.devtools.livereload.enabled= false - - +logging.config=classpath:logging/logback-${spring.profiles.active}.xml +spring.devtools.livereload.enabled=false log.file.root=/data/projects/flink-streaming-platform-web/logs/ diff --git a/flink-streaming-web/src/main/resources/application-prod.properties b/flink-streaming-web/src/main/resources/application-prod.properties index 90cb5280..41ede201 100644 --- a/flink-streaming-web/src/main/resources/application-prod.properties +++ b/flink-streaming-web/src/main/resources/application-prod.properties @@ -1,6 +1,4 @@ - spring.profiles.active=prod -logging.config= classpath:logging/logback-${spring.profiles.active}.xml - -spring.devtools.livereload.enabled= false +logging.config=classpath:logging/logback-${spring.profiles.active}.xml +spring.devtools.livereload.enabled=false diff --git a/flink-streaming-web/src/main/resources/application.properties b/flink-streaming-web/src/main/resources/application.properties index ef81f500..a389e029 100644 --- a/flink-streaming-web/src/main/resources/application.properties +++ b/flink-streaming-web/src/main/resources/application.properties @@ -1,16 +1,11 @@ server.port=8180 spring.profiles.active=dev -logging.config= classpath:logging/logback-${spring.profiles.active}.xml - -spring.devtools.livereload.enabled= true - - +logging.config=classpath:logging/logback-${spring.profiles.active}.xml +spring.devtools.livereload.enabled=true spring.mvc.static-path-pattern=/static/** - spring.http.encoding.force=true ###mybatis mybatis.mapper-locations=classpath:mapper/*.xml - ####jdbc连接池 spring.datasource.url=jdbc:mysql://localhost:3306/flink_web?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=false spring.datasource.username=root @@ -38,11 +33,10 @@ spring.datasource.druid.stat-view-servlet.url-pattern=/druid/* spring.datasource.druid.stat-view-servlet.reset-enable=false spring.datasource.druid.stat-view-servlet.login-username=admin spring.datasource.druid.stat-view-servlet.login-password=123456 - #日志 -log.file.root= ../logs/ -log.file.maxHistory= 20 -log.file.maxSize= 200MB +log.file.root=../logs/ +log.file.maxHistory=20 +log.file.maxSize=200MB diff --git a/flink-streaming-web/src/main/resources/logging/logback-dev.xml b/flink-streaming-web/src/main/resources/logging/logback-dev.xml index d90d2d0c..7468b212 100644 --- a/flink-streaming-web/src/main/resources/logging/logback-dev.xml +++ b/flink-streaming-web/src/main/resources/logging/logback-dev.xml @@ -1,51 +1,51 @@ - - - - - - - - - - - - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - [%logger{0}:%L - %M] %msg%n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level - [%logger{0}:%L - %M] %msg%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flink-streaming-web/src/main/resources/logging/logback-docker.xml b/flink-streaming-web/src/main/resources/logging/logback-docker.xml index 41ab5243..71203756 100644 --- a/flink-streaming-web/src/main/resources/logging/logback-docker.xml +++ b/flink-streaming-web/src/main/resources/logging/logback-docker.xml @@ -1,96 +1,99 @@ - - - - - - - - - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - [%logger{0} - %M] %msg%n - - - - - ${LOG_HOME}/info.log - - INFO - - - - ${LOG_HOME}/old/info.log.%d{yyyy-MM-dd}.%i - - - ${LOG_SIZE} - - - ${LOG_NUM} - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [TxId : %X{PtxId}] %-5level %logger{50} - [%logger{0} - %M] %msg%n - - - - - ${LOG_HOME}/error.log - - - ERROR - ACCEPT - DENY - - - - ${LOG_HOME}/old/error.log.%d{yyyy-MM-dd}.%i - - - ${LOG_SIZE} - - !--日志文件保留天数--> - ${LOG_NUM} - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - [%logger{0} - %M] %msg%n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{0} - [%logger{0} - %M] + %msg%n + + + + + + ${LOG_HOME}/info.log + + INFO + + + + ${LOG_HOME}/old/info.log.%d{yyyy-MM-dd}.%i + + + ${LOG_SIZE} + + + ${LOG_NUM} + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [TxId : %X{PtxId}] %-5level %logger{50} - + [%logger{0} - %M] %msg%n + + + + + + ${LOG_HOME}/error.log + + + ERROR + ACCEPT + DENY + + + + ${LOG_HOME}/old/error.log.%d{yyyy-MM-dd}.%i + + + ${LOG_SIZE} + + !--日志文件保留天数--> + ${LOG_NUM} + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - [%logger{0} - %M] %msg%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/flink-streaming-web/src/main/resources/logging/logback-prod.xml b/flink-streaming-web/src/main/resources/logging/logback-prod.xml index 9e3b5489..e8914423 100644 --- a/flink-streaming-web/src/main/resources/logging/logback-prod.xml +++ b/flink-streaming-web/src/main/resources/logging/logback-prod.xml @@ -1,87 +1,89 @@ - - - - - - + + + + + + - - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}[%M:%L] %msg%n - - + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}[%M:%L] %msg%n + + - - ${LOG_HOME}/info.log - - - - ${LOG_HOME}/old/info.log.%d{yyyy-MM-dd}.%i - - - ${LOG_SIZE} - - - ${LOG_NUM} - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%logger{50} - %M:%L] %msg%n - - + + ${LOG_HOME}/info.log + + + + ${LOG_HOME}/old/info.log.%d{yyyy-MM-dd}.%i + + + ${LOG_SIZE} + + + ${LOG_NUM} + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%logger{50} - %M:%L] %msg%n + + - - ${LOG_HOME}/error.log - - - ERROR - ACCEPT - DENY - - - - ${LOG_HOME}/old/error.log.%d{yyyy-MM-dd}.%i - - - ${LOG_SIZE} - - - ${LOG_NUM} - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%logger - %M:%L] %msg%n - - + + ${LOG_HOME}/error.log + + + ERROR + ACCEPT + DENY + + + + ${LOG_HOME}/old/error.log.%d{yyyy-MM-dd}.%i + + + ${LOG_SIZE} + + + ${LOG_NUM} + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%logger - %M:%L] %msg%n + + - - - + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + diff --git a/flink-streaming-web/src/main/resources/mapper/AlartLogMapper.xml b/flink-streaming-web/src/main/resources/mapper/AlartLogMapper.xml index 9744350c..4ad2c6cc 100644 --- a/flink-streaming-web/src/main/resources/mapper/AlartLogMapper.xml +++ b/flink-streaming-web/src/main/resources/mapper/AlartLogMapper.xml @@ -1,76 +1,80 @@ - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - id, job_config_id, job_name,message, type, status, is_deleted, create_time, edit_time, creator, + + id + , job_config_id, job_name,message, type, status, is_deleted, create_time, edit_time, creator, editor - - - fail_log - + + + fail_log + - - - SELECT LAST_INSERT_ID() - - insert into alart_log (job_config_id, message,job_name, type, - status, is_deleted, create_time, - edit_time, creator, editor, - fail_log) - values (#{jobConfigId,jdbcType=BIGINT}, #{message,jdbcType=VARCHAR},#{jobName,jdbcType=VARCHAR}, #{type,jdbcType=BIT}, - #{status,jdbcType=BIT}, 0, now(), - now(), 'sys', 'sys', - #{failLog,jdbcType=LONGVARCHAR}) - + + + SELECT LAST_INSERT_ID() + + insert into alart_log (job_config_id, message,job_name, type, + status, is_deleted, create_time, + edit_time, creator, editor, + fail_log) + values (#{jobConfigId,jdbcType=BIGINT}, #{message,jdbcType=VARCHAR},#{jobName,jdbcType=VARCHAR}, + #{type,jdbcType=BIT}, + #{status,jdbcType=BIT}, 0, now(), + now(), 'sys', 'sys', + #{failLog,jdbcType=LONGVARCHAR}) + - + select + - from alart_log - where is_deleted=0 and create_time>=DATE_SUB(CURDATE(), INTERVAL 30 DAY) - - and job_config_id = #{jobConfigId,jdbcType=BIGINT} - + from alart_log + where is_deleted=0 and create_time>=DATE_SUB(CURDATE(), INTERVAL 30 DAY) + + and job_config_id = #{jobConfigId,jdbcType=BIGINT} + - - and type = #{type,jdbcType=BIT} - - - and status = #{status,jdbcType=BIT} - - order by create_time desc - + + and type = #{type,jdbcType=BIT} + + + and status = #{status,jdbcType=BIT} + + order by create_time desc + - + diff --git a/flink-streaming-web/src/main/resources/mapper/IpStatusMapper.xml b/flink-streaming-web/src/main/resources/mapper/IpStatusMapper.xml index 7f346787..b01dbdcf 100644 --- a/flink-streaming-web/src/main/resources/mapper/IpStatusMapper.xml +++ b/flink-streaming-web/src/main/resources/mapper/IpStatusMapper.xml @@ -1,80 +1,80 @@ - + - - - - - - - - - + + + + + + + + + - - id, ip, status, last_time, is_deleted, create_time, edit_time, creator, editor - + + id + , ip, status, last_time, is_deleted, create_time, edit_time, creator, editor + - - - SELECT LAST_INSERT_ID() - - insert into ip_status (ip, status, last_time, - is_deleted, create_time, edit_time, - creator, editor) - values ( - #{ip,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{lastTime,jdbcType=TIMESTAMP}, - 0, now(), now(), - 'sys', 'sys') - + + + SELECT LAST_INSERT_ID() + + insert into ip_status (ip, status, last_time, + is_deleted, create_time, edit_time, + creator, editor) + values ( + #{ip,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{lastTime,jdbcType=TIMESTAMP}, + 0, now(), now(), + 'sys', 'sys') + - + - + - + - - - update ip_status - - - status = #{status,jdbcType=INTEGER}, - - - last_time = #{lastTime,jdbcType=TIMESTAMP}, - - - is_deleted = #{isDeleted,jdbcType=BIT}, - - - where ip = #{ip,jdbcType=VARCHAR} - - + + update ip_status + + + status = #{status,jdbcType=INTEGER}, + + + last_time = #{lastTime,jdbcType=TIMESTAMP}, + + + is_deleted = #{isDeleted,jdbcType=BIT}, + + + where ip = #{ip,jdbcType=VARCHAR} + diff --git a/flink-streaming-web/src/main/resources/mapper/JobAlarmConfigMapper.xml b/flink-streaming-web/src/main/resources/mapper/JobAlarmConfigMapper.xml index 0b81f35c..fb2f57a6 100644 --- a/flink-streaming-web/src/main/resources/mapper/JobAlarmConfigMapper.xml +++ b/flink-streaming-web/src/main/resources/mapper/JobAlarmConfigMapper.xml @@ -1,63 +1,65 @@ - + - - - - - - - - - - - - - - id, job_id, type, version, is_deleted, create_time, edit_time, creator, editor - - - - - insert into job_alarm_config (job_id, type, version, - is_deleted, create_time, edit_time, - creator, editor) - values - - (#{item.jobId}, #{item.type}, 0, - 0, now(), now(), - 'sys', 'sys') - - - - - - - - - - - - - update job_alarm_config - set is_deleted=1 - where job_id = #{jobId,jdbcType=BIGINT} and is_deleted=0 - + + + + + + + + + + + + + + id + , job_id, type, version, is_deleted, create_time, edit_time, creator, editor + + + + + insert into job_alarm_config (job_id, type, version, + is_deleted, create_time, edit_time, + creator, editor) + values + + (#{item.jobId}, #{item.type}, 0, + 0, now(), now(), + 'sys', 'sys') + + + + + + + + + + + + update job_alarm_config + set is_deleted=1 + where job_id = #{jobId,jdbcType=BIGINT} + and is_deleted = 0 + diff --git a/flink-streaming-web/src/main/resources/mapper/JobConfigHistoryMapper.xml b/flink-streaming-web/src/main/resources/mapper/JobConfigHistoryMapper.xml index 72246d66..70c005a7 100644 --- a/flink-streaming-web/src/main/resources/mapper/JobConfigHistoryMapper.xml +++ b/flink-streaming-web/src/main/resources/mapper/JobConfigHistoryMapper.xml @@ -1,29 +1,32 @@ - + - - - + + + - - - - + + + + - - - - - - + + + + + + - - + + - id, job_config_id, job_name, job_desc, deploy_mode, flink_run_config, flink_checkpoint_config, + id + , job_config_id, job_name, job_desc, deploy_mode, flink_run_config, flink_checkpoint_config, ext_jar_path, version, job_type, is_deleted, create_time, edit_time, creator, editor @@ -40,7 +43,8 @@ ext_jar_path, version, job_type, is_deleted, create_time, edit_time, creator, editor, flink_sql) - values (#{jobConfigId,jdbcType=BIGINT}, #{jobName,jdbcType=VARCHAR}, #{jobDesc,jdbcType=VARCHAR}, #{deployMode,jdbcType=VARCHAR}, + values (#{jobConfigId,jdbcType=BIGINT}, #{jobName,jdbcType=VARCHAR}, + #{jobDesc,jdbcType=VARCHAR}, #{deployMode,jdbcType=VARCHAR}, #{flinkRunConfig,jdbcType=VARCHAR}, #{flinkCheckpointConfig,jdbcType=VARCHAR}, #{extJarPath,jdbcType=VARCHAR}, #{version,jdbcType=INTEGER}, #{jobType,jdbcType=INTEGER}, 0, now(), now(), #{creator,jdbcType=VARCHAR}, @@ -49,9 +53,9 @@ select - + , - + from job_config_history where id = #{id,jdbcType=BIGINT} and is_deleted=0 - - + + diff --git a/flink-streaming-web/src/main/resources/mapper/JobConfigMapper.xml b/flink-streaming-web/src/main/resources/mapper/JobConfigMapper.xml index cc2ef763..005fc15e 100644 --- a/flink-streaming-web/src/main/resources/mapper/JobConfigMapper.xml +++ b/flink-streaming-web/src/main/resources/mapper/JobConfigMapper.xml @@ -1,39 +1,41 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + , job_name, job_desc, deploy_mode, @@ -55,237 +57,243 @@ edit_time, creator, editor - - - flink_sql - - - - - SELECT LAST_INSERT_ID() - - insert into job_config (job_name, job_desc, deploy_mode, flink_run_config, - flink_checkpoint_config, job_id, is_open, - status, last_start_time, version, job_type,custom_args,custom_main_class,custom_jar_url, - is_deleted, create_time, edit_time, - creator, editor, flink_sql,ext_jar_path - ) - values (#{jobName,jdbcType=VARCHAR}, #{jobDesc,jdbcType=VARCHAR}, - #{deployMode,jdbcType=VARCHAR}, #{flinkRunConfig,jdbcType=VARCHAR}, - #{flinkCheckpointConfig,jdbcType=VARCHAR}, #{jobId,jdbcType=VARCHAR}, #{isOpen,jdbcType=BIT}, - #{status,jdbcType=BIT}, #{lastStartTime,jdbcType=TIMESTAMP}, 0,#{jobType,jdbcType=BIT}, - #{customArgs,jdbcType=VARCHAR},#{customMainClass,jdbcType=VARCHAR},#{customJarUrl,jdbcType=VARCHAR}, - 0, now(), now(), - #{creator,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}, #{flinkSql,jdbcType=LONGVARCHAR}, - #{extJarPath,jdbcType=VARCHAR} - ) - - - - insert into job_config (id, job_name, job_desc, deploy_mode, flink_run_config, - flink_checkpoint_config, job_id, is_open, - status, last_start_time, version, job_type,custom_args,custom_main_class,custom_jar_url, - is_deleted, create_time, edit_time, - creator, editor, flink_sql,ext_jar_path - ) - values (#{id,jdbcType=BIGINT}, #{jobName,jdbcType=VARCHAR}, #{jobDesc,jdbcType=VARCHAR}, - #{deployMode,jdbcType=VARCHAR}, #{flinkRunConfig,jdbcType=VARCHAR}, - #{flinkCheckpointConfig,jdbcType=VARCHAR}, #{jobId,jdbcType=VARCHAR}, #{isOpen,jdbcType=BIT}, - #{status,jdbcType=BIT}, #{lastStartTime,jdbcType=TIMESTAMP}, 0,#{jobType,jdbcType=BIT}, - #{customArgs,jdbcType=VARCHAR},#{customMainClass,jdbcType=VARCHAR},#{customJarUrl,jdbcType=VARCHAR}, - 0, now(), now(), - #{creator,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}, #{flinkSql,jdbcType=LONGVARCHAR}, - #{extJarPath,jdbcType=VARCHAR} - ) - - - - - - - + select + + , + + from job_config + where id = #{id,jdbcType=BIGINT} and is_deleted=0 + + + + + + - + select + - from job_config + from job_config - where is_deleted=0 and status in + where is_deleted=0 and status in - - #{id} - + + #{id} + - + - - - - - update job_config - - version=version+1, - editor = #{userName,jdbcType=VARCHAR}, - status = #{status,jdbcType=BIT}, - last_run_log_id = #{jobRunLogId,jdbcType=BIT} - - where id = #{id,jdbcType=BIGINT} and is_deleted=0 and version=#{oldVersion,jdbcType=INTEGER} - - - - - update job_config - - version=version+1, - - - job_name = #{jobName,jdbcType=VARCHAR}, - - - job_desc = #{jobDesc,jdbcType=VARCHAR}, - - - deploy_mode = #{deployMode,jdbcType=VARCHAR}, - - - flink_run_config = #{flinkRunConfig,jdbcType=VARCHAR}, - - - flink_checkpoint_config = #{flinkCheckpointConfig,jdbcType=VARCHAR}, - - - job_id = #{jobId,jdbcType=VARCHAR}, - - - is_open = #{isOpen,jdbcType=BIT}, - - - status = #{status,jdbcType=BIT}, - - - - ext_jar_path = #{extJarPath,jdbcType=VARCHAR}, - - - - last_start_time = #{lastStartTime,jdbcType=TIMESTAMP}, - - - - custom_args = #{customArgs,jdbcType=VARCHAR}, - - - custom_main_class = #{customMainClass,jdbcType=VARCHAR}, - - - custom_jar_url = #{customJarUrl,jdbcType=VARCHAR}, - - - - is_deleted = #{isDeleted,jdbcType=BIT}, - - - - editor = #{editor,jdbcType=VARCHAR}, - - - flink_sql = #{flinkSql,jdbcType=LONGVARCHAR}, - - - - last_run_log_id = #{lastRunLogId,jdbcType=BIT}, - - - where id = #{id,jdbcType=BIGINT} and is_deleted=0 - - - - update job_config - set is_deleted=1, - editor = #{userName,jdbcType=VARCHAR} - where id = #{id,jdbcType=BIGINT} - and is_deleted = 0 - - - - update job_config - set is_deleted=0, editor=#{userName,jdbcType=VARCHAR} - where id=#{id,jdbcType=BIGINT} and is_deleted=1 - + + + + + + update job_config + + version=version+1, + editor = #{userName,jdbcType=VARCHAR}, + status = #{status,jdbcType=BIT}, + last_run_log_id = #{jobRunLogId,jdbcType=BIT} + + where id = #{id,jdbcType=BIGINT} and is_deleted=0 and version=#{oldVersion,jdbcType=INTEGER} + + + + + update job_config + + version=version+1, + + + job_name = #{jobName,jdbcType=VARCHAR}, + + + job_desc = #{jobDesc,jdbcType=VARCHAR}, + + + deploy_mode = #{deployMode,jdbcType=VARCHAR}, + + + flink_run_config = #{flinkRunConfig,jdbcType=VARCHAR}, + + + flink_checkpoint_config = #{flinkCheckpointConfig,jdbcType=VARCHAR}, + + + job_id = #{jobId,jdbcType=VARCHAR}, + + + is_open = #{isOpen,jdbcType=BIT}, + + + status = #{status,jdbcType=BIT}, + + + + ext_jar_path = #{extJarPath,jdbcType=VARCHAR}, + + + + last_start_time = #{lastStartTime,jdbcType=TIMESTAMP}, + + + + custom_args = #{customArgs,jdbcType=VARCHAR}, + + + custom_main_class = #{customMainClass,jdbcType=VARCHAR}, + + + custom_jar_url = #{customJarUrl,jdbcType=VARCHAR}, + + + + is_deleted = #{isDeleted,jdbcType=BIT}, + + + + editor = #{editor,jdbcType=VARCHAR}, + + + flink_sql = #{flinkSql,jdbcType=LONGVARCHAR}, + + + + last_run_log_id = #{lastRunLogId,jdbcType=BIT}, + + + where id = #{id,jdbcType=BIGINT} and is_deleted=0 + + + + update job_config + set is_deleted=1, + editor = #{userName,jdbcType=VARCHAR} + where id = #{id,jdbcType=BIGINT} + and is_deleted = 0 + + + + update job_config + set is_deleted=0, + editor=#{userName,jdbcType=VARCHAR} + where id = #{id,jdbcType=BIGINT} + and is_deleted = 1 + diff --git a/flink-streaming-web/src/main/resources/mapper/JobRunLogMapper.xml b/flink-streaming-web/src/main/resources/mapper/JobRunLogMapper.xml index 4a479a35..1f7c0dca 100644 --- a/flink-streaming-web/src/main/resources/mapper/JobRunLogMapper.xml +++ b/flink-streaming-web/src/main/resources/mapper/JobRunLogMapper.xml @@ -1,31 +1,33 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - id, + + + + + + + + + + + + + + + + + + + + + + + + id + , job_config_id, job_name, job_desc, @@ -41,112 +43,113 @@ edit_time, creator, editor - - - local_log - - - - - - SELECT LAST_INSERT_ID() - - insert into job_run_log (job_config_id, job_name, job_desc, deploy_mode, - job_id, remote_log_url, start_time, - end_time, job_status, is_deleted, - create_time, edit_time, creator, - editor, local_log, run_ip) - values (#{jobConfigId,jdbcType=BIGINT}, #{jobName,jdbcType=VARCHAR}, #{jobDesc,jdbcType=VARCHAR}, #{deployMode,jdbcType=VARCHAR}, - #{jobId,jdbcType=VARCHAR}, #{remoteLogUrl,jdbcType=VARCHAR}, #{startTime,jdbcType=TIMESTAMP}, - #{endTime,jdbcType=TIMESTAMP}, #{jobStatus,jdbcType=VARCHAR}, 0, - now(), now(), #{creator,jdbcType=VARCHAR}, - #{editor,jdbcType=VARCHAR}, #{localLog,jdbcType=LONGVARCHAR},#{runIp,jdbcType=VARCHAR}) - - - - - update job_run_log - - - remote_log_url = #{remoteLogUrl,jdbcType=VARCHAR}, - - - start_time = #{startTime,jdbcType=TIMESTAMP}, - - - end_time = #{endTime,jdbcType=TIMESTAMP}, - - - job_status = #{jobStatus,jdbcType=VARCHAR}, - - - job_id = #{jobId,jdbcType=VARCHAR}, - - - - local_log = #{localLog,jdbcType=LONGVARCHAR}, - - - where id = #{id,jdbcType=BIGINT} - - - - + select + + + , + + + from job_run_log + + where is_deleted=0 and create_time>=DATE_SUB(CURDATE(), INTERVAL 30 DAY) + + + - + - - + - + - - + - + - order by create_time desc + order by create_time desc - + - + select - - , - + + , + - from job_run_log + from job_run_log - where is_deleted=0 and id=#{id,jdbcType=BIGINT} + where is_deleted=0 and id=#{id,jdbcType=BIGINT} - + - + - update job_run_log - set is_deleted=1 - where is_deleted = 0 - and job_config_id = #{jobConfigId,jdbcType=BIGINT} - + update job_run_log + set is_deleted=1 + where is_deleted = 0 + and job_config_id = #{jobConfigId,jdbcType=BIGINT} + diff --git a/flink-streaming-web/src/main/resources/mapper/SavepointBackupMapper.xml b/flink-streaming-web/src/main/resources/mapper/SavepointBackupMapper.xml index d641ce1e..2a847e21 100644 --- a/flink-streaming-web/src/main/resources/mapper/SavepointBackupMapper.xml +++ b/flink-streaming-web/src/main/resources/mapper/SavepointBackupMapper.xml @@ -1,51 +1,54 @@ - + - - - - - - - - - + + + + + + + + + - id, job_config_id, savepoint_path,backup_time, is_deleted, create_time, edit_time, creator, editor + id + , job_config_id, savepoint_path,backup_time, is_deleted, create_time, edit_time, creator, editor - - - SELECT LAST_INSERT_ID() - - insert into savepoint_backup (job_config_id, savepoint_path,backup_time, is_deleted, - create_time, edit_time, creator, - editor) - values (#{jobConfigId,jdbcType=BIGINT}, #{savepointPath,jdbcType=VARCHAR},#{backupTime,jdbcType=TIMESTAMP}, 0, - now(), now(), 'sys', - 'sys') - - - - - - - + + + SELECT LAST_INSERT_ID() + + insert into savepoint_backup (job_config_id, savepoint_path,backup_time, is_deleted, + create_time, edit_time, creator, + editor) + values (#{jobConfigId,jdbcType=BIGINT}, + #{savepointPath,jdbcType=VARCHAR},#{backupTime,jdbcType=TIMESTAMP}, 0, + now(), now(), 'sys', + 'sys') + + + + + + diff --git a/flink-streaming-web/src/main/resources/mapper/SystemConfigMapper.xml b/flink-streaming-web/src/main/resources/mapper/SystemConfigMapper.xml index b9e08136..3e988d98 100644 --- a/flink-streaming-web/src/main/resources/mapper/SystemConfigMapper.xml +++ b/flink-streaming-web/src/main/resources/mapper/SystemConfigMapper.xml @@ -1,67 +1,69 @@ - + - - - - - - - - - + + + + + + + + + - - id, `key`, val,type, is_deleted, create_time, edit_time, creator, editor - + + id + , `key`, val,type, is_deleted, create_time, edit_time, creator, editor + - - insert into system_config (id, `key`, val,type, is_deleted, - create_time, edit_time, creator, - editor) - values (#{id,jdbcType=BIGINT}, #{key,jdbcType=VARCHAR}, #{val,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, 0, - now(), now(), 'sys', - 'sys') - + + insert into system_config (id, `key`, val, type, is_deleted, + create_time, edit_time, creator, + editor) + values (#{id,jdbcType=BIGINT}, #{key,jdbcType=VARCHAR}, #{val,jdbcType=VARCHAR}, + #{type,jdbcType=VARCHAR}, 0, + now(), now(), 'sys', + 'sys') + - - update system_config set is_deleted=1 where `key`= #{key,jdbcType=VARCHAR} and is_deleted=0 - + + update system_config + set is_deleted=1 + where `key` = #{key,jdbcType=VARCHAR} + and is_deleted = 0 + - + + + - - - - - - - update system_config - - - val = #{val,jdbcType=VARCHAR}, - - - where is_deleted=0 and `key`= #{key,jdbcType=VARCHAR} - + + update system_config + + + val = #{val,jdbcType=VARCHAR}, + + + where is_deleted=0 and `key`= #{key,jdbcType=VARCHAR} + diff --git a/flink-streaming-web/src/main/resources/mapper/UserMapper.xml b/flink-streaming-web/src/main/resources/mapper/UserMapper.xml index c7e17b5b..799153af 100644 --- a/flink-streaming-web/src/main/resources/mapper/UserMapper.xml +++ b/flink-streaming-web/src/main/resources/mapper/UserMapper.xml @@ -1,106 +1,112 @@ - + - - - - - - - - - - + + + + + + + + + + - id, username, name, password, status, is_deleted, create_time, edit_time, creator, editor + id + , username, name, password, status, is_deleted, create_time, edit_time, creator, editor - - - SELECT LAST_INSERT_ID() - - insert into user (username, name, password, status, is_deleted, create_time, edit_time, creator, editor) - values (#{username,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{status,jdbcType=BIT}, - 0, now(), now(), #{creator,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}) - + + + SELECT LAST_INSERT_ID() + + insert into user (username, name, password, status, is_deleted, create_time, edit_time, creator, + editor) + values (#{username,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, + #{status,jdbcType=BIT}, + 0, now(), now(), #{creator,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}) + - - update user - - - name = #{name,jdbcType=VARCHAR}, - - - password = #{password,jdbcType=VARCHAR}, - - - status = #{status,jdbcType=BIT}, - - - edit_time = #{editTime,jdbcType=TIMESTAMP}, - - - editor = #{editor,jdbcType=VARCHAR}, - - - where username = #{username,jdbcType=VARCHAR} and is_deleted=0 - + + update user + + + name = #{name,jdbcType=VARCHAR}, + + + password = #{password,jdbcType=VARCHAR}, + + + status = #{status,jdbcType=BIT}, + + + edit_time = #{editTime,jdbcType=TIMESTAMP}, + + + editor = #{editor,jdbcType=VARCHAR}, + + + where username = #{username,jdbcType=VARCHAR} and is_deleted=0 + - - update user - - - name = #{name,jdbcType=VARCHAR}, - - - password = #{password,jdbcType=VARCHAR}, - - - status = #{status,jdbcType=BIT}, - - - edit_time = #{editTime,jdbcType=TIMESTAMP}, - - - editor = #{editor,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} and is_deleted=0 - + + update user + + + name = #{name,jdbcType=VARCHAR}, + + + password = #{password,jdbcType=VARCHAR}, + + + status = #{status,jdbcType=BIT}, + + + edit_time = #{editTime,jdbcType=TIMESTAMP}, + + + editor = #{editor,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} and is_deleted=0 + - - - + + + diff --git a/flink-streaming-web/src/main/resources/static/ui/index.html b/flink-streaming-web/src/main/resources/static/ui/index.html index a8b09569..bab74196 100644 --- a/flink-streaming-web/src/main/resources/static/ui/index.html +++ b/flink-streaming-web/src/main/resources/static/ui/index.html @@ -1 +1,392 @@ -Flink管理平台
\ No newline at end of file + + + + + + + + + Flink管理平台 + + + + + + + + + +
+ + + + + + \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-1147343e.db22aedf.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-1147343e.db22aedf.css index ddcbbacf..8b9b911b 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-1147343e.db22aedf.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-1147343e.db22aedf.css @@ -1 +1,3 @@ -.errPage-container[data-v-d5a4ca3c]{padding:30px} \ No newline at end of file +.errPage-container[data-v-d5a4ca3c] { + padding: 30px +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-176ca70f.f6fe2be1.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-176ca70f.f6fe2be1.css index 0db8581f..31a9b7f0 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-176ca70f.f6fe2be1.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-176ca70f.f6fe2be1.css @@ -1 +1,7 @@ -.app-container .roles-table[data-v-4e814f56]{margin-top:30px}.app-container .permission-tree[data-v-4e814f56]{margin-bottom:30px} \ No newline at end of file +.app-container .roles-table[data-v-4e814f56] { + margin-top: 30px +} + +.app-container .permission-tree[data-v-4e814f56] { + margin-bottom: 30px +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-1c7e07ca.8394d684.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-1c7e07ca.8394d684.css index f7321fa9..be6092b8 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-1c7e07ca.8394d684.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-1c7e07ca.8394d684.css @@ -1 +1,5 @@ -.chart-container[data-v-98dd0a84]{position:relative;width:100%;height:calc(100vh - 84px)} \ No newline at end of file +.chart-container[data-v-98dd0a84] { + position: relative; + width: 100%; + height: calc(100vh - 84px) +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-2b6fca86.5cd3a7d8.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-2b6fca86.5cd3a7d8.css index e37bb6f1..a5749d97 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-2b6fca86.5cd3a7d8.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-2b6fca86.5cd3a7d8.css @@ -1 +1,8 @@ -.tab-container[data-v-3addadee]{margin:20px}.fl-form-item[data-v-3addadee]{width:500px;margin-right:5px} \ No newline at end of file +.tab-container[data-v-3addadee] { + margin: 20px +} + +.fl-form-item[data-v-3addadee] { + width: 500px; + margin-right: 5px +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-324159a4.90a6ce5e.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-324159a4.90a6ce5e.css index 932ab7ef..5075417e 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-324159a4.90a6ce5e.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-324159a4.90a6ce5e.css @@ -1 +1,5 @@ -.chart-container[data-v-7defdb5e]{position:relative;width:100%;height:calc(100vh - 84px)} \ No newline at end of file +.chart-container[data-v-7defdb5e] { + position: relative; + width: 100%; + height: calc(100vh - 84px) +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-3876589c.0fb6e111.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-3876589c.0fb6e111.css index 6291f4ee..4266eb0e 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-3876589c.0fb6e111.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-3876589c.0fb6e111.css @@ -1 +1,7 @@ -.editor-container[data-v-18de7d28]{margin-bottom:30px}.tag-title[data-v-18de7d28]{margin-bottom:5px} \ No newline at end of file +.editor-container[data-v-18de7d28] { + margin-bottom: 30px +} + +.tag-title[data-v-18de7d28] { + margin-bottom: 5px +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-3a7c4bfc.ae037ade.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-3a7c4bfc.ae037ade.css index f881fece..8ec9bcb9 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-3a7c4bfc.ae037ade.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-3a7c4bfc.ae037ade.css @@ -1 +1,3 @@ -.editor-content[data-v-576db089]{margin-top:20px} \ No newline at end of file +.editor-content[data-v-576db089] { + margin-top: 20px +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-42990da2.a44d9352.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-42990da2.a44d9352.css index 3fdf27af..fd77270c 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-42990da2.a44d9352.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-42990da2.a44d9352.css @@ -1 +1,3 @@ -.tab-container[data-v-4794197c]{margin:30px} \ No newline at end of file +.tab-container[data-v-4794197c] { + margin: 30px +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-7a8911e6.33cb7757.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-7a8911e6.33cb7757.css index 7638f686..56636b4f 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-7a8911e6.33cb7757.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-7a8911e6.33cb7757.css @@ -1 +1,9 @@ -.edit-input[data-v-15b0fc52]{padding-right:100px}.cancel-btn[data-v-15b0fc52]{position:absolute;right:15px;top:10px} \ No newline at end of file +.edit-input[data-v-15b0fc52] { + padding-right: 100px +} + +.cancel-btn[data-v-15b0fc52] { + position: absolute; + right: 15px; + top: 10px +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-a6df3e9a.55203a7a.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-a6df3e9a.55203a7a.css index 4027e449..60372836 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-a6df3e9a.55203a7a.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-a6df3e9a.55203a7a.css @@ -1 +1,6 @@ -.radio-label{font-size:14px;color:#606266;line-height:40px;padding:0 12px 0 30px} \ No newline at end of file +.radio-label { + font-size: 14px; + color: #606266; + line-height: 40px; + padding: 0 12px 0 30px +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-bb4a12f2.55c028b5.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-bb4a12f2.55c028b5.css index dbd2da12..8d2e62d7 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-bb4a12f2.55c028b5.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-bb4a12f2.55c028b5.css @@ -1 +1,7 @@ -.components-container div[data-v-59e55d26]{margin:10px}.time-container[data-v-59e55d26]{display:inline-block} \ No newline at end of file +.components-container div[data-v-59e55d26] { + margin: 10px +} + +.time-container[data-v-59e55d26] { + display: inline-block +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-e0b6b12a.95371419.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-e0b6b12a.95371419.css index c3b1f5a3..a973691e 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-e0b6b12a.95371419.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-e0b6b12a.95371419.css @@ -1 +1,5 @@ -.chart-container[data-v-47239e0b]{position:relative;width:100%;height:calc(100vh - 84px)} \ No newline at end of file +.chart-container[data-v-47239e0b] { + position: relative; + width: 100%; + height: calc(100vh - 84px) +} \ No newline at end of file diff --git a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-fd4175ca.1d1ddef2.css b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-fd4175ca.1d1ddef2.css index bbcc06a5..a4bde0fd 100644 --- a/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-fd4175ca.1d1ddef2.css +++ b/flink-streaming-web/src/main/resources/static/ui/static/css/chunk-fd4175ca.1d1ddef2.css @@ -1 +1,8 @@ -.tab-container[data-v-f05b3544]{margin:20px}.fl-form-item[data-v-f05b3544]{width:500px;margin-right:5px} \ No newline at end of file +.tab-container[data-v-f05b3544] { + margin: 20px +} + +.fl-form-item[data-v-f05b3544] { + width: 500px; + margin-right: 5px +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index dcb43b30..9929376c 100644 --- a/pom.xml +++ b/pom.xml @@ -159,7 +159,7 @@ false false false - true + false warning