-
Notifications
You must be signed in to change notification settings - Fork 641
[ISSUE #4750] Replace sun.net.httpserver.HttpServer to use netty server #4739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pil0tXia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a AdminProcessor in EventMeshHTTPServer like AdminMetricsProcessor, is enough, admin is not a protocol.
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java
Outdated
Show resolved
Hide resolved
...time/src/main/java/org/apache/eventmesh/runtime/admin/controller/ClientManageController.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/org/apache/eventmesh/runtime/admin/controller/HttpHandlerManagerAdapter.java
Outdated
Show resolved
Hide resolved
|
I didn't see changes under Furthermore, Lines 150 to 162 in e837f34
|
|
@Pil0tXia I think this issue should be handled in two PRs. 1. Convert the existing HTTP server to Netty server, and maintain the compatibility of the original Handler. 2. Change the HTTP handler to the Netty HttpRequestProcessor used in the project. |
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshAdminServer.java
Show resolved
Hide resolved
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java
Outdated
Show resolved
Hide resolved
|
You may merge lastest |
4299a27 to
18708df
Compare
@karsonto Please create two subtask issues of #4738 and link this PR to one of them. |
| thread.start(); | ||
| started.compareAndSet(false, true); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L86, better not to edit the startup status boolean of an abstract class (AbstractHTTPServer).
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractHTTPServer.java
Show resolved
Hide resolved
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/AbstractRemotingServer.java
Show resolved
Hide resolved
...-runtime/src/main/java/org/apache/eventmesh/runtime/admin/controller/HttpHandlerManager.java
Outdated
Show resolved
Hide resolved
| @Sharable | ||
| private class HttpConnectionHandler extends ChannelDuplexHandler { | ||
| protected class HttpConnectionHandler extends ChannelDuplexHandler { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to keep it private here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EventMeshAdminServer can not use If this HttpConnectionHandler keep private .
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/util/HttpResponseUtils.java
Outdated
Show resolved
Hide resolved
| public void exec(ChannelHandlerContext ctx, HttpRequest httpRequest) { | ||
| String uriStr = httpRequest.uri(); | ||
| URI uri = URI.create(uriStr); | ||
| HttpHandler httpHandler = httpHandlerMap.get(uri.getPath()); | ||
| if (httpHandler != null) { | ||
| try { | ||
| HttpHandlerManager.AdminHttpExchange adminHttpExchange = new HttpHandlerManager.AdminHttpExchange(ctx, httpRequest); | ||
| httpHandler.handle(adminHttpExchange); | ||
| adminHttpExchange.writeAndFlash(); | ||
| return; | ||
| } catch (Exception e) { | ||
| log.error(e.getMessage(), e); | ||
| ctx.writeAndFlush(HttpResponseUtils.createInternalServerError()).addListener(ChannelFutureListener.CLOSE); | ||
| } | ||
| } else { | ||
| ctx.writeAndFlush(HttpResponseUtils.createNotFound()).addListener(ChannelFutureListener.CLOSE); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about integrating EventMeshAdminServer with HandlerService instead of implementing a group of http processing logic seperately for admin?
Pil0tXia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that you haven't implement EventMeshAdminBootstrap.
Your means add AdminBootstrap startup list in EventMeshServer? |
| import org.apache.eventmesh.runtime.admin.handler.UpdateWebHookConfigHandler; | ||
| import org.apache.eventmesh.runtime.boot.EventMeshAdminServer; | ||
| import org.apache.eventmesh.runtime.boot.EventMeshAdminBootstrap; | ||
| import org.apache.eventmesh.runtime.boot.EventMeshGrpcServer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EventMeshAdminBootstrap should be referenced by EventMeshServer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it,please review again
|
|
||
| private transient ClientManageController clientManageController; | ||
| // private transient ClientManageController clientManageController; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why commented here?
|
|
||
| import org.apache.eventmesh.runtime.admin.controller.HttpHandlerManager; | ||
| import org.apache.eventmesh.runtime.admin.controller.ClientManageController; | ||
| import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that referencing ClientManageController in EventMeshAdminBootstrap is not a good practice. I think the design of ClientManageController and HttpHandlerManager has been outdated and it will be great if you may redesign them to fit EventMesh style of Netty HTTP Server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right,please review it.
| private void registerHttpHandler() { | ||
| initHandler(new ShowClientHandler(eventMeshTCPServer)); | ||
| initHandler(new ShowClientBySystemHandler(eventMeshTCPServer)); | ||
| initHandler(new RejectAllClientHandler(eventMeshTCPServer)); | ||
| initHandler(new RejectClientByIpPortHandler(eventMeshTCPServer)); | ||
| initHandler(new RejectClientBySubSystemHandler(eventMeshTCPServer)); | ||
| initHandler(new RedirectClientBySubSystemHandler(eventMeshTCPServer)); | ||
| initHandler(new RedirectClientByPathHandler(eventMeshTCPServer)); | ||
| initHandler(new RedirectClientByIpPortHandler(eventMeshTCPServer)); | ||
| initHandler(new ShowListenClientByTopicHandler(eventMeshTCPServer)); | ||
| initHandler(new QueryRecommendEventMeshHandler(eventMeshTCPServer)); | ||
| initHandler(new TCPClientHandler(eventMeshTCPServer)); | ||
| initHandler(new HTTPClientHandler(eventMeshHTTPServer)); | ||
| initHandler(new GrpcClientHandler(eventMeshGrpcServer)); | ||
| initHandler(new ConfigurationHandler( | ||
| eventMeshTCPServer.getEventMeshTCPConfiguration(), | ||
| eventMeshHTTPServer.getEventMeshHttpConfiguration(), | ||
| eventMeshGrpcServer.getEventMeshGrpcConfiguration())); | ||
| initHandler(new MetricsHandler(eventMeshHTTPServer, eventMeshTCPServer)); | ||
| initHandler(new TopicHandler(eventMeshTCPServer.getEventMeshTCPConfiguration().getEventMeshStoragePluginType())); | ||
| initHandler(new EventHandler(eventMeshTCPServer.getEventMeshTCPConfiguration().getEventMeshStoragePluginType())); | ||
| initHandler(new MetaHandler(eventMeshMetaStorage)); | ||
| if (Objects.nonNull(adminWebHookConfigOperationManage.getWebHookConfigOperation())) { | ||
| WebHookConfigOperation webHookConfigOperation = adminWebHookConfigOperationManage.getWebHookConfigOperation(); | ||
| initHandler(new InsertWebHookConfigHandler(webHookConfigOperation)); | ||
| initHandler(new UpdateWebHookConfigHandler(webHookConfigOperation)); | ||
| initHandler(new DeleteWebHookConfigHandler(webHookConfigOperation)); | ||
| initHandler(new QueryWebHookConfigByIdHandler(webHookConfigOperation)); | ||
| initHandler(new QueryWebHookConfigByManufacturerHandler(webHookConfigOperation)); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about putting this method (registering endpoints) in a Manager class just like the ConsumerManager does in EventMeshHTTPServer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure,please review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please have a throughout test on endpoint handlers.
Need more reviewers to check whether this PR's AdminServer implementation fit the EventMesh style.
| String connectorPluginType, | ||
| HttpHandlerManager httpHandlerManager) { | ||
| super(httpHandlerManager); | ||
| String connectorPluginType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this param seems like storagePluginType, as well as the comment on this Class, not the connector plugin type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be optimized in the future.Thank you.
| } catch (Exception ex) { | ||
| log.error("AdminHttpServer shutdown error!", ex); | ||
| } | ||
| System.exit(-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it appropriate for the admin server to exit when it starts a failed process? Older versions of admin server didn't have such strong constraints. Please keep an eye on the community, I'm not sure if it's appropriate or not.
admin server启动失败进程就退出是否合适?旧版的admin server没有这么强的约束。请社区留意,我不知道合适与否。
…y server (apache#4739) * fix 4738 * fix some bug * fix bug * remove initProducerManager from AbstractRemotingServer init * bug fix * bug fix * some enhance * some enhance * add admin bootstrap * some enhance * remove HttpHandlerManager and ClientManageController. * modify some unit test * add admin http handlermanager
Fixes #4750 Replace sun.net.httpserver.HttpServer to use netty server
Motivation
Explain the content here.
Explain why you want to make the changes and what problem you're trying to solve.
Modifications
Describe the modifications you've done.
Documentation