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/06/06 01:17:42 UTC
[GitHub] [rocketmq] hzh0425 commented on a diff in pull request #4414: [Summer of code] Record haconnection's lastCaughtUpTimeMs in haService's map
hzh0425 commented on code in PR #4414:
URL: https://github.com/apache/rocketmq/pull/4414#discussion_r889765811
##########
store/src/main/java/org/apache/rocketmq/store/ha/autoswitch/AutoSwitchHAService.java:
##########
@@ -162,15 +165,13 @@ public Set<String> maybeShrinkInSyncStateSet() {
final Set<String> currentSyncStateSet = getSyncStateSet();
final HashSet<String> newSyncStateSet = new HashSet<>(currentSyncStateSet);
final long haMaxTimeSlaveNotCatchup = this.defaultMessageStore.getMessageStoreConfig().getHaMaxTimeSlaveNotCatchup();
- for (HAConnection haConnection : this.connectionList) {
- final AutoSwitchHAConnection connection = (AutoSwitchHAConnection) haConnection;
- final String slaveAddress = connection.getSlaveAddress();
+ for (Map.Entry<String, Long> next: this.connectionCaughtUpTimeTable.entrySet()) {
+ final String slaveAddress = next.getKey();
if (currentSyncStateSet.contains(slaveAddress)) {
- if (connection.getSlaveAckOffset() < 0 || this.defaultMessageStore.getMaxPhyOffset() == connection.getSlaveAckOffset()) {
- continue;
- }
- if ((System.currentTimeMillis() - connection.getLastCatchUpTimeMs()) > haMaxTimeSlaveNotCatchup) {
+ final Long lastCaughtUpTimeMs = this.connectionCaughtUpTimeTable.get(slaveAddress);
+ if ((System.currentTimeMillis() - lastCaughtUpTimeMs) > haMaxTimeSlaveNotCatchup) {
newSyncStateSet.remove(slaveAddress);
+ this.connectionCaughtUpTimeTable.remove(slaveAddress);
}
Review Comment:
那 connectionCaughtUpTimeTable 等 syncStateSet 上报成功后再移除么
--
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