Skip to content

Commit 8481187

Browse files
authored
EventMesh function admin (#4851)
* own * dependency * finish registry
1 parent f45141d commit 8481187

30 files changed

+787
-0
lines changed

Diff for: build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ subprojects {
574574
dependency "software.amazon.awssdk:s3:2.20.29"
575575
dependency "com.github.rholder:guava-retrying:2.0.0"
576576

577+
dependency "org.mybatis.spring.boot:mybatis-spring-boot-starter:2.3.2"
578+
dependency "com.alibaba:druid-spring-boot-starter:1.2.22"
579+
dependency "org.springframework.boot:spring-boot-starter-jetty:2.7.10"
577580
}
578581
}
579582
}

Diff for: 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

Diff for: eventmesh-admin-server/build.gradle

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
dependencies {
2+
implementation project(":eventmesh-spi")
3+
implementation project(":eventmesh-common")
4+
implementation "com.alibaba.nacos:nacos-client"
5+
implementation ("org.springframework.boot:spring-boot-starter-web") {
6+
exclude group: "org.springframework.boot" ,module: "spring-boot-starter-tomcat"
7+
}
8+
implementation 'org.springframework.boot:spring-boot-starter-jetty'
9+
10+
implementation "org.mybatis.spring.boot:mybatis-spring-boot-starter"
11+
// https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter
12+
implementation "com.alibaba:druid-spring-boot-starter"
13+
compileOnly 'org.projectlombok:lombok'
14+
annotationProcessor 'org.projectlombok:lombok'
15+
}
16+

Diff for: eventmesh-admin-server/gradle.properties

+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,24 @@
1+
package com.apache.eventmesh.admin.server;
2+
3+
import org.apache.eventmesh.common.utils.PagedList;
4+
5+
import com.apache.eventmesh.admin.server.task.Task;
6+
7+
public interface Admin extends ComponentLifeCycle{
8+
/**
9+
* support for web or ops
10+
**/
11+
boolean createOrUpdateTask(Task task);
12+
boolean deleteTask(Long id);
13+
Task getTask(Long id);
14+
// paged list
15+
PagedList<Task> getTaskPaged(Task task);
16+
17+
/**
18+
* support for task
19+
*/
20+
void reportHeartbeat(HeartBeat heartBeat);
21+
22+
23+
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.apache.eventmesh.admin.server;
2+
3+
public class AdminException extends RuntimeException {
4+
public AdminException(String message) {
5+
super(message);
6+
}
7+
8+
public AdminException(String message, Throwable cause) {
9+
super(message, cause);
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.apache.eventmesh.admin.server;
2+
3+
import com.apache.eventmesh.admin.server.registry.EventMeshAdminServerRegisterInfo;
4+
import com.apache.eventmesh.admin.server.registry.RegistryService;
5+
import org.apache.eventmesh.common.utils.PagedList;
6+
7+
import com.apache.eventmesh.admin.server.task.Task;
8+
9+
public class AdminServer implements Admin {
10+
11+
private RegistryService registryService;
12+
13+
private EventMeshAdminServerRegisterInfo registerInfo;
14+
15+
public AdminServer(RegistryService registryService, EventMeshAdminServerRegisterInfo registerInfo) {
16+
this.registryService = registryService;
17+
this.registerInfo = registerInfo;
18+
}
19+
20+
public static final String ConfigurationKey = "admin-server";
21+
@Override
22+
public boolean createOrUpdateTask(Task task) {
23+
return false;
24+
}
25+
26+
@Override
27+
public boolean deleteTask(Long id) {
28+
return false;
29+
}
30+
31+
@Override
32+
public Task getTask(Long id) {
33+
return null;
34+
}
35+
36+
@Override
37+
public PagedList<Task> getTaskPaged(Task task) {
38+
return null;
39+
}
40+
41+
@Override
42+
public void reportHeartbeat(HeartBeat heartBeat) {
43+
44+
}
45+
46+
@Override
47+
public void start() {
48+
49+
registryService.register(registerInfo);
50+
}
51+
52+
@Override
53+
public void destroy() {
54+
registryService.unRegister(registerInfo);
55+
registryService.shutdown();
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.apache.eventmesh.admin.server;
2+
3+
public interface ComponentLifeCycle {
4+
void start();
5+
void destroy();
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.apache.eventmesh.admin.server;
2+
3+
import com.apache.eventmesh.admin.server.task.JobState;
4+
import com.apache.eventmesh.admin.server.task.Position;
5+
6+
public class HeartBeat {
7+
private String address;
8+
private String reportedTimeStamp;
9+
private String jobID;
10+
private Position position;
11+
private JobState state;
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.apache.eventmesh.admin.server.registry;
2+
3+
public abstract class AbstractRegistryListener<T> implements RegistryListener {
4+
protected abstract boolean checkType(Object data);
5+
@Override
6+
@SuppressWarnings("unchecked")
7+
public void onChange(Object data) {
8+
if (!checkType(data)) {
9+
return;
10+
}
11+
process((T)data);
12+
}
13+
protected abstract void process(T data);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.apache.eventmesh.admin.server.registry;
2+
3+
import lombok.Data;
4+
import lombok.EqualsAndHashCode;
5+
import lombok.NoArgsConstructor;
6+
import org.apache.eventmesh.common.config.CommonConfiguration;
7+
import org.apache.eventmesh.common.config.Config;
8+
import org.apache.eventmesh.common.config.ConfigFiled;
9+
10+
@Data
11+
@NoArgsConstructor
12+
@EqualsAndHashCode(callSuper = true)
13+
@Config(prefix = "eventMesh.admin")
14+
public class EventMeshAdminServerConfiguration extends CommonConfiguration {
15+
@ConfigFiled(field = "server.http.port")
16+
private int eventMeshHttpServerPort = 10000;
17+
18+
@ConfigFiled(field = "server.gRPC.port")
19+
private int eventMeshGrpcServerPort = 10000;
20+
21+
@ConfigFiled(field = "registry.plugin.server-addr", notEmpty = true)
22+
private String registryCenterAddr = "";
23+
24+
@ConfigFiled(field = "registry.plugin.type", notEmpty = true)
25+
private String eventMeshRegistryPluginType = "nacos";
26+
27+
@ConfigFiled(field = "registry.plugin.username")
28+
private String eventMeshRegistryPluginUsername = "";
29+
30+
@ConfigFiled(field = "registry.plugin.password")
31+
private String eventMeshRegistryPluginPassword = "";
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.apache.eventmesh.admin.server.registry;
2+
3+
import lombok.Data;
4+
5+
import java.util.Map;
6+
7+
@Data
8+
public class EventMeshAdminServerRegisterInfo {
9+
private String eventMeshClusterName;
10+
private String eventMeshName;
11+
private String address;
12+
13+
private Map<String, String> metadata;
14+
}

0 commit comments

Comments
 (0)