From a15fb1857f6474901efea4bf8c36b4a4f84622af Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Tue, 27 Jun 2023 10:31:08 +0800 Subject: [PATCH] =?UTF-8?q?feature(web):=20=E5=A2=9E=E5=8A=A0=E8=B0=83?= =?UTF-8?q?=E5=BA=A6=E8=AE=A1=E5=88=92=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/schedule/ScheduleStrategy.java | 53 +++++++++++++++++++ .../forest/service/ScheduleService.java | 35 ++++++++++++ .../web/controller/OverviewController.java | 10 +++- test/test.http | 6 ++- web/components/overview-tab.js | 18 +++++++ 5 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/entity/schedule/ScheduleStrategy.java create mode 100644 service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/ScheduleService.java diff --git a/service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/entity/schedule/ScheduleStrategy.java b/service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/entity/schedule/ScheduleStrategy.java new file mode 100644 index 0000000..9c1f810 --- /dev/null +++ b/service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/entity/schedule/ScheduleStrategy.java @@ -0,0 +1,53 @@ +package com.lanyuanxiaoyao.service.configuration.entity.schedule; + +/** + * @author lanyuanxiaoyao + * @date 2023-06-27 + */ +public class ScheduleStrategy { + private String name; + private String comment; + private String job; + private String trigger; + private Long lastFireTime; + private Long nextFireTime; + + public ScheduleStrategy() { + } + + public String getName() { + return name; + } + + public String getComment() { + return comment; + } + + public String getJob() { + return job; + } + + public String getTrigger() { + return trigger; + } + + public Long getLastFireTime() { + return lastFireTime; + } + + public Long getNextFireTime() { + return nextFireTime; + } + + @Override + public String toString() { + return "ScheduleStrategy{" + + "name='" + name + '\'' + + ", comment='" + comment + '\'' + + ", job='" + job + '\'' + + ", trigger='" + trigger + '\'' + + ", lastFireTime=" + lastFireTime + + ", nextFireTime=" + nextFireTime + + '}'; + } +} diff --git a/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/ScheduleService.java b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/ScheduleService.java new file mode 100644 index 0000000..5dcd688 --- /dev/null +++ b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/ScheduleService.java @@ -0,0 +1,35 @@ +package com.lanyuanxiaoyao.service.forest.service; + +import com.dtflys.forest.annotation.BaseRequest; +import com.dtflys.forest.annotation.Get; +import com.dtflys.forest.annotation.Query; +import com.lanyuanxiaoyao.service.configuration.entity.schedule.ScheduleStrategy; +import org.eclipse.collections.api.list.ImmutableList; + +/** + * @author lanyuanxiaoyao + * @date 2023-06-27 + */ +@BaseRequest(baseURL = "http://service-scheduler/schedule") +public interface ScheduleService { + @Get("/schedule_jobs") + ImmutableList scheduleJobs(); + + @Get("/all") + void scheduleAllTable(); + + @Get("/all_focus") + void scheduleAllFocus(); + + @Get("/all_un_scheduled") + void scheduleAllUnScheduledTable(); + + @Get("/table") + void scheduleTable(@Query("flink_job_id") Long flinkJobId, @Query("alias") String alias); + + @Get("/table") + void scheduleTableForce(@Query("flink_job_id") Long flinkJobId, @Query("alias") String alias, @Query("force") String forceCluster); + + @Get("/table") + void scheduleTableRecommend(@Query("flink_job_id") Long flinkJobId, @Query("alias") String alias, @Query("recommend") String recommendCluster); +} diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/OverviewController.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/OverviewController.java index 67cbd8e..2caa873 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/OverviewController.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/OverviewController.java @@ -9,6 +9,7 @@ import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnApplication; import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnRootQueue; import com.lanyuanxiaoyao.service.forest.service.InfoService; import com.lanyuanxiaoyao.service.forest.service.QueueService; +import com.lanyuanxiaoyao.service.forest.service.ScheduleService; import com.lanyuanxiaoyao.service.forest.service.YarnService; import com.lanyuanxiaoyao.service.web.entity.JobIdAndAliasVO; import java.time.LocalDateTime; @@ -41,12 +42,14 @@ public class OverviewController extends BaseController { private final InfoService infoService; private final YarnService yarnService; private final QueueService queueService; + private final ScheduleService scheduleService; @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") - public OverviewController(InfoService infoService, YarnService yarnService, QueueService queueService) { + public OverviewController(InfoService infoService, YarnService yarnService, QueueService queueService, ScheduleService scheduleService) { this.infoService = infoService; this.yarnService = yarnService; this.queueService = queueService; + this.scheduleService = scheduleService; } @GetMapping("") @@ -158,4 +161,9 @@ public class OverviewController extends BaseController { } return responseCrudData(jobIdAndAliases.collect(JobIdAndAliasVO::new)); } + + @GetMapping("schedule_jobs") + public AmisResponse scheduleJobs() { + return responseCrudData(scheduleService.scheduleJobs()); + } } diff --git a/test/test.http b/test/test.http index ca15255..5b99920 100644 --- a/test/test.http +++ b/test/test.http @@ -4,6 +4,7 @@ @password = cYxg3b4PtWoVD5SjFayWxtnSVsjzRsg4 @url = http://{{username}}:{{password}}@{{host}}:{{port}} @queue-url = {{url}}/hudi_services/queue +@scheduler-url = {{url}}/hudi_services/service_scheduler ### 队列名称 GET {{queue-url}}/queue/names @@ -41,4 +42,7 @@ Content-Type: application/json GET http://{{username}}:{{password}}@132.122.116.146:18166/info/compaction_metrics?flink_job_id=1542097996099055616&alias=acct_acct_item_fs&filter_completes=true ### Info -GET http://{{username}}:{{password}}@132.122.116.150:27510/table/list_compaction_metrics?search_flink_job_id=1542097996099055616&search_alias=acct_acct_item_fs \ No newline at end of file +GET http://{{username}}:{{password}}@132.122.116.150:27510/table/list_compaction_metrics?search_flink_job_id=1542097996099055616&search_alias=acct_acct_item_fs + +### Query Scheduler +GET {{scheduler-url}}/schedule/schedule_jobs diff --git a/web/components/overview-tab.js b/web/components/overview-tab.js index eb63c25..ad3dd8f 100644 --- a/web/components/overview-tab.js +++ b/web/components/overview-tab.js @@ -292,6 +292,24 @@ function overviewTab() { }, versionDetailDialog('unSchedule.normal', 'unScheduled_normal'), ] + }, + {type: 'divider'}, + { + type: 'service', + api: '${base}/overview/schedule_jobs', + interval: 60000, + silentPolling: true, + body: [ + '调度策略', + { + type: 'each', + name: 'items', + items: { + type: 'tpl', + tpl: '
${trigger} (${job})
' + } + } + ] } ] }