* [ISSUE #9816] check expected final state before remove redo data. * check expected final state before remove subscriber redo data. * update NamingGrpcRedoServiceTest when test remove * update NamingGrpcRedoService, set expect register status to false when subscribers deregister
This commit is contained in:
parent
428e0bc668
commit
30954dc612
@ -177,8 +177,12 @@ public class NamingGrpcRedoService implements ConnectionEventListener {
|
||||
* @param groupName group name
|
||||
*/
|
||||
public void removeInstanceForRedo(String serviceName, String groupName) {
|
||||
String key = NamingUtils.getGroupedName(serviceName, groupName);
|
||||
synchronized (registeredInstances) {
|
||||
registeredInstances.remove(NamingUtils.getGroupedName(serviceName, groupName));
|
||||
InstanceRedoData redoData = registeredInstances.get(key);
|
||||
if (null != redoData && !redoData.isExpectedRegistered()) {
|
||||
registeredInstances.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,6 +248,7 @@ public class NamingGrpcRedoService implements ConnectionEventListener {
|
||||
SubscriberRedoData redoData = subscribes.get(key);
|
||||
if (null != redoData) {
|
||||
redoData.setUnregistering(true);
|
||||
redoData.setExpectedRegistered(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -272,8 +277,12 @@ public class NamingGrpcRedoService implements ConnectionEventListener {
|
||||
* @param cluster cluster
|
||||
*/
|
||||
public void removeSubscriberForRedo(String serviceName, String groupName, String cluster) {
|
||||
String key = ServiceInfo.getKey(NamingUtils.getGroupedName(serviceName, groupName), cluster);
|
||||
synchronized (subscribes) {
|
||||
subscribes.remove(ServiceInfo.getKey(NamingUtils.getGroupedName(serviceName, groupName), cluster));
|
||||
SubscriberRedoData redoData = subscribes.get(key);
|
||||
if (null != redoData && !redoData.isExpectedRegistered()) {
|
||||
subscribes.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,6 +156,7 @@ public class NamingGrpcRedoServiceTest {
|
||||
assertTrue(registeredInstances.isEmpty());
|
||||
redoService.cacheInstanceForRedo(SERVICE, GROUP, new Instance());
|
||||
assertFalse(registeredInstances.isEmpty());
|
||||
redoService.instanceDeregister(SERVICE, GROUP);
|
||||
redoService.removeInstanceForRedo(SERVICE, GROUP);
|
||||
assertTrue(registeredInstances.isEmpty());
|
||||
}
|
||||
@ -221,6 +222,7 @@ public class NamingGrpcRedoServiceTest {
|
||||
assertTrue(subscribes.isEmpty());
|
||||
redoService.cacheSubscriberForRedo(SERVICE, GROUP, CLUSTER);
|
||||
assertFalse(subscribes.isEmpty());
|
||||
redoService.subscriberDeregister(SERVICE, GROUP, CLUSTER);
|
||||
redoService.removeSubscriberForRedo(SERVICE, GROUP, CLUSTER);
|
||||
assertTrue(subscribes.isEmpty());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user