Skip to content

Commit

Permalink
Instance eliminate module naming optimization (#3093)
Browse files Browse the repository at this point in the history
* Instance eliminate module naming optimization

* Solve PMD check failed
  • Loading branch information
pengzhengfa authored Jun 17, 2020
1 parent 67829bb commit d24f36b
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions naming/src/main/java/com/alibaba/nacos/naming/core/Cluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,22 +347,21 @@ private List<Instance> updatedIps(Collection<Instance> newInstance, Collection<I

return new ArrayList<>(instanceMap.values());
}
private List<Instance> subtract(Collection<Instance> a, Collection<Instance> b) {
Map<String, Instance> mapa = new HashMap<>(b.size());
for (Instance o : b) {
mapa.put(o.getIp() + ":" + o.getPort(), o);

private List<Instance> subtract(Collection<Instance> oldIp, Collection<Instance> ips) {
Map<String, Instance> ipsMap = new HashMap<>(ips.size());
for (Instance instance : ips) {
ipsMap.put(instance.getIp() + ":" + instance.getPort(), instance);
}
List<Instance> result = new ArrayList<>();
for (Instance o : a) {
if (!mapa.containsKey(o.getIp() + ":" + o.getPort())) {
result.add(o);

List<Instance> instanceResult = new ArrayList<>();

for (Instance instance : oldIp) {
if (!ipsMap.containsKey(instance.getIp() + ":" + instance.getPort())) {
instanceResult.add(instance);
}
}

return result;
return instanceResult;
}

@Override
Expand Down

0 comments on commit d24f36b

Please sign in to comment.