Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小五666\n哈哈
Rocketmq
提交
114b6ae0
R
Rocketmq
项目概览
小五666\n哈哈
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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看板
提交
114b6ae0
编写于
9月 20, 2017
作者:
Y
yukon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor polish
上级
0b88e66f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
64 addition
and
55 deletion
+64
-55
remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/buffer/ByteBufferWrapper.java
...pache/rocketmq/remoting/api/buffer/ByteBufferWrapper.java
+14
-14
remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/buffer/NettyByteBufferWrapper.java
...rocketmq/remoting/impl/buffer/NettyByteBufferWrapper.java
+38
-35
remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingAbstract.java
...e/rocketmq/remoting/impl/netty/NettyRemotingAbstract.java
+11
-5
remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/handler/Decoder.java
.../apache/rocketmq/remoting/impl/netty/handler/Decoder.java
+1
-1
未找到文件。
remoting-core/remoting-api/src/main/java/org/apache/rocketmq/remoting/api/buffer/ByteBufferWrapper.java
浏览文件 @
114b6ae0
...
@@ -20,37 +20,37 @@ package org.apache.rocketmq.remoting.api.buffer;
...
@@ -20,37 +20,37 @@ package org.apache.rocketmq.remoting.api.buffer;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
public
interface
ByteBufferWrapper
{
public
interface
ByteBufferWrapper
{
void
writeByte
(
int
index
,
byte
data
);
void
writeByte
(
byte
data
);
void
writeByte
(
byte
data
);
byte
readByte
();
void
writeByte
(
int
index
,
byte
data
);
void
writeInt
(
int
data
);
void
writeBytes
(
byte
[]
data
);
void
writeBytes
(
byte
[]
data
);
void
writeBytes
(
ByteBuffer
data
);
void
writeBytes
(
ByteBuffer
data
);
int
readableBytes
(
);
void
writeInt
(
int
data
);
int
readInt
();
void
writeShort
(
short
value
);
void
writeLong
(
long
id
);
byte
readByte
();
void
readBytes
(
byte
[]
dst
);
void
readBytes
(
byte
[]
dst
);
void
readBytes
(
ByteBuffer
dst
);
void
readBytes
(
ByteBuffer
dst
);
int
readerIndex
();
short
readShort
();
void
setReaderIndex
(
int
readerIndex
);
void
writeLong
(
long
id
);
int
readInt
(
);
long
readLong
();
long
readLong
();
void
ensureCapacity
(
int
capacity
);
int
readableBytes
(
);
short
readShort
();
int
readerIndex
();
void
writeShort
(
short
value
);
void
setReaderIndex
(
int
readerIndex
);
void
ensureCapacity
(
int
capacity
);
}
}
remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/buffer/NettyByteBufferWrapper.java
浏览文件 @
114b6ae0
...
@@ -18,39 +18,27 @@
...
@@ -18,39 +18,27 @@
package
org.apache.rocketmq.remoting.impl.buffer
;
package
org.apache.rocketmq.remoting.impl.buffer
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.channel.Channel
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
org.apache.rocketmq.remoting.api.buffer.ByteBufferWrapper
;
import
org.apache.rocketmq.remoting.api.buffer.ByteBufferWrapper
;
public
class
NettyByteBufferWrapper
implements
ByteBufferWrapper
{
public
class
NettyByteBufferWrapper
implements
ByteBufferWrapper
{
private
final
ByteBuf
buffer
;
private
final
ByteBuf
buffer
;
private
final
Channel
channel
;
public
NettyByteBufferWrapper
(
ByteBuf
buffer
)
{
public
NettyByteBufferWrapper
(
ByteBuf
buffer
)
{
this
(
buffer
,
null
);
}
public
NettyByteBufferWrapper
(
ByteBuf
buffer
,
Channel
channel
)
{
this
.
channel
=
channel
;
this
.
buffer
=
buffer
;
this
.
buffer
=
buffer
;
}
}
public
void
writeByte
(
int
index
,
byte
data
)
{
@Override
buffer
.
writeByte
(
data
);
}
public
void
writeByte
(
byte
data
)
{
public
void
writeByte
(
byte
data
)
{
buffer
.
writeByte
(
data
);
buffer
.
writeByte
(
data
);
}
}
public
byte
readByte
()
{
@Override
return
buffer
.
readByte
();
public
void
writeByte
(
int
index
,
byte
data
)
{
}
buffer
.
writeByte
(
data
);
public
void
writeInt
(
int
data
)
{
buffer
.
writeInt
(
data
);
}
}
@Override
public
void
writeBytes
(
byte
[]
data
)
{
public
void
writeBytes
(
byte
[]
data
)
{
buffer
.
writeBytes
(
data
);
buffer
.
writeBytes
(
data
);
}
}
...
@@ -60,16 +48,24 @@ public class NettyByteBufferWrapper implements ByteBufferWrapper {
...
@@ -60,16 +48,24 @@ public class NettyByteBufferWrapper implements ByteBufferWrapper {
buffer
.
writeBytes
(
data
);
buffer
.
writeBytes
(
data
);
}
}
public
int
readableBytes
()
{
@Override
return
buffer
.
readableBytes
();
public
void
writeShort
(
final
short
value
)
{
buffer
.
writeShort
(
value
);
}
}
public
int
readInt
()
{
@Override
return
buffer
.
readInt
();
public
void
writeInt
(
int
data
)
{
buffer
.
writeInt
(
data
);
}
}
public
void
readBytes
(
byte
[]
dst
)
{
@Override
buffer
.
readBytes
(
dst
);
public
void
writeLong
(
long
value
)
{
buffer
.
writeLong
(
value
);
}
@Override
public
byte
readByte
()
{
return
buffer
.
readByte
();
}
}
@Override
@Override
...
@@ -77,17 +73,19 @@ public class NettyByteBufferWrapper implements ByteBufferWrapper {
...
@@ -77,17 +73,19 @@ public class NettyByteBufferWrapper implements ByteBufferWrapper {
buffer
.
readBytes
(
dst
);
buffer
.
readBytes
(
dst
);
}
}
public
int
readerIndex
()
{
@Override
return
buffer
.
readerIndex
();
public
void
readBytes
(
byte
[]
dst
)
{
buffer
.
readBytes
(
dst
);
}
}
public
void
setReaderIndex
(
int
index
)
{
@Override
buffer
.
setIndex
(
index
,
buffer
.
writerIndex
());
public
short
readShort
()
{
return
buffer
.
readShort
();
}
}
@Override
@Override
public
void
writeLong
(
long
value
)
{
public
int
readInt
(
)
{
buffer
.
writeLong
(
value
);
return
buffer
.
readInt
(
);
}
}
@Override
@Override
...
@@ -96,18 +94,23 @@ public class NettyByteBufferWrapper implements ByteBufferWrapper {
...
@@ -96,18 +94,23 @@ public class NettyByteBufferWrapper implements ByteBufferWrapper {
}
}
@Override
@Override
public
void
ensureCapacity
(
int
capacity
)
{
public
int
readableBytes
(
)
{
buffer
.
capacity
(
capacity
);
return
buffer
.
readableBytes
(
);
}
}
@Override
@Override
public
short
readShort
()
{
public
int
readerIndex
()
{
return
buffer
.
read
Short
();
return
buffer
.
read
erIndex
();
}
}
@Override
@Override
public
void
writeShort
(
final
short
value
)
{
public
void
setReaderIndex
(
int
index
)
{
buffer
.
writeShort
(
value
);
buffer
.
setIndex
(
index
,
buffer
.
writerIndex
());
}
@Override
public
void
ensureCapacity
(
int
capacity
)
{
buffer
.
capacity
(
capacity
);
}
}
}
}
...
...
remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingAbstract.java
浏览文件 @
114b6ae0
...
@@ -77,7 +77,7 @@ public abstract class NettyRemotingAbstract implements RemotingService {
...
@@ -77,7 +77,7 @@ public abstract class NettyRemotingAbstract implements RemotingService {
private
final
Semaphore
semaphoreAsync
;
private
final
Semaphore
semaphoreAsync
;
private
final
Map
<
Integer
,
ResponseResult
>
ackTables
=
new
ConcurrentHashMap
<
Integer
,
ResponseResult
>(
256
);
private
final
Map
<
Integer
,
ResponseResult
>
ackTables
=
new
ConcurrentHashMap
<
Integer
,
ResponseResult
>(
256
);
private
final
Map
<
String
,
Pair
<
RequestProcessor
,
ExecutorService
>>
processorTables
=
new
ConcurrentHashMap
<
String
,
Pair
<
RequestProcessor
,
ExecutorService
>>();
private
final
Map
<
String
,
Pair
<
RequestProcessor
,
ExecutorService
>>
processorTables
=
new
ConcurrentHashMap
<
String
,
Pair
<
RequestProcessor
,
ExecutorService
>>();
private
final
AtomicLong
count
=
new
AtomicLong
(
0
);
private
final
AtomicLong
responseCounter
=
new
AtomicLong
(
0
);
private
final
RemotingCommandFactory
remotingCommandFactory
;
private
final
RemotingCommandFactory
remotingCommandFactory
;
private
final
String
remotingInstanceId
=
UIDGenerator
.
instance
().
createUID
();
private
final
String
remotingInstanceId
=
UIDGenerator
.
instance
().
createUID
();
...
@@ -93,8 +93,13 @@ public abstract class NettyRemotingAbstract implements RemotingService {
...
@@ -93,8 +93,13 @@ public abstract class NettyRemotingAbstract implements RemotingService {
NettyRemotingAbstract
(
RemotingConfig
clientConfig
,
RemotingCommandFactoryMeta
remotingCommandFactoryMeta
)
{
NettyRemotingAbstract
(
RemotingConfig
clientConfig
,
RemotingCommandFactoryMeta
remotingCommandFactoryMeta
)
{
this
.
semaphoreOneway
=
new
Semaphore
(
clientConfig
.
getClientOnewayInvokeSemaphore
(),
true
);
this
.
semaphoreOneway
=
new
Semaphore
(
clientConfig
.
getClientOnewayInvokeSemaphore
(),
true
);
this
.
semaphoreAsync
=
new
Semaphore
(
clientConfig
.
getClientAsyncInvokeSemaphore
(),
true
);
this
.
semaphoreAsync
=
new
Semaphore
(
clientConfig
.
getClientAsyncInvokeSemaphore
(),
true
);
this
.
publicExecutor
=
ThreadUtils
.
newThreadPoolExecutor
(
clientConfig
.
getClientAsyncCallbackExecutorThreads
(),
clientConfig
.
getClientAsyncCallbackExecutorThreads
(),
60
,
this
.
publicExecutor
=
ThreadUtils
.
newThreadPoolExecutor
(
TimeUnit
.
SECONDS
,
new
ArrayBlockingQueue
<
Runnable
>(
10000
),
"PublicExecutor"
,
true
);
clientConfig
.
getClientAsyncCallbackExecutorThreads
(),
clientConfig
.
getClientAsyncCallbackExecutorThreads
(),
60
,
TimeUnit
.
SECONDS
,
new
ArrayBlockingQueue
<
Runnable
>(
10000
),
"PublicExecutor"
,
true
);
this
.
remotingCommandFactory
=
new
RemotingCommandFactoryImpl
(
remotingCommandFactoryMeta
);
this
.
remotingCommandFactory
=
new
RemotingCommandFactoryImpl
(
remotingCommandFactoryMeta
);
}
}
...
@@ -237,9 +242,10 @@ public abstract class NettyRemotingAbstract implements RemotingService {
...
@@ -237,9 +242,10 @@ public abstract class NettyRemotingAbstract implements RemotingService {
long
time
=
System
.
currentTimeMillis
();
long
time
=
System
.
currentTimeMillis
();
ackTables
.
remove
(
cmd
.
requestID
());
ackTables
.
remove
(
cmd
.
requestID
());
if
(
count
.
incrementAndGet
()
%
5000
==
0
)
if
(
responseCounter
.
incrementAndGet
()
%
5000
==
0
)
{
LOG
.
warn
(
"REQUEST ID:{}, cost time:{}, ackTables.size:{}"
,
cmd
.
requestID
(),
time
-
responseResult
.
getBeginTimestamp
(),
LOG
.
info
(
"REQUEST ID:{}, cost time:{}, ackTables.size:{}"
,
cmd
.
requestID
(),
time
-
responseResult
.
getBeginTimestamp
(),
ackTables
.
size
());
ackTables
.
size
());
}
if
(
responseResult
.
getAsyncHandler
()
!=
null
)
{
if
(
responseResult
.
getAsyncHandler
()
!=
null
)
{
boolean
sameThread
=
false
;
boolean
sameThread
=
false
;
ExecutorService
executor
=
this
.
getCallbackExecutor
();
ExecutorService
executor
=
this
.
getCallbackExecutor
();
...
...
remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/handler/Decoder.java
浏览文件 @
114b6ae0
...
@@ -44,7 +44,7 @@ public class Decoder extends ByteToMessageDecoder {
...
@@ -44,7 +44,7 @@ public class Decoder extends ByteToMessageDecoder {
return
;
return
;
}
}
NettyByteBufferWrapper
wrapper
=
new
NettyByteBufferWrapper
(
in
,
ctx
.
channel
()
);
NettyByteBufferWrapper
wrapper
=
new
NettyByteBufferWrapper
(
in
);
Object
msg
=
this
.
decode
(
ctx
,
wrapper
);
Object
msg
=
this
.
decode
(
ctx
,
wrapper
);
if
(
msg
!=
null
)
{
if
(
msg
!=
null
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录