+ // update forwarding for endpoint
+ updatedRendEps.forEach(rEpKey -> {
+ AddressEndpointWithLocation addrEpWithLocBefore =
+ policyCtxBefore.getAddrEpByKey().get(KeyFactory.addressEndpointKey(rEpKey));
+ AddressEndpointWithLocation addrEpWithLocAfter =
+ policyCtxAfter.getAddrEpByKey().get(KeyFactory.addressEndpointKey(rEpKey));
+ if (isLocationChanged(addrEpWithLocBefore, addrEpWithLocAfter)) {
+ LOG.debug("Location is changed in endpoint {}", rEpKey);
+ LOG.debug("\nLocation before: {}\nLocation after: {}", addrEpWithLocBefore.getAbsoluteLocation(),
+ addrEpWithLocAfter.getAbsoluteLocation());
+ fwManager.removeForwardingForEndpoint(rEpKey, policyCtxBefore);
+ fwManager.createForwardingForEndpoint(rEpKey, policyCtxAfter);
+ }
+ });
+ ImmutableSet<RuleGroupKey> rulesBefore = policyCtxAfter.getRuleGroupByKey().keySet();
+ ImmutableSet<RuleGroupKey> rulesAfter = policyCtxBefore.getRuleGroupByKey().keySet();
+ SetView<RuleGroupKey> removedRules = Sets.difference(rulesAfter, rulesBefore);
+ SetView<RuleGroupKey> createdRules = Sets.difference(rulesBefore, rulesAfter);
+ LOG.debug("Updated rules: {}", Sets.intersection(rulesBefore, rulesAfter));
+ LOG.debug("Removed rules {}", removedRules);
+ LOG.debug("Created rules {}", createdRules);
+ LOG.debug("Updated renderer endpoints {}", updatedRendEps);
+ LOG.debug("Created renderer endpoints {}", createdRendEps);
+ LOG.debug("Updated renderer endpoints {}", updatedRendEps);
+ aclManager.resolveRulesToConfigure(policyCtxBefore, removedRendEps, removedRules, false);
+ aclManager.resolveRulesToConfigure(policyCtxAfter, createdRendEps, createdRules, true);
+ }
+
+ private static boolean isLocationChanged(AddressEndpointWithLocation before, AddressEndpointWithLocation after) {
+ ExternalLocationCase locationBefore = ForwardingManager.resolveAndValidateLocation(before);
+ ExternalLocationCase locationAfter = ForwardingManager.resolveAndValidateLocation(after);
+ if (locationBefore == null && locationAfter == null) {
+ return false;
+ }
+ if (locationBefore == null || locationAfter == null) {
+ return true;
+ }
+ return !locationBefore.equals(locationAfter);