Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
ff6b6871
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
270
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看板
提交
ff6b6871
编写于
2月 23, 2019
作者:
D
duhenglucky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the issue of storesize and bornhost inaccurate in push message
上级
14a75e5c
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
29 addition
and
60 deletion
+29
-60
broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
...pache/rocketmq/broker/processor/SendMessageProcessor.java
+3
-10
common/src/main/java/org/apache/rocketmq/common/protocol/body/SnodeClusterInfo.java
...pache/rocketmq/common/protocol/body/SnodeClusterInfo.java
+2
-2
common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
...etmq/common/protocol/header/SendMessageRequestHeader.java
+6
-7
common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
...mq/common/protocol/header/SendMessageRequestHeaderV2.java
+6
-7
remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java
...ava/org/apache/rocketmq/remoting/common/RemotingUtil.java
+0
-13
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
...rg/apache/rocketmq/remoting/protocol/RemotingCommand.java
+0
-1
snode/src/main/java/org/apache/rocketmq/snode/SnodeStartup.java
...src/main/java/org/apache/rocketmq/snode/SnodeStartup.java
+4
-1
snode/src/main/java/org/apache/rocketmq/snode/offset/ConsumerOffsetManager.java
...g/apache/rocketmq/snode/offset/ConsumerOffsetManager.java
+0
-13
snode/src/main/java/org/apache/rocketmq/snode/processor/SendMessageProcessor.java
...apache/rocketmq/snode/processor/SendMessageProcessor.java
+3
-2
snode/src/main/java/org/apache/rocketmq/snode/service/impl/PushServiceImpl.java
...g/apache/rocketmq/snode/service/impl/PushServiceImpl.java
+3
-2
store/src/main/java/org/apache/rocketmq/store/CommitLog.java
store/src/main/java/org/apache/rocketmq/store/CommitLog.java
+2
-2
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
浏览文件 @
ff6b6871
...
...
@@ -78,13 +78,11 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
if
(
requestHeader
==
null
)
{
return
null
;
}
mqtraceContext
=
buildMsgContext
(
ctx
,
requestHeader
);
this
.
executeSendMessageHookBefore
(
ctx
,
request
,
mqtraceContext
);
RemotingCommand
response
;
// String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
SocketAddress
bornHost
=
ctx
.
channel
().
remoteAddress
();
SocketAddress
bornHost
=
RemotingHelper
.
string2SocketAddress
(
requestHeader
.
getBornHost
());
if
(
requestHeader
.
isBatch
())
{
response
=
this
.
sendBatchMessage
(
bornHost
,
request
,
mqtraceContext
,
requestHeader
);
...
...
@@ -350,12 +348,10 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
MessageAccessor
.
setProperties
(
msgInner
,
MessageDecoder
.
string2messageProperties
(
requestHeader
.
getProperties
()));
msgInner
.
setPropertiesString
(
requestHeader
.
getProperties
());
msgInner
.
setBornTimestamp
(
requestHeader
.
getBornTimestamp
());
msgInner
.
setBornHost
(
re
questHeader
.
getBornHost
()
);
msgInner
.
setBornHost
(
re
moteAddress
);
msgInner
.
setStoreHost
(
this
.
getStoreHost
());
msgInner
.
setReconsumeTimes
(
requestHeader
.
getReconsumeTimes
()
==
null
?
0
:
requestHeader
.
getReconsumeTimes
());
msgInner
.
setBornHost
(
remoteAddress
);
// ByteBuffer hostHolder = ByteBuffer.allocate(8);
// String bornHost = msgInner.getStoreHostBytes(hostHolder).toString();
PutMessageResult
putMessageResult
=
null
;
Map
<
String
,
String
>
oriProps
=
MessageDecoder
.
string2messageProperties
(
requestHeader
.
getProperties
());
String
traFlag
=
oriProps
.
get
(
MessageConst
.
PROPERTY_TRANSACTION_PREPARED
);
...
...
@@ -548,14 +544,11 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
MessageAccessor
.
setProperties
(
messageExtBatch
,
MessageDecoder
.
string2messageProperties
(
requestHeader
.
getProperties
()));
messageExtBatch
.
setBody
(
request
.
getBody
());
messageExtBatch
.
setBornTimestamp
(
requestHeader
.
getBornTimestamp
());
messageExtBatch
.
setBornHost
(
re
questHeader
.
getBornHost
()
);
messageExtBatch
.
setBornHost
(
re
moteAddress
);
messageExtBatch
.
setStoreHost
(
this
.
getStoreHost
());
messageExtBatch
.
setReconsumeTimes
(
requestHeader
.
getReconsumeTimes
()
==
null
?
0
:
requestHeader
.
getReconsumeTimes
());
// ByteBuffer hostHolder = ByteBuffer.allocate(8);
// String storeHost = messageExtBatch.getStoreHostBytes(hostHolder).toString();
PutMessageResult
putMessageResult
=
this
.
brokerController
.
getMessageStore
().
putMessages
(
messageExtBatch
);
return
handlePutMessageResult
(
putMessageResult
,
response
,
request
,
messageExtBatch
,
responseHeader
,
sendMessageContext
,
queueIdInt
,
storeHost
);
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/body/SnodeClusterInfo.java
浏览文件 @
ff6b6871
package
org.apache.rocketmq.common.protocol.body
;
/*
/*
* 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.
...
...
@@ -14,7 +14,7 @@ package org.apache.rocketmq.common.protocol.body;/*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.common.protocol.body
;
import
java.util.HashMap
;
import
java.util.Set
;
import
org.apache.rocketmq.common.protocol.route.SnodeData
;
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeader.java
浏览文件 @
ff6b6871
...
...
@@ -20,7 +20,6 @@
*/
package
org.apache.rocketmq.common.protocol.header
;
import
java.net.SocketAddress
;
import
org.apache.rocketmq.remoting.CommandCustomHeader
;
import
org.apache.rocketmq.remoting.annotation.CFNotNull
;
import
org.apache.rocketmq.remoting.annotation.CFNullable
;
...
...
@@ -56,9 +55,9 @@ public class SendMessageRequestHeader implements CommandCustomHeader {
private
String
enodeName
;
private
S
ocketAddress
bornHost
;
private
S
tring
bornHost
;
private
S
ocketAddress
snodeHost
;
private
S
tring
snodeHost
;
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
...
...
@@ -176,19 +175,19 @@ public class SendMessageRequestHeader implements CommandCustomHeader {
this
.
enodeName
=
enodeName
;
}
public
S
ocketAddress
getBornHost
()
{
public
S
tring
getBornHost
()
{
return
bornHost
;
}
public
void
setBornHost
(
S
ocketAddress
bornHost
)
{
public
void
setBornHost
(
S
tring
bornHost
)
{
this
.
bornHost
=
bornHost
;
}
public
S
ocketAddress
getSnodeHost
()
{
public
S
tring
getSnodeHost
()
{
return
snodeHost
;
}
public
void
setSnodeHost
(
S
ocketAddress
snodeHost
)
{
public
void
setSnodeHost
(
S
tring
snodeHost
)
{
this
.
snodeHost
=
snodeHost
;
}
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/SendMessageRequestHeaderV2.java
浏览文件 @
ff6b6871
...
...
@@ -17,7 +17,6 @@
package
org.apache.rocketmq.common.protocol.header
;
import
java.net.SocketAddress
;
import
org.apache.rocketmq.remoting.CommandCustomHeader
;
import
org.apache.rocketmq.remoting.annotation.CFNotNull
;
import
org.apache.rocketmq.remoting.annotation.CFNullable
;
...
...
@@ -57,9 +56,9 @@ public class SendMessageRequestHeaderV2 implements CommandCustomHeader {
private
String
n
;
//enode name
private
S
ocketAddress
o
;
//born host
private
S
tring
o
;
//born host
private
S
ocketAddress
p
;
//snode host
private
S
tring
p
;
//snode host
public
static
SendMessageRequestHeader
createSendMessageRequestHeaderV1
(
final
SendMessageRequestHeaderV2
v2
)
{
SendMessageRequestHeader
v1
=
new
SendMessageRequestHeader
();
...
...
@@ -219,19 +218,19 @@ public class SendMessageRequestHeaderV2 implements CommandCustomHeader {
this
.
n
=
n
;
}
public
S
ocketAddress
getO
()
{
public
S
tring
getO
()
{
return
o
;
}
public
void
setO
(
S
ocketAddress
o
)
{
public
void
setO
(
S
tring
o
)
{
this
.
o
=
o
;
}
public
S
ocketAddress
getP
()
{
public
S
tring
getP
()
{
return
p
;
}
public
void
setP
(
S
ocketAddress
p
)
{
public
void
setP
(
S
tring
p
)
{
this
.
p
=
p
;
}
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingUtil.java
浏览文件 @
ff6b6871
...
...
@@ -153,19 +153,6 @@ public class RemotingUtil {
return
isa
;
}
public
static
SocketAddress
string2SocketAddressWithIp
(
final
String
address
)
{
String
[]
s
=
address
.
split
(
":"
);
try
{
String
ip
=
s
[
0
].
substring
(
1
);
InetAddress
inetAddress
=
InetAddress
.
getByName
(
ip
);
InetSocketAddress
isa
=
new
InetSocketAddress
(
inetAddress
,
Integer
.
parseInt
(
s
[
1
]));
return
isa
;
}
catch
(
Exception
e
)
{
log
.
error
(
"Failed to obtain address"
,
e
);
}
return
null
;
}
public
static
String
socketAddress2String
(
final
SocketAddress
addr
)
{
StringBuilder
sb
=
new
StringBuilder
();
InetSocketAddress
inetSocketAddress
=
(
InetSocketAddress
)
addr
;
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingCommand.java
浏览文件 @
ff6b6871
...
...
@@ -49,7 +49,6 @@ public class RemotingCommand {
private
static
final
int
RPC_ONEWAY
=
1
;
private
static
volatile
int
configVersion
=
-
1
;
private
static
AtomicInteger
requestId
=
new
AtomicInteger
(
0
);
...
...
snode/src/main/java/org/apache/rocketmq/snode/SnodeStartup.java
浏览文件 @
ff6b6871
...
...
@@ -29,6 +29,7 @@ import org.apache.commons.cli.CommandLine;
import
org.apache.commons.cli.Option
;
import
org.apache.commons.cli.Options
;
import
org.apache.commons.cli.PosixParser
;
import
org.apache.rocketmq.broker.BrokerController
;
import
org.apache.rocketmq.broker.BrokerStartup
;
import
org.apache.rocketmq.common.MixAll
;
import
org.apache.rocketmq.common.SnodeConfig
;
...
...
@@ -54,7 +55,9 @@ public class SnodeStartup {
public
static
void
main
(
String
[]
args
)
throws
IOException
,
JoranException
{
SnodeConfig
snodeConfig
=
loadConfig
(
args
);
if
(
snodeConfig
.
isEmbeddedModeEnable
())
{
BrokerStartup
.
start
(
BrokerStartup
.
createBrokerController
(
args
));
BrokerController
brokerController
=
BrokerStartup
.
createBrokerController
(
args
);
BrokerStartup
.
start
(
brokerController
);
snodeConfig
.
setSnodeName
(
brokerController
.
getBrokerConfig
().
getBrokerName
());
}
SnodeController
snodeController
=
createSnodeController
(
snodeConfig
);
startup
(
snodeController
);
...
...
snode/src/main/java/org/apache/rocketmq/snode/offset/ConsumerOffsetManager.java
浏览文件 @
ff6b6871
...
...
@@ -75,19 +75,6 @@ public class ConsumerOffsetManager {
}
}
// private long parserOffset(final RemotingChannel remotingChannel, final String enodeName, final String group,
// final String topic, final int queueId) {
// try {
// RemotingCommand remotingCommand = queryOffset(remotingChannel, enodeName, group, topic, queueId);
// QueryConsumerOffsetResponseHeader responseHeader =
// (QueryConsumerOffsetResponseHeader) remotingCommand.decodeCommandCustomHeader(QueryConsumerOffsetResponseHeader.class);
// return responseHeader.getOffset();
// } catch (Exception ex) {
// log.error("Load offset from broker error", ex);
// }
// return -1;
// }
public
long
queryCacheOffset
(
final
String
enodeName
,
final
String
group
,
final
String
topic
,
final
int
queueId
)
{
String
key
=
buildKey
(
enodeName
,
topic
,
group
);
ConcurrentMap
<
Integer
,
CacheOffset
>
map
=
this
.
offsetTable
.
get
(
key
);
...
...
snode/src/main/java/org/apache/rocketmq/snode/processor/SendMessageProcessor.java
浏览文件 @
ff6b6871
...
...
@@ -28,6 +28,7 @@ import org.apache.rocketmq.logging.InternalLogger;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
import
org.apache.rocketmq.remoting.RemotingChannel
;
import
org.apache.rocketmq.remoting.RequestProcessor
;
import
org.apache.rocketmq.remoting.common.RemotingHelper
;
import
org.apache.rocketmq.remoting.exception.RemotingCommandException
;
import
org.apache.rocketmq.remoting.interceptor.ExceptionContext
;
import
org.apache.rocketmq.remoting.interceptor.RequestContext
;
...
...
@@ -74,8 +75,9 @@ public class SendMessageProcessor implements RequestProcessor {
request
.
getCode
()
==
RequestCode
.
SEND_BATCH_MESSAGE
)
{
sendMessageRequestHeaderV2
=
(
SendMessageRequestHeaderV2
)
request
.
decodeCommandCustomHeader
(
SendMessageRequestHeaderV2
.
class
);
enodeName
=
sendMessageRequestHeaderV2
.
getN
();
sendMessageRequestHeaderV2
.
setP
(
remotingChannel
.
localAddress
());
stringBuffer
.
append
(
sendMessageRequestHeaderV2
.
getB
());
request
.
getExtFields
().
putIfAbsent
(
"o"
,
RemotingHelper
.
parseChannelRemoteAddr
(
remotingChannel
.
remoteAddress
()));
request
.
getExtFields
().
putIfAbsent
(
"p"
,
RemotingHelper
.
parseChannelRemoteAddr
(
remotingChannel
.
localAddress
()));
}
else
{
isSendBack
=
true
;
consumerSendMsgBackRequestHeader
=
(
ConsumerSendMsgBackRequestHeader
)
request
.
decodeCommandCustomHeader
(
ConsumerSendMsgBackRequestHeader
.
class
);
...
...
@@ -85,7 +87,6 @@ public class SendMessageProcessor implements RequestProcessor {
CompletableFuture
<
RemotingCommand
>
responseFuture
=
snodeController
.
getEnodeService
().
sendMessage
(
remotingChannel
,
enodeName
,
request
);
sendMessageRequestHeaderV2
.
setO
(
remotingChannel
.
remoteAddress
());
final
byte
[]
message
=
request
.
getBody
();
final
boolean
needPush
=
!
isSendBack
;
final
SendMessageRequestHeader
sendMessageRequestHeader
=
...
...
snode/src/main/java/org/apache/rocketmq/snode/service/impl/PushServiceImpl.java
浏览文件 @
ff6b6871
...
...
@@ -87,10 +87,11 @@ public class PushServiceImpl implements PushService {
messageExt
.
setReconsumeTimes
(
sendMessageRequestHeader
.
getReconsumeTimes
());
messageExt
.
setCommitLogOffset
(
sendMessageResponseHeader
.
getCommitLogOffset
());
messageExt
.
setBornTimestamp
(
sendMessageRequestHeader
.
getBornTimestamp
());
messageExt
.
setBornHost
(
sendMessageRequestHeader
.
getBornHost
(
));
messageExt
.
setStoreHost
(
RemotingUtil
.
string2SocketAddress
WithIp
(
sendMessageResponseHeader
.
getStoreHost
()));
messageExt
.
setBornHost
(
RemotingUtil
.
string2SocketAddress
(
sendMessageRequestHeader
.
getBornHost
()
));
messageExt
.
setStoreHost
(
RemotingUtil
.
string2SocketAddress
(
sendMessageResponseHeader
.
getStoreHost
()));
messageExt
.
setStoreTimestamp
(
sendMessageResponseHeader
.
getStoreTimestamp
());
messageExt
.
setWaitStoreMsgOK
(
false
);
messageExt
.
setStoreSize
(
sendMessageResponseHeader
.
getStoreSize
());
messageExt
.
setSysFlag
(
sendMessageRequestHeader
.
getSysFlag
());
messageExt
.
setFlag
(
sendMessageRequestHeader
.
getFlag
());
messageExt
.
setBody
(
message
);
...
...
store/src/main/java/org/apache/rocketmq/store/CommitLog.java
浏览文件 @
ff6b6871
...
...
@@ -26,14 +26,14 @@ import java.util.concurrent.TimeUnit;
import
org.apache.rocketmq.common.ServiceThread
;
import
org.apache.rocketmq.common.UtilAll
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
import
org.apache.rocketmq.common.message.MessageAccessor
;
import
org.apache.rocketmq.common.message.MessageConst
;
import
org.apache.rocketmq.common.message.MessageDecoder
;
import
org.apache.rocketmq.common.message.MessageExt
;
import
org.apache.rocketmq.common.message.MessageExtBatch
;
import
org.apache.rocketmq.common.sysflag.MessageSysFlag
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
import
org.apache.rocketmq.store.config.BrokerRole
;
import
org.apache.rocketmq.store.config.FlushDiskType
;
import
org.apache.rocketmq.store.ha.HAService
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录