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. (apache#8026)

Co-authored-by: zhenyu zhang <[email protected]>
  • Loading branch information
hadley0828 and zhenyu zhang authored Mar 16, 2022
1 parent 7cf49db commit a5b1d17
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 a5b1d17

Please sign in to comment.