use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowServiceImpl method patchFlow.
@Override
public CompletableFuture<FlowResponseV2> patchFlow(String flowId, FlowPatchV2 flowPatchDto) {
logger.info("Patch flow request for flow {}", flowId);
String correlationId = RequestCorrelationId.getId();
FlowPatch flowPatch;
try {
flowPatch = flowMapper.toFlowPatch(flowPatchDto);
} catch (IllegalArgumentException e) {
logger.error("Can not parse arguments: {}", e.getMessage(), e);
throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments of the flow patch request");
}
flowPatch.setFlowId(flowId);
CommandMessage request = new CommandMessage(new FlowPatchRequest(flowPatch), System.currentTimeMillis(), correlationId);
return messagingChannel.sendAndGet(nbworkerTopic, request).thenApply(FlowResponse.class::cast).thenApply(FlowResponse::getPayload).thenApply(flowMapper::toFlowResponseV2);
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowOperationsServiceTest method shouldPrepareFlowUpdateResultWithNeedUpdateFlag.
@Test
public void shouldPrepareFlowUpdateResultWithNeedUpdateFlag() {
String flowId = "test_flow_id";
Flow flow = Flow.builder().flowId(flowId).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).srcPort(2).srcVlan(3).destSwitch(Switch.builder().switchId(new SwitchId(2)).build()).destPort(4).destVlan(5).bandwidth(1000).allocateProtectedPath(true).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(PathComputationStrategy.COST).build();
// new src switch
FlowPatch flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().switchId(new SwitchId(3)).build()).build();
UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new src port
flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().portNumber(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new src vlan
flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().vlanId(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new src inner vlan
flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().innerVlanId(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new src LLDP flag
flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().trackLldpConnectedDevices(true).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new src ARP flag
flowPatch = FlowPatch.builder().source(PatchEndpoint.builder().trackArpConnectedDevices(true).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst switch
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().switchId(new SwitchId(3)).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst port
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().portNumber(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst vlan
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().vlanId(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst inner vlan
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().innerVlanId(9).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst LLDP flag
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().trackLldpConnectedDevices(true).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new dst ARP flag
flowPatch = FlowPatch.builder().destination(PatchEndpoint.builder().trackArpConnectedDevices(true).build()).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new maximum bandwidth
flowPatch = FlowPatch.builder().bandwidth(9000L).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new flag allocate protected path
flowPatch = FlowPatch.builder().allocateProtectedPath(false).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// add diverse flow id
flowPatch = FlowPatch.builder().diverseFlowId("diverse_flow_id").build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new ignore bandwidth flag
flowPatch = FlowPatch.builder().ignoreBandwidth(true).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new encapsulation type
flowPatch = FlowPatch.builder().encapsulationType(FlowEncapsulationType.VXLAN).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
// new path computation strategy
flowPatch = FlowPatch.builder().pathComputationStrategy(PathComputationStrategy.LATENCY).build();
result = flowOperationsService.prepareFlowUpdateResult(flowPatch, flow).build();
assertTrue(result.isNeedUpdateFlow());
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowOperationsServiceTest method shouldPrepareFlowUpdateResultShouldNotUpdateFirstCase.
@Test
public void shouldPrepareFlowUpdateResultShouldNotUpdateFirstCase() {
// given: FlowPatch with max latency and MAX_LATENCY strategy
// and Flow with MAX_LATENCY strategy and same max latency
String flowId = "test_flow_id";
FlowPatch flowDto = FlowPatch.builder().flowId(flowId).maxLatency(100L).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).build();
Flow flow = Flow.builder().flowId(flowId).srcSwitch(Switch.builder().switchId(new SwitchId(1)).build()).destSwitch(Switch.builder().switchId(new SwitchId(2)).build()).maxLatency(100L).pathComputationStrategy(PathComputationStrategy.MAX_LATENCY).build();
// when: compare this flows
UpdateFlowResult result = flowOperationsService.prepareFlowUpdateResult(flowDto, flow).build();
// then: needRerouteFlow flag set to false
assertFalse(result.isNeedUpdateFlow());
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowOperationsServiceTest method testStrictBandwidthAndIgnoreBandwidthPatchConflict.
@Test(expected = IllegalArgumentException.class)
public void testStrictBandwidthAndIgnoreBandwidthPatchConflict() throws FlowNotFoundException {
String testFlowId = "flow_id";
Flow flow = new TestFlowBuilder().flowId(testFlowId).srcSwitch(createSwitch(SWITCH_ID_1)).destSwitch(createSwitch(SWITCH_ID_2)).build();
flowRepository.add(flow);
FlowPatch receivedFlow = FlowPatch.builder().flowId(testFlowId).strictBandwidth(true).ignoreBandwidth(true).build();
flowOperationsService.updateFlow(new FlowCarrierImpl(), receivedFlow);
}
use of org.openkilda.messaging.model.FlowPatch in project open-kilda by telstra.
the class FlowServiceImpl method patchFlow.
@Override
public CompletableFuture<FlowResponsePayload> patchFlow(String flowId, FlowPatchDto flowPatchDto) {
logger.info("Patch flow request for flow {}", flowId);
String correlationId = RequestCorrelationId.getId();
FlowPatch flowPatch;
try {
flowPatch = flowMapper.toFlowPatch(flowPatchDto);
} catch (IllegalArgumentException e) {
logger.error("Can not parse arguments: {}", e.getMessage(), e);
throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments of the flow patch request");
}
flowPatch.setFlowId(flowId);
CommandMessage request = new CommandMessage(new FlowPatchRequest(flowPatch), System.currentTimeMillis(), correlationId);
return messagingChannel.sendAndGet(nbworkerTopic, request).thenApply(FlowResponse.class::cast).thenApply(FlowResponse::getPayload).thenApply(flowMapper::toFlowResponseOutput);
}
Aggregations