-
Notifications
You must be signed in to change notification settings - Fork 642
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
1,841 additions
and
691 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
eventmesh-admin-server/src/main/java/com/apache/eventmesh/admin/server/AdminException.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...h-admin-server/src/main/java/com/apache/eventmesh/admin/server/AdminServerProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.apache.eventmesh.admin.server; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@ConfigurationProperties("event-mesh.admin-server") | ||
@Getter | ||
@Setter | ||
public class AdminServerProperties { | ||
private int port; | ||
private boolean enableSSL; | ||
private String configurationPath; | ||
private String configurationFile; | ||
private String serviceName; | ||
} |
12 changes: 12 additions & 0 deletions
12
...n-server/src/main/java/com/apache/eventmesh/admin/server/AdminServerRuntimeException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.apache.eventmesh.admin.server; | ||
|
||
import lombok.Getter; | ||
|
||
public class AdminServerRuntimeException extends RuntimeException { | ||
@Getter | ||
private final int code; | ||
public AdminServerRuntimeException(int code, String message) { | ||
super(message); | ||
this.code = code; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...mesh-admin-server/src/main/java/com/apache/eventmesh/admin/server/ComponentLifeCycle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.apache.eventmesh.admin.server; | ||
|
||
public interface ComponentLifeCycle { | ||
void start(); | ||
void start() throws Exception; | ||
void destroy(); | ||
} |
32 changes: 0 additions & 32 deletions
32
...er/src/main/java/com/apache/eventmesh/admin/server/EventMeshAdminServerConfiguration.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...mesh-admin-server/src/main/java/com/apache/eventmesh/admin/server/ExampleAdminServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.apache.eventmesh.admin.server; | ||
|
||
import com.apache.eventmesh.admin.server.constatns.AdminServerConstants; | ||
import org.apache.eventmesh.common.config.ConfigService; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class ExampleAdminServer { | ||
public static void main(String[] args) throws Exception { | ||
ConfigService.getInstance().setConfigPath(AdminServerConstants.EVENTMESH_CONF_HOME).setRootConfig(AdminServerConstants.EVENTMESH_CONF_FILE); | ||
SpringApplication.run(ExampleAdminServer.class); | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
eventmesh-admin-server/src/main/java/com/apache/eventmesh/admin/server/HeartBeat.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...erver/src/main/java/com/apache/eventmesh/admin/server/constatns/AdminServerConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.apache.eventmesh.admin.server.constatns; | ||
|
||
public class AdminServerConstants { | ||
public static final String CONF_ENV = "configurationPath"; | ||
|
||
public static final String EVENTMESH_CONF_HOME = System.getProperty(CONF_ENV, System.getenv(CONF_ENV)); | ||
|
||
public static final String EVENTMESH_CONF_FILE = "eventmesh-admin.properties"; | ||
} |
8 changes: 0 additions & 8 deletions
8
eventmesh-admin-server/src/main/java/com/apache/eventmesh/admin/server/task/Job.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
eventmesh-admin-server/src/main/java/com/apache/eventmesh/admin/server/task/JobState.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
eventmesh-admin-server/src/main/java/com/apache/eventmesh/admin/server/task/JobType.java
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
eventmesh-admin-server/src/main/java/com/apache/eventmesh/admin/server/task/Position.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
eventmesh-admin-server/src/main/java/com/apache/eventmesh/admin/server/task/Task.java
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
...esh-admin-server/src/main/java/com/apache/eventmesh/admin/server/web/AdminGrpcServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.apache.eventmesh.admin.server.web; | ||
|
||
import com.apache.eventmesh.admin.server.AdminServerRuntimeException; | ||
import com.apache.eventmesh.admin.server.web.handler.BaseRequestHandler; | ||
import com.apache.eventmesh.admin.server.web.handler.RequestHandlerFactory; | ||
import io.grpc.stub.ServerCallStreamObserver; | ||
import io.grpc.stub.StreamObserver; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.eventmesh.common.protocol.grpc.adminserver.AdminServiceGrpc; | ||
import org.apache.eventmesh.common.protocol.grpc.adminserver.Payload; | ||
import org.apache.eventmesh.common.remote.exception.ErrorCode; | ||
import org.apache.eventmesh.common.remote.payload.PayloadUtil; | ||
import org.apache.eventmesh.common.remote.request.BaseRemoteRequest; | ||
import org.apache.eventmesh.common.remote.response.BaseRemoteResponse; | ||
import org.apache.eventmesh.common.remote.response.EmptyAckResponse; | ||
import org.apache.eventmesh.common.remote.response.FailResponse; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public class AdminGrpcServer extends AdminServiceGrpc.AdminServiceImplBase { | ||
@Autowired | ||
RequestHandlerFactory handlerFactory; | ||
|
||
private Payload process(Payload value) { | ||
if (value == null || StringUtils.isBlank(value.getMetadata().getType())) { | ||
return PayloadUtil.from(FailResponse.build(ErrorCode.BAD_REQUEST, "bad request: type not " + | ||
"exists")); | ||
} | ||
try { | ||
BaseRequestHandler<BaseRemoteRequest, BaseRemoteResponse> handler = | ||
handlerFactory.getHandler(value.getMetadata().getType()); | ||
if (handler == null) { | ||
return PayloadUtil.from(FailResponse.build(BaseRemoteResponse.UNKNOWN, | ||
"not match any request handler")); | ||
} | ||
BaseRemoteResponse response = handler.handlerRequest((BaseRemoteRequest) PayloadUtil.parse(value), value.getMetadata()); | ||
if (response == null || response instanceof EmptyAckResponse) { | ||
return null; | ||
} | ||
return PayloadUtil.from(response); | ||
} catch (Exception e) { | ||
log.warn("process payload {} fail", value.getMetadata().getType(), e); | ||
if (e instanceof AdminServerRuntimeException) { | ||
return PayloadUtil.from(FailResponse.build(((AdminServerRuntimeException)e).getCode(), | ||
e.getMessage())); | ||
} | ||
return PayloadUtil.from(FailResponse.build(ErrorCode.INTERNAL_ERR, "admin server internal err")); | ||
} | ||
} | ||
|
||
public StreamObserver<Payload> invokeBiStream(StreamObserver<Payload> responseObserver) { | ||
return new StreamObserver<Payload>() { | ||
@Override | ||
public void onNext(Payload value) { | ||
Payload payload = process(value); | ||
if (payload == null) { | ||
return; | ||
} | ||
responseObserver.onNext(payload); | ||
} | ||
|
||
@Override | ||
public void onError(Throwable t) { | ||
if (responseObserver instanceof ServerCallStreamObserver) { | ||
if (!((ServerCallStreamObserver<Payload>) responseObserver).isCancelled()) { | ||
log.warn("admin gRPC server fail", t); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onCompleted() { | ||
responseObserver.onCompleted(); | ||
} | ||
}; | ||
} | ||
|
||
public void invoke(Payload request, StreamObserver<Payload> responseObserver) { | ||
responseObserver.onNext(process(request)); | ||
responseObserver.onCompleted(); | ||
} | ||
} |
Oops, something went wrong.