Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
21d18b35
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看板
提交
21d18b35
编写于
2月 07, 2019
作者:
D
duhenglucky
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'snode' of github.com:apache/rocketmq into snode
上级
cb90409e
3b62168c
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
128 addition
and
29 deletion
+128
-29
client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
.../rocketmq/client/consumer/store/LocalFileOffsetStore.java
+6
-0
client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
...rg/apache/rocketmq/client/consumer/store/OffsetStore.java
+8
-0
client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
...cketmq/client/consumer/store/RemoteBrokerOffsetStore.java
+59
-4
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
...java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
+1
-1
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
...ketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
+2
-2
client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumerTest.java
...e/rocketmq/client/consumer/DefaultMQPullConsumerTest.java
+2
-0
client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumerTest.java
...e/rocketmq/client/consumer/DefaultMQPushConsumerTest.java
+2
-0
client/src/test/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStoreTest.java
...mq/client/consumer/store/RemoteBrokerOffsetStoreTest.java
+1
-3
client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java
...pache/rocketmq/client/producer/DefaultMQProducerTest.java
+2
-0
common/src/main/java/org/apache/rocketmq/common/SnodeConfig.java
...src/main/java/org/apache/rocketmq/common/SnodeConfig.java
+4
-4
snode/src/main/java/org/apache/rocketmq/snode/SnodeController.java
.../main/java/org/apache/rocketmq/snode/SnodeController.java
+1
-1
snode/src/main/java/org/apache/rocketmq/snode/SnodeStartup.java
...src/main/java/org/apache/rocketmq/snode/SnodeStartup.java
+24
-2
snode/src/main/java/org/apache/rocketmq/snode/client/ClientHousekeepingService.java
...ache/rocketmq/snode/client/ClientHousekeepingService.java
+1
-1
snode/src/main/java/org/apache/rocketmq/snode/processor/ConsumerManageProcessor.java
...che/rocketmq/snode/processor/ConsumerManageProcessor.java
+1
-1
snode/src/main/java/org/apache/rocketmq/snode/processor/DefaultMqttMessageProcessor.java
...rocketmq/snode/processor/DefaultMqttMessageProcessor.java
+4
-0
snode/src/main/java/org/apache/rocketmq/snode/service/NnodeService.java
.../java/org/apache/rocketmq/snode/service/NnodeService.java
+1
-1
snode/src/main/java/org/apache/rocketmq/snode/service/impl/NnodeServiceImpl.java
.../apache/rocketmq/snode/service/impl/NnodeServiceImpl.java
+1
-1
snode/src/main/java/org/apache/rocketmq/snode/service/impl/ScheduledServiceImpl.java
...che/rocketmq/snode/service/impl/ScheduledServiceImpl.java
+1
-1
snode/src/test/java/org/apache/rocketmq/snode/SnodeControllerTest.java
...t/java/org/apache/rocketmq/snode/SnodeControllerTest.java
+1
-1
snode/src/test/java/org/apache/rocketmq/snode/processor/DefaultMqttMessageProcessorTest.java
...etmq/snode/processor/DefaultMqttMessageProcessorTest.java
+1
-1
snode/src/test/java/org/apache/rocketmq/snode/processor/MqttConnectMessageHandlerTest.java
...cketmq/snode/processor/MqttConnectMessageHandlerTest.java
+1
-1
snode/src/test/java/org/apache/rocketmq/snode/processor/SendMessageProcessorTest.java
...he/rocketmq/snode/processor/SendMessageProcessorTest.java
+1
-1
snode/src/test/java/org/apache/rocketmq/snode/service/EnodeServiceImplTest.java
...g/apache/rocketmq/snode/service/EnodeServiceImplTest.java
+1
-1
snode/src/test/java/org/apache/rocketmq/snode/service/NnodeServiceImplTest.java
...g/apache/rocketmq/snode/service/NnodeServiceImplTest.java
+1
-1
snode/src/test/java/org/apache/rocketmq/snode/service/SlowConsumerServiceImplTest.java
...e/rocketmq/snode/service/SlowConsumerServiceImplTest.java
+1
-1
未找到文件。
client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
浏览文件 @
21d18b35
...
...
@@ -160,6 +160,12 @@ public class LocalFileOffsetStore implements OffsetStore {
}
@Override
public
void
updateConsumeOffsetToSnode
(
final
MessageQueue
mq
,
final
long
offset
,
final
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
}
@Override
public
void
updateConsumeOffsetToBroker
(
final
MessageQueue
mq
,
final
long
offset
,
final
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
...
...
client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
浏览文件 @
21d18b35
...
...
@@ -71,4 +71,12 @@ public interface OffsetStore {
*/
void
updateConsumeOffsetToBroker
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
;
/**
* @param mq
* @param offset
* @param isOneway
*/
void
updateConsumeOffsetToSnode
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
;
}
client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
浏览文件 @
21d18b35
...
...
@@ -87,7 +87,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
}
case
READ_FROM_STORE:
{
try
{
long
brokerOffset
=
this
.
fetchConsumeOffsetFrom
Broker
(
mq
);
long
brokerOffset
=
this
.
fetchConsumeOffsetFrom
Snode
(
mq
);
AtomicLong
offset
=
new
AtomicLong
(
brokerOffset
);
this
.
updateOffset
(
mq
,
offset
.
get
(),
false
);
return
brokerOffset
;
...
...
@@ -195,14 +195,14 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
private
void
updateConsumeOffsetToSnode
(
MessageQueue
mq
,
long
offset
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
updateConsumeOffsetTo
Broker
(
mq
,
offset
,
true
);
updateConsumeOffsetTo
Snode
(
mq
,
offset
,
true
);
}
/**
* Update the Consumer Offset synchronously, once the Master is off, updated to Slave, here need to be optimized.
*/
@Override
public
void
updateConsumeOffsetTo
Broker
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
public
void
updateConsumeOffsetTo
Snode
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
String
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
...
...
@@ -226,10 +226,65 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
snodeAddr
,
requestHeader
,
1000
*
5
);
}
}
else
{
throw
new
MQClientException
(
"Update offset to Broker["
+
mq
.
getBrokerName
()
+
"] failed, Snode is null."
,
null
);
throw
new
MQClientException
(
"Update offset to Snode["
+
mq
.
getBrokerName
()
+
"] failed, Snode is null."
,
null
);
}
}
/**
* Preserved firstly,Compatible with RocketMQ 4.X Version
*/
@Override
public
void
updateConsumeOffsetToBroker
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
FindBrokerResult
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
if
(
null
==
findBrokerResult
)
{
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
mq
.
getTopic
());
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
}
if
(
findBrokerResult
!=
null
)
{
UpdateConsumerOffsetRequestHeader
requestHeader
=
new
UpdateConsumerOffsetRequestHeader
();
requestHeader
.
setTopic
(
mq
.
getTopic
());
requestHeader
.
setConsumerGroup
(
this
.
groupName
);
requestHeader
.
setQueueId
(
mq
.
getQueueId
());
requestHeader
.
setCommitOffset
(
offset
);
requestHeader
.
setEnodeName
(
mq
.
getBrokerName
());
if
(
isOneway
)
{
this
.
mQClientFactory
.
getMQClientAPIImpl
().
updateConsumerOffsetOneway
(
findBrokerResult
.
getBrokerAddr
(),
requestHeader
,
1000
*
5
);
}
else
{
this
.
mQClientFactory
.
getMQClientAPIImpl
().
updateConsumerOffset
(
findBrokerResult
.
getBrokerAddr
(),
requestHeader
,
1000
*
5
);
}
}
else
{
throw
new
MQClientException
(
"The broker["
+
mq
.
getBrokerName
()
+
"] not exist"
,
null
);
}
}
private
long
fetchConsumeOffsetFromSnode
(
MessageQueue
mq
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
String
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
if
(
null
==
snodeAddr
)
{
this
.
mQClientFactory
.
updateSnodeInfoFromNameServer
();
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
}
if
(
snodeAddr
!=
null
)
{
QueryConsumerOffsetRequestHeader
requestHeader
=
new
QueryConsumerOffsetRequestHeader
();
requestHeader
.
setTopic
(
mq
.
getTopic
());
requestHeader
.
setConsumerGroup
(
this
.
groupName
);
requestHeader
.
setQueueId
(
mq
.
getQueueId
());
requestHeader
.
setEnodeName
(
mq
.
getBrokerName
());
return
this
.
mQClientFactory
.
getMQClientAPIImpl
().
queryConsumerOffset
(
snodeAddr
,
requestHeader
,
1000
*
5
);
}
else
{
throw
new
MQClientException
(
"Get Offset from Snode["
+
mq
.
getBrokerName
()
+
"] failed, Snode is not exist"
,
null
);
}
}
/**
* Preserved firstly,Compatible with RocketMQ 4.X Version
*/
private
long
fetchConsumeOffsetFromBroker
(
MessageQueue
mq
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
String
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
...
...
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
浏览文件 @
21d18b35
...
...
@@ -1194,7 +1194,7 @@ public class MQClientAPIImpl {
public
SnodeClusterInfo
getSnodeClusterInfo
(
//Todo Redifine snode exception
final
long
timeoutMillis
)
throws
InterruptedException
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
,
MQBrokerException
{
RemotingSendRequestException
,
RemotingConnectException
,
MQBrokerException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
GET_SNODE_CLUSTER_INFO
,
null
);
RemotingCommand
response
=
this
.
remotingClient
.
invokeSync
(
null
,
request
,
timeoutMillis
);
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
浏览文件 @
21d18b35
...
...
@@ -480,9 +480,9 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
sendMessageBack
(
msg
,
delayLevel
,
brokerName
,
this
.
defaultMQPullConsumer
.
getConsumerGroup
());
}
public
void
updateConsumeOffsetTo
Broker
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
public
void
updateConsumeOffsetTo
Snode
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
this
.
offsetStore
.
updateConsumeOffsetTo
Broker
(
mq
,
offset
,
isOneway
);
this
.
offsetStore
.
updateConsumeOffsetTo
Snode
(
mq
,
offset
,
isOneway
);
}
public
void
sendMessageBack
(
MessageExt
msg
,
int
delayLevel
,
final
String
brokerName
,
String
consumerGroup
)
...
...
client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPullConsumerTest.java
浏览文件 @
21d18b35
...
...
@@ -77,6 +77,8 @@ public class DefaultMQPullConsumerTest {
field
.
set
(
mQClientFactory
,
mQClientAPIImpl
);
when
(
mQClientFactory
.
findBrokerAddressInSubscribe
(
anyString
(),
anyLong
(),
anyBoolean
())).
thenReturn
(
new
FindBrokerResult
(
"127.0.0.1:10911"
,
false
));
when
(
mQClientFactory
.
findSnodeAddressInPublish
()).
thenReturn
(
"127.0.0.1:10911"
);
}
@After
...
...
client/src/test/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumerTest.java
浏览文件 @
21d18b35
...
...
@@ -147,6 +147,8 @@ public class DefaultMQPushConsumerTest {
});
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
);
...
...
client/src/test/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStoreTest.java
浏览文件 @
21d18b35
...
...
@@ -20,7 +20,6 @@ import java.util.Collections;
import
java.util.HashSet
;
import
org.apache.rocketmq.client.ClientConfig
;
import
org.apache.rocketmq.client.exception.MQBrokerException
;
import
org.apache.rocketmq.client.impl.FindBrokerResult
;
import
org.apache.rocketmq.client.impl.MQClientAPIImpl
;
import
org.apache.rocketmq.client.impl.factory.MQClientInstance
;
import
org.apache.rocketmq.common.message.MessageQueue
;
...
...
@@ -34,7 +33,6 @@ import org.mockito.Mock;
import
org.mockito.invocation.InvocationOnMock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.mockito.stubbing.Answer
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyLong
;
...
...
@@ -58,8 +56,8 @@ public class RemoteBrokerOffsetStoreTest {
System
.
setProperty
(
"rocketmq.client.localOffsetStoreDir"
,
System
.
getProperty
(
"java.io.tmpdir"
)
+
".rocketmq_offsets"
);
String
clientId
=
new
ClientConfig
().
buildMQClientId
()
+
"#TestNamespace"
+
System
.
currentTimeMillis
();
when
(
mQClientFactory
.
getClientId
()).
thenReturn
(
clientId
);
when
(
mQClientFactory
.
findBrokerAddressInAdmin
(
brokerName
)).
thenReturn
(
new
FindBrokerResult
(
"127.0.0.1"
,
false
));
when
(
mQClientFactory
.
getMQClientAPIImpl
()).
thenReturn
(
mqClientAPI
);
when
(
mQClientFactory
.
findSnodeAddressInPublish
()).
thenReturn
(
"127.0.0.1:10911"
);
}
@Test
...
...
client/src/test/java/org/apache/rocketmq/client/producer/DefaultMQProducerTest.java
浏览文件 @
21d18b35
...
...
@@ -106,6 +106,8 @@ public class DefaultMQProducerTest {
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"
);
}
@After
...
...
snode/src/main/java/org/apache/rocketmq/snode/config
/SnodeConfig.java
→
common/src/main/java/org/apache/rocketmq/common
/SnodeConfig.java
浏览文件 @
21d18b35
...
...
@@ -14,21 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.
snode.config
;
package
org.apache.rocketmq.
common
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
org.apache.rocketmq.common.MixAll
;
import
org.apache.rocketmq.common.annotation.ImportantField
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
import
org.apache.rocketmq.remoting.common.RemotingUtil
;
import
static
org
.
apache
.
rocketmq
.
client
.
ClientConfig
.
SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY
;
public
class
SnodeConfig
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
COMMON_LOGGER_NAME
);
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
SNODE_LOGGER_NAME
);
public
static
final
String
SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY
=
"com.rocketmq.sendMessageWithVIPChannel"
;
private
String
rocketmqHome
=
System
.
getProperty
(
MixAll
.
ROCKETMQ_HOME_PROPERTY
,
System
.
getenv
(
MixAll
.
ROCKETMQ_HOME_ENV
));
...
...
snode/src/main/java/org/apache/rocketmq/snode/SnodeController.java
浏览文件 @
21d18b35
...
...
@@ -24,6 +24,7 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.rocketmq.acl.AccessValidator
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.common.ThreadFactoryImpl
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.common.protocol.RequestCode
;
...
...
@@ -55,7 +56,6 @@ import org.apache.rocketmq.snode.client.impl.IOTClientManagerImpl;
import
org.apache.rocketmq.snode.client.impl.ProducerManagerImpl
;
import
org.apache.rocketmq.snode.client.impl.SlowConsumerServiceImpl
;
import
org.apache.rocketmq.snode.client.impl.SubscriptionManagerImpl
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.apache.rocketmq.snode.offset.ConsumerOffsetManager
;
import
org.apache.rocketmq.snode.processor.ConsumerManageProcessor
;
import
org.apache.rocketmq.snode.processor.DefaultMqttMessageProcessor
;
...
...
snode/src/main/java/org/apache/rocketmq/snode/SnodeStartup.java
浏览文件 @
21d18b35
...
...
@@ -26,11 +26,13 @@ import java.io.FileInputStream;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
import
java.util.concurrent.atomic.AtomicInteger
;
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.common.MixAll
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
...
...
@@ -39,7 +41,6 @@ import org.apache.rocketmq.remoting.ServerConfig;
import
org.apache.rocketmq.remoting.common.TlsMode
;
import
org.apache.rocketmq.remoting.netty.TlsSystemConfig
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.apache.rocketmq.srvutil.ServerUtil
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -123,19 +124,31 @@ public class SnodeStartup {
nettyClientConfig
,
snodeConfig
);
boolean
initResult
=
snodeController
.
initialize
();
if
(!
initResult
)
{
snodeController
.
shutdown
();
System
.
exit
(-
3
);
}
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
new
Runnable
()
{
private
volatile
boolean
hasShutdown
=
false
;
private
AtomicInteger
shutdownTimes
=
new
AtomicInteger
(
0
);
@Override
public
void
run
()
{
synchronized
(
this
)
{
log
.
info
(
"Shutdown hook was invoked, {}"
,
this
.
shutdownTimes
.
incrementAndGet
());
if
(!
this
.
hasShutdown
)
{
this
.
hasShutdown
=
true
;
long
beginTime
=
System
.
currentTimeMillis
();
snodeController
.
shutdown
();
long
consumingTimeTotal
=
System
.
currentTimeMillis
()
-
beginTime
;
log
.
info
(
"Shutdown hook over, consuming total time(ms): {}"
,
consumingTimeTotal
);
}
}
}
}));
}
,
"ShutdownHook"
));
return
snodeController
;
}
...
...
@@ -143,6 +156,15 @@ public class SnodeStartup {
Option
opt
=
new
Option
(
"c"
,
"configFile"
,
true
,
"SNode config properties file"
);
opt
.
setRequired
(
false
);
options
.
addOption
(
opt
);
opt
=
new
Option
(
"p"
,
"printConfigItem"
,
false
,
"Print all config item"
);
opt
.
setRequired
(
false
);
options
.
addOption
(
opt
);
opt
=
new
Option
(
"m"
,
"printImportantConfig"
,
false
,
"Print important config item"
);
opt
.
setRequired
(
false
);
options
.
addOption
(
opt
);
return
options
;
}
}
...
...
snode/src/main/java/org/apache/rocketmq/snode/client/ClientHousekeepingService.java
浏览文件 @
21d18b35
...
...
@@ -28,7 +28,7 @@ import org.apache.rocketmq.remoting.netty.NettyChannelImpl;
import
org.apache.rocketmq.snode.constant.SnodeConstant
;
public
class
ClientHousekeepingService
implements
ChannelEventListener
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
BROKER
_LOGGER_NAME
);
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
SNODE
_LOGGER_NAME
);
private
final
ClientManager
producerManager
;
private
final
ClientManager
consumerManager
;
private
final
ClientManager
iotClientManager
;
...
...
snode/src/main/java/org/apache/rocketmq/snode/processor/ConsumerManageProcessor.java
浏览文件 @
21d18b35
...
...
@@ -43,7 +43,7 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import
org.apache.rocketmq.snode.SnodeController
;
public
class
ConsumerManageProcessor
implements
RequestProcessor
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
BROKER
_LOGGER_NAME
);
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
SNODE
_LOGGER_NAME
);
private
final
SnodeController
snodeController
;
...
...
snode/src/main/java/org/apache/rocketmq/snode/processor/DefaultMqttMessageProcessor.java
浏览文件 @
21d18b35
...
...
@@ -28,6 +28,9 @@ import java.io.UnsupportedEncodingException;
import
java.nio.charset.Charset
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.rocketmq.common.constant.LoggerName
;
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.RemotingUtil
;
...
...
@@ -38,6 +41,7 @@ import org.apache.rocketmq.remoting.transport.mqtt.RocketMQMqttConnectPayload;
import
org.apache.rocketmq.snode.processor.mqtthandler.MessageHandler
;
public
class
DefaultMqttMessageProcessor
implements
RequestProcessor
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
SNODE_LOGGER_NAME
);
private
Map
<
MqttMessageType
,
MessageHandler
>
type2handler
=
new
HashMap
<>();
private
static
final
int
MIN_AVAILABLE_VERSION
=
3
;
...
...
snode/src/main/java/org/apache/rocketmq/snode/service/NnodeService.java
浏览文件 @
21d18b35
...
...
@@ -18,12 +18,12 @@ package org.apache.rocketmq.snode.service;
import
java.util.Set
;
import
org.apache.rocketmq.client.exception.MQClientException
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.common.protocol.body.ClusterInfo
;
import
org.apache.rocketmq.common.protocol.route.TopicRouteData
;
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.snode.config.SnodeConfig
;
public
interface
NnodeService
{
/**
...
...
snode/src/main/java/org/apache/rocketmq/snode/service/impl/NnodeServiceImpl.java
浏览文件 @
21d18b35
...
...
@@ -22,6 +22,7 @@ import java.util.Set;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.apache.rocketmq.client.exception.MQClientException
;
import
org.apache.rocketmq.common.MixAll
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.common.namesrv.TopAddressing
;
import
org.apache.rocketmq.common.protocol.RequestCode
;
...
...
@@ -37,7 +38,6 @@ import org.apache.rocketmq.remoting.exception.RemotingSendRequestException;
import
org.apache.rocketmq.remoting.exception.RemotingTimeoutException
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
org.apache.rocketmq.snode.SnodeController
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.apache.rocketmq.snode.constant.SnodeConstant
;
import
org.apache.rocketmq.snode.service.NnodeService
;
...
...
snode/src/main/java/org/apache/rocketmq/snode/service/impl/ScheduledServiceImpl.java
浏览文件 @
21d18b35
...
...
@@ -20,6 +20,7 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ThreadFactory
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.common.protocol.RequestCode
;
import
org.apache.rocketmq.common.protocol.heartbeat.HeartbeatData
;
...
...
@@ -28,7 +29,6 @@ import org.apache.rocketmq.logging.InternalLogger;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
org.apache.rocketmq.snode.SnodeController
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.apache.rocketmq.snode.service.ScheduledService
;
public
class
ScheduledServiceImpl
implements
ScheduledService
{
...
...
snode/src/test/java/org/apache/rocketmq/snode/SnodeControllerTest.java
浏览文件 @
21d18b35
...
...
@@ -16,9 +16,9 @@
*/
package
org.apache.rocketmq.snode
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.remoting.ClientConfig
;
import
org.apache.rocketmq.remoting.ServerConfig
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.junit.Test
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
snode/src/test/java/org/apache/rocketmq/snode/processor/DefaultMqttMessageProcessorTest.java
浏览文件 @
21d18b35
...
...
@@ -22,6 +22,7 @@ import io.netty.handler.codec.mqtt.MqttMessageType;
import
io.netty.handler.codec.mqtt.MqttQoS
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.charset.Charset
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.common.protocol.RequestCode
;
import
org.apache.rocketmq.remoting.ClientConfig
;
import
org.apache.rocketmq.remoting.RemotingChannel
;
...
...
@@ -33,7 +34,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import
org.apache.rocketmq.remoting.transport.mqtt.MqttHeader
;
import
org.apache.rocketmq.remoting.transport.mqtt.RocketMQMqttConnectPayload
;
import
org.apache.rocketmq.snode.SnodeController
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.apache.rocketmq.snode.processor.mqtthandler.MqttConnectMessageHandler
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
snode/src/test/java/org/apache/rocketmq/snode/processor/MqttConnectMessageHandlerTest.java
浏览文件 @
21d18b35
...
...
@@ -22,11 +22,11 @@ import io.netty.handler.codec.mqtt.MqttConnectVariableHeader;
import
io.netty.handler.codec.mqtt.MqttFixedHeader
;
import
io.netty.handler.codec.mqtt.MqttMessageType
;
import
io.netty.handler.codec.mqtt.MqttQoS
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.remoting.ClientConfig
;
import
org.apache.rocketmq.remoting.RemotingChannel
;
import
org.apache.rocketmq.remoting.ServerConfig
;
import
org.apache.rocketmq.snode.SnodeController
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.apache.rocketmq.snode.processor.mqtthandler.MqttConnectMessageHandler
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
snode/src/test/java/org/apache/rocketmq/snode/processor/SendMessageProcessorTest.java
浏览文件 @
21d18b35
...
...
@@ -18,6 +18,7 @@ package org.apache.rocketmq.snode.processor;
import
java.util.concurrent.CompletableFuture
;
import
org.apache.rocketmq.common.MixAll
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.common.protocol.RequestCode
;
import
org.apache.rocketmq.common.protocol.ResponseCode
;
import
org.apache.rocketmq.common.protocol.header.SendMessageRequestHeaderV2
;
...
...
@@ -28,7 +29,6 @@ import org.apache.rocketmq.remoting.exception.RemotingCommandException;
import
org.apache.rocketmq.remoting.netty.CodecHelper
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
org.apache.rocketmq.snode.SnodeController
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.apache.rocketmq.snode.service.EnodeService
;
import
org.apache.rocketmq.snode.service.NnodeService
;
import
org.junit.Before
;
...
...
snode/src/test/java/org/apache/rocketmq/snode/service/EnodeServiceImplTest.java
浏览文件 @
21d18b35
...
...
@@ -18,6 +18,7 @@ package org.apache.rocketmq.snode.service;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.common.TopicConfig
;
import
org.apache.rocketmq.common.protocol.RequestCode
;
import
org.apache.rocketmq.common.protocol.ResponseCode
;
...
...
@@ -30,7 +31,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import
org.apache.rocketmq.remoting.transport.rocketmq.NettyRemotingClient
;
import
org.apache.rocketmq.snode.SnodeController
;
import
org.apache.rocketmq.snode.SnodeTestBase
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.apache.rocketmq.snode.service.impl.EnodeServiceImpl
;
import
org.apache.rocketmq.store.GetMessageResult
;
import
org.apache.rocketmq.store.GetMessageStatus
;
...
...
snode/src/test/java/org/apache/rocketmq/snode/service/NnodeServiceImplTest.java
浏览文件 @
21d18b35
...
...
@@ -18,6 +18,7 @@ package org.apache.rocketmq.snode.service;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.remoting.ClientConfig
;
import
org.apache.rocketmq.remoting.ServerConfig
;
import
org.apache.rocketmq.remoting.exception.RemotingConnectException
;
...
...
@@ -27,7 +28,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import
org.apache.rocketmq.remoting.transport.rocketmq.NettyRemotingClient
;
import
org.apache.rocketmq.snode.SnodeController
;
import
org.apache.rocketmq.snode.SnodeTestBase
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.apache.rocketmq.snode.service.impl.NnodeServiceImpl
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
snode/src/test/java/org/apache/rocketmq/snode/service/SlowConsumerServiceImplTest.java
浏览文件 @
21d18b35
...
...
@@ -16,12 +16,12 @@
*/
package
org.apache.rocketmq.snode.service
;
import
org.apache.rocketmq.common.SnodeConfig
;
import
org.apache.rocketmq.remoting.ClientConfig
;
import
org.apache.rocketmq.remoting.ServerConfig
;
import
org.apache.rocketmq.snode.SnodeController
;
import
org.apache.rocketmq.snode.client.SlowConsumerService
;
import
org.apache.rocketmq.snode.client.impl.SlowConsumerServiceImpl
;
import
org.apache.rocketmq.snode.config.SnodeConfig
;
import
org.apache.rocketmq.snode.offset.ConsumerOffsetManager
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录