Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
6593294f
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
267
Star
16139
Fork
68
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6593294f
编写于
9月 20, 2017
作者:
Y
yukon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish thread poll create method
上级
489b1d8b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
37 addition
and
56 deletion
+37
-56
remoting-core/pom.xml
remoting-core/pom.xml
+1
-1
remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/external/ThreadUtils.java
...va/org/apache/rocketmq/remoting/external/ThreadUtils.java
+17
-9
remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingAbstract.java
...e/rocketmq/remoting/impl/netty/NettyRemotingAbstract.java
+2
-6
remoting-core/rpc-impl/src/main/java/org/apache/rocketmq/rpc/impl/client/SimpleClientImpl.java
...org/apache/rocketmq/rpc/impl/client/SimpleClientImpl.java
+3
-7
remoting-core/rpc-impl/src/main/java/org/apache/rocketmq/rpc/impl/server/SimpleServerImpl.java
...org/apache/rocketmq/rpc/impl/server/SimpleServerImpl.java
+3
-7
remoting-core/rpc-impl/src/main/java/org/apache/rocketmq/rpc/impl/service/RpcInstanceAbstract.java
...apache/rocketmq/rpc/impl/service/RpcInstanceAbstract.java
+5
-13
remoting-core/rpc-impl/src/main/java/org/apache/rocketmq/rpc/impl/service/RpcProxyCommon.java
.../org/apache/rocketmq/rpc/impl/service/RpcProxyCommon.java
+6
-13
未找到文件。
remoting-core/pom.xml
浏览文件 @
6593294f
...
...
@@ -77,7 +77,7 @@
<dependency>
<groupId>
io.netty
</groupId>
<artifactId>
netty-all
</artifactId>
<version>
4.1.
6
.Final
</version>
<version>
4.1.
15
.Final
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
...
...
remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/external/ThreadUtils.java
浏览文件 @
6593294f
...
...
@@ -20,6 +20,7 @@ package org.apache.rocketmq.remoting.external;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ThreadFactory
;
import
java.util.concurrent.ThreadPoolExecutor
;
...
...
@@ -43,25 +44,32 @@ public final class ThreadUtils {
int
maximumPoolSize
,
long
keepAliveTime
,
TimeUnit
unit
,
BlockingQueue
<
Runnable
>
workQueue
,
String
processName
,
boolean
isDaemon
)
{
return
new
ThreadPoolExecutor
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
unit
,
workQueue
,
newThreadFactory
(
processName
,
isDaemon
));
BlockingQueue
<
Runnable
>
workQueue
,
String
processName
,
boolean
isDaemon
)
{
return
new
ThreadPoolExecutor
(
corePoolSize
,
maximumPoolSize
,
keepAliveTime
,
unit
,
workQueue
,
newGenericThreadFactory
(
processName
,
isDaemon
));
}
public
static
ExecutorService
newFixedThreadPool
(
int
nThreads
,
int
workQueueCapacity
,
String
processName
,
boolean
isDaemon
)
{
return
new
ThreadPoolExecutor
(
nThreads
,
nThreads
,
0
,
TimeUnit
.
MILLISECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(
workQueueCapacity
),
newGenericThreadFactory
(
processName
,
isDaemon
));
}
public
static
ExecutorService
newSingleThreadExecutor
(
String
processName
,
boolean
isDaemon
)
{
return
Executors
.
newSingleThreadExecutor
(
newThreadFactory
(
processName
,
isDaemon
));
return
Executors
.
newSingleThreadExecutor
(
new
Generic
ThreadFactory
(
processName
,
isDaemon
));
}
public
static
ScheduledExecutorService
newSingleThreadScheduledExecutor
(
String
processName
,
boolean
isDaemon
)
{
return
Executors
.
newSingleThreadScheduledExecutor
(
newThreadFactory
(
processName
,
isDaemon
));
return
Executors
.
newSingleThreadScheduledExecutor
(
new
Generic
ThreadFactory
(
processName
,
isDaemon
));
}
public
static
ScheduledExecutorService
newFixedThreadScheduledPool
(
int
nThreads
,
String
processName
,
boolean
isDaemon
)
{
return
Executors
.
newScheduledThreadPool
(
nThreads
,
newThreadFactory
(
processName
,
isDaemon
));
}
public
static
ThreadFactory
newThreadFactory
(
String
processName
,
boolean
isDaemon
)
{
return
newGenericThreadFactory
(
"Remoting-"
+
processName
,
isDaemon
);
return
Executors
.
newScheduledThreadPool
(
nThreads
,
newGenericThreadFactory
(
processName
,
isDaemon
));
}
public
static
ThreadFactory
newGenericThreadFactory
(
String
processName
)
{
...
...
remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingAbstract.java
浏览文件 @
6593294f
...
...
@@ -92,13 +92,9 @@ public abstract class NettyRemotingAbstract implements RemotingService {
NettyRemotingAbstract
(
RemotingConfig
clientConfig
,
RemotingCommandFactoryMeta
remotingCommandFactoryMeta
)
{
this
.
semaphoreOneway
=
new
Semaphore
(
clientConfig
.
getClientOnewayInvokeSemaphore
(),
true
);
this
.
semaphoreAsync
=
new
Semaphore
(
clientConfig
.
getClientAsyncInvokeSemaphore
(),
true
);
this
.
publicExecutor
=
ThreadUtils
.
new
ThreadPoolExecutor
(
this
.
publicExecutor
=
ThreadUtils
.
new
FixedThreadPool
(
clientConfig
.
getClientAsyncCallbackExecutorThreads
(),
clientConfig
.
getClientAsyncCallbackExecutorThreads
(),
60
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(
10000
),
"PublicExecutor"
,
true
);
10000
,
"Remoting-PublicExecutor"
,
true
);
this
.
remotingCommandFactory
=
new
RemotingCommandFactoryImpl
(
remotingCommandFactoryMeta
);
}
...
...
remoting-core/rpc-impl/src/main/java/org/apache/rocketmq/rpc/impl/client/SimpleClientImpl.java
浏览文件 @
6593294f
...
...
@@ -19,7 +19,6 @@ package org.apache.rocketmq.rpc.impl.client;
import
java.util.Properties
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.rocketmq.remoting.api.RemotingClient
;
import
org.apache.rocketmq.remoting.api.RemotingService
;
...
...
@@ -48,13 +47,10 @@ public class SimpleClientImpl extends RpcInstanceAbstract implements SimpleClien
super
(
rpcCommonConfig
);
this
.
remotingClient
=
remotingClient
;
this
.
rpcCommonConfig
=
rpcCommonConfig
;
this
.
callServiceThreadPool
=
ThreadUtils
.
new
ThreadPoolExecutor
(
this
.
callServiceThreadPool
=
ThreadUtils
.
new
FixedThreadPool
(
rpcCommonConfig
.
getClientAsyncCallbackExecutorThreads
(),
rpcCommonConfig
.
getClientAsyncCallbackExecutorThreads
(),
rpcCommonConfig
.
getServiceThreadKeepAliveTime
(),
TimeUnit
.
MILLISECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(
rpcCommonConfig
.
getServiceThreadBlockQueueSize
()),
"clientCallServiceThread"
,
true
);
rpcCommonConfig
.
getServiceThreadBlockQueueSize
(),
"RPC-ClientCallServiceThread"
,
true
);
}
public
void
initialize
()
{
...
...
remoting-core/rpc-impl/src/main/java/org/apache/rocketmq/rpc/impl/server/SimpleServerImpl.java
浏览文件 @
6593294f
...
...
@@ -19,7 +19,6 @@ package org.apache.rocketmq.rpc.impl.server;
import
java.util.Properties
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.rocketmq.remoting.api.RemotingServer
;
import
org.apache.rocketmq.remoting.api.RemotingService
;
...
...
@@ -40,13 +39,10 @@ public class SimpleServerImpl extends RpcInstanceAbstract implements SimpleServe
public
SimpleServerImpl
(
final
RpcCommonConfig
remotingConfig
)
{
this
(
remotingConfig
,
RemotingBootstrapFactory
.
createRemotingServer
(
remotingConfig
));
this
.
rpcCommonConfig
=
remotingConfig
;
this
.
callServiceThreadPool
=
ThreadUtils
.
new
ThreadPoolExecutor
(
this
.
callServiceThreadPool
=
ThreadUtils
.
new
FixedThreadPool
(
rpcCommonConfig
.
getClientAsyncCallbackExecutorThreads
(),
rpcCommonConfig
.
getClientAsyncCallbackExecutorThreads
(),
rpcCommonConfig
.
getServiceThreadKeepAliveTime
(),
TimeUnit
.
MILLISECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(
remotingConfig
.
getServiceThreadBlockQueueSize
()),
"serverCallServiceThread"
,
true
);
remotingConfig
.
getServiceThreadBlockQueueSize
(),
"RPC-ServerCallServiceThread"
,
true
);
}
public
SimpleServerImpl
(
final
RpcCommonConfig
remotingConfig
,
final
RemotingServer
remotingServer
)
{
...
...
remoting-core/rpc-impl/src/main/java/org/apache/rocketmq/rpc/impl/service/RpcInstanceAbstract.java
浏览文件 @
6593294f
...
...
@@ -18,8 +18,6 @@
package
org.apache.rocketmq.rpc.impl.service
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.rocketmq.remoting.external.ThreadUtils
;
import
org.apache.rocketmq.rpc.impl.command.RpcRequestCode
;
...
...
@@ -29,15 +27,13 @@ import org.apache.rocketmq.rpc.impl.metrics.DefaultServiceAPIImpl;
import
org.apache.rocketmq.rpc.impl.metrics.ThreadStats
;
import
org.apache.rocketmq.rpc.impl.processor.RpcRequestProcessor
;
import
static
org
.
apache
.
rocketmq
.
remoting
.
external
.
ThreadUtils
.
newThreadFactory
;
public
abstract
class
RpcInstanceAbstract
extends
RpcProxyCommon
{
protected
final
RpcRequestProcessor
rpcRequestProcessor
;
protected
final
ThreadLocal
<
RpcProviderContext
>
threadLocalProviderContext
=
new
ThreadLocal
<
RpcProviderContext
>();
protected
final
RpcCommonConfig
rpcCommonConfig
;
protected
ThreadStats
threadStats
;
private
DefaultServiceAPIImpl
defaultServiceAPI
;
private
ThreadPoolExecutor
invokeServiceThreadPool
;
private
ExecutorService
invokeServiceThreadPool
;
public
RpcInstanceAbstract
(
RpcCommonConfig
rpcCommonConfig
)
{
super
(
rpcCommonConfig
);
...
...
@@ -45,13 +41,9 @@ public abstract class RpcInstanceAbstract extends RpcProxyCommon {
this
.
rpcCommonConfig
=
rpcCommonConfig
;
this
.
rpcRequestProcessor
=
new
RpcRequestProcessor
(
this
.
threadLocalProviderContext
,
this
,
serviceStats
);
this
.
invokeServiceThreadPool
=
new
ThreadPoolExecutor
(
rpcCommonConfig
.
getClientAsyncCallbackExecutorThreads
(),
this
.
invokeServiceThreadPool
=
ThreadUtils
.
newFixedThreadPool
(
rpcCommonConfig
.
getClientAsyncCallbackExecutorThreads
(),
60
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(
rpcCommonConfig
.
getServiceThreadBlockQueueSize
()),
newThreadFactory
(
"rpcInvokeServiceThread"
,
true
));
rpcCommonConfig
.
getServiceThreadBlockQueueSize
(),
"RPC-InvokeServiceThread"
,
true
);
}
...
...
@@ -81,11 +73,11 @@ public abstract class RpcInstanceAbstract extends RpcProxyCommon {
public
abstract
void
registerServiceListener
();
public
ThreadPoolExecutor
getInvokeServiceThreadPool
()
{
public
ExecutorService
getInvokeServiceThreadPool
()
{
return
invokeServiceThreadPool
;
}
public
void
setInvokeServiceThreadPool
(
ThreadPoolExecutor
invokeServiceThreadPool
)
{
public
void
setInvokeServiceThreadPool
(
ExecutorService
invokeServiceThreadPool
)
{
this
.
invokeServiceThreadPool
=
invokeServiceThreadPool
;
}
...
...
remoting-core/rpc-impl/src/main/java/org/apache/rocketmq/rpc/impl/service/RpcProxyCommon.java
浏览文件 @
6593294f
...
...
@@ -25,7 +25,6 @@ import java.util.concurrent.Callable;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.rocketmq.remoting.api.AsyncHandler
;
import
org.apache.rocketmq.remoting.api.RemotingService
;
...
...
@@ -68,20 +67,14 @@ public abstract class RpcProxyCommon {
public
RpcProxyCommon
(
RpcCommonConfig
rpcCommonConfig
)
{
this
.
rpcCommonConfig
=
rpcCommonConfig
;
this
.
serviceStats
=
new
ServiceStats
();
this
.
promiseExecutorService
=
ThreadUtils
.
new
ThreadPoolExecutor
(
this
.
promiseExecutorService
=
ThreadUtils
.
new
FixedThreadPool
(
rpcCommonConfig
.
getClientAsyncCallbackExecutorThreads
(),
rpcCommonConfig
.
getServiceThreadBlockQueueSize
(),
"Remoting-PromiseExecutorService"
,
true
);
this
.
callServiceThreadPool
=
ThreadUtils
.
newFixedThreadPool
(
rpcCommonConfig
.
getClientAsyncCallbackExecutorThreads
(),
rpcCommonConfig
.
getServiceThreadKeepAliveTime
(),
TimeUnit
.
MILLISECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(
rpcCommonConfig
.
getServiceThreadBlockQueueSize
()),
"promiseExecutorService"
,
true
);
this
.
callServiceThreadPool
=
ThreadUtils
.
newThreadPoolExecutor
(
rpcCommonConfig
.
getClientAsyncCallbackExecutorThreads
(),
rpcCommonConfig
.
getClientAsyncCallbackExecutorThreads
(),
rpcCommonConfig
.
getServiceThreadKeepAliveTime
(),
TimeUnit
.
MILLISECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(
rpcCommonConfig
.
getServiceThreadBlockQueueSize
()),
"callServiceThread"
,
true
);
rpcCommonConfig
.
getServiceThreadBlockQueueSize
(),
"Remoting-CallServiceThread"
,
true
);
}
private
RemotingCommand
createRemoteRequest
(
RemoteService
serviceExport
,
Method
method
,
Object
[]
args
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录