Move remove listener logic to ServiceManager
This commit is contained in:
parent
ea515428ce
commit
b8b111320a
@ -231,10 +231,6 @@ public class PersistentServiceProcessor extends LogProcessor4CP implements Persi
|
||||
final ValueChangeEvent event = ValueChangeEvent.builder().key(key).value(value)
|
||||
.action(Op.Delete.equals(op) ? DataOperation.DELETE : DataOperation.CHANGE).build();
|
||||
NotifyCenter.publishEvent(event);
|
||||
// remove listeners of key to avoid mem leak
|
||||
if (Op.Delete.equals(op)) {
|
||||
notifier.deregisterAllListener(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import com.alibaba.nacos.naming.consistency.ConsistencyService;
|
||||
import com.alibaba.nacos.naming.consistency.Datum;
|
||||
import com.alibaba.nacos.naming.consistency.KeyBuilder;
|
||||
import com.alibaba.nacos.naming.consistency.RecordListener;
|
||||
import com.alibaba.nacos.naming.consistency.persistent.impl.PersistentServiceProcessor;
|
||||
import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeer;
|
||||
import com.alibaba.nacos.naming.consistency.persistent.raft.RaftPeerSet;
|
||||
import com.alibaba.nacos.naming.misc.GlobalExecutor;
|
||||
@ -229,10 +230,14 @@ public class ServiceManager implements RecordListener<Service> {
|
||||
|
||||
if (service != null) {
|
||||
service.destroy();
|
||||
consistencyService.remove(KeyBuilder.buildInstanceListKey(namespace, name, true));
|
||||
|
||||
consistencyService.remove(KeyBuilder.buildInstanceListKey(namespace, name, false));
|
||||
|
||||
String ephemeralInstanceListKey = KeyBuilder.buildInstanceListKey(namespace, name, true);
|
||||
String persistInstanceListKey = KeyBuilder.buildInstanceListKey(namespace, name, false);
|
||||
consistencyService.remove(ephemeralInstanceListKey);
|
||||
consistencyService.remove(persistInstanceListKey);
|
||||
|
||||
// remove listeners of key to avoid mem leak
|
||||
consistencyService.unListen(ephemeralInstanceListKey, service);
|
||||
consistencyService.unListen(persistInstanceListKey, service);
|
||||
consistencyService.unListen(KeyBuilder.buildServiceMetaKey(namespace, name), service);
|
||||
Loggers.SRV_LOG.info("[DEAD-SERVICE] {}", service.toJson());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user