8000 [ISSUE#4355] Do not retry distro sync again if member has removed. by KomachiSion · Pull Request #4586 · alibaba/nacos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[ISSUE#4355] Do not retry distro sync again if member has removed. #4586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.alibaba.nacos.naming.consistency.ephemeral.distro;

import com.alibaba.nacos.core.cluster.ServerMemberManager;
import com.alibaba.nacos.core.distributed.distro.component.DistroComponentHolder;
import com.alibaba.nacos.core.distributed.distro.task.DistroTaskEngineHolder;
import com.alibaba.nacos.naming.consistency.KeyBuilder;
Expand Down Expand Up @@ -49,15 +50,18 @@ public class DistroHttpRegistry {

private final DistroConsistencyServiceImpl consistencyService;

private final ServerMemberManager memberManager;

public DistroHttpRegistry(DistroComponentHolder componentHolder, DistroTaskEngineHolder taskEngineHolder,
DataStore dataStore, DistroMapper distroMapper, GlobalConfig globalConfig,
DistroConsistencyServiceImpl consistencyService) {
DistroConsistencyServiceImpl consistencyService, ServerMemberManager memberManager) {
this.componentHolder = componentHolder;
this.taskEngineHolder = taskEngineHolder;
this.dataStore = dataStore;
this.distroMapper = distroMapper;
this.globalConfig = globalConfig;
this.consistencyService = consistencyService;
this.memberManager = memberManager;
}

/**
Expand All @@ -67,7 +71,7 @@ public DistroHttpRegistry(DistroComponentHolder componentHolder, DistroTaskEngin
public void doRegister() {
componentHolder.registerDataStorage(KeyBuilder.INSTANCE_LIST_KEY_PREFIX,
new DistroDataStorageImpl(dataStore, distroMapper));
componentHolder.registerTransportAgent(KeyBuilder.INSTANCE_LIST_KEY_PREFIX, new DistroHttpAgent());
componentHolder.registerTransportAgent(KeyBuilder.INSTANCE_LIST_KEY_PREFIX, new DistroHttpAgent(memberManager));
componentHolder.registerFailedTaskHandler(KeyBuilder.INSTANCE_LIST_KEY_PREFIX,
new DistroHttpCombinedKeyTaskFailedHandler(globalConfig, taskEngineHolder));
taskEngineHolder.registerNacosTaskProcessor(KeyBuilder.INSTANCE_LIST_KEY_PREFIX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

package com.alibaba.nacos.naming.consistency.ephemeral.distro.component;

import com.alibaba.nacos.naming.consistency.KeyBuilder;
import com.alibaba.nacos.naming.consistency.ephemeral.distro.combined.DistroHttpCombinedKey;
import com.alibaba.nacos.core.cluster.ServerMemberManager;
import com.alibaba.nacos.core.distributed.distro.component.DistroCallback;
import com.alibaba.nacos.core.distributed.distro.component.DistroTransportAgent;
import com.alibaba.nacos.core.distributed.distro.entity.DistroData;
import com.alibaba.nacos.core.distributed.distro.entity.DistroKey;
import com.alibaba.nacos.core.distributed.distro.exception.DistroException;
import com.alibaba.nacos.naming.consistency.KeyBuilder;
import com.alibaba.nacos.naming.consistency.ephemeral.distro.combined.DistroHttpCombinedKey;
import com.alibaba.nacos.naming.misc.NamingProxy;

import java.util.ArrayList;
Expand All @@ -35,8 +36,17 @@
*/
public class DistroHttpAgent implements DistroTransportAgent {

private final ServerMemberManager memberManager;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And can we transfer a static method to check targetServer in memberManager, the logic maybe used in other place. When we want to use the logic, didn't inject memberManager.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too Many static method and object will caused over-coupling, and hard to modified and refactor


public DistroHttpAgent(ServerMemberManager memberManager) {
this.memberManager = memberManager;
}

@Override
public boolean syncData(DistroData data, String targetServer) {
if (!memberManager.hasMember(targetServer)) {
return true;
}
byte[] dataContent = data.getContent();
return NamingProxy.syncData(dataContent, data.getDistroKey().getTargetServer());
}
Expand All @@ -48,6 +58,9 @@ public void syncData(DistroData data, String targetServer, DistroCallback callba

@Override
public boolean syncVerifyData(DistroData verifyData, String targetServer) {
if (!memberManager.hasMember(targetServer)) {
return true;
}
NamingProxy.syncCheckSums(verifyData.getContent(), targetServer);
return true;
}
Expand Down
0