feat(exporter): 提供exporter项目专注于提供外部访问接口
单独使用exporter项目提供外部接口可以方便针对外部接口进行管理,比如加入更强的安全认证
This commit is contained in:
4
bin/build-exporter.sh
Executable file
4
bin/build-exporter.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
mvn -pl service-dependencies,service-configuration,service-forest clean deploy -D skipTests -P local -s ~/.m2/settings-development.xml
|
||||||
|
mvn -pl service-exporter clean package spring-boot:repackage -D skipTests -s ~/.m2/settings-development.xml
|
||||||
|
ytp-transfer2 /Users/lanyuanxiaoyao/Project/IdeaProjects/hudi-service/service-exporter/target/service-exporter-1.0.0-SNAPSHOT.jar
|
||||||
1
pom.xml
1
pom.xml
@@ -26,6 +26,7 @@
|
|||||||
<module>service-uploader</module>
|
<module>service-uploader</module>
|
||||||
<module>service-executor</module>
|
<module>service-executor</module>
|
||||||
<module>service-cloud-query</module>
|
<module>service-cloud-query</module>
|
||||||
|
<module>service-exporter</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -149,3 +149,6 @@ deploy:
|
|||||||
executor_history-server-archive-dir: ${deploy.runtime.executor.archive-hdfs-path}
|
executor_history-server-archive-dir: ${deploy.runtime.executor.archive-hdfs-path}
|
||||||
executor_task-jar-path: ${deploy.runtime.executor.task-jar-path}
|
executor_task-jar-path: ${deploy.runtime.executor.task-jar-path}
|
||||||
executor_task-result-path: ${deploy.runtime.executor.task-result-path}
|
executor_task-result-path: ${deploy.runtime.executor.task-result-path}
|
||||||
|
- name: service-exporter
|
||||||
|
source-jar: service-exporter-1.0.0-SNAPSHOT.jar
|
||||||
|
replicas: 3
|
||||||
|
|||||||
45
service-exporter/pom.xml
Normal file
45
service-exporter/pom.xml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.lanyuanxiaoyao</groupId>
|
||||||
|
<artifactId>hudi-service</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>service-exporter</artifactId>
|
||||||
|
<description>用于提供系统外部接口</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lanyuanxiaoyao</groupId>
|
||||||
|
<artifactId>service-dependencies</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lanyuanxiaoyao</groupId>
|
||||||
|
<artifactId>service-configuration</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lanyuanxiaoyao</groupId>
|
||||||
|
<artifactId>service-forest</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.exporter;
|
||||||
|
|
||||||
|
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.retry.annotation.EnableRetry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动类
|
||||||
|
*
|
||||||
|
* @author lanyuanxiaoyao
|
||||||
|
* @date 2023-04-30
|
||||||
|
*/
|
||||||
|
@EnableDiscoveryClient
|
||||||
|
@SpringBootApplication(
|
||||||
|
scanBasePackages = {"com.lanyuanxiaoyao.service"},
|
||||||
|
exclude = {
|
||||||
|
GsonAutoConfiguration.class,
|
||||||
|
DataSourceAutoConfiguration.class
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@EnableConfigurationProperties
|
||||||
|
@EnableEncryptableProperties
|
||||||
|
@EnableRetry
|
||||||
|
public class ExporterApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ExporterApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.exporter.controller;
|
||||||
|
|
||||||
|
import com.eshore.odcp.hudi.connector.utils.NameHelper;
|
||||||
|
import com.lanyuanxiaoyao.service.configuration.entity.zookeeper.ZookeeperNode;
|
||||||
|
import com.lanyuanxiaoyao.service.exporter.entity.FlinkJobIdAndName;
|
||||||
|
import com.lanyuanxiaoyao.service.forest.service.InfoService;
|
||||||
|
import com.lanyuanxiaoyao.service.forest.service.ZookeeperService;
|
||||||
|
import org.eclipse.collections.api.list.ImmutableList;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 出口
|
||||||
|
*
|
||||||
|
* @author lanyuanxiaoyao
|
||||||
|
* @date 2024-02-02
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("exporter")
|
||||||
|
@CacheConfig(cacheManager = "normal-cache")
|
||||||
|
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||||
|
public class ExporterController {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ExporterController.class);
|
||||||
|
|
||||||
|
private final InfoService infoService;
|
||||||
|
private final ZookeeperService zookeeperService;
|
||||||
|
|
||||||
|
public ExporterController(InfoService infoService, ZookeeperService zookeeperService) {
|
||||||
|
this.infoService = infoService;
|
||||||
|
this.zookeeperService = zookeeperService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("un_running_flink_job")
|
||||||
|
@Cacheable(value = "un_running_flink_job", sync = true)
|
||||||
|
public ImmutableList<FlinkJobIdAndName> unRunningFlinkJob() {
|
||||||
|
ImmutableList<String> locks = zookeeperService.getChildren(NameHelper.ZK_SYNC_RUNNING_LOCK_PATH).collect(ZookeeperNode::getPath);
|
||||||
|
return infoService.flinkJobList()
|
||||||
|
.reject(job -> locks.contains(NameHelper.syncFlinkName(job.getId(), job.getName())))
|
||||||
|
.collect(job -> new FlinkJobIdAndName(job.getId(), job.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.lanyuanxiaoyao.service.exporter.entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lanyuanxiaoyao
|
||||||
|
* @date 2024-02-02
|
||||||
|
*/
|
||||||
|
public class FlinkJobIdAndName {
|
||||||
|
private final Long id;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public FlinkJobIdAndName(Long id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "FlinkJobIdAndName{" +
|
||||||
|
"id=" + id +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
5
service-exporter/src/main/resources/application.yml
Normal file
5
service-exporter/src/main/resources/application.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: service-exporter
|
||||||
|
profiles:
|
||||||
|
include: random-port,common,discovery,metrics,forest
|
||||||
52
service-exporter/src/main/resources/logback-spring.xml
Normal file
52
service-exporter/src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<configuration>
|
||||||
|
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||||
|
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||||
|
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||||
|
|
||||||
|
<springProperty scope="context" name="LOKI_PUSH_URL" source="loki.url"/>
|
||||||
|
<springProperty scope="context" name="LOGGING_PARENT" source="logging.parent"/>
|
||||||
|
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||||
|
|
||||||
|
<appender name="Loki" class="com.github.loki4j.logback.Loki4jAppender">
|
||||||
|
<metricsEnabled>true</metricsEnabled>
|
||||||
|
<http class="com.github.loki4j.logback.ApacheHttpSender">
|
||||||
|
<url>${LOKI_PUSH_URL:-http://localhost/loki/api/v1/push}</url>
|
||||||
|
</http>
|
||||||
|
<format>
|
||||||
|
<label>
|
||||||
|
<pattern>app=${APP_NAME:-none},host=${HOSTNAME:-none},level=%level</pattern>
|
||||||
|
<readMarkers>true</readMarkers>
|
||||||
|
</label>
|
||||||
|
<message>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [${HOSTNAME}] [%t] %logger #@# %m%n%wEx</pattern>
|
||||||
|
</message>
|
||||||
|
<sortByTime>true</sortByTime>
|
||||||
|
</format>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %clr(%5p) %clr([${HOSTNAME}]){yellow} %clr([%t]){magenta} %clr(%logger{40}){cyan} #@# %m%n%wEx</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${LOGGING_PARENT:-.}/${APP_NAME:-run}.log</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${LOGGING_PARENT:-.}/archive/${APP_NAME:-run}-%d{yyyy-MM-dd}.gz</fileNamePattern>
|
||||||
|
<MaxHistory>7</MaxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [${HOSTNAME}] [%t] %logger #@# %m%n%wEx</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<logger name="com.zaxxer.hikari" level="ERROR"/>
|
||||||
|
<logger name="com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver" level="WARN"/>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="Loki"/>
|
||||||
|
<appender-ref ref="Console"/>
|
||||||
|
<appender-ref ref="RollingFile"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
||||||
@@ -50,6 +50,7 @@ public class GatewayApplication {
|
|||||||
.route("scheduler", createRoute("/hudi_services/service_scheduler", "lb://service-scheduler"))
|
.route("scheduler", createRoute("/hudi_services/service_scheduler", "lb://service-scheduler"))
|
||||||
.route("web", createRoute("/hudi_services/service_web", "lb://service-web"))
|
.route("web", createRoute("/hudi_services/service_web", "lb://service-web"))
|
||||||
.route("services", createRoute("/hudi_services/service_cloud_query", "lb://service-cloud-query"))
|
.route("services", createRoute("/hudi_services/service_cloud_query", "lb://service-cloud-query"))
|
||||||
|
.route("exporter", createRoute("/hudi_services/service-exporter", "lb://service-exporter"))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user