Search in sources :

Example 1 with SharedEndpoint

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

the class AbstractYFlowTest method createYFlowViaTransit.

protected YFlow createYFlowViaTransit(String yFlowId) {
    // Create sub-flows
    Flow firstFlow = dummyFactory.makeMainAffinityFlow(firstSharedEndpoint, firstEndpoint, islSharedToTransit, islTransitToFirst);
    Flow secondFlow = dummyFactory.makeFlow(secondSharedEndpoint, secondEndpoint, firstFlow.getAffinityGroupId(), islSharedToTransit, islTransitToSecond);
    SwitchId yPoint = SWITCH_TRANSIT;
    FlowMeter yPointMeter = dummyFactory.makeFlowMeter(yPoint, yFlowId, null);
    FlowMeter sharedEndpointMeter = dummyFactory.makeFlowMeter(firstSharedEndpoint.getSwitchId(), yFlowId, null);
    YFlow yFlow = YFlow.builder().yFlowId(yFlowId).sharedEndpoint(new SharedEndpoint(firstSharedEndpoint.getSwitchId(), firstSharedEndpoint.getPortNumber())).sharedEndpointMeterId(sharedEndpointMeter.getMeterId()).yPoint(yPoint).meterId(yPointMeter.getMeterId()).status(FlowStatus.UP).build();
    yFlow.setSubFlows(Stream.of(firstFlow, secondFlow).map(flow -> YSubFlow.builder().sharedEndpointVlan(flow.getSrcVlan()).sharedEndpointInnerVlan(flow.getSrcInnerVlan()).endpointSwitchId(flow.getDestSwitchId()).endpointPort(flow.getDestPort()).endpointVlan(flow.getDestVlan()).endpointInnerVlan(flow.getDestInnerVlan()).flow(flow).yFlow(yFlow).build()).collect(Collectors.toSet()));
    YFlowRepository yFlowRepository = persistenceManager.getRepositoryFactory().createYFlowRepository();
    yFlowRepository.add(yFlow);
    return yFlow;
}
Also used : YFlow(org.openkilda.model.YFlow) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) SwitchId(org.openkilda.model.SwitchId) SharedEndpoint(org.openkilda.model.YFlow.SharedEndpoint) FlowMeter(org.openkilda.model.FlowMeter) Flow(org.openkilda.model.Flow) YSubFlow(org.openkilda.model.YSubFlow) YFlow(org.openkilda.model.YFlow)

Example 2 with SharedEndpoint

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

the class AbstractYFlowTest method createYFlowWithProtected.

protected YFlow createYFlowWithProtected(String yFlowId) {
    dummyFactory.getFlowDefaults().setAllocateProtectedPath(true);
    // Create sub-flows
    Flow firstFlow = dummyFactory.makeMainAffinityFlowWithProtectedPath(firstSharedEndpoint, firstEndpoint, asList(islSharedToTransit, islTransitToFirst), asList(islSharedToAltTransit, islAltTransitToFirst));
    Flow secondFlow = dummyFactory.makeFlowWithProtectedPath(secondSharedEndpoint, secondEndpoint, firstFlow.getAffinityGroupId(), asList(islSharedToTransit, islTransitToSecond), asList(islSharedToAltTransit, islAltTransitToSecond));
    YFlow yFlow = YFlow.builder().yFlowId(yFlowId).sharedEndpoint(new SharedEndpoint(firstSharedEndpoint.getSwitchId(), firstSharedEndpoint.getPortNumber())).allocateProtectedPath(true).status(FlowStatus.UP).build();
    yFlow.setSubFlows(Stream.of(firstFlow, secondFlow).map(flow -> YSubFlow.builder().sharedEndpointVlan(flow.getSrcVlan()).sharedEndpointInnerVlan(flow.getSrcInnerVlan()).endpointSwitchId(flow.getDestSwitchId()).endpointPort(flow.getDestPort()).endpointVlan(flow.getDestVlan()).endpointInnerVlan(flow.getDestInnerVlan()).flow(flow).yFlow(yFlow).build()).collect(Collectors.toSet()));
    YFlowRepository yFlowRepository = persistenceManager.getRepositoryFactory().createYFlowRepository();
    yFlowRepository.add(yFlow);
    return yFlow;
}
Also used : YFlow(org.openkilda.model.YFlow) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) SharedEndpoint(org.openkilda.model.YFlow.SharedEndpoint) Flow(org.openkilda.model.Flow) YSubFlow(org.openkilda.model.YSubFlow) YFlow(org.openkilda.model.YFlow)

Example 3 with SharedEndpoint

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

the class RerouteQueueServiceTest method shouldSendCorrectErrorMessageForManualRerouteRequestForPinnedYFlow.

@Test
public void shouldSendCorrectErrorMessageForManualRerouteRequestForPinnedYFlow() {
    String flowId = "test flow";
    when(yFlowRepository.findById(flowId)).thenReturn(Optional.of(YFlow.builder().yFlowId(flowId).sharedEndpoint(new SharedEndpoint(SWITCH_A.getSwitchId(), 10)).priority(2).pinned(true).build()));
    FlowThrottlingData actual = getFlowThrottlingData(yFlow, CORRELATION_ID).build();
    rerouteQueueService.processManualRequest(flowId, actual);
    assertEquals(0, rerouteQueueService.getReroutes().size());
    verify(carrier).emitFlowRerouteError(argThat(pinnedYFlowErrorData(flowId)));
}
Also used : FlowThrottlingData(org.openkilda.wfm.topology.reroute.model.FlowThrottlingData) SharedEndpoint(org.openkilda.model.YFlow.SharedEndpoint) Test(org.junit.Test)

Example 4 with SharedEndpoint

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

the class RerouteQueueServiceTest method setup.

@Before
public void setup() {
    flow = Flow.builder().flowId(FLOW_ID).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).priority(2).build();
    when(flowRepository.findById(FLOW_ID)).thenReturn(Optional.of(flow));
    yFlow = YFlow.builder().yFlowId(YFLOW_ID).sharedEndpoint(new SharedEndpoint(SWITCH_A.getSwitchId(), 10)).priority(2).build();
    when(yFlowRepository.findById(YFLOW_ID)).thenReturn(Optional.of(yFlow));
    RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
    when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
    when(repositoryFactory.createYFlowRepository()).thenReturn(yFlowRepository);
    PersistenceManager persistenceManager = mock(PersistenceManager.class);
    when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
    rerouteQueueService = new RerouteQueueService(carrier, persistenceManager, 0, 3);
}
Also used : PersistenceManager(org.openkilda.persistence.PersistenceManager) SharedEndpoint(org.openkilda.model.YFlow.SharedEndpoint) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) Before(org.junit.Before)

Example 5 with SharedEndpoint

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

the class AbstractFlowTest method createTestYFlowForSubFlow.

protected void createTestYFlowForSubFlow(Flow subFlow) {
    YFlow yFlow = YFlow.builder().yFlowId("test_y_flow").sharedEndpoint(new SharedEndpoint(subFlow.getSrcSwitchId(), subFlow.getSrcPort())).status(FlowStatus.UP).build();
    yFlow.setSubFlows(singleton(YSubFlow.builder().sharedEndpointVlan(subFlow.getSrcVlan()).sharedEndpointInnerVlan(subFlow.getSrcInnerVlan()).endpointSwitchId(subFlow.getDestSwitchId()).endpointPort(subFlow.getDestPort()).endpointVlan(subFlow.getDestVlan()).endpointInnerVlan(subFlow.getDestInnerVlan()).flow(subFlow).yFlow(yFlow).build()));
    YFlowRepository yFlowRepository = persistenceManager.getRepositoryFactory().createYFlowRepository();
    yFlowRepository.add(yFlow);
}
Also used : YFlow(org.openkilda.model.YFlow) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) SharedEndpoint(org.openkilda.model.YFlow.SharedEndpoint)

Aggregations

SharedEndpoint (org.openkilda.model.YFlow.SharedEndpoint)8 YFlow (org.openkilda.model.YFlow)5 YSubFlow (org.openkilda.model.YSubFlow)4 Flow (org.openkilda.model.Flow)3 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)3 Before (org.junit.Before)2 Test (org.junit.Test)2 PathId (org.openkilda.model.PathId)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 FlowMeter (org.openkilda.model.FlowMeter)1 FlowPath (org.openkilda.model.FlowPath)1 PathSegment (org.openkilda.model.PathSegment)1 SwitchId (org.openkilda.model.SwitchId)1 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)1 PersistenceManager (org.openkilda.persistence.PersistenceManager)1 RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)1 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)1