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;
}
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());
}
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();
}
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());
}
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;
}
Aggregations