Search in sources :

Example 1 with FlowMeter

use of org.openkilda.model.FlowMeter 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 FlowMeter

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

the class FermaFlowMeterRepositoryTest method shouldDeleteFoundFlowMeter.

@Test
public void shouldDeleteFoundFlowMeter() {
    createFlowMeter();
    transactionManager.doInTransaction(() -> {
        Collection<FlowMeter> allMeters = flowMeterRepository.findAll();
        FlowMeter foundMeter = allMeters.iterator().next();
        flowMeterRepository.remove(foundMeter);
    });
    assertEquals(0, flowMeterRepository.findAll().size());
}
Also used : FlowMeter(org.openkilda.model.FlowMeter) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 3 with FlowMeter

use of org.openkilda.model.FlowMeter 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 4 with FlowMeter

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

the class FermaFlowMeterRepositoryTest method shouldDeleteFlowMeter.

@Test
public void shouldDeleteFlowMeter() {
    FlowMeter meter = createFlowMeter();
    transactionManager.doInTransaction(() -> flowMeterRepository.remove(meter));
    assertEquals(0, flowMeterRepository.findAll().size());
}
Also used : FlowMeter(org.openkilda.model.FlowMeter) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 5 with FlowMeter

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

the class FermaFlowMeterRepositoryTest method createFlowMeter.

private FlowMeter createFlowMeter(int meterId, PathId pathId) {
    FlowMeter flowMeter = FlowMeter.builder().switchId(theSwitch.getSwitchId()).meterId(new MeterId(meterId)).pathId(pathId).flowId(TEST_FLOW_ID).build();
    flowMeterRepository.add(flowMeter);
    return flowMeter;
}
Also used : FlowMeter(org.openkilda.model.FlowMeter) MeterId(org.openkilda.model.MeterId)

Aggregations

FlowMeter (org.openkilda.model.FlowMeter)11 Test (org.junit.Test)4 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)4 MeterId (org.openkilda.model.MeterId)3 FlowPath (org.openkilda.model.FlowPath)2 PathId (org.openkilda.model.PathId)2 MeterInfoEntry (org.openkilda.messaging.info.switches.MeterInfoEntry)1 Flow (org.openkilda.model.Flow)1 SwitchId (org.openkilda.model.SwitchId)1 YFlow (org.openkilda.model.YFlow)1 SharedEndpoint (org.openkilda.model.YFlow.SharedEndpoint)1 YSubFlow (org.openkilda.model.YSubFlow)1 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)1