Search in sources :

Example 31 with PathId

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

the class FermaFlowPathRepositoryTest method buildTestFlow.

private Flow buildTestFlow(String flowId, Switch srcSwitch, int srcPort, int srcVlan, Switch destSwitch, int destPort, int destVlan) {
    Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(srcPort).srcVlan(srcVlan).destSwitch(destSwitch).destPort(destPort).destVlan(destVlan).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).status(FlowStatus.UP).build();
    FlowPath forwardFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_forward_path")).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, 1L)).meterId(new MeterId(1)).srcSwitch(srcSwitch).destSwitch(destSwitch).status(FlowPathStatus.ACTIVE).build();
    flow.setForwardPath(forwardFlowPath);
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardFlowPath.getPathId()).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(destSwitch).destPort(destPort).build();
    forwardFlowPath.setSegments(Collections.singletonList(forwardSegment));
    FlowPath reverseFlowPath = FlowPath.builder().pathId(new PathId(flowId + "_reverse_path")).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, 1L)).meterId(new MeterId(2)).srcSwitch(destSwitch).destSwitch(srcSwitch).status(FlowPathStatus.ACTIVE).build();
    flow.setReversePath(reverseFlowPath);
    PathSegment reverseSegment = PathSegment.builder().pathId(reverseFlowPath.getPathId()).srcSwitch(destSwitch).srcPort(destPort).destSwitch(srcSwitch).destPort(srcPort).build();
    reverseFlowPath.setSegments(Collections.singletonList(reverseSegment));
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Example 32 with PathId

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

the class FermaMirrorGroupRepositoryTest method shouldGetZeroMirrorGroupsForPath.

@Test
public void shouldGetZeroMirrorGroupsForPath() {
    Collection<MirrorGroup> meters = mirrorGroupRepository.findByPathId(new PathId(TEST_PATH_ID));
    assertTrue(meters.isEmpty());
}
Also used : PathId(org.openkilda.model.PathId) MirrorGroup(org.openkilda.model.MirrorGroup) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 33 with PathId

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

the class FermaFlowMeterRepositoryTest method shouldNotGetMoreThanOneMetersForPath.

@Ignore("InMemoryGraph doesn't enforce constraint")
@Test(expected = PersistenceException.class)
public void shouldNotGetMoreThanOneMetersForPath() {
    createFlowMeter(1, new PathId(TEST_PATH_ID));
    createFlowMeter(2, new PathId(TEST_PATH_ID));
    flowMeterRepository.findByPathId(new PathId(TEST_PATH_ID));
}
Also used : PathId(org.openkilda.model.PathId) Ignore(org.junit.Ignore) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 34 with PathId

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

the class FermaFlowMeterRepositoryTest method findUnassignedMeterAndCreate.

private long findUnassignedMeterAndCreate(String flowId, String pathId) {
    MeterId availableMeterId = flowMeterRepository.findFirstUnassignedMeter(theSwitch.getSwitchId(), MIN_METER_ID, MAX_METER_ID).get();
    FlowMeter flowMeterId = FlowMeter.builder().switchId(theSwitch.getSwitchId()).meterId(availableMeterId).pathId(new PathId(flowId + "_" + pathId)).flowId(flowId).build();
    flowMeterRepository.add(flowMeterId);
    return availableMeterId.getValue();
}
Also used : PathId(org.openkilda.model.PathId) FlowMeter(org.openkilda.model.FlowMeter) MeterId(org.openkilda.model.MeterId)

Example 35 with PathId

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

the class FermaIslRepositoryTest method createFlowWithPath.

private Flow createFlowWithPath(int forwardBandwidth, int reverseBandwidth) {
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(switchA).destSwitch(switchB).status(FlowStatus.UP).build();
    FlowPath forwardPath = FlowPath.builder().srcSwitch(switchA).destSwitch(switchB).pathId(new PathId(TEST_FLOW_ID + "_forward_path")).cookie(new FlowSegmentCookie(1)).meterId(new MeterId(1)).status(FlowPathStatus.ACTIVE).bandwidth(forwardBandwidth).ignoreBandwidth(false).build();
    flow.setForwardPath(forwardPath);
    PathSegment forwardSegment = PathSegment.builder().pathId(forwardPath.getPathId()).srcSwitch(switchA).srcPort(1).destSwitch(switchB).destPort(2).build();
    forwardPath.setSegments(Collections.singletonList(forwardSegment));
    FlowPath reversePath = FlowPath.builder().srcSwitch(switchB).destSwitch(switchA).pathId(new PathId(TEST_FLOW_ID + "_reverse_path")).cookie(new FlowSegmentCookie(2)).meterId(new MeterId(2)).status(FlowPathStatus.ACTIVE).bandwidth(reverseBandwidth).ignoreBandwidth(false).build();
    flow.setReversePath(reversePath);
    PathSegment reverseSegment = PathSegment.builder().pathId(reversePath.getPathId()).srcSwitch(switchB).srcPort(2).destSwitch(switchA).destPort(1).build();
    reversePath.setSegments(Collections.singletonList(reverseSegment));
    flowRepository.add(flow);
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) MeterId(org.openkilda.model.MeterId)

Aggregations

PathId (org.openkilda.model.PathId)124 Flow (org.openkilda.model.Flow)65 FlowPath (org.openkilda.model.FlowPath)65 Test (org.junit.Test)44 Switch (org.openkilda.model.Switch)29 SwitchId (org.openkilda.model.SwitchId)28 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)27 PathSegment (org.openkilda.model.PathSegment)26 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)21 MeterId (org.openkilda.model.MeterId)19 ArrayList (java.util.ArrayList)18 List (java.util.List)13 Slf4j (lombok.extern.slf4j.Slf4j)11 GetPathsResult (org.openkilda.pce.GetPathsResult)11 FlowMirrorPoints (org.openkilda.model.FlowMirrorPoints)10 Path (org.openkilda.pce.Path)10 Collection (java.util.Collection)9 RecoverableException (org.openkilda.pce.exception.RecoverableException)9 String.format (java.lang.String.format)8 HashMap (java.util.HashMap)8