Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
Rocketmq
提交
9297d560
R
Rocketmq
项目概览
s920243400
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
1
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看板
提交
9297d560
编写于
2月 18, 2019
作者:
D
duhenglucky
浏览文件
操作
浏览文件
下载
差异文件
Add local metrics sample and compute process
上级
7692d466
e7b71078
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
88 addition
and
21 deletion
+88
-21
acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java
.../org/apache/rocketmq/acl/plain/PlainPermissionLoader.java
+2
-2
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
...ain/java/org/apache/rocketmq/broker/BrokerController.java
+0
-2
client/src/test/java/org/apache/rocketmq/client/trace/DefaultMQConsumerWithTraceTest.java
...rocketmq/client/trace/DefaultMQConsumerWithTraceTest.java
+4
-1
client/src/test/java/org/apache/rocketmq/client/trace/DefaultMQProducerWithTraceTest.java
...rocketmq/client/trace/DefaultMQProducerWithTraceTest.java
+1
-0
remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ClientImpl.java
...he/rocketmq/remoting/transport/http2/Http2ClientImpl.java
+3
-3
remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ServerImpl.java
...he/rocketmq/remoting/transport/http2/Http2ServerImpl.java
+6
-6
snode/src/main/java/org/apache/rocketmq/snode/mqtrace/MsgTraceServiceImpl.java
...rg/apache/rocketmq/snode/mqtrace/MsgTraceServiceImpl.java
+48
-0
snode/src/main/java/org/apache/rocketmq/snode/processor/SendMessageProcessor.java
...apache/rocketmq/snode/processor/SendMessageProcessor.java
+4
-2
snode/src/main/resources/META-INF/service/org.apache.rocketmq.snode.interceptor.SendMessageInterceptor
....apache.rocketmq.snode.interceptor.SendMessageInterceptor
+1
-0
snode/src/test/java/org/apache/rocketmq/snode/processor/SendMessageProcessorTest.java
...he/rocketmq/snode/processor/SendMessageProcessorTest.java
+19
-5
未找到文件。
acl/src/main/java/org/apache/rocketmq/acl/plain/PlainPermissionLoader.java
浏览文件 @
9297d560
...
...
@@ -130,8 +130,8 @@ public class PlainPermissionLoader {
if
(!
ownedPermMap
.
containsKey
(
resource
))
{
// Check the default perm
byte
ownedPerm
=
isGroup
?
needCheck
edAccess
.
getDefaultGroupPerm
()
:
needCheck
edAccess
.
getDefaultTopicPerm
();
byte
ownedPerm
=
isGroup
?
own
edAccess
.
getDefaultGroupPerm
()
:
own
edAccess
.
getDefaultTopicPerm
();
if
(!
Permission
.
checkPermission
(
neededPerm
,
ownedPerm
))
{
throw
new
AclException
(
String
.
format
(
"No default permission for %s"
,
PlainAccessResource
.
printStr
(
resource
,
isGroup
)));
}
...
...
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
浏览文件 @
9297d560
...
...
@@ -469,8 +469,6 @@ public class BrokerController {
}
}
initialTransaction
();
initialAcl
();
// initialRpcHooks();
}
return
result
;
}
...
...
client/src/test/java/org/apache/rocketmq/client/trace/DefaultMQConsumerWithTraceTest.java
浏览文件 @
9297d560
...
...
@@ -65,6 +65,7 @@ import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import
org.apache.rocketmq.remoting.exception.RemotingException
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.mockito.invocation.InvocationOnMock
;
...
...
@@ -185,6 +186,8 @@ public class DefaultMQConsumerWithTraceTest {
});
doReturn
(
new
FindBrokerResult
(
"127.0.0.1:10911"
,
false
)).
when
(
mQClientFactory
).
findBrokerAddressInSubscribe
(
anyString
(),
anyLong
(),
anyBoolean
());
doReturn
(
"127.0.0.1:10911"
).
when
(
mQClientFactory
).
findSnodeAddressInPublish
();
Set
<
MessageQueue
>
messageQueueSet
=
new
HashSet
<
MessageQueue
>();
messageQueueSet
.
add
(
createPullRequest
().
getMessageQueue
());
pushConsumer
.
getDefaultMQPushConsumerImpl
().
updateTopicSubscribeInfo
(
topic
,
messageQueueSet
);
...
...
@@ -195,7 +198,7 @@ public class DefaultMQConsumerWithTraceTest {
pushConsumer
.
shutdown
();
}
//
@Test
@Test
public
void
testPullMessage_WithTrace_Success
()
throws
InterruptedException
,
RemotingException
,
MQBrokerException
,
MQClientException
{
traceProducer
.
getDefaultMQProducerImpl
().
getmQClientFactory
().
registerProducer
(
producerGroupTraceTemp
,
traceProducer
.
getDefaultMQProducerImpl
());
...
...
client/src/test/java/org/apache/rocketmq/client/trace/DefaultMQProducerWithTraceTest.java
浏览文件 @
9297d560
...
...
@@ -116,6 +116,7 @@ public class DefaultMQProducerWithTraceTest {
when
(
mQClientAPIImpl
.
sendMessage
(
anyString
(),
anyString
(),
any
(
Message
.
class
),
any
(
SendMessageRequestHeader
.
class
),
anyLong
(),
any
(
CommunicationMode
.
class
),
nullable
(
SendCallback
.
class
),
nullable
(
TopicPublishInfo
.
class
),
nullable
(
MQClientInstance
.
class
),
anyInt
(),
nullable
(
SendMessageContext
.
class
),
any
(
DefaultMQProducerImpl
.
class
)))
.
thenReturn
(
createSendResult
(
SendStatus
.
SEND_OK
));
when
(
mQClientFactory
.
findSnodeAddressInPublish
()).
thenReturn
(
"127.0.0.1:10911"
);
}
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ClientImpl.java
浏览文件 @
9297d560
...
...
@@ -82,13 +82,13 @@ public class Http2ClientImpl extends NettyRemotingClientAbstract implements Remo
public
RemotingClient
init
(
ClientConfig
clientConfig
,
ChannelEventListener
channelEventListener
)
{
this
.
nettyClientConfig
=
clientConfig
;
this
.
channelEventListener
=
channelEventListener
;
this
.
ioGroup
=
new
NioEventLoopGroup
(
clientConfig
.
getClientWorkerThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"NettyClientEpollIoThreads"
,
this
.
ioGroup
=
new
NioEventLoopGroup
(
clientConfig
.
getClientWorkerThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"
Http2
NettyClientEpollIoThreads"
,
clientConfig
.
getClientWorkerThreads
()));
this
.
publicExecutor
=
ThreadUtils
.
newFixedThreadPool
(
clientConfig
.
getClientCallbackExecutorThreads
(),
10000
,
"Remoting-PublicExecutor"
,
true
);
10000
,
"
Http2
Remoting-PublicExecutor"
,
true
);
this
.
defaultEventExecutorGroup
=
new
DefaultEventExecutorGroup
(
clientConfig
.
getClientWorkerThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"NettyClientWorkerThreads"
,
clientConfig
.
getClientWorkerThreads
()));
ThreadUtils
.
newGenericThreadFactory
(
"
Http2
NettyClientWorkerThreads"
,
clientConfig
.
getClientWorkerThreads
()));
buildHttp2SslClientContext
();
return
this
;
}
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ServerImpl.java
浏览文件 @
9297d560
...
...
@@ -97,23 +97,23 @@ public class Http2ServerImpl extends NettyRemotingServerAbstract implements Remo
this
.
channelEventListener
=
channelEventListener
;
this
.
publicExecutor
=
ThreadUtils
.
newFixedThreadPool
(
serverConfig
.
getServerCallbackExecutorThreads
(),
10000
,
"Remoting-PublicExecutor"
,
true
);
10000
,
"
Http2
Remoting-PublicExecutor"
,
true
);
if
(
JvmUtils
.
isLinux
()
&&
this
.
serverConfig
.
isUseEpollNativeSelector
())
{
this
.
ioGroup
=
new
EpollEventLoopGroup
(
serverConfig
.
getServerSelectorThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"NettyEpollIoThreads"
,
this
.
ioGroup
=
new
EpollEventLoopGroup
(
serverConfig
.
getServerSelectorThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"
Http2
NettyEpollIoThreads"
,
serverConfig
.
getServerSelectorThreads
()));
this
.
bossGroup
=
new
EpollEventLoopGroup
(
serverConfig
.
getServerAcceptorThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"NettyBossThreads"
,
this
.
bossGroup
=
new
EpollEventLoopGroup
(
serverConfig
.
getServerAcceptorThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"
Http2
NettyBossThreads"
,
serverConfig
.
getServerAcceptorThreads
()));
this
.
socketChannelClass
=
EpollServerSocketChannel
.
class
;
}
else
{
this
.
bossGroup
=
new
NioEventLoopGroup
(
serverConfig
.
getServerAcceptorThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"NettyBossThreads"
,
this
.
bossGroup
=
new
NioEventLoopGroup
(
serverConfig
.
getServerAcceptorThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"
Http2
NettyBossThreads"
,
serverConfig
.
getServerAcceptorThreads
()));
this
.
ioGroup
=
new
NioEventLoopGroup
(
serverConfig
.
getServerSelectorThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"NettyNioIoThreads"
,
this
.
ioGroup
=
new
NioEventLoopGroup
(
serverConfig
.
getServerSelectorThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"
Http2
NettyNioIoThreads"
,
serverConfig
.
getServerSelectorThreads
()));
this
.
socketChannelClass
=
NioServerSocketChannel
.
class
;
}
this
.
workerGroup
=
new
DefaultEventExecutorGroup
(
serverConfig
.
getServerWorkerThreads
(),
ThreadUtils
.
newGenericThreadFactory
(
"NettyWorkerThreads"
,
serverConfig
.
getServerWorkerThreads
()));
ThreadUtils
.
newGenericThreadFactory
(
"
Http2
NettyWorkerThreads"
,
serverConfig
.
getServerWorkerThreads
()));
this
.
port
=
nettyServerConfig
.
getListenPort
();
buildHttp2SslServerContext
();
return
this
;
...
...
snode/src/main/java/org/apache/rocketmq/snode/mqtrace/MsgTraceServiceImpl.java
0 → 100644
浏览文件 @
9297d560
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.snode.mqtrace
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
import
org.apache.rocketmq.remoting.interceptor.ExceptionContext
;
import
org.apache.rocketmq.remoting.interceptor.Interceptor
;
import
org.apache.rocketmq.remoting.interceptor.RequestContext
;
import
org.apache.rocketmq.remoting.interceptor.ResponseContext
;
public
class
MsgTraceServiceImpl
implements
Interceptor
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
SNODE_LOGGER_NAME
);
@Override
public
String
interceptorName
()
{
return
"snodeMsgTraceInterceptor"
;
}
@Override
public
void
beforeRequest
(
RequestContext
requestContext
)
{
}
@Override
public
void
afterRequest
(
ResponseContext
responseContext
)
{
}
@Override
public
void
onException
(
ExceptionContext
exceptionContext
)
{
}
}
snode/src/main/java/org/apache/rocketmq/snode/processor/SendMessageProcessor.java
浏览文件 @
9297d560
...
...
@@ -67,14 +67,16 @@ public class SendMessageProcessor implements RequestProcessor {
String
enodeName
;
SendMessageRequestHeaderV2
sendMessageRequestHeaderV2
=
null
;
final
StringBuffer
stringBuffer
=
new
StringBuffer
();
ConsumerSendMsgBackRequestHeader
consumerSendMsgBackRequestHeader
=
null
;
boolean
isSendBack
=
false
;
if
(
request
.
getCode
()
==
RequestCode
.
SEND_MESSAGE_V2
)
{
if
(
request
.
getCode
()
==
RequestCode
.
SEND_MESSAGE_V2
||
request
.
getCode
()
==
RequestCode
.
SEND_BATCH_MESSAGE
)
{
sendMessageRequestHeaderV2
=
(
SendMessageRequestHeaderV2
)
request
.
decodeCommandCustomHeader
(
SendMessageRequestHeaderV2
.
class
);
enodeName
=
sendMessageRequestHeaderV2
.
getN
();
stringBuffer
.
append
(
sendMessageRequestHeaderV2
.
getB
());
}
else
{
isSendBack
=
true
;
ConsumerSendMsgBackRequestHeader
consumerSendMsgBackRequestHeader
=
(
ConsumerSendMsgBackRequestHeader
)
request
.
decodeCommandCustomHeader
(
ConsumerSendMsgBackRequestHeader
.
class
);
consumerSendMsgBackRequestHeader
=
(
ConsumerSendMsgBackRequestHeader
)
request
.
decodeCommandCustomHeader
(
ConsumerSendMsgBackRequestHeader
.
class
);
enodeName
=
consumerSendMsgBackRequestHeader
.
getEnodeName
();
stringBuffer
.
append
(
MixAll
.
getRetryTopic
(
consumerSendMsgBackRequestHeader
.
getGroup
()));
}
...
...
snode/src/main/resources/META-INF/service/org.apache.rocketmq.snode.interceptor.SendMessageInterceptor
浏览文件 @
9297d560
org.apache.rocketmq.snode.mqtrace.MsgTraceServiceImpl
\ No newline at end of file
snode/src/test/java/org/apache/rocketmq/snode/processor/SendMessageProcessorTest.java
浏览文件 @
9297d560
...
...
@@ -71,12 +71,18 @@ public class SendMessageProcessorTest {
}
@Test
public
void
testProcessRequest
()
throws
RemotingCommandException
{
public
void
testSendMessageV2ProcessRequest
()
throws
RemotingCommandException
{
CompletableFuture
<
RemotingCommand
>
future
=
new
CompletableFuture
<>();
RemotingCommand
request
=
createSendMesssageV2Command
();
when
(
this
.
snodeController
.
getEnodeService
().
sendMessage
(
anyString
(),
any
(
RemotingCommand
.
class
))).
thenReturn
(
future
);
sendMessageProcessor
.
processRequest
(
remotingChannel
,
request
);
}
@Test
public
void
testSendBatchMessageProcessRequest
()
throws
RemotingCommandException
{
snodeController
.
setEnodeService
(
enodeService
);
CompletableFuture
<
RemotingCommand
>
future
=
new
CompletableFuture
<>();
RemotingCommand
request
=
createSendMesssageCommand
();
SendMessageRequestHeaderV2
sendMessageRequestHeaderV2
=
(
SendMessageRequestHeaderV2
)
request
.
decodeCommandCustomHeader
(
SendMessageRequestHeaderV2
.
class
);
System
.
out
.
println
(
"sendMessageRequestHeaderV2: "
+
sendMessageRequestHeaderV2
);
RemotingCommand
request
=
createSendBatchMesssageCommand
();
when
(
this
.
snodeController
.
getEnodeService
().
sendMessage
(
anyString
(),
any
(
RemotingCommand
.
class
))).
thenReturn
(
future
);
sendMessageProcessor
.
processRequest
(
remotingChannel
,
request
);
}
...
...
@@ -95,7 +101,7 @@ public class SendMessageProcessorTest {
return
requestHeader
;
}
private
RemotingCommand
createSendMesssageCommand
()
{
private
RemotingCommand
createSendMesssage
V2
Command
()
{
SendMessageRequestHeaderV2
sendMessageRequestHeaderV2
=
createSendMsgRequestHeader
();
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
SEND_MESSAGE_V2
,
sendMessageRequestHeaderV2
);
request
.
setBody
(
new
byte
[]
{
'a'
});
...
...
@@ -103,6 +109,14 @@ public class SendMessageProcessorTest {
return
request
;
}
private
RemotingCommand
createSendBatchMesssageCommand
()
{
SendMessageRequestHeaderV2
sendMessageRequestHeaderV2
=
createSendMsgRequestHeader
();
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
SEND_BATCH_MESSAGE
,
sendMessageRequestHeaderV2
);
request
.
setBody
(
new
byte
[]
{
'b'
});
CodecHelper
.
makeCustomHeaderToNet
(
request
);
return
request
;
}
RemotingCommand
createSendMessageResponse
(
int
responseCode
)
{
return
RemotingCommand
.
createResponseCommand
(
ResponseCode
.
SUCCESS
,
null
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录