You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by yu...@apache.org on 2019/06/28 11:19:59 UTC

[rocketmq-remoting] 24/39: Remove remoting instance from NettyRemotingAbstract and add some comments

This is an automated email from the ASF dual-hosted git repository.

yukon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-remoting.git

commit ec19732349e253fa34ee53cc29d2e4f015a44482
Author: yukon <yu...@apache.org>
AuthorDate: Wed Jun 5 14:34:36 2019 +0800

    Remove remoting instance from NettyRemotingAbstract and add some comments
---
 .../rocketmq/remoting/api/RemotingService.java     |  2 --
 .../remoting/impl/netty/NettyRemotingAbstract.java | 35 +++++++++++++++-------
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingService.java b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingService.java
index 9cb59b4..68fa08c 100644
--- a/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingService.java
+++ b/remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/RemotingService.java
@@ -33,7 +33,5 @@ public interface RemotingService extends ConnectionService, ObjectLifecycle {
 
     Pair<RequestProcessor, ExecutorService> processor(short requestCode);
 
-    String remotingInstanceId();
-
     RemotingCommandFactory commandFactory();
 }
diff --git a/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingAbstract.java b/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingAbstract.java
index cbd0059..9e865d0 100644
--- a/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingAbstract.java
+++ b/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingAbstract.java
@@ -58,20 +58,42 @@ import org.apache.rocketmq.remoting.impl.channel.NettyChannelImpl;
 import org.apache.rocketmq.remoting.impl.command.RemotingCommandFactoryImpl;
 import org.apache.rocketmq.remoting.impl.command.RemotingSysResponseCode;
 import org.apache.rocketmq.remoting.internal.RemotingUtil;
-import org.apache.rocketmq.remoting.internal.UIDGenerator;
 import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class NettyRemotingAbstract implements RemotingService {
+    /**
+     * Remoting logger instance.
+     */
     protected static final Logger LOG = LoggerFactory.getLogger(NettyRemotingAbstract.class);
+
+    /**
+     * Executor to feed netty events to user defined {@link ChannelEventListener}.
+     */
     protected final ChannelEventExecutor channelEventExecutor = new ChannelEventExecutor("ChannelEventExecutor");
+
+    /**
+     * Semaphore to limit maximum number of on-going one-way requests, which protects system memory footprint.
+     */
     private final Semaphore semaphoreOneway;
+
+    /**
+     * Semaphore to limit maximum number of on-going asynchronous requests, which protects system memory footprint.
+     */
     private final Semaphore semaphoreAsync;
+
+    /**
+     * This map caches all on-going requests.
+     */
     private final Map<Integer, ResponseFuture> ackTables = new ConcurrentHashMap<Integer, ResponseFuture>(256);
+
+    /**
+     * This container holds all processors per request code, aka, for each incoming request, we may look up the
+     * responding processor in this map to handle the request.
+     */
     private final Map<Short, Pair<RequestProcessor, ExecutorService>> processorTables = new ConcurrentHashMap<>();
     private final RemotingCommandFactory remotingCommandFactory;
-    private final String remotingInstanceId = UIDGenerator.instance().createUID();
 
     private final ExecutorService publicExecutor;
     private final ExecutorService asyncHandlerExecutor;
@@ -498,19 +520,10 @@ public abstract class NettyRemotingAbstract implements RemotingService {
     }
 
     @Override
-    public String remotingInstanceId() {
-        return this.getRemotingInstanceId();
-    }
-
-    @Override
     public RemotingCommandFactory commandFactory() {
         return this.remotingCommandFactory;
     }
 
-    public String getRemotingInstanceId() {
-        return remotingInstanceId;
-    }
-
     @Override
     public void registerChannelEventListener(ChannelEventListener listener) {
         this.channelEventListenerGroup.registerChannelEventListener(listener);