You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/05/19 02:28:10 UTC
[GitHub] [rocketmq] hzh0425 opened a new pull request, #4341: [Summer of code] Let broker send heartbeat to controller
hzh0425 opened a new pull request, #4341:
URL: https://github.com/apache/rocketmq/pull/4341
## What is the purpose of the change
tracking issue: https://github.com/apache/rocketmq/issues/4330
## Brief changelog
When the controller is deployed independently, let the broker send the heartbeat to the controller.
## Verifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
- [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
- [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
- [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test` to make sure integration-test pass.
- [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] codecov-commenter commented on pull request #4341: [Summer of code] Let broker send heartbeat to controller
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #4341:
URL: https://github.com/apache/rocketmq/pull/4341#issuecomment-1131168190
# [Codecov](https://codecov.io/gh/apache/rocketmq/pull/4341?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#4341](https://codecov.io/gh/apache/rocketmq/pull/4341?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (12873a3) into [5.0.0-beta-dledger-controller](https://codecov.io/gh/apache/rocketmq/commit/4e9e4e3efb3e75fd82ef37782d3714115533a880?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (4e9e4e3) will **decrease** coverage by `0.07%`.
> The diff coverage is `8.88%`.
```diff
@@ Coverage Diff @@
## 5.0.0-beta-dledger-controller #4341 +/- ##
===================================================================
- Coverage 43.55% 43.48% -0.08%
+ Complexity 6319 6310 -9
===================================================================
Files 835 835
Lines 59199 59233 +34
Branches 8068 8070 +2
===================================================================
- Hits 25787 25758 -29
- Misses 30091 30144 +53
- Partials 3321 3331 +10
```
| [Impacted Files](https://codecov.io/gh/apache/rocketmq/pull/4341?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../rocketmq/broker/hacontroller/ReplicasManager.java](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvaGFjb250cm9sbGVyL1JlcGxpY2FzTWFuYWdlci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...org/apache/rocketmq/broker/out/BrokerOuterAPI.java](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvb3V0L0Jyb2tlck91dGVyQVBJLmphdmE=) | `19.25% <0.00%> (-0.61%)` | :arrow_down: |
| [...ache/rocketmq/container/InnerBrokerController.java](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29udGFpbmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb250YWluZXIvSW5uZXJCcm9rZXJDb250cm9sbGVyLmphdmE=) | `44.00% <0.00%> (ø)` | |
| [...a/org/apache/rocketmq/broker/BrokerController.java](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvQnJva2VyQ29udHJvbGxlci5qYXZh) | `48.13% <5.88%> (-0.44%)` | :arrow_down: |
| [.../java/org/apache/rocketmq/common/BrokerConfig.java](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vQnJva2VyQ29uZmlnLmphdmE=) | `28.23% <25.00%> (-0.06%)` | :arrow_down: |
| [...q/namesrv/routeinfo/BrokerHousekeepingService.java](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bmFtZXNydi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvbmFtZXNydi9yb3V0ZWluZm8vQnJva2VySG91c2VrZWVwaW5nU2VydmljZS5qYXZh) | `72.72% <0.00%> (-9.10%)` | :arrow_down: |
| [...org/apache/rocketmq/common/stats/StatsItemSet.java](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jb21tb24vc3RhdHMvU3RhdHNJdGVtU2V0LmphdmE=) | `41.79% <0.00%> (-8.96%)` | :arrow_down: |
| [...a/org/apache/rocketmq/filter/util/BloomFilter.java](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmlsdGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9maWx0ZXIvdXRpbC9CbG9vbUZpbHRlci5qYXZh) | `59.13% <0.00%> (-2.16%)` | :arrow_down: |
| [.../rocketmq/broker/filter/ConsumerFilterManager.java](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvZmlsdGVyL0NvbnN1bWVyRmlsdGVyTWFuYWdlci5qYXZh) | `72.19% <0.00%> (-1.80%)` | :arrow_down: |
| [.../apache/rocketmq/logging/inner/LoggingBuilder.java](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bG9nZ2luZy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcm9ja2V0bXEvbG9nZ2luZy9pbm5lci9Mb2dnaW5nQnVpbGRlci5qYXZh) | `63.44% <0.00%> (-1.27%)` | :arrow_down: |
| ... and [12 more](https://codecov.io/gh/apache/rocketmq/pull/4341/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/rocketmq/pull/4341?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/rocketmq/pull/4341?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [4e9e4e3...12873a3](https://codecov.io/gh/apache/rocketmq/pull/4341?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] RongtongJin commented on a diff in pull request #4341: [Summer of code] Let broker send heartbeat to controller
Posted by GitBox <gi...@apache.org>.
RongtongJin commented on code in PR #4341:
URL: https://github.com/apache/rocketmq/pull/4341#discussion_r877792429
##########
common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java:
##########
@@ -293,10 +293,24 @@ public class BrokerConfig extends BrokerIdentity {
*/
private boolean lockInStrictMode = false;
- private String controllerAddr = "";
-
private boolean compatibleWithOldNameSrv = true;
+ /**
+ * Is startup controller mode, which support auto switch broker's role.
+ */
+ private boolean startupControllerMode = false;
+
+ /**
+ * Whether the controller is deployed independently
+ */
+ private boolean isControllerDeployedStandAlone = false;
+
+ /**
+ * If isControllerDeployedStandAlone = false, controllerAddr should be equal to namesrv's address.
Review Comment:
改下注释吧,Controller内嵌入nameserver时,controllerAddr不需要和namesever地址完全一致
##########
broker/src/main/java/org/apache/rocketmq/broker/hacontroller/ReplicasManager.java:
##########
@@ -235,18 +273,26 @@ private boolean registerBroker() {
private void schedulingSyncBrokerMetadata() {
this.scheduledService.scheduleAtFixedRate(() -> {
try {
- final Pair<GetReplicaInfoResponseHeader, SyncStateSet> result = this.brokerOuterAPI.getReplicaInfo(this.controllerLeaderAddress, this.brokerConfig.getBrokerName());
+ final Pair<GetReplicaInfoResponseHeader, SyncStateSet> result = this.brokerOuterAPI.getReplicaInfo(this.controllerLeaderAddress, this.brokerConfig.getBrokerName(), this.localAddress);
final GetReplicaInfoResponseHeader info = result.getObject1();
final SyncStateSet syncStateSet = result.getObject2();
final String newMasterAddress = info.getMasterAddress();
final int newMasterEpoch = info.getMasterEpoch();
+ final long brokerId = info.getBrokerId();
synchronized (this) {
// Check if master changed
if (StringUtils.isNoneEmpty(newMasterAddress) && !StringUtils.equals(this.masterAddress, newMasterAddress) && newMasterEpoch > this.masterEpoch) {
if (StringUtils.equals(newMasterAddress, this.localAddress)) {
changeToMaster(newMasterEpoch, syncStateSet.getSyncStateSetEpoch());
} else {
changeToSlave(newMasterAddress, newMasterEpoch);
Review Comment:
changeToSlave了两次,可以把brokerId传入changeToSlave,在里面有修改brokerId,和changeToMaster一样
##########
broker/src/main/java/org/apache/rocketmq/broker/hacontroller/ReplicasManager.java:
##########
@@ -354,4 +400,8 @@ public String getMasterAddress() {
public int getMasterEpoch() {
return masterEpoch;
}
+
+ public List<String> getControllerAddresses() {
+ return new ArrayList<>(this.controllerAddresses);
+ }
Review Comment:
为什么这里需要重新new一个?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] RongtongJin commented on a diff in pull request #4341: [Summer of code] Let broker send heartbeat to controller
Posted by GitBox <gi...@apache.org>.
RongtongJin commented on code in PR #4341:
URL: https://github.com/apache/rocketmq/pull/4341#discussion_r876669314
##########
common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java:
##########
@@ -293,10 +293,24 @@ public class BrokerConfig extends BrokerIdentity {
*/
private boolean lockInStrictMode = false;
- private String controllerAddr = "";
-
private boolean compatibleWithOldNameSrv = true;
+ /**
+ * Is startup controller mode, which support auto switch broker's role.
+ */
+ private boolean startupControllerMode = false;
Review Comment:
Why not directly use startupControllerMode in messageStoreConfig?
##########
common/src/main/java/org/apache/rocketmq/common/BrokerConfig.java:
##########
@@ -293,10 +293,24 @@ public class BrokerConfig extends BrokerIdentity {
*/
private boolean lockInStrictMode = false;
- private String controllerAddr = "";
-
private boolean compatibleWithOldNameSrv = true;
+ /**
+ * Is startup controller mode, which support auto switch broker's role.
+ */
+ private boolean startupControllerMode = false;
+
+ /**
+ * Whether the controller is deployed independently
+ */
+ private boolean isControllerDeployedStandAlone = false;
Review Comment:
Could we remove this parameter?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] coveralls commented on pull request #4341: [Summer of code] Let broker send heartbeat to controller
Posted by GitBox <gi...@apache.org>.
coveralls commented on PR #4341:
URL: https://github.com/apache/rocketmq/pull/4341#issuecomment-1131169820
[![Coverage Status](https://coveralls.io/builds/49256939/badge)](https://coveralls.io/builds/49256939)
Coverage increased (+0.04%) to 47.683% when pulling **12873a3abfea1e3880043423e1e5b294dd7bb403 on hzh0425:feature/broker-sendheartbeat-to-controller** into **4e9e4e3efb3e75fd82ef37782d3714115533a880 on apache:5.0.0-beta-dledger-controller**.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] RongtongJin merged pull request #4341: [Summer of code] Let broker send heartbeat to controller
Posted by GitBox <gi...@apache.org>.
RongtongJin merged PR #4341:
URL: https://github.com/apache/rocketmq/pull/4341
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [rocketmq] RongtongJin commented on a diff in pull request #4341: [Summer of code] Let broker send heartbeat to controller
Posted by GitBox <gi...@apache.org>.
RongtongJin commented on code in PR #4341:
URL: https://github.com/apache/rocketmq/pull/4341#discussion_r876982262
##########
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java:
##########
@@ -1637,6 +1638,21 @@ protected void sendHeartbeat() {
this.brokerConfig.getSendHeartbeatTimeoutMillis(),
this.brokerConfig.isInBrokerContainer());
}
+ // If in controller mode and the controller is deployed independently
+ if (this.brokerConfig.isStartupControllerMode() && this.brokerConfig.isControllerDeployedStandAlone()) {
+ final String controllerLeaderAddress = this.replicasManager.getControllerLeaderAddress();
+ if (StringUtils.isNotEmpty(controllerLeaderAddress)) {
+ this.brokerOuterAPI.sendHeartbeatToController(
+ controllerLeaderAddress,
Review Comment:
We should send heartbeats to all controllers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org