Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
81b4293a
R
Rocketmq
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
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看板
未验证
提交
81b4293a
编写于
2月 01, 2019
作者:
H
Heng Du
提交者:
GitHub
2月 01, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #745 from zongtanghu/snode
[ISSUE #743]adjust some codes of supporting Http2 for rocketmq.
上级
ba48f6a2
72680765
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
19 deletion
+48
-19
remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ClientImpl.java
...he/rocketmq/remoting/transport/http2/Http2ClientImpl.java
+6
-10
remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2Handler.java
...pache/rocketmq/remoting/transport/http2/Http2Handler.java
+8
-7
remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ServerImpl.java
...he/rocketmq/remoting/transport/http2/Http2ServerImpl.java
+2
-2
remoting/src/test/java/org/apache/rocketmq/remoting/RemotingHttp2InvokingTest.java
...g/apache/rocketmq/remoting/RemotingHttp2InvokingTest.java
+32
-0
未找到文件。
remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ClientImpl.java
浏览文件 @
81b4293a
...
...
@@ -89,11 +89,11 @@ public class Http2ClientImpl extends NettyRemotingClientAbstract implements Remo
10000
,
"Remoting-PublicExecutor"
,
true
);
this
.
defaultEventExecutorGroup
=
new
DefaultEventExecutorGroup
(
clientConfig
.
getClientWorkerThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"NettyClientWorkerThreads"
,
clientConfig
.
getClientWorkerThreads
()));
build
Ssl
Context
();
build
Http2SslClient
Context
();
return
this
;
}
private
void
build
Ssl
Context
()
{
private
void
build
Http2SslClient
Context
()
{
SslProvider
provider
=
OpenSsl
.
isAvailable
()
?
SslProvider
.
OPENSSL
:
SslProvider
.
JDK
;
try
{
sslContext
=
SslContextBuilder
.
forClient
()
...
...
@@ -104,7 +104,7 @@ public class Http2ClientImpl extends NettyRemotingClientAbstract implements Remo
.
trustManager
(
InsecureTrustManagerFactory
.
INSTANCE
)
.
build
();
}
catch
(
SSLException
e
)
{
e
.
printStackTrace
(
);
log
.
error
(
"Can not build Http2 SSL Client context !"
,
e
);
}
}
...
...
@@ -147,16 +147,12 @@ public class Http2ClientImpl extends NettyRemotingClientAbstract implements Remo
if
(
this
.
defaultEventExecutorGroup
!=
null
)
{
this
.
defaultEventExecutorGroup
.
shutdownGracefully
();
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Http2ClientImpl shutdown exception, "
,
e
);
}
if
(
this
.
publicExecutor
!=
null
)
{
try
{
if
(
this
.
publicExecutor
!=
null
)
{
this
.
publicExecutor
.
shutdown
();
}
catch
(
Exception
e
)
{
log
.
error
(
"NettyRemotingServer shutdown exception, "
,
e
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Http2ClientImpl shutdown exception, "
,
e
);
}
}
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2Handler.java
浏览文件 @
81b4293a
...
...
@@ -78,12 +78,11 @@ public class Http2Handler extends Http2ConnectionHandler {
frameReader
);
Http2Settings
settings
=
new
Http2Settings
();
if
(!
isServer
)
{
settings
.
pushEnabled
(
true
);
}
settings
.
initialWindowSize
(
1048576
*
10
);
//10MiB
//10MiB
settings
.
initialWindowSize
(
1048576
0
);
settings
.
maxConcurrentStreams
(
Integer
.
MAX_VALUE
);
return
newHandler
(
decoder
,
encoder
,
settings
,
isServer
);
...
...
@@ -98,8 +97,10 @@ public class Http2Handler extends Http2ConnectionHandler {
public
void
write
(
final
ChannelHandlerContext
ctx
,
final
Object
msg
,
final
ChannelPromise
promise
)
throws
Exception
{
if
(
isServer
)
{
assert
msg
instanceof
ByteBuf
;
sendAPushPromise
(
ctx
,
lastStreamId
,
lastStreamId
+
1
,
(
ByteBuf
)
msg
);
if
(!(
msg
instanceof
ByteBuf
))
{
return
;
}
sendAndPushPromise
(
ctx
,
lastStreamId
,
lastStreamId
+
1
,
(
ByteBuf
)
msg
);
}
else
{
final
Http2Headers
headers
=
new
DefaultHttp2Headers
();
...
...
@@ -111,13 +112,13 @@ public class Http2Handler extends Http2ConnectionHandler {
encoder
().
writeData
(
ctx
,
(
int
)
streamId
,
(
ByteBuf
)
msg
,
0
,
false
,
ctx
.
newPromise
());
ctx
.
flush
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
log
.
error
(
"Http2Handler write data exception,"
,
e
);
}
}
}
private
void
sendAPushPromise
(
ChannelHandlerContext
ctx
,
int
streamId
,
int
pushPromiseStreamId
,
private
void
sendA
nd
PushPromise
(
ChannelHandlerContext
ctx
,
int
streamId
,
int
pushPromiseStreamId
,
ByteBuf
payload
)
throws
Http2Exception
{
encoder
().
writePushPromise
(
ctx
,
streamId
,
pushPromiseStreamId
,
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ServerImpl.java
浏览文件 @
81b4293a
...
...
@@ -115,11 +115,11 @@ public class Http2ServerImpl extends NettyRemotingServerAbstract implements Remo
this
.
workerGroup
=
new
DefaultEventExecutorGroup
(
serverConfig
.
getServerWorkerThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"NettyWorkerThreads"
,
serverConfig
.
getServerWorkerThreads
()));
this
.
port
=
nettyServerConfig
.
getListenPort
();
buildHttp2SslContext
();
buildHttp2Ssl
Server
Context
();
return
this
;
}
private
void
buildHttp2SslContext
()
{
private
void
buildHttp2Ssl
Server
Context
()
{
try
{
SslProvider
provider
=
OpenSsl
.
isAvailable
()
?
SslProvider
.
OPENSSL
:
SslProvider
.
JDK
;
SelfSignedCertificate
ssc
;
...
...
remoting/src/test/java/org/apache/rocketmq/remoting/RemotingHttp2InvokingTest.java
浏览文件 @
81b4293a
...
...
@@ -17,13 +17,17 @@
package
org.apache.rocketmq.remoting
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.rocketmq.remoting.annotation.CFNullable
;
import
org.apache.rocketmq.remoting.common.RemotingUtil
;
import
org.apache.rocketmq.remoting.exception.RemotingCommandException
;
import
org.apache.rocketmq.remoting.exception.RemotingConnectException
;
import
org.apache.rocketmq.remoting.exception.RemotingSendRequestException
;
import
org.apache.rocketmq.remoting.exception.RemotingTimeoutException
;
import
org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException
;
import
org.apache.rocketmq.remoting.netty.ResponseFuture
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
org.apache.rocketmq.remoting.serialize.LanguageCode
;
import
org.junit.After
;
...
...
@@ -90,6 +94,34 @@ public class RemotingHttp2InvokingTest {
}
@Test
public
void
testInvokeOneway
()
throws
InterruptedException
,
RemotingConnectException
,
RemotingTimeoutException
,
RemotingTooMuchRequestException
,
RemotingSendRequestException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
0
,
null
);
request
.
setRemark
(
"messi"
);
remotingHttp2Client
.
invokeOneway
(
"localhost:8888"
,
request
,
1000
*
3
);
}
@Test
public
void
testInvokeAsync
()
throws
InterruptedException
,
RemotingConnectException
,
RemotingTimeoutException
,
RemotingTooMuchRequestException
,
RemotingSendRequestException
{
final
CountDownLatch
latch
=
new
CountDownLatch
(
1
);
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
0
,
null
);
request
.
setRemark
(
"messi"
);
remotingHttp2Client
.
invokeAsync
(
"localhost:8888"
,
request
,
1000
*
3
,
new
InvokeCallback
()
{
@Override
public
void
operationComplete
(
ResponseFuture
responseFuture
)
{
latch
.
countDown
();
assertTrue
(
responseFuture
!=
null
);
assertThat
(
responseFuture
.
getResponseCommand
().
getLanguage
()).
isEqualTo
(
LanguageCode
.
JAVA
);
assertThat
(
responseFuture
.
getResponseCommand
().
getExtFields
()).
hasSize
(
2
);
}
});
latch
.
await
(
3000
,
TimeUnit
.
SECONDS
);
}
class
Http2RequestHeader
implements
CommandCustomHeader
{
@CFNullable
private
Integer
count
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录