* [ISSUE #9230] Fix missing dependency between event publisher and subscriber triggered on snapshot loading. * [ISSUE #9230] Fix codestyle. * [ISSUE #9230] Fix missing dependency between event publisher and subscriber triggered on persistent clients' snapshot loading. * [ISSUE #9230] Fix import.
This commit is contained in:
parent
71d7d36951
commit
af22d35d6f
@ -24,6 +24,7 @@ import com.alibaba.nacos.naming.core.v2.client.impl.IpPortBasedClient;
|
||||
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;
|
||||
@ -34,6 +35,7 @@ import java.util.HashSet;
|
||||
*
|
||||
* @author xiweng.yy
|
||||
*/
|
||||
@DependsOn({"clientServiceIndexesManager", "namingMetadataManager"})
|
||||
@Component("clientManager")
|
||||
public class ClientManagerDelegate implements ClientManager {
|
||||
|
||||
|
@ -34,6 +34,7 @@ import com.alibaba.nacos.naming.misc.GlobalExecutor;
|
||||
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;
|
||||
@ -46,6 +47,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*
|
||||
* @author xiweng.yy
|
||||
*/
|
||||
@DependsOn("clientServiceIndexesManager")
|
||||
@Component("ephemeralIpPortClientManager")
|
||||
public class EphemeralIpPortClientManager implements ClientManager {
|
||||
|
||||
|
@ -115,7 +115,12 @@ public class InstancePublishInfo implements Serializable {
|
||||
|
||||
@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) {
|
||||
|
@ -24,6 +24,7 @@ import com.alibaba.nacos.naming.core.v2.service.impl.EphemeralClientOperationSer
|
||||
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;
|
||||
@ -31,8 +32,11 @@ 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:liaochuntao@live.com">liaochuntao</a>
|
||||
*/
|
||||
@DependsOn("namingSubscriberServiceV2Impl")
|
||||
@SuppressWarnings("PMD.ServiceOrDaoClassShouldEndWithImplRule")
|
||||
@Component
|
||||
public class ClientOperationServiceProxy implements ClientOperationService {
|
||||
|
@ -34,6 +34,7 @@ import com.alibaba.nacos.consistency.snapshot.Reader;
|
||||
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;
|
||||
@ -113,6 +114,7 @@ public class PersistentClientOperationServiceImpl extends RequestProcessor4CP im
|
||||
|
||||
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);
|
||||
}
|
||||
@ -160,6 +162,7 @@ public class PersistentClientOperationServiceImpl extends RequestProcessor4CP im
|
||||
|
||||
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);
|
||||
}
|
||||
@ -313,6 +316,7 @@ public class PersistentClientOperationServiceImpl extends RequestProcessor4CP im
|
||||
@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);
|
||||
@ -323,6 +327,7 @@ public class PersistentClientOperationServiceImpl extends RequestProcessor4CP im
|
||||
}
|
||||
}
|
||||
loadSnapshot(snapshotBytes);
|
||||
Loggers.RAFT.info("snapshot success to load from : {}", readerPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -357,6 +362,7 @@ public class PersistentClientOperationServiceImpl extends RequestProcessor4CP im
|
||||
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()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user