Skip to content

Commit

Permalink
Merge branch 'eventmesh-function' of https://github.com/apache/eventmesh
Browse files Browse the repository at this point in the history
 into eventmesh-function

� Conflicts:
�	settings.gradle
  • Loading branch information
xwm1992 committed Apr 18, 2024
2 parents be163fb + 8481187 commit b91598b
Show file tree
Hide file tree
Showing 30 changed files with 787 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,9 @@ subprojects {
dependency "software.amazon.awssdk:s3:2.20.29"
dependency "com.github.rholder:guava-retrying:2.0.0"

dependency "org.mybatis.spring.boot:mybatis-spring-boot-starter:2.3.2"
dependency "com.alibaba:druid-spring-boot-starter:1.2.22"
dependency "org.springframework.boot:spring-boot-starter-jetty:2.7.10"
}
}
}
42 changes: 42 additions & 0 deletions eventmesh-admin-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
16 changes: 16 additions & 0 deletions eventmesh-admin-server/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
dependencies {
implementation project(":eventmesh-spi")
implementation project(":eventmesh-common")
implementation "com.alibaba.nacos:nacos-client"
implementation ("org.springframework.boot:spring-boot-starter-web") {
exclude group: "org.springframework.boot" ,module: "spring-boot-starter-tomcat"
}
implementation 'org.springframework.boot:spring-boot-starter-jetty'

implementation "org.mybatis.spring.boot:mybatis-spring-boot-starter"
// https://mvnrepository.com/artifact/com.alibaba/druid-spring-boot-starter
implementation "com.alibaba:druid-spring-boot-starter"
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}

16 changes: 16 additions & 0 deletions eventmesh-admin-server/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.apache.eventmesh.admin.server;

import org.apache.eventmesh.common.utils.PagedList;

import com.apache.eventmesh.admin.server.task.Task;

public interface Admin extends ComponentLifeCycle{
/**
* support for web or ops
**/
boolean createOrUpdateTask(Task task);
boolean deleteTask(Long id);
Task getTask(Long id);
// paged list
PagedList<Task> getTaskPaged(Task task);

/**
* support for task
*/
void reportHeartbeat(HeartBeat heartBeat);



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.apache.eventmesh.admin.server;

public class AdminException extends RuntimeException {
public AdminException(String message) {
super(message);
}

public AdminException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.apache.eventmesh.admin.server;

import com.apache.eventmesh.admin.server.registry.EventMeshAdminServerRegisterInfo;
import com.apache.eventmesh.admin.server.registry.RegistryService;
import org.apache.eventmesh.common.utils.PagedList;

import com.apache.eventmesh.admin.server.task.Task;

public class AdminServer implements Admin {

private RegistryService registryService;

private EventMeshAdminServerRegisterInfo registerInfo;

public AdminServer(RegistryService registryService, EventMeshAdminServerRegisterInfo registerInfo) {
this.registryService = registryService;
this.registerInfo = registerInfo;
}

public static final String ConfigurationKey = "admin-server";
@Override
public boolean createOrUpdateTask(Task task) {
return false;
}

@Override
public boolean deleteTask(Long id) {
return false;
}

@Override
public Task getTask(Long id) {
return null;
}

@Override
public PagedList<Task> getTaskPaged(Task task) {
return null;
}

@Override
public void reportHeartbeat(HeartBeat heartBeat) {

}

@Override
public void start() {

registryService.register(registerInfo);
}

@Override
public void destroy() {
registryService.unRegister(registerInfo);
registryService.shutdown();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.apache.eventmesh.admin.server;

public interface ComponentLifeCycle {
void start();
void destroy();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.apache.eventmesh.admin.server;

import com.apache.eventmesh.admin.server.task.JobState;
import com.apache.eventmesh.admin.server.task.Position;

public class HeartBeat {
private String address;
private String reportedTimeStamp;
private String jobID;
private Position position;
private JobState state;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.apache.eventmesh.admin.server.registry;

public abstract class AbstractRegistryListener<T> implements RegistryListener {
protected abstract boolean checkType(Object data);
@Override
@SuppressWarnings("unchecked")
public void onChange(Object data) {
if (!checkType(data)) {
return;
}
process((T)data);
}
protected abstract void process(T data);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.apache.eventmesh.admin.server.registry;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.eventmesh.common.config.CommonConfiguration;
import org.apache.eventmesh.common.config.Config;
import org.apache.eventmesh.common.config.ConfigFiled;

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Config(prefix = "eventMesh.admin")
public class EventMeshAdminServerConfiguration extends CommonConfiguration {
@ConfigFiled(field = "server.http.port")
private int eventMeshHttpServerPort = 10000;

@ConfigFiled(field = "server.gRPC.port")
private int eventMeshGrpcServerPort = 10000;

@ConfigFiled(field = "registry.plugin.server-addr", notEmpty = true)
private String registryCenterAddr = "";

@ConfigFiled(field = "registry.plugin.type", notEmpty = true)
private String eventMeshRegistryPluginType = "nacos";

@ConfigFiled(field = "registry.plugin.username")
private String eventMeshRegistryPluginUsername = "";

@ConfigFiled(field = "registry.plugin.password")
private String eventMeshRegistryPluginPassword = "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.apache.eventmesh.admin.server.registry;

import lombok.Data;

import java.util.Map;

@Data
public class EventMeshAdminServerRegisterInfo {
private String eventMeshClusterName;
private String eventMeshName;
private String address;

private Map<String, String> metadata;
}
Loading

0 comments on commit b91598b

Please sign in to comment.