use of org.openkilda.model.MeterId 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.MeterId 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;
}
use of org.openkilda.model.MeterId 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;
}
use of org.openkilda.model.MeterId in project open-kilda by telstra.
the class FlowMeterModifyFsm method modifyMeters.
protected void modifyMeters(FlowMeterModifyState from, FlowMeterModifyState to, FlowMeterModifyEvent event, Object context) {
log.info("Key: {}; Send commands to modify meters", key);
SwitchId forwardSwitchId = flow.getForwardPath().getSrcSwitchId();
SwitchId reverseSwitchId = flow.getReversePath().getSrcSwitchId();
long bandwidth = flow.getForwardPath().getBandwidth();
MeterId forwardMeterId = flow.getForwardPath().getMeterId();
MeterId reverseMeterId = flow.getReversePath().getMeterId();
if (forwardMeterId == null || reverseMeterId == null) {
sendException(String.format("Flow '%s' is unmetered", flowId), "Modify meters in FlowMeterModifyFsm ", ErrorType.REQUEST_INVALID);
return;
}
carrier.sendCommandToSpeakerWorker(key, new MeterModifyCommandRequest(forwardSwitchId, forwardMeterId.getValue(), bandwidth));
carrier.sendCommandToSpeakerWorker(key, new MeterModifyCommandRequest(reverseSwitchId, reverseMeterId.getValue(), bandwidth));
}
use of org.openkilda.model.MeterId in project open-kilda by telstra.
the class RuleManagerHelperTest method buildFullFlowSpeakerCommandData.
private FlowSpeakerData buildFullFlowSpeakerCommandData(MeterId goToMeterId, UUID dependsOnUuid) {
Set<FieldMatch> match = Arrays.stream(Field.values()).map(f -> FieldMatch.builder().field(f).value(f.ordinal()).mask(f.ordinal() + 1L).build()).collect(Collectors.toSet());
Set<OfFlowFlag> flags = Sets.newHashSet(OfFlowFlag.values());
List<Action> applyActions = new ArrayList<>(buildAllActions());
applyActions.addAll(buildAllActions());
Instructions instructions = Instructions.builder().goToMeter(goToMeterId).goToTable(OfTable.INPUT).writeMetadata(new OfMetadata(15, 0xff)).writeActions(new HashSet<>(buildAllActions())).applyActions(applyActions).build();
return FlowSpeakerData.builder().uuid(UUID.randomUUID()).cookie(new Cookie(123)).priority(PRIORITY).table(OfTable.INPUT).match(match).instructions(instructions).flags(flags).switchId(SWITCH_ID).ofVersion(OfVersion.OF_13).dependsOn(dependsOnUuid == null ? newArrayList() : newArrayList(dependsOnUuid)).build();
}
Aggregations