diff --git a/bin/build-web.sh b/bin/build-web.sh index ad137ae..b66e99c 100755 --- a/bin/build-web.sh +++ b/bin/build-web.sh @@ -1,5 +1,5 @@ #!/bin/bash -mvn -pl service-configuration clean deploy -D skipTests -P local -s ~/.m2/settings-development.xml +mvn -pl service-configuration,service-forest clean deploy -D skipTests -P local -s ~/.m2/settings-development.xml mvn -pl service-web clean package spring-boot:repackage -D skipTests -s ~/.m2/settings-development.xml sshpass -p $(/Users/lanyuanxiaoyao/Project/Work/Host/keepassxc-password.sh SSH/iap/132.122.1.162) scp /Users/lanyuanxiaoyao/Project/IdeaProjects/hudi-service/service-web/target/service-web-1.0.0-SNAPSHOT.jar iap@132.122.1.162:/apps/iap/tmp/lanyuanxiaoyao sshpass -p $(/Users/lanyuanxiaoyao/Project/Work/Host/keepassxc-password.sh SSH/iap/132.122.1.162) ssh -o 'StrictHostKeyChecking no' iap@132.122.1.162 'curl ftp://yyy:QeY\!68\)4nH1@132.121.122.15:2222 -T /apps/iap/tmp/lanyuanxiaoyao/service-web-1.0.0-SNAPSHOT.jar' \ No newline at end of file diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/CompactionYarnService.java b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/CompactionYarnService.java similarity index 82% rename from service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/CompactionYarnService.java rename to service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/CompactionYarnService.java index e99732d..e610ab8 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/CompactionYarnService.java +++ b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/CompactionYarnService.java @@ -1,4 +1,4 @@ -package com.lanyuanxiaoyao.service.web.service; +package com.lanyuanxiaoyao.service.forest.service; import com.dtflys.forest.annotation.BaseRequest; diff --git a/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/InfoService.java b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/InfoService.java index 1d19de9..73842fe 100644 --- a/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/InfoService.java +++ b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/InfoService.java @@ -1,7 +1,6 @@ package com.lanyuanxiaoyao.service.forest.service; import com.dtflys.forest.annotation.BaseRequest; -import com.dtflys.forest.annotation.ForestClient; import com.dtflys.forest.annotation.Get; import com.dtflys.forest.annotation.Query; import com.eshore.odcp.hudi.connector.entity.FlinkJob; @@ -19,7 +18,6 @@ import org.eclipse.collections.api.list.ImmutableList; * @author lanyuanxiaoyao * @date 2023-04-24 */ -@ForestClient @BaseRequest(baseURL = "http://service-info-query") public interface InfoService { @Get("/info/job_id_alias") diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/PulsarService.java b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/PulsarService.java similarity index 95% rename from service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/PulsarService.java rename to service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/PulsarService.java index fc5a5e9..cf98d6f 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/PulsarService.java +++ b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/PulsarService.java @@ -1,4 +1,4 @@ -package com.lanyuanxiaoyao.service.web.service; +package com.lanyuanxiaoyao.service.forest.service; import com.dtflys.forest.annotation.BaseRequest; import com.dtflys.forest.annotation.Get; diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/SyncYarnService.java b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/SyncYarnService.java similarity index 82% rename from service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/SyncYarnService.java rename to service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/SyncYarnService.java index 1a63570..f09dcb8 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/SyncYarnService.java +++ b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/SyncYarnService.java @@ -1,4 +1,4 @@ -package com.lanyuanxiaoyao.service.web.service; +package com.lanyuanxiaoyao.service.forest.service; import com.dtflys.forest.annotation.BaseRequest; diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/YarnService.java b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/YarnService.java similarity index 95% rename from service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/YarnService.java rename to service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/YarnService.java index eaa1d8e..f602bdb 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/YarnService.java +++ b/service-forest/src/main/java/com/lanyuanxiaoyao/service/forest/service/YarnService.java @@ -1,4 +1,4 @@ -package com.lanyuanxiaoyao.service.web.service; +package com.lanyuanxiaoyao.service.forest.service; import com.dtflys.forest.annotation.Get; import com.dtflys.forest.annotation.Query; diff --git a/service-web/pom.xml b/service-web/pom.xml index b7d8386..5c134f0 100644 --- a/service-web/pom.xml +++ b/service-web/pom.xml @@ -17,6 +17,11 @@ service-configuration 1.0.0-SNAPSHOT + + com.lanyuanxiaoyao + service-forest + 1.0.0-SNAPSHOT + com.dtflys.forest forest-spring-boot-starter diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/configuration/LoginConfiguration.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/configuration/LoginConfiguration.java deleted file mode 100644 index 5d7aee1..0000000 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/configuration/LoginConfiguration.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.lanyuanxiaoyao.service.web.configuration; - -import org.springframework.context.annotation.Configuration; - -/** - * 登录设置 - * - * @author lanyuanxiaoyao - * @date 2023-04-30 - */ -@Configuration -public class LoginConfiguration { - -} diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/configuration/forest/ForestsConfiguration.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/configuration/forest/ForestsConfiguration.java deleted file mode 100644 index 9cd1e96..0000000 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/configuration/forest/ForestsConfiguration.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.lanyuanxiaoyao.service.web.configuration.forest; - -import com.dtflys.forest.converter.json.ForestJacksonConverter; -import com.fasterxml.jackson.datatype.eclipsecollections.EclipseCollectionsModule; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author lanyuanxiaoyao - * @date 2023-04-24 - */ -@Configuration -public class ForestsConfiguration { - @Bean - public ForestJacksonConverter forestJacksonConverter() { - ForestJacksonConverter converter = new ForestJacksonConverter(); - converter.getMapper().registerModule(new EclipseCollectionsModule()); - return converter; - } -} diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/configuration/forest/SringCloudDiscovryInterceptor.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/configuration/forest/SringCloudDiscovryInterceptor.java deleted file mode 100644 index 0ea751c..0000000 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/configuration/forest/SringCloudDiscovryInterceptor.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.lanyuanxiaoyao.service.web.configuration.forest; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.RandomUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.core.util.URLUtil; -import com.dtflys.forest.auth.BasicAuth; -import com.dtflys.forest.http.ForestAddress; -import com.dtflys.forest.http.ForestRequest; -import com.dtflys.forest.interceptor.Interceptor; -import java.net.URL; -import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.cloud.client.ServiceInstance; -import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.stereotype.Component; - -/** - * @author lanyuanxiaoyao - * @date 2023-04-24 - */ -@Component -public class SringCloudDiscovryInterceptor implements Interceptor { - private static final Logger logger = LoggerFactory.getLogger(SringCloudDiscovryInterceptor.class); - - private final DiscoveryClient client; - - public SringCloudDiscovryInterceptor(DiscoveryClient client) { - this.client = client; - } - - @Override - public boolean beforeExecute(ForestRequest request) { - // Load - URL url = URLUtil.url(request.getUrl()); - String host = url.getHost(); - if (StrUtil.isNotBlank(host)) { - List instances = client.getInstances(host); - if (ObjectUtil.isNotEmpty(instances)) { - int index = RandomUtil.randomInt(instances.size()); - ServiceInstance instance = instances.get(index); - request.setAddress(new ForestAddress(instance.getScheme(), instance.getHost(), instance.getPort())); - } - } - - // Basic auth - BasicAuth basicAuth = new BasicAuth("AxhEbscwsJDbYMH2", "cYxg3b4PtWoVD5SjFayWxtnSVsjzRsg4"); - basicAuth.enhanceAuthorization(request); - - return Interceptor.super.beforeExecute(request); - } -} diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/BaseController.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/BaseController.java index 2b44fbb..bafd64f 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/BaseController.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/BaseController.java @@ -6,8 +6,8 @@ import cn.hutool.core.util.StrUtil; import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse; import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnApplication; import com.lanyuanxiaoyao.service.configuration.entity.yarn.YarnQueue; +import com.lanyuanxiaoyao.service.forest.service.YarnService; import com.lanyuanxiaoyao.service.web.entity.YarnApplicationVO; -import com.lanyuanxiaoyao.service.web.service.YarnService; import com.lanyuanxiaoyao.service.web.utils.ComparatorUtil; import java.util.Comparator; import java.util.Map; @@ -26,6 +26,12 @@ import org.eclipse.collections.api.map.ImmutableMap; public class BaseController { private static final int SUCCESS_STATUS = 0; private static final String SUCCESS_MESSAGE = "OK"; + private static final ImmutableMap> SORT_MAP = Maps.immutable.of( + "startedTime", + YarnApplication::getStartedTime, + "finishedTime", + YarnApplication::getFinishedTime + ); protected AmisResponse responseData(Map data) { return AmisResponse.builder() @@ -70,13 +76,6 @@ public class BaseController { .build(); } - private static final ImmutableMap> SORT_MAP = Maps.immutable.of( - "startedTime", - YarnApplication::getStartedTime, - "finishedTime", - YarnApplication::getFinishedTime - ); - protected AmisResponse jobList( YarnService yarnService, Integer page, diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/CompactionYarnController.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/CompactionYarnController.java index 106c982..694bafb 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/CompactionYarnController.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/CompactionYarnController.java @@ -1,7 +1,7 @@ package com.lanyuanxiaoyao.service.web.controller; import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse; -import com.lanyuanxiaoyao.service.web.service.CompactionYarnService; +import com.lanyuanxiaoyao.service.forest.service.CompactionYarnService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.GetMapping; diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/PulsarController.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/PulsarController.java index 5a83403..60a5af0 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/PulsarController.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/PulsarController.java @@ -1,8 +1,8 @@ package com.lanyuanxiaoyao.service.web.controller; import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse; +import com.lanyuanxiaoyao.service.forest.service.PulsarService; import com.lanyuanxiaoyao.service.web.entity.TopicVO; -import com.lanyuanxiaoyao.service.web.service.PulsarService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.GetMapping; diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/SyncYarnController.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/SyncYarnController.java index 4ec8a58..cd65f42 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/SyncYarnController.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/SyncYarnController.java @@ -1,7 +1,7 @@ package com.lanyuanxiaoyao.service.web.controller; import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse; -import com.lanyuanxiaoyao.service.web.service.SyncYarnService; +import com.lanyuanxiaoyao.service.forest.service.SyncYarnService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.GetMapping; diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/TableController.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/TableController.java index c6495c2..037f6e0 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/TableController.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/TableController.java @@ -8,11 +8,11 @@ import com.eshore.odcp.hudi.connector.entity.TableMeta; import com.lanyuanxiaoyao.service.configuration.entity.AmisResponse; import com.lanyuanxiaoyao.service.configuration.entity.PageResponse; import com.lanyuanxiaoyao.service.configuration.entity.info.JobIdAndAlias; +import com.lanyuanxiaoyao.service.forest.service.CompactionYarnService; +import com.lanyuanxiaoyao.service.forest.service.InfoService; +import com.lanyuanxiaoyao.service.forest.service.SyncYarnService; import com.lanyuanxiaoyao.service.web.entity.SyncStateVO; import com.lanyuanxiaoyao.service.web.entity.TableVO; -import com.lanyuanxiaoyao.service.web.service.CompactionYarnService; -import com.lanyuanxiaoyao.service.web.service.InfoService; -import com.lanyuanxiaoyao.service.web.service.SyncYarnService; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -39,7 +39,7 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("table") public class TableController extends BaseController { private static final Logger logger = LoggerFactory.getLogger(TableController.class); - + private static final ExecutorService EXECUTOR = Executors.newWorkStealingPool(20); private final InfoService infoService; private final SyncYarnService syncYarnService; private final CompactionYarnService compactionYarnService; @@ -51,8 +51,6 @@ public class TableController extends BaseController { this.compactionYarnService = compactionYarnService; } - private static final ExecutorService EXECUTOR = Executors.newWorkStealingPool(20); - @GetMapping("list") public AmisResponse list( @RequestParam(value = "page", defaultValue = "1") Integer page, diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/entity/CloudServiceVO.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/entity/CloudServiceVO.java index b616c9c..bbd96c0 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/entity/CloudServiceVO.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/entity/CloudServiceVO.java @@ -1,7 +1,6 @@ package com.lanyuanxiaoyao.service.web.entity; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Map; import org.eclipse.collections.api.list.ImmutableList; import org.eclipse.collections.api.map.ImmutableMap; diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/entity/TableVO.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/entity/TableVO.java index e731fb0..4af5eab 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/entity/TableVO.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/entity/TableVO.java @@ -15,11 +15,11 @@ public class TableVO { private final String flinkJobId; private final FlinkJob flinkJob; private final TableMeta tableMeta; + private final SyncStateVO syncState; private String syncJobName; private YarnApplicationVO syncApp; private String compactionJobName; private YarnApplicationVO compactionApp; - private final SyncStateVO syncState; public TableVO(FlinkJob flinkJob, TableMeta tableMeta, SyncStateVO syncState) { this.flinkJobId = ObjectUtil.isNull(flinkJob) ? null : flinkJob.getId().toString(); diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/InfoService.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/InfoService.java deleted file mode 100644 index 7db9604..0000000 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/service/InfoService.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.lanyuanxiaoyao.service.web.service; - -import com.dtflys.forest.annotation.BaseRequest; -import com.dtflys.forest.annotation.Get; -import com.dtflys.forest.annotation.Query; -import com.eshore.odcp.hudi.connector.entity.FlinkJob; -import com.eshore.odcp.hudi.connector.entity.SyncState; -import com.eshore.odcp.hudi.connector.entity.TableMeta; -import com.lanyuanxiaoyao.service.configuration.entity.PageResponse; -import com.lanyuanxiaoyao.service.configuration.entity.info.JobAndMetas; -import com.lanyuanxiaoyao.service.configuration.entity.info.JobIdAndAlias; -import java.util.Map; -import org.eclipse.collections.api.list.ImmutableList; - -/** - * Info 接口 - * - * @author lanyuanxiaoyao - * @date 2023-04-24 - */ -@BaseRequest(baseURL = "http://service-info-query") -public interface InfoService { - @Get("/info/job_id_alias") - PageResponse jobIdAndAlias(@Query Map queryMap); - - @Get("/info/job_metas") - ImmutableList jobAndMetas(); - - @Get("/info/flink_job/list") - ImmutableList flinkJobList(); - - @Get("/info/flink_job/detail") - FlinkJob flinkJobDetail(@Query("flink_job_id") Long flinkJobId); - - @Get("/info/table_meta/list") - ImmutableList tableMetaList(); - - @Get("/info/table_meta/list") - ImmutableList tableMetaList(@Query("flink_job_id") Long flinkJobId); - - @Get("/info/table_meta/detail") - TableMeta tableMetaDetail(@Query("flink_job_id") Long flinkJobId, @Query("alias") String alias); - - @Get("/info/sync_state/detail") - SyncState syncStateDetail(@Query("flink_job_id") Long flinkJobId, @Query("alias") String alias); -} diff --git a/service-web/src/main/resources/application.yml b/service-web/src/main/resources/application.yml index 7719b59..466d920 100644 --- a/service-web/src/main/resources/application.yml +++ b/service-web/src/main/resources/application.yml @@ -1,35 +1,9 @@ -server: - port: 38000 spring: application: name: service-web - main: - banner-mode: off + profiles: + include: common,eureka,metrics,forest jackson: - serialization: - fail-on-empty-beans: false default-property-inclusion: non_null -management: - endpoints: - web: - exposure: - include: "*" - endpoint: - prometheus: - enabled: true - metrics: - export: - jmx: - enabled: false -eureka: - instance: - hostname: localhost - prefer-ip-address: true - instance-id: ${spring.application.name}-${eureka.instance.hostname}-${random.uuid}-${datetime} - client: - service-url: - defaultZone: http://localhost:35670/eureka/ -forest: - interceptors: com.lanyuanxiaoyao.service.web.configuration.forest.SringCloudDiscovryInterceptor - log-enabled: false - timeout: 60000 \ No newline at end of file +server: + port: 38000 \ No newline at end of file