@Test public void syncFlows() throws Exception { DestinationMapperFlows flows = mock(DestinationMapperFlows.class); EndpointBuilder endpointBuilder = buildEndpoint(IPV4_1, MAC_1, CONNECTOR_1); when(ctx.getTenant(any(TenantId.class))).thenReturn(getTestIndexedTenant()); when(ctx.getEndpointManager()).thenReturn(endpointManager); when(ctx.getPolicyManager()).thenReturn(policyManager); when(ctx.getCurrentPolicy()).thenReturn(policyInfo); destinationMapper.syncFlows(flows, endpointBuilder.build(), null, ofWriter); verify(ctx, times(3)).getTenant(any(TenantId.class)); verify(ctx, times(5)).getEndpointManager(); verify(ctx, times(2)).getPolicyManager(); verify(ctx, times(2)).getCurrentPolicy(); InOrder order = inOrder(flows); order.verify(flows, times(1)).dropFlow(anyInt(), anyLong(), eq(ofWriter)); order.verify(flows, times(1)).createBroadcastFlow(anyInt(), any(OrdinalFactory.EndpointFwdCtxOrdinals.class), any(MacAddress.class), eq(ofWriter)); }
@VisibleForTesting void syncFlows(DestinationMapperFlows flows, Endpoint endpoint, NodeId nodeId, OfWriter ofWriter) { flows.dropFlow(DROP_FLOW, null, ofWriter); List<Subnet> localSubnets = utils.getLocalSubnets(nodeId); if (localSubnets != null) { syncLocalFlows(flows, endpoint, localSubnets, ofWriter); syncEndpointFlows(flows, nodeId, endpoint, ofWriter); } TenantId tenantId = endpoint.getTenant(); syncArpFlow(flows, tenantId, ofWriter); EndpointFwdCtxOrdinals ordinals = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, endpoint); if (ordinals != null) { flows.createBroadcastFlow(BROADCAST, ordinals, MULTICAST_MAC, ofWriter); } Collection<EndpointL3Prefix> prefixes = ctx.getEndpointManager().getEndpointsL3PrefixForTenant(tenantId); if (prefixes != null) { LOG.trace("DestinationMapper - Processing L3PrefixEndpoint"); syncL3PrefixFlow(flows, prefixes, tenantId, nodeId, ofWriter); } }
DestinationMapper extends FlowTable { @VisibleForTesting void syncFlows(DestinationMapperFlows flows, Endpoint endpoint, NodeId nodeId, OfWriter ofWriter) { flows.dropFlow(DROP_FLOW, null, ofWriter); List<Subnet> localSubnets = utils.getLocalSubnets(nodeId); if (localSubnets != null) { syncLocalFlows(flows, endpoint, localSubnets, ofWriter); syncEndpointFlows(flows, nodeId, endpoint, ofWriter); } TenantId tenantId = endpoint.getTenant(); syncArpFlow(flows, tenantId, ofWriter); EndpointFwdCtxOrdinals ordinals = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, endpoint); if (ordinals != null) { flows.createBroadcastFlow(BROADCAST, ordinals, MULTICAST_MAC, ofWriter); } Collection<EndpointL3Prefix> prefixes = ctx.getEndpointManager().getEndpointsL3PrefixForTenant(tenantId); if (prefixes != null) { LOG.trace("DestinationMapper - Processing L3PrefixEndpoint"); syncL3PrefixFlow(flows, prefixes, tenantId, nodeId, ofWriter); } } }
DestinationMapper extends FlowTable { @VisibleForTesting void syncFlows(DestinationMapperFlows flows, Endpoint endpoint, NodeId nodeId, OfWriter ofWriter) { flows.dropFlow(DROP_FLOW, null, ofWriter); List<Subnet> localSubnets = utils.getLocalSubnets(nodeId); if (localSubnets != null) { syncLocalFlows(flows, endpoint, localSubnets, ofWriter); syncEndpointFlows(flows, nodeId, endpoint, ofWriter); } TenantId tenantId = endpoint.getTenant(); syncArpFlow(flows, tenantId, ofWriter); EndpointFwdCtxOrdinals ordinals = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, endpoint); if (ordinals != null) { flows.createBroadcastFlow(BROADCAST, ordinals, MULTICAST_MAC, ofWriter); } Collection<EndpointL3Prefix> prefixes = ctx.getEndpointManager().getEndpointsL3PrefixForTenant(tenantId); if (prefixes != null) { LOG.trace("DestinationMapper - Processing L3PrefixEndpoint"); syncL3PrefixFlow(flows, prefixes, tenantId, nodeId, ofWriter); } } DestinationMapper(OfContext ctx, short tableId); }
DestinationMapper extends FlowTable { @VisibleForTesting void syncFlows(DestinationMapperFlows flows, Endpoint endpoint, NodeId nodeId, OfWriter ofWriter) { flows.dropFlow(DROP_FLOW, null, ofWriter); List<Subnet> localSubnets = utils.getLocalSubnets(nodeId); if (localSubnets != null) { syncLocalFlows(flows, endpoint, localSubnets, ofWriter); syncEndpointFlows(flows, nodeId, endpoint, ofWriter); } TenantId tenantId = endpoint.getTenant(); syncArpFlow(flows, tenantId, ofWriter); EndpointFwdCtxOrdinals ordinals = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, endpoint); if (ordinals != null) { flows.createBroadcastFlow(BROADCAST, ordinals, MULTICAST_MAC, ofWriter); } Collection<EndpointL3Prefix> prefixes = ctx.getEndpointManager().getEndpointsL3PrefixForTenant(tenantId); if (prefixes != null) { LOG.trace("DestinationMapper - Processing L3PrefixEndpoint"); syncL3PrefixFlow(flows, prefixes, tenantId, nodeId, ofWriter); } } DestinationMapper(OfContext ctx, short tableId); @Override short getTableId(); @Override void sync(Endpoint endpoint, OfWriter ofWriter); }
DestinationMapper extends FlowTable { @VisibleForTesting void syncFlows(DestinationMapperFlows flows, Endpoint endpoint, NodeId nodeId, OfWriter ofWriter) { flows.dropFlow(DROP_FLOW, null, ofWriter); List<Subnet> localSubnets = utils.getLocalSubnets(nodeId); if (localSubnets != null) { syncLocalFlows(flows, endpoint, localSubnets, ofWriter); syncEndpointFlows(flows, nodeId, endpoint, ofWriter); } TenantId tenantId = endpoint.getTenant(); syncArpFlow(flows, tenantId, ofWriter); EndpointFwdCtxOrdinals ordinals = OrdinalFactory.getEndpointFwdCtxOrdinals(ctx, endpoint); if (ordinals != null) { flows.createBroadcastFlow(BROADCAST, ordinals, MULTICAST_MAC, ofWriter); } Collection<EndpointL3Prefix> prefixes = ctx.getEndpointManager().getEndpointsL3PrefixForTenant(tenantId); if (prefixes != null) { LOG.trace("DestinationMapper - Processing L3PrefixEndpoint"); syncL3PrefixFlow(flows, prefixes, tenantId, nodeId, ofWriter); } } DestinationMapper(OfContext ctx, short tableId); @Override short getTableId(); @Override void sync(Endpoint endpoint, OfWriter ofWriter); static final MacAddress ROUTER_MAC; }