Skip to content

Commit

Permalink
[ISSUE#8405] Fix istio module cycle dependency problem. (#8440)
Browse files Browse the repository at this point in the history
* Get ResourceManager when runtime to resolve cycle dependence temp.

* Fix Ut problem.

* Rollback changes for ClusterControllerTest

* Fix UT problem.
  • Loading branch information
KomachiSion authored May 23, 2022
1 parent 74c3355 commit 58968f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.alibaba.nacos.istio.misc.Loggers;
import com.alibaba.nacos.istio.util.IstioExecutor;
import com.alibaba.nacos.istio.xds.NacosXdsService;
import com.alibaba.nacos.sys.utils.ApplicationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand All @@ -31,6 +32,8 @@
import java.util.concurrent.TimeUnit;

/**
* EventProcessor.
*
* @author special.fy
*/
@Component
Expand All @@ -44,15 +47,19 @@ public class EventProcessor {
@Autowired
private NacosXdsService nacosXdsService;

@Autowired
private NacosResourceManager resourceManager;

private final BlockingQueue<Event> events;

public EventProcessor() {
events = new ArrayBlockingQueue<>(20);
}


/**
* notify.
*
* @param event event
*/
public void notify(Event event) {
try {
events.put(event);
Expand Down Expand Up @@ -121,6 +128,9 @@ private class EventHandleTask implements Callable<Void> {

@Override
public Void call() throws Exception {
if (null == resourceManager) {
resourceManager = ApplicationUtils.getBean(NacosResourceManager.class);
}
ResourceSnapshot snapshot = resourceManager.createResourceSnapshot();
nacosXdsService.handleEvent(snapshot, event);
nacosMcpService.handleEvent(snapshot, event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.alibaba.nacos.naming.core.ServiceManager;
import com.alibaba.nacos.naming.core.v2.index.ServiceStorage;
import com.alibaba.nacos.naming.core.v2.upgrade.doublewrite.delay.DoubleWriteDelayTaskEngine;
import com.alibaba.nacos.naming.monitor.MetricsMonitor;
import com.alibaba.nacos.sys.env.Constants;
import com.alibaba.nacos.sys.env.EnvUtil;
import com.alibaba.nacos.sys.utils.ApplicationUtils;
Expand Down Expand Up @@ -98,6 +99,8 @@ public void setUp() throws Exception {
upgradeJudgement = new UpgradeJudgement(raftPeerSet, raftCore, versionJudgement, memberManager, serviceManager,
upgradeStates, doubleWriteDelayTaskEngine);
NotifyCenter.deregisterSubscriber(upgradeJudgement);
MetricsMonitor.getIpCountMonitor().set(0);
MetricsMonitor.getDomCountMonitor().set(0);
}

@After
Expand Down

0 comments on commit 58968f9

Please sign in to comment.