Pil0tXia commented on code in PR #4739:
URL: https://github.com/apache/eventmesh/pull/4739#discussion_r1451036613
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java:
##########
@@ -104,21 +101,26 @@ public ClientManageController(EventMeshTCPServer
eventMeshTCPServer,
public void start() throws IOException {
// Get the server's admin port.
int port =
eventMeshTCPServer.getEventMeshTCPConfiguration().getEventMeshServerAdminPort();
- // Create an HTTP server and bind it to the specified port.
- HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
-
HttpHandlerManager httpHandlerManager = new HttpHandlerManager();
+ HttpHandlerManagerAdapter adapter = new
HttpHandlerManagerAdapter(httpHandlerManager);
+ EventMeshAdminServer server = new EventMeshAdminServer(port, false,
eventMeshHTTPServer.getEventMeshHttpConfiguration(), adapter);
+ adapter.bind(server);
+ try {
+ server.init();
+ // TODO: Optimized for automatic injection
+
+ // Initialize the client handler and register it with the HTTP
handler manager.
+ initClientHandler(eventMeshTCPServer, eventMeshHTTPServer,
+ eventMeshGrpcServer, eventMeshMetaStorage, httpHandlerManager);
+
+ // Register the handlers from the HTTP handler manager with the
HTTP server.
+ httpHandlerManager.registerHttpWrapper(adapter);
+
+ server.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
Review Comment:
Please use Slf4j instead.
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java:
##########
@@ -58,15 +59,15 @@ private void buildBossGroup(final String threadPrefix) {
}
- private void buildIOGroup(final String threadPrefix) {
+ protected void buildIOGroup(final String threadPrefix) {
if (useEpoll()) {
ioGroup = new EpollEventLoopGroup(MAX_THREADS, new
EventMeshThreadFactory(threadPrefix + "-NettyEpoll-IO"));
} else {
ioGroup = new NioEventLoopGroup(MAX_THREADS, new
EventMeshThreadFactory(threadPrefix + "-NettyNio-IO"));
}
}
- private void buildWorkerGroup(final String threadPrefix) {
+ protected void buildWorkerGroup(final String threadPrefix) {
Review Comment:
Why do method namespaces need to be upgraded in AbstractRemotingServer and
AbstractHTTPServer?
##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/HttpHandlerManagerAdapter.java:
##########
@@ -0,0 +1,243 @@
+/*
+ * 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.
+ */
+
+package org.apache.eventmesh.runtime.admin.controller;
+
+import org.apache.eventmesh.runtime.boot.AbstractHTTPServer;
+import org.apache.eventmesh.runtime.common.EventHttpHandler;
+import org.apache.eventmesh.runtime.util.Utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.http.DefaultFullHttpResponse;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpRequest;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.HttpVersion;
+
+import com.sun.net.httpserver.Headers;
+import com.sun.net.httpserver.HttpContext;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpPrincipal;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class HttpHandlerManagerAdapter {
+
+ Map<String, HttpHandler> httpHandlerMap = new ConcurrentHashMap<>();
Review Comment:
I don't think adding a server for a new port requires the use of an
additional adapter pattern.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]