Skip to content

Commit f7a9517

Browse files
xwm1992sodaRyCNPil0tXiacnzakiikarsonto
authored
Merge EventMesh function branch to master (#4941)
* EventMesh function admin (#4851) * own * dependency * finish registry * EventMesh function admin (#4853) * own * dependency * finish registry * init * Eventmesh function admin (#4854) * own * dependency * finish registry * init * 0419 * 0419 * more discovery and move gRPC * fix dependency * EventMesh function connector runtime (#4858) * [ISSUE #4812] Set up Admin Endpoints v2 (#4813) * Remove redundant overloaded methods * Simplify write() result param * Add writeJson(); Add PUT; Add JavaDoc * Rename EventHttpHandler to EventMeshHttpHandler * Correct server thread name * Clean up messy & non-hierarchical overloading * No need to set headers manually any more * Set up v1&v2 endpoints * Set up v1&v2 response dto * Introduce fastjson2 * Fix fastjson2 "level too large : 2048" error caused by IPAddress * Correct @ConfigField naming * Return properties format json key * Add format option to query string * Introduce Result * Reduce duplicate builder code * Fix all checkstyle warnings in eventmesh-runtime * Add known dependency * [ISSUE #4814] Migrate from fastjson 1.2.83 to fastjson2 (#4819) * [Enhancement] Migrate from fastjson 1.2.83 to fastjson2 #4814 * fix_dependencies_problem * fix_check * [ISSUE #4551] modify the logic of time-consumption statistics (#4822) * init connector runtime v2 * [ISSUE #4804] Fix SubStreamHandler exception loop by closeOnError (#4807) * Handle exception loop by closeOnError * Lombok optimization * some format optimization * Avoid closing multiple times * Remove redundant set null * Revert "Avoid closing multiple times" This reverts commit 774397f. * Use synchronized latch to keep senderOnComplete called once * Use boolean to prevent latch called by somebody else * Remove the unique callee/caller close() of onCompleted() * [ISSUE #4838] Deprecate unused `eventMesh.connector.plugin.type` etc. properties (#4839) * Remove all references of `eventMesh.connector.plugin.type` * Deprecate `eventMesh.connector.plugin.type` and sort properties * Remove misconfigured & not-used `registerIntervalInMills`, `fetchRegistryAddrIntervalInMills` * Remove 'defibus' related un-used usages * Supplement #4809 for `null != object` * [ISSUE #4832] Downgrade stale bot to v8 to resolve state cache reserving error (#4833) * Revert stale bot to v8 to resolve state cache reserving error * Reduce operations-per-run to default value to ease pressure * Unify yaml to yml * [ISSUE #4820] Bug fix EventHandler not return json (#4821) * bug fix * bug fix * bug fix * update runtime v2 * update connector runtime * update connector runtime * update connector runtime * update connector runtime * update connector runtime --------- Co-authored-by: Pil0tXia <xiatian@apache.org> Co-authored-by: Zaki <91261012+cnzakii@users.noreply.github.com> Co-authored-by: Karson <karsontao@hotmail.com> * [ISSUE #4931]Add Registry Module for Discovery AdminServer * [ISSUES #4933]Add Admin Module * [ISSUE #4935] Add and Move the Pojo Used By Both Runtime and Admin to Common * [ISSUE #4937]fix gradle dependecy and add runtime v2 * [ISSUES #4939]add canal connector * fix missing apache header * fix missing apache header * fix missing apache header * update gradle dependencies * fix admin server ci check error * fix admin server ci check error * fix ci checkStyle error * fix ci check error --------- Co-authored-by: sodaRyCN <35725024+sodaRyCN@users.noreply.github.com> Co-authored-by: Pil0tXia <xiatian@apache.org> Co-authored-by: Zaki <91261012+cnzakii@users.noreply.github.com> Co-authored-by: Karson <karsontao@hotmail.com>
1 parent 5a409fd commit f7a9517

File tree

423 files changed

+15326
-759
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

423 files changed

+15326
-759
lines changed

.github/workflows/docker.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ jobs:
4747
tags: ${{ steps.meta.outputs.tags }}
4848
labels: ${{ steps.meta.outputs.labels }}
4949
file: ./docker/Dockerfile_jdk8
50-
context: ./
50+
context: ./

.idea/icon.png

-14.5 KB
Binary file not shown.

build.gradle

+11-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ allprojects {
9595

9696
checkstyleMain.exclude('**/org/apache/eventmesh/client/grpc/protos**')
9797
.exclude('**/org/apache/eventmesh/common/protocol/grpc/cloudevents**')
98-
.exclude('**/org/apache/eventmesh/common/protocol/grpc/protos/**')
98+
.exclude('**/org/apache/eventmesh/common/protocol/grpc/proto**')
99+
.exclude('**/org/apache/eventmesh/common/protocol/grpc/adminserver/**')
99100
.exclude('**/org/apache/eventmesh/connector/openfunction/client/EventMeshGrpcService**')
100101
.exclude('**/org/apache/eventmesh/connector/openfunction/client/CallbackServiceGrpc**')
101102
.exclude('**/org/apache/eventmesh/connector/jdbc/antlr**')
@@ -405,7 +406,7 @@ tasks.register('checkDeniedLicense') {
405406
"BSD-4-Clause", "BSD-4-Clause-UC", "NPL-1.0", "NPL-1.1", "JSON"
406407
]
407408
// Update exemptions according to https://github.com/apache/eventmesh/issues/4842
408-
def allowedArtifacts = ["amqp-client", "stax-api", "javassist", "ST4", "xsdlib"]
409+
def allowedArtifacts = ["amqp-client", "stax-api", "javassist", "ST4", "xsdlib", "jsqlparser"]
409410

410411
def licenseFile = file('tools/dist-license/LICENSE')
411412
def lines = licenseFile.readLines()
@@ -751,6 +752,13 @@ subprojects {
751752

752753
dependency "software.amazon.awssdk:s3:2.25.55"
753754
dependency "com.github.rholder:guava-retrying:2.0.0"
755+
756+
dependency "org.mybatis.spring.boot:mybatis-spring-boot-starter:2.3.1"
757+
dependency "com.alibaba:druid-spring-boot-starter:1.2.22"
758+
dependency "org.springframework.boot:spring-boot-starter-jetty:2.7.10"
759+
760+
dependency "com.baomidou:mybatis-plus:3.5.6"
761+
dependency "com.mysql:mysql-connector-j:8.0.33"
754762
}
755763
}
756-
}
764+
}

eventmesh-admin-server/.gitignore

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.gradle
2+
build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
!**/src/main/**/build/
5+
!**/src/test/**/build/
6+
7+
### IntelliJ IDEA ###
8+
.idea/modules.xml
9+
.idea/jarRepositories.xml
10+
.idea/compiler.xml
11+
.idea/libraries/
12+
*.iws
13+
*.iml
14+
*.ipr
15+
out/
16+
!**/src/main/**/out/
17+
!**/src/test/**/out/
18+
19+
### Eclipse ###
20+
.apt_generated
21+
.classpath
22+
.factorypath
23+
.project
24+
.settings
25+
.springBeans
26+
.sts4-cache
27+
bin/
28+
!**/src/main/**/bin/
29+
!**/src/test/**/bin/
30+
31+
### NetBeans ###
32+
/nbproject/private/
33+
/nbbuild/
34+
/dist/
35+
/nbdist/
36+
/.nb-gradle/
37+
38+
### VS Code ###
39+
.vscode/
40+
41+
### Mac OS ###
42+
.DS_Store

eventmesh-admin-server/build.gradle

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
dependencies {
19+
implementation project(":eventmesh-spi")
20+
implementation project(":eventmesh-common")
21+
implementation project(":eventmesh-registry:eventmesh-registry-api")
22+
implementation project(":eventmesh-registry:eventmesh-registry-nacos")
23+
implementation project(':eventmesh-openconnect:eventmesh-openconnect-offsetmgmt-plugin:eventmesh-openconnect-offsetmgmt-api')
24+
implementation "com.alibaba.nacos:nacos-client"
25+
implementation ("org.springframework.boot:spring-boot-starter-web") {
26+
exclude group: "org.springframework.boot", module: "spring-boot-starter-tomcat"
27+
}
28+
implementation 'org.springframework.boot:spring-boot-starter-jetty'
29+
implementation "io.grpc:grpc-core"
30+
implementation "io.grpc:grpc-protobuf"
31+
implementation "io.grpc:grpc-stub"
32+
implementation "io.grpc:grpc-netty-shaded"
33+
34+
// https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter
35+
implementation group: 'com.baomidou', name: 'mybatis-plus-boot-starter', version: '3.5.5'
36+
implementation "org.reflections:reflections:0.10.2"
37+
38+
// https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter
39+
implementation "com.alibaba:druid-spring-boot-starter"
40+
compileOnly 'com.mysql:mysql-connector-j'
41+
compileOnly 'org.projectlombok:lombok'
42+
annotationProcessor 'org.projectlombok:lombok'
43+
}
44+
45+
configurations.implementation {
46+
exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
47+
}
48+
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.admin.server;
19+
20+
import org.apache.eventmesh.common.remote.Task;
21+
import org.apache.eventmesh.common.remote.request.ReportHeartBeatRequest;
22+
import org.apache.eventmesh.common.utils.PagedList;
23+
24+
/**
25+
* Admin
26+
*/
27+
public interface Admin extends ComponentLifeCycle {
28+
29+
/**
30+
* support for web or ops
31+
**/
32+
boolean createOrUpdateTask(Task task);
33+
34+
boolean deleteTask(Long id);
35+
36+
Task getTask(Long id);
37+
38+
// paged list
39+
PagedList<Task> getTaskPaged(Task task);
40+
41+
/**
42+
* support for task
43+
*/
44+
void reportHeartbeat(ReportHeartBeatRequest heartBeat);
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.admin.server;
19+
20+
import org.apache.eventmesh.common.Constants;
21+
import org.apache.eventmesh.common.config.CommonConfiguration;
22+
import org.apache.eventmesh.common.config.ConfigService;
23+
import org.apache.eventmesh.common.remote.Task;
24+
import org.apache.eventmesh.common.remote.exception.ErrorCode;
25+
import org.apache.eventmesh.common.remote.request.ReportHeartBeatRequest;
26+
import org.apache.eventmesh.common.utils.IPUtils;
27+
import org.apache.eventmesh.common.utils.PagedList;
28+
import org.apache.eventmesh.registry.RegisterServerInfo;
29+
import org.apache.eventmesh.registry.RegistryFactory;
30+
import org.apache.eventmesh.registry.RegistryService;
31+
32+
import org.apache.commons.lang3.StringUtils;
33+
34+
import javax.annotation.PostConstruct;
35+
36+
import org.springframework.boot.context.event.ApplicationReadyEvent;
37+
import org.springframework.context.ApplicationListener;
38+
import org.springframework.stereotype.Service;
39+
40+
import lombok.extern.slf4j.Slf4j;
41+
42+
@Service
43+
@Slf4j
44+
public class AdminServer implements Admin, ApplicationListener<ApplicationReadyEvent> {
45+
46+
private final RegistryService registryService;
47+
48+
private final RegisterServerInfo adminServeInfo;
49+
50+
private final CommonConfiguration configuration;
51+
52+
public AdminServer(AdminServerProperties properties) {
53+
configuration =
54+
ConfigService.getInstance().buildConfigInstance(CommonConfiguration.class);
55+
if (configuration == null) {
56+
throw new AdminServerRuntimeException(ErrorCode.STARTUP_CONFIG_MISS, "common configuration file miss");
57+
}
58+
this.adminServeInfo = new RegisterServerInfo();
59+
60+
adminServeInfo.setHealth(true);
61+
adminServeInfo.setAddress(IPUtils.getLocalAddress() + ":" + properties.getPort());
62+
String name = Constants.ADMIN_SERVER_REGISTRY_NAME;
63+
if (StringUtils.isNotBlank(properties.getServiceName())) {
64+
name = properties.getServiceName();
65+
}
66+
adminServeInfo.setServiceName(name);
67+
registryService = RegistryFactory.getInstance(configuration.getEventMeshRegistryPluginType());
68+
}
69+
70+
71+
@Override
72+
public boolean createOrUpdateTask(Task task) {
73+
return false;
74+
}
75+
76+
@Override
77+
public boolean deleteTask(Long id) {
78+
return false;
79+
}
80+
81+
@Override
82+
public Task getTask(Long id) {
83+
return null;
84+
}
85+
86+
@Override
87+
public PagedList<Task> getTaskPaged(Task task) {
88+
return null;
89+
}
90+
91+
@Override
92+
public void reportHeartbeat(ReportHeartBeatRequest heartBeat) {
93+
94+
}
95+
96+
@Override
97+
@PostConstruct
98+
public void start() {
99+
if (configuration.isEventMeshRegistryPluginEnabled()) {
100+
registryService.init();
101+
}
102+
}
103+
104+
@Override
105+
public void destroy() {
106+
if (configuration.isEventMeshRegistryPluginEnabled()) {
107+
registryService.unRegister(adminServeInfo);
108+
try {
109+
Thread.sleep(3000);
110+
} catch (InterruptedException ignore) {
111+
log.warn("interrupted when sleep");
112+
Thread.currentThread().interrupt();
113+
}
114+
registryService.shutdown();
115+
}
116+
}
117+
118+
@Override
119+
public void onApplicationEvent(ApplicationReadyEvent event) {
120+
if (configuration.isEventMeshRegistryPluginEnabled()) {
121+
log.info("application is started and registry plugin is enabled, it's will register admin self");
122+
registryService.register(adminServeInfo);
123+
}
124+
}
125+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.admin.server;
19+
20+
import org.springframework.boot.context.properties.ConfigurationProperties;
21+
22+
import lombok.Getter;
23+
import lombok.Setter;
24+
25+
@ConfigurationProperties("event-mesh.admin-server")
26+
@Getter
27+
@Setter
28+
public class AdminServerProperties {
29+
30+
private int port;
31+
private boolean enableSSL;
32+
private String configurationPath;
33+
private String configurationFile;
34+
private String serviceName;
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.eventmesh.admin.server;
19+
20+
import lombok.Getter;
21+
22+
public class AdminServerRuntimeException extends RuntimeException {
23+
24+
@Getter
25+
private final int code;
26+
27+
public AdminServerRuntimeException(int code, String message) {
28+
super(message);
29+
this.code = code;
30+
}
31+
}

0 commit comments

Comments
 (0)