Skip to content
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

[ISSUE #4320] Fixing the Naming consistency module could not start in cluster mode #4321

Merged
merged 17 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
63ac93b
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Aug 21, 2020
b39970a
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Sep 11, 2020
9aaea7f
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Sep 17, 2020
0ee59bb
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Oct 6, 2020
756a0cc
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Oct 13, 2020
2f93d35
Merge branch 'new_develop' of https://github.com/chuntaojun/nacos int…
chuntaojun Oct 13, 2020
ba36469
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Oct 19, 2020
c6dd4c4
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Oct 29, 2020
1d514cd
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Nov 1, 2020
1e36b81
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Nov 7, 2020
fcd4e22
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Nov 10, 2020
85ee079
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Nov 14, 2020
6738713
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Nov 18, 2020
6e9b647
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Nov 20, 2020
ceb20c1
refactor: refactor issue #4291
chuntaojun Nov 20, 2020
55b0c92
Merge branch 'develop' of https://github.com/alibaba/nacos into new_d…
chuntaojun Nov 24, 2020
2fce320
fix: fixing the Naming consistency module could not start in cluster …
chuntaojun Nov 24, 2020
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 @@ -17,11 +17,15 @@
package com.alibaba.nacos.naming.consistency.persistent;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.core.distributed.ProtocolManager;
import com.alibaba.nacos.naming.consistency.Datum;
import com.alibaba.nacos.naming.consistency.RecordListener;
import com.alibaba.nacos.naming.consistency.persistent.impl.BasePersistentServiceProcessor;
import com.alibaba.nacos.naming.consistency.persistent.impl.PersistentServiceProcessor;
import com.alibaba.nacos.naming.consistency.persistent.impl.StandalonePersistentServiceProcessor;
import com.alibaba.nacos.naming.consistency.persistent.raft.RaftConsistencyServiceImpl;
import com.alibaba.nacos.naming.pojo.Record;
import com.alibaba.nacos.sys.env.EnvUtil;
import org.springframework.stereotype.Component;

/**
Expand All @@ -41,11 +45,11 @@ public class PersistentConsistencyServiceDelegateImpl implements PersistentConsi
private volatile boolean switchNewPersistentService = false;

public PersistentConsistencyServiceDelegateImpl(ClusterVersionJudgement versionJudgement,
RaftConsistencyServiceImpl oldPersistentConsistencyService,
BasePersistentServiceProcessor newPersistentConsistencyService) {
RaftConsistencyServiceImpl oldPersistentConsistencyService, ProtocolManager protocolManager)
throws Exception {
this.versionJudgement = versionJudgement;
this.oldPersistentConsistencyService = oldPersistentConsistencyService;
this.newPersistentConsistencyService = newPersistentConsistencyService;
this.newPersistentConsistencyService = createNewPersistentServiceProcessor(protocolManager, versionJudgement);
init();
}

Expand Down Expand Up @@ -88,4 +92,13 @@ public boolean isAvailable() {
private PersistentConsistencyService switchOne() {
return switchNewPersistentService ? newPersistentConsistencyService : oldPersistentConsistencyService;
}

private BasePersistentServiceProcessor createNewPersistentServiceProcessor(ProtocolManager protocolManager,
ClusterVersionJudgement versionJudgement) throws Exception {
final BasePersistentServiceProcessor processor =
EnvUtil.getStandaloneMode() ? new StandalonePersistentServiceProcessor(versionJudgement)
: new PersistentServiceProcessor(protocolManager, versionJudgement);
processor.afterConstruct();
return processor;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,10 @@ public BasePersistentServiceProcessor(final ClusterVersionJudgement judgement) t
throw new NacosRuntimeException(ex.getErrCode(), ex.getErrMsg());
}
});
afterConstruct();
}

@SuppressWarnings("unchecked")
protected void afterConstruct() {
public void afterConstruct() {
NotifyCenter.registerToPublisher(ValueChangeEvent.class, 16384);
paderlol marked this conversation as resolved.
Show resolved Hide resolved
listenOldRaftClose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import com.alibaba.nacos.naming.utils.Constants;
import com.alibaba.nacos.sys.env.EnvUtil;
import com.google.protobuf.ByteString;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -49,8 +47,6 @@
* @author <a href="mailto:[email protected]">liaochuntao</a>
*/
@SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule")
@ConditionalOnProperty(value = "nacos.standalone", havingValue = "false")
@Service
public class PersistentServiceProcessor extends BasePersistentServiceProcessor {

private final CPProtocol protocol;
Expand All @@ -67,7 +63,7 @@ public PersistentServiceProcessor(ProtocolManager protocolManager, ClusterVersio
}

@Override
protected void afterConstruct() {
public void afterConstruct() {
super.afterConstruct();
this.protocol.addLogProcessors(Collections.singletonList(this));
this.protocol.protocolMetaData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import com.alibaba.nacos.naming.pojo.Record;
import com.alibaba.nacos.naming.utils.Constants;
import com.google.protobuf.ByteString;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
Expand All @@ -40,8 +38,6 @@
* @author <a href="mailto:[email protected]">liaochuntao</a>
*/
@SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule")
@ConditionalOnProperty(value = "nacos.standalone", havingValue = "true")
@Service
public class StandalonePersistentServiceProcessor extends BasePersistentServiceProcessor {

public StandalonePersistentServiceProcessor(final ClusterVersionJudgement judgement) throws Exception {
Expand Down