Merge branch 'jraft-naming' of https://github.com/KomachiSion/nacos into jraft_naming

This commit is contained in:
chuntaojun 2020-10-13 15:16:08 +08:00
commit 73a29ebc85
3 changed files with 11 additions and 14 deletions

View File

@ -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);
}
}
}

View File

@ -95,13 +95,10 @@ public class RaftConsistencyServiceImpl implements PersistentConsistencyService
checkIsStopWork();
try {
if (KeyBuilder.matchInstanceListKey(key) && !raftCore.isLeader()) {
Datum datum = new Datum();
datum.key = key;
raftCore.onDelete(datum.key, peers.getLeader());
raftCore.unlistenAll(key);
return;
raftCore.onDelete(key, peers.getLeader());
} else {
raftCore.signalDelete(key);
}
raftCore.signalDelete(key);
raftCore.unlistenAll(key);
} catch (Exception e) {
Loggers.RAFT.error("Raft remove failed.", e);

View File

@ -228,10 +228,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());
}