@Test public void updateEndpointTestNewLocNullOldLocNullExternalPut() { when(endpoint1.getAugmentation(OfOverlayContext.class)).thenReturn(null); when(endpoint2.getAugmentation(OfOverlayContext.class)).thenReturn(null); manager.processEndpoint(endpoint1, endpoint2); verify(endpointListener, never()).endpointUpdated(any(EpKey.class)); verify(endpointListener, never()).nodeEndpointUpdated(any(NodeId.class), any(EpKey.class)); }
protected synchronized void processEndpoint(Endpoint oldEp, Endpoint newEp) { NodeId oldLoc = getLocation(oldEp); NodeId newLoc = getLocation(newEp); EpKey oldEpKey = getEpKey(oldEp); EpKey newEpKey = getEpKey(newEp); TenantId tenantId = (newEp == null) ? null : newEp.getTenant(); if (newEp != null && !isValidEp(newEp)) { LOG.info("Endpoint is not valid: {}", newEp); return; } Set<EndpointGroupId> oldEpgIds = getEndpointGroupsFromEndpoint(oldEp); Set<EndpointGroupId> newEpgIds = getEndpointGroupsFromEndpoint(newEp); boolean notifyOldLoc = false; boolean notifyNewLoc = false; boolean notifyOldEg = false; boolean notifyNewEg = false; if (oldEp == null && newEp != null) { if (newLoc != null) { createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); endpoints.put(newEpKey, newEp); notifyEndpointUpdated(newEpKey); notifyNewLoc = true; notifyNewEg = true; } else { externalEndpointsWithoutLocation.put(newEpKey, newEp); } } else if (oldEp != null && newEp != null && oldEpKey != null && newEpKey != null) { if (newLoc != null && oldLoc == null) { createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); externalEndpointsWithoutLocation.remove(oldEpKey); endpoints.put(newEpKey, newEp); notifyEndpointUpdated(newEpKey); notifyNewLoc = true; notifyNewEg = true; } else if (newLoc == null && oldLoc != null) { removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); externalEndpointsWithoutLocation.put(newEpKey, newEp); endpoints.remove(oldEpKey); notifyEndpointUpdated(oldEpKey); notifyOldLoc = true; notifyOldEg = true; } else if (newLoc != null && oldLoc != null) { if (!(oldLoc.getValue().equals(newLoc.getValue()))) { notifyOldLoc = true; notifyNewLoc = true; } if (!oldEpgIds.equals(newEpgIds)) { notifyOldEg = true; notifyNewEg = true; } removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); notifyEndpointUpdated(newEpKey); } } else if (oldEp != null && newEp == null) { if (oldLoc != null) { removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); endpoints.remove(oldEpKey); notifyEndpointUpdated(oldEpKey); notifyOldLoc = true; notifyOldEg = true; } else { externalEndpointsWithoutLocation.remove(oldEpKey); } } if (notifyOldLoc) notifyNodeEndpointUpdated(oldLoc, oldEpKey); if (notifyNewLoc) notifyNodeEndpointUpdated(newLoc, newEpKey); if (notifyOldEg) for (EndpointGroupId oldEpgId : oldEpgIds) { EgKey oldEgKey = new EgKey(oldEp.getTenant(), oldEpgId); notifyGroupEndpointUpdated(oldEgKey, oldEpKey); } if (notifyNewEg) for (EndpointGroupId newEpgId : newEpgIds) { EgKey newEgKey = new EgKey(newEp.getTenant(), newEpgId); notifyGroupEndpointUpdated(newEgKey, newEpKey); } }
EndpointManager implements AutoCloseable { protected synchronized void processEndpoint(Endpoint oldEp, Endpoint newEp) { NodeId oldLoc = getLocation(oldEp); NodeId newLoc = getLocation(newEp); EpKey oldEpKey = getEpKey(oldEp); EpKey newEpKey = getEpKey(newEp); TenantId tenantId = (newEp == null) ? null : newEp.getTenant(); if (newEp != null && !isValidEp(newEp)) { LOG.info("Endpoint is not valid: {}", newEp); return; } Set<EndpointGroupId> oldEpgIds = getEndpointGroupsFromEndpoint(oldEp); Set<EndpointGroupId> newEpgIds = getEndpointGroupsFromEndpoint(newEp); boolean notifyOldLoc = false; boolean notifyNewLoc = false; boolean notifyOldEg = false; boolean notifyNewEg = false; if (oldEp == null && newEp != null) { if (newLoc != null) { createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); endpoints.put(newEpKey, newEp); notifyEndpointUpdated(newEpKey); notifyNewLoc = true; notifyNewEg = true; } else { externalEndpointsWithoutLocation.put(newEpKey, newEp); } } else if (oldEp != null && newEp != null && oldEpKey != null && newEpKey != null) { if (newLoc != null && oldLoc == null) { createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); externalEndpointsWithoutLocation.remove(oldEpKey); endpoints.put(newEpKey, newEp); notifyEndpointUpdated(newEpKey); notifyNewLoc = true; notifyNewEg = true; } else if (newLoc == null && oldLoc != null) { removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); externalEndpointsWithoutLocation.put(newEpKey, newEp); endpoints.remove(oldEpKey); notifyEndpointUpdated(oldEpKey); notifyOldLoc = true; notifyOldEg = true; } else if (newLoc != null && oldLoc != null) { if (!(oldLoc.getValue().equals(newLoc.getValue()))) { notifyOldLoc = true; notifyNewLoc = true; } if (!oldEpgIds.equals(newEpgIds)) { notifyOldEg = true; notifyNewEg = true; } removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); notifyEndpointUpdated(newEpKey); } } else if (oldEp != null && newEp == null) { if (oldLoc != null) { removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); endpoints.remove(oldEpKey); notifyEndpointUpdated(oldEpKey); notifyOldLoc = true; notifyOldEg = true; } else { externalEndpointsWithoutLocation.remove(oldEpKey); } } if (notifyOldLoc) notifyNodeEndpointUpdated(oldLoc, oldEpKey); if (notifyNewLoc) notifyNodeEndpointUpdated(newLoc, newEpKey); if (notifyOldEg) for (EndpointGroupId oldEpgId : oldEpgIds) { EgKey oldEgKey = new EgKey(oldEp.getTenant(), oldEpgId); notifyGroupEndpointUpdated(oldEgKey, oldEpKey); } if (notifyNewEg) for (EndpointGroupId newEpgId : newEpgIds) { EgKey newEgKey = new EgKey(newEp.getTenant(), newEpgId); notifyGroupEndpointUpdated(newEgKey, newEpKey); } } }
EndpointManager implements AutoCloseable { protected synchronized void processEndpoint(Endpoint oldEp, Endpoint newEp) { NodeId oldLoc = getLocation(oldEp); NodeId newLoc = getLocation(newEp); EpKey oldEpKey = getEpKey(oldEp); EpKey newEpKey = getEpKey(newEp); TenantId tenantId = (newEp == null) ? null : newEp.getTenant(); if (newEp != null && !isValidEp(newEp)) { LOG.info("Endpoint is not valid: {}", newEp); return; } Set<EndpointGroupId> oldEpgIds = getEndpointGroupsFromEndpoint(oldEp); Set<EndpointGroupId> newEpgIds = getEndpointGroupsFromEndpoint(newEp); boolean notifyOldLoc = false; boolean notifyNewLoc = false; boolean notifyOldEg = false; boolean notifyNewEg = false; if (oldEp == null && newEp != null) { if (newLoc != null) { createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); endpoints.put(newEpKey, newEp); notifyEndpointUpdated(newEpKey); notifyNewLoc = true; notifyNewEg = true; } else { externalEndpointsWithoutLocation.put(newEpKey, newEp); } } else if (oldEp != null && newEp != null && oldEpKey != null && newEpKey != null) { if (newLoc != null && oldLoc == null) { createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); externalEndpointsWithoutLocation.remove(oldEpKey); endpoints.put(newEpKey, newEp); notifyEndpointUpdated(newEpKey); notifyNewLoc = true; notifyNewEg = true; } else if (newLoc == null && oldLoc != null) { removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); externalEndpointsWithoutLocation.put(newEpKey, newEp); endpoints.remove(oldEpKey); notifyEndpointUpdated(oldEpKey); notifyOldLoc = true; notifyOldEg = true; } else if (newLoc != null && oldLoc != null) { if (!(oldLoc.getValue().equals(newLoc.getValue()))) { notifyOldLoc = true; notifyNewLoc = true; } if (!oldEpgIds.equals(newEpgIds)) { notifyOldEg = true; notifyNewEg = true; } removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); notifyEndpointUpdated(newEpKey); } } else if (oldEp != null && newEp == null) { if (oldLoc != null) { removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); endpoints.remove(oldEpKey); notifyEndpointUpdated(oldEpKey); notifyOldLoc = true; notifyOldEg = true; } else { externalEndpointsWithoutLocation.remove(oldEpKey); } } if (notifyOldLoc) notifyNodeEndpointUpdated(oldLoc, oldEpKey); if (notifyNewLoc) notifyNodeEndpointUpdated(newLoc, newEpKey); if (notifyOldEg) for (EndpointGroupId oldEpgId : oldEpgIds) { EgKey oldEgKey = new EgKey(oldEp.getTenant(), oldEpgId); notifyGroupEndpointUpdated(oldEgKey, oldEpKey); } if (notifyNewEg) for (EndpointGroupId newEpgId : newEpgIds) { EgKey newEgKey = new EgKey(newEp.getTenant(), newEpgId); notifyGroupEndpointUpdated(newEgKey, newEpKey); } } EndpointManager(DataBroker dataProvider,PacketProcessingService packetProcessingService,
            SalFlowService flowService, NotificationService notificationService,
            ScheduledExecutorService executor, SwitchManager switchManager); }
EndpointManager implements AutoCloseable { protected synchronized void processEndpoint(Endpoint oldEp, Endpoint newEp) { NodeId oldLoc = getLocation(oldEp); NodeId newLoc = getLocation(newEp); EpKey oldEpKey = getEpKey(oldEp); EpKey newEpKey = getEpKey(newEp); TenantId tenantId = (newEp == null) ? null : newEp.getTenant(); if (newEp != null && !isValidEp(newEp)) { LOG.info("Endpoint is not valid: {}", newEp); return; } Set<EndpointGroupId> oldEpgIds = getEndpointGroupsFromEndpoint(oldEp); Set<EndpointGroupId> newEpgIds = getEndpointGroupsFromEndpoint(newEp); boolean notifyOldLoc = false; boolean notifyNewLoc = false; boolean notifyOldEg = false; boolean notifyNewEg = false; if (oldEp == null && newEp != null) { if (newLoc != null) { createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); endpoints.put(newEpKey, newEp); notifyEndpointUpdated(newEpKey); notifyNewLoc = true; notifyNewEg = true; } else { externalEndpointsWithoutLocation.put(newEpKey, newEp); } } else if (oldEp != null && newEp != null && oldEpKey != null && newEpKey != null) { if (newLoc != null && oldLoc == null) { createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); externalEndpointsWithoutLocation.remove(oldEpKey); endpoints.put(newEpKey, newEp); notifyEndpointUpdated(newEpKey); notifyNewLoc = true; notifyNewEg = true; } else if (newLoc == null && oldLoc != null) { removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); externalEndpointsWithoutLocation.put(newEpKey, newEp); endpoints.remove(oldEpKey); notifyEndpointUpdated(oldEpKey); notifyOldLoc = true; notifyOldEg = true; } else if (newLoc != null && oldLoc != null) { if (!(oldLoc.getValue().equals(newLoc.getValue()))) { notifyOldLoc = true; notifyNewLoc = true; } if (!oldEpgIds.equals(newEpgIds)) { notifyOldEg = true; notifyNewEg = true; } removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); notifyEndpointUpdated(newEpKey); } } else if (oldEp != null && newEp == null) { if (oldLoc != null) { removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); endpoints.remove(oldEpKey); notifyEndpointUpdated(oldEpKey); notifyOldLoc = true; notifyOldEg = true; } else { externalEndpointsWithoutLocation.remove(oldEpKey); } } if (notifyOldLoc) notifyNodeEndpointUpdated(oldLoc, oldEpKey); if (notifyNewLoc) notifyNodeEndpointUpdated(newLoc, newEpKey); if (notifyOldEg) for (EndpointGroupId oldEpgId : oldEpgIds) { EgKey oldEgKey = new EgKey(oldEp.getTenant(), oldEpgId); notifyGroupEndpointUpdated(oldEgKey, oldEpKey); } if (notifyNewEg) for (EndpointGroupId newEpgId : newEpgIds) { EgKey newEgKey = new EgKey(newEp.getTenant(), newEpgId); notifyGroupEndpointUpdated(newEgKey, newEpKey); } } EndpointManager(DataBroker dataProvider,PacketProcessingService packetProcessingService,
            SalFlowService flowService, NotificationService notificationService,
            ScheduledExecutorService executor, SwitchManager switchManager); void registerListener(EndpointListener listener); synchronized Set<EgKey> getGroupsForNode(NodeId nodeId); synchronized Set<NodeId> getNodesForGroup(final EgKey egKey); synchronized Collection<Endpoint> getEndpointsForNode(NodeId nodeId, EgKey eg); synchronized Collection<Endpoint> getEndpointsForNode(final NodeId nodeId); Endpoint getEndpoint(EpKey epKey); HashSet<Endpoint> getEndpoints(); synchronized Collection<Endpoint> getEndpointsForGroup(EgKey eg); synchronized Collection<Endpoint> getExtEpsNoLocForGroup(final EgKey eg); @Override void close(); static boolean isExternal(Endpoint ep, @Nullable Collection<ExternalImplicitGroup> eigs); static boolean isInternal(Endpoint ep, @Nullable Collection<ExternalImplicitGroup> eigs); Endpoint getL2EndpointFromL3(EndpointL3 endpointL3); EndpointL3 getL3Endpoint(L3ContextId l3c, IpAddress ipAddress, @Nullable TenantId tenantId); Collection<EndpointL3Prefix> getEndpointsL3PrefixForTenant(final TenantId tenantId); @Nonnull Collection<EndpointL3> getL3EndpointsWithNat(); @SuppressWarnings({"UnusedParameters", "EmptyMethod"}) void setLearningMode(OfOverlayConfig.LearningMode learningMode); List<ConditionName> getConditionsForEndpoint(Endpoint endpoint); NodeId getEndpointNodeId(Endpoint endpoint); NodeConnectorId getEndpointNodeConnectorId(Endpoint endpoint); Set<EgKey> getEgKeysForEndpoint(Endpoint ep); EgKey getEgKey(Endpoint endpoint); }
EndpointManager implements AutoCloseable { protected synchronized void processEndpoint(Endpoint oldEp, Endpoint newEp) { NodeId oldLoc = getLocation(oldEp); NodeId newLoc = getLocation(newEp); EpKey oldEpKey = getEpKey(oldEp); EpKey newEpKey = getEpKey(newEp); TenantId tenantId = (newEp == null) ? null : newEp.getTenant(); if (newEp != null && !isValidEp(newEp)) { LOG.info("Endpoint is not valid: {}", newEp); return; } Set<EndpointGroupId> oldEpgIds = getEndpointGroupsFromEndpoint(oldEp); Set<EndpointGroupId> newEpgIds = getEndpointGroupsFromEndpoint(newEp); boolean notifyOldLoc = false; boolean notifyNewLoc = false; boolean notifyOldEg = false; boolean notifyNewEg = false; if (oldEp == null && newEp != null) { if (newLoc != null) { createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); endpoints.put(newEpKey, newEp); notifyEndpointUpdated(newEpKey); notifyNewLoc = true; notifyNewEg = true; } else { externalEndpointsWithoutLocation.put(newEpKey, newEp); } } else if (oldEp != null && newEp != null && oldEpKey != null && newEpKey != null) { if (newLoc != null && oldLoc == null) { createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); externalEndpointsWithoutLocation.remove(oldEpKey); endpoints.put(newEpKey, newEp); notifyEndpointUpdated(newEpKey); notifyNewLoc = true; notifyNewEg = true; } else if (newLoc == null && oldLoc != null) { removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); externalEndpointsWithoutLocation.put(newEpKey, newEp); endpoints.remove(oldEpKey); notifyEndpointUpdated(oldEpKey); notifyOldLoc = true; notifyOldEg = true; } else if (newLoc != null && oldLoc != null) { if (!(oldLoc.getValue().equals(newLoc.getValue()))) { notifyOldLoc = true; notifyNewLoc = true; } if (!oldEpgIds.equals(newEpgIds)) { notifyOldEg = true; notifyNewEg = true; } removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); createEndpoint(newLoc, newEpKey, newEpgIds, tenantId); notifyEndpointUpdated(newEpKey); } } else if (oldEp != null && newEp == null) { if (oldLoc != null) { removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds); endpoints.remove(oldEpKey); notifyEndpointUpdated(oldEpKey); notifyOldLoc = true; notifyOldEg = true; } else { externalEndpointsWithoutLocation.remove(oldEpKey); } } if (notifyOldLoc) notifyNodeEndpointUpdated(oldLoc, oldEpKey); if (notifyNewLoc) notifyNodeEndpointUpdated(newLoc, newEpKey); if (notifyOldEg) for (EndpointGroupId oldEpgId : oldEpgIds) { EgKey oldEgKey = new EgKey(oldEp.getTenant(), oldEpgId); notifyGroupEndpointUpdated(oldEgKey, oldEpKey); } if (notifyNewEg) for (EndpointGroupId newEpgId : newEpgIds) { EgKey newEgKey = new EgKey(newEp.getTenant(), newEpgId); notifyGroupEndpointUpdated(newEgKey, newEpKey); } } EndpointManager(DataBroker dataProvider,PacketProcessingService packetProcessingService,
            SalFlowService flowService, NotificationService notificationService,
            ScheduledExecutorService executor, SwitchManager switchManager); void registerListener(EndpointListener listener); synchronized Set<EgKey> getGroupsForNode(NodeId nodeId); synchronized Set<NodeId> getNodesForGroup(final EgKey egKey); synchronized Collection<Endpoint> getEndpointsForNode(NodeId nodeId, EgKey eg); synchronized Collection<Endpoint> getEndpointsForNode(final NodeId nodeId); Endpoint getEndpoint(EpKey epKey); HashSet<Endpoint> getEndpoints(); synchronized Collection<Endpoint> getEndpointsForGroup(EgKey eg); synchronized Collection<Endpoint> getExtEpsNoLocForGroup(final EgKey eg); @Override void close(); static boolean isExternal(Endpoint ep, @Nullable Collection<ExternalImplicitGroup> eigs); static boolean isInternal(Endpoint ep, @Nullable Collection<ExternalImplicitGroup> eigs); Endpoint getL2EndpointFromL3(EndpointL3 endpointL3); EndpointL3 getL3Endpoint(L3ContextId l3c, IpAddress ipAddress, @Nullable TenantId tenantId); Collection<EndpointL3Prefix> getEndpointsL3PrefixForTenant(final TenantId tenantId); @Nonnull Collection<EndpointL3> getL3EndpointsWithNat(); @SuppressWarnings({"UnusedParameters", "EmptyMethod"}) void setLearningMode(OfOverlayConfig.LearningMode learningMode); List<ConditionName> getConditionsForEndpoint(Endpoint endpoint); NodeId getEndpointNodeId(Endpoint endpoint); NodeConnectorId getEndpointNodeConnectorId(Endpoint endpoint); Set<EgKey> getEgKeysForEndpoint(Endpoint ep); EgKey getEgKey(Endpoint endpoint);  }