Search in sources :

Example 56 with FlowSegmentCookie

use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.

the class FermaSwitchRepositoryTest method createOneSwitchFlow.

private void createOneSwitchFlow() {
    Switch switchA = createTestSwitch(TEST_SWITCH_ID_A.getId());
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID_A).srcSwitch(switchA).srcPort(1).destSwitch(switchA).destPort(2).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(switchA).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(switchA).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    flowRepository.add(flow);
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Example 57 with FlowSegmentCookie

use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.

the class FermaSwitchRepositoryTest method createTwoFlows.

private void createTwoFlows() {
    Switch switchA = createTestSwitch(TEST_SWITCH_ID_A.getId());
    Switch switchB = createTestSwitch(TEST_SWITCH_ID_B.getId());
    // create flow TEST_FLOW_ID_A
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID_A).srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(4).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(switchA).destSwitch(switchB).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(2).destSwitch(switchB).destPort(3).build();
    forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_A + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(switchB).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchB).srcPort(3).destSwitch(switchA).destPort(2).build();
    reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
    flowRepository.add(flow);
    Switch switchC = createTestSwitch(TEST_SWITCH_ID_C.getId());
    // create flow TEST_FLOW_ID_B
    flow = Flow.builder().flowId(TEST_FLOW_ID_B).srcSwitch(switchA).srcPort(1).destSwitch(switchC).destPort(7).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    forwardFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(3)).srcSwitch(switchA).destSwitch(switchC).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    PathSegment forwardSegmentA = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchA).srcPort(2).destSwitch(switchB).destPort(3).build();
    PathSegment forwardSegmentB = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(switchB).srcPort(5).destSwitch(switchC).destPort(6).build();
    forwardFlowPath.setSegments(Lists.newArrayList(forwardSegmentA, forwardSegmentB));
    reverseFlowPath = FlowPath.builder().pathId(new PathId(TEST_FLOW_ID_B + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(4)).srcSwitch(switchC).destSwitch(switchA).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    PathSegment reverseSegmentA = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchC).srcPort(6).destSwitch(switchB).destPort(5).build();
    PathSegment reverseSegmentB = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(switchB).srcPort(3).destSwitch(switchA).destPort(2).build();
    reverseFlowPath.setSegments(Lists.newArrayList(reverseSegmentA, reverseSegmentB));
    flowRepository.add(flow);
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Example 58 with FlowSegmentCookie

use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.

the class KildaEntryCacheServiceTest method shouldRefreshYFlowSubFlowCookieCache.

@Test
public void shouldRefreshYFlowSubFlowCookieCache() {
    Switch srcSwitch = Switch.builder().switchId(SRC_SWITCH_ID).build();
    Switch destSwitch = Switch.builder().switchId(DST_SWITCH_ID).build();
    Switch transitSwitch = Switch.builder().switchId(TRANSIT_SWITCH_ID).build();
    Flow flow = new TestFlowBuilder().yFlowId("dummy-y-flow-id").srcSwitch(srcSwitch).addTransitionEndpoint(srcSwitch, 2).addTransitionEndpoint(transitSwitch, 1).addTransitionEndpoint(transitSwitch, 2).addTransitionEndpoint(destSwitch, 1).unmaskedCookie(FLOW_UNMASKED_COOKIE).forwardMeterId(FORWARD_METER_ID).reverseMeterId(REVERSE_METER_ID).destSwitch(destSwitch).build();
    when(flowRepository.findAll()).thenReturn(Collections.singletonList(flow));
    when(yFlowRepository.findAll()).thenReturn(Collections.emptyList());
    service.refreshCache();
    final FlowSegmentCookie forwardPathCookie = flow.getForwardPath().getCookie();
    final FlowSegmentCookie reversePathCookie = flow.getReversePath().getCookie();
    // source switch
    service.completeAndForwardFlowStats(new FlowStatsData(flow.getSrcSwitchId(), asList(new FlowStatsEntry(0, forwardPathCookie.getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, reversePathCookie.getValue(), 0, 0, 0, 0))));
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    List<FlowStatsAndDescriptor> statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 2, 2);
    assertCookieCache(statsEntries, forwardPathCookie, new YFlowSubDescriptor(flow.getSrcSwitchId(), INGRESS, flow.getYFlowId(), flow.getFlowId(), forwardPathCookie, flow.getForwardPath().getMeterId()));
    assertCookieCache(statsEntries, reversePathCookie, new YFlowSubDescriptor(flow.getSrcSwitchId(), EGRESS, flow.getYFlowId(), flow.getFlowId(), reversePathCookie, null));
    // transit
    service.completeAndForwardFlowStats(new FlowStatsData(transitSwitch.getSwitchId(), asList(new FlowStatsEntry(0, forwardPathCookie.getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, reversePathCookie.getValue(), 0, 0, 0, 0))));
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 2, 2);
    assertCookieCache(statsEntries, forwardPathCookie, new YFlowSubDescriptor(transitSwitch.getSwitchId(), TRANSIT, flow.getYFlowId(), flow.getFlowId(), forwardPathCookie, null));
    assertCookieCache(statsEntries, reversePathCookie, new YFlowSubDescriptor(transitSwitch.getSwitchId(), TRANSIT, flow.getYFlowId(), flow.getFlowId(), reversePathCookie, null));
    // egress
    service.completeAndForwardFlowStats(new FlowStatsData(flow.getDestSwitchId(), asList(new FlowStatsEntry(0, forwardPathCookie.getValue(), 0, 0, 0, 0), new FlowStatsEntry(0, reversePathCookie.getValue(), 0, 0, 0, 0))));
    verify(carrier, atLeastOnce()).emitFlowStats(cookieCacheCaptor.capture());
    statsEntries = cookieCacheCaptor.getValue().getStatsEntries();
    assertDescriptionPopulation(statsEntries, 2, 2);
    assertCookieCache(statsEntries, forwardPathCookie, new YFlowSubDescriptor(flow.getDestSwitchId(), EGRESS, flow.getYFlowId(), flow.getFlowId(), forwardPathCookie, null));
    assertCookieCache(statsEntries, reversePathCookie, new YFlowSubDescriptor(flow.getDestSwitchId(), INGRESS, flow.getYFlowId(), flow.getFlowId(), reversePathCookie, flow.getReversePath().getMeterId()));
}
Also used : FlowStatsAndDescriptor(org.openkilda.wfm.topology.stats.model.FlowStatsAndDescriptor) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) FlowStatsEntry(org.openkilda.messaging.info.stats.FlowStatsEntry) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) YFlowSubDescriptor(org.openkilda.wfm.topology.stats.model.YFlowSubDescriptor) TestFlowBuilder(org.openkilda.wfm.share.flow.TestFlowBuilder) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) Test(org.junit.Test)

Example 59 with FlowSegmentCookie

use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.

the class FlowEndpointStatsEntryHandler method emitMeterPoints.

private void emitMeterPoints(TagsFormatter tags, MeasurePoint measurePoint) {
    FlowSegmentCookie cookie = decodeFlowSegmentCookie(statsEntry.getCookie());
    if (cookie != null && !isFlowSatelliteEntry(cookie)) {
        directionFromCookieIntoTags(cookie, tags);
        switch(measurePoint) {
            case INGRESS:
                emitIngressPoints(tags);
                break;
            case EGRESS:
                emitEgressPoints(tags);
                break;
            case ONE_SWITCH:
                emitIngressPoints(tags);
                emitEgressPoints(tags);
                break;
            default:
        }
    }
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie)

Aggregations

FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)59 Flow (org.openkilda.model.Flow)33 FlowPath (org.openkilda.model.FlowPath)31 PathId (org.openkilda.model.PathId)23 MeterId (org.openkilda.model.MeterId)19 Test (org.junit.Test)15 PathSegment (org.openkilda.model.PathSegment)15 Switch (org.openkilda.model.Switch)15 ArrayList (java.util.ArrayList)8 SwitchId (org.openkilda.model.SwitchId)8 FlowEntry (org.openkilda.messaging.info.rule.FlowEntry)6 UUID (java.util.UUID)5 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)5 IngressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory)5 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)5 DeleteRulesCriteria (org.openkilda.messaging.command.switches.DeleteRulesCriteria)4 MirrorConfig (org.openkilda.model.MirrorConfig)4 YFlow (org.openkilda.model.YFlow)4 Before (org.junit.Before)3 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)3