Skip to content

Commit

Permalink
add a new method for getting the number of consumer service addresses…
Browse files Browse the repository at this point in the history
… in the case of multiple registries.
  • Loading branch information
zhenyu zhang committed Jun 10, 2021
1 parent fd4f765 commit c99dbb6
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,24 @@ public static int getConsumerAddressNum(ConsumerModel consumerModel) {
}
return num;
}

//for the situation that QoS wants to query the address number of a consumer in all Registries
public static int getConsumerAddressNumInAllRegistries(ConsumerModel consumerModel){
int num = 0;

Collection<Registry> registries = AbstractRegistryFactory.getRegistries();
if(CollectionUtils.isNotEmpty(registries)){
for(Registry registry: registries){
AbstractRegistry abstractRegistry = (AbstractRegistry) registry;
for(Map.Entry<URL, Map<String, List<URL>>> entry: abstractRegistry.getNotified().entrySet()){
if(entry.getKey().getServiceKey().equals(consumerModel.getServiceKey())){
if(CollectionUtils.isNotEmptyMap(entry.getValue())){
num += entry.getValue().size();
}
}
}
}
}
return num;
}
}

0 comments on commit c99dbb6

Please sign in to comment.