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 #9230] Fix missing dependency between event publisher and subs… #9231

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 @@ -24,6 +24,7 @@
import com.alibaba.nacos.naming.core.v2.client.manager.impl.ConnectionBasedClientManager;
import com.alibaba.nacos.naming.core.v2.client.manager.impl.EphemeralIpPortClientManager;
import com.alibaba.nacos.naming.core.v2.client.manager.impl.PersistentIpPortClientManager;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

import java.util.Collection;
Expand All @@ -34,6 +35,7 @@
*
* @author xiweng.yy
*/
@DependsOn({"clientServiceIndexesManager", "namingMetadataManager"})
@Component("clientManager")
public class ClientManagerDelegate implements ClientManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.misc.NamingExecuteTaskDispatcher;
import com.alibaba.nacos.naming.misc.SwitchDomain;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

import java.util.Collection;
Expand All @@ -46,6 +47,7 @@
*
* @author xiweng.yy
*/
@DependsOn("clientServiceIndexesManager")
@Component("ephemeralIpPortClientManager")
public class EphemeralIpPortClientManager implements ClientManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ public int hashCode() {

@Override
public String toString() {
return "InstancePublishInfo{" + "ip='" + ip + '\'' + ", port=" + port + ", healthy=" + healthy + '}';
return "InstancePublishInfo{"
+ "ip='" + ip + '\''
+ ", port=" + port
+ ", healthy=" + healthy
+ ", cluster='" + cluster + '\''
+ '}';
}

public static String genMetadataId(String ip, int port, String cluster) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@
import com.alibaba.nacos.naming.core.v2.service.impl.PersistentClientOperationServiceImpl;
import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.pojo.Subscriber;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

import java.util.List;

/**
* Implementation of external exposure.
*
* <p>Depends on {@link com.alibaba.nacos.naming.push.v2.NamingSubscriberServiceV2Impl namingSubscriberServiceV2Impl}
* having listen on related {@link com.alibaba.nacos.naming.core.v2.event.service.ServiceEvent.ServiceChangedEvent events}.
* @author <a href="mailto:[email protected]">liaochuntao</a>
*/
@DependsOn("namingSubscriberServiceV2Impl")
@SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule")
@Component
public class ClientOperationServiceProxy implements ClientOperationService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.alibaba.nacos.consistency.snapshot.SnapshotOperation;
import com.alibaba.nacos.consistency.snapshot.Writer;
import com.alibaba.nacos.core.distributed.ProtocolManager;
import com.alibaba.nacos.core.utils.Loggers;
import com.alibaba.nacos.naming.consistency.persistent.impl.AbstractSnapshotOperation;
import com.alibaba.nacos.naming.constants.Constants;
import com.alibaba.nacos.naming.core.v2.ServiceManager;
Expand Down Expand Up @@ -113,6 +114,7 @@ public void registerInstance(Service service, Instance instance, String clientId

try {
protocol.write(writeRequest);
Loggers.RAFT.info("Client registered. service={}, clientId={}, instance={}", service, instance, clientId);
} catch (Exception e) {
throw new NacosRuntimeException(NacosException.SERVER_ERROR, e);
}
Expand Down Expand Up @@ -160,6 +162,7 @@ public void deregisterInstance(Service service, Instance instance, String client

try {
protocol.write(writeRequest);
Loggers.RAFT.info("Client unregistered. service={}, clientId={}, instance={}", service, instance, clientId);
} catch (Exception e) {
throw new NacosRuntimeException(NacosException.SERVER_ERROR, e);
}
Expand Down Expand Up @@ -313,6 +316,7 @@ protected boolean writeSnapshot(Writer writer) throws IOException {
@Override
protected boolean readSnapshot(Reader reader) throws Exception {
final String readerPath = reader.getPath();
Loggers.RAFT.info("snapshot start to load from : {}", readerPath);
final String sourceFile = Paths.get(readerPath, SNAPSHOT_ARCHIVE).toString();
final Checksum checksum = new CRC64();
byte[] snapshotBytes = DiskUtils.decompress(sourceFile, checksum);
Expand All @@ -323,6 +327,7 @@ protected boolean readSnapshot(Reader reader) throws Exception {
}
}
loadSnapshot(snapshotBytes);
Loggers.RAFT.info("snapshot success to load from : {}", readerPath);
return true;
}

Expand Down Expand Up @@ -357,6 +362,7 @@ private void loadSyncDataToClient(Map.Entry<String, ClientSyncData> entry, IpPor
Service service = Service.newService(namespaces.get(i), groupNames.get(i), serviceNames.get(i), false);
Service singleton = ServiceManager.getInstance().getSingleton(service);
client.putServiceInstance(singleton, instances.get(i));
Loggers.RAFT.info("[SNAPSHOT-LOAD] service={}, instance={}", service, instances.get(i));
NotifyCenter.publishEvent(
new ClientOperationEvent.ClientRegisterServiceEvent(singleton, client.getClientId()));
}
Expand Down