use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowCreateHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = pullKey(input);
FlowRequest payload = pullValue(input, FIELD_ID_PAYLOAD, FlowRequest.class);
try {
service.handleRequest(currentKey, getCommandContext(), payload);
} catch (DuplicateKeyException e) {
log.error("Failed to handle a request with key {}. {}", currentKey, e.getMessage());
}
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateFlowIfNoPathAvailable.
@Test
public void shouldFailUpdateFlowIfNoPathAvailable() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
Flow origin = makeFlow();
when(pathComputer.getPath(makeFlowArgumentMatch(origin.getFlowId()), anyCollection())).thenThrow(new UnroutableFlowException(injectedErrorMessage));
FlowRequest request = makeRequest().flowId(origin.getFlowId()).bandwidth(origin.getBandwidth() + 1).build();
Flow result = testExpectedFailure(request, origin, ErrorType.NOT_FOUND);
Assert.assertEquals(origin.getBandwidth(), result.getBandwidth());
verify(pathComputer, times(11)).getPath(makeFlowArgumentMatch(origin.getFlowId()), any());
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateOnUnsuccessfulValidation.
@Test
public void shouldFailUpdateOnUnsuccessfulValidation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
FlowUpdateService service = makeService();
service.handleUpdateRequest(dummyRequestKey, commandContext, request);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
verifyNorthboundSuccessResponse(carrier);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (speakerRequest.isVerifyRequest()) {
service.handleAsyncResponse(dummyRequestKey, FlowErrorResponse.errorBuilder().errorCode(ErrorCode.UNKNOWN).description(injectedErrorMessage).messageContext(speakerRequest.getMessageContext()).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).build());
} else {
service.handleAsyncResponse(dummyRequestKey, SpeakerFlowSegmentResponse.builder().messageContext(speakerRequest.getMessageContext()).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).success(true).build());
}
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyNoPathReplace(origin, result);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateFlowIfRecoverableException.
@Test
public void shouldFailUpdateFlowIfRecoverableException() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
Flow origin = makeFlow();
when(pathComputer.getPath(makeFlowArgumentMatch(origin.getFlowId()), anyCollection())).thenThrow(new RecoverableException(injectedErrorMessage));
FlowRequest request = makeRequest().flowId(origin.getFlowId()).bandwidth(origin.getBandwidth() + 1).build();
testExpectedFailure(request, origin, ErrorType.INTERNAL_ERROR);
verify(pathComputer, times(PATH_ALLOCATION_RETRIES_LIMIT + 1)).getPath(makeFlowArgumentMatch(origin.getFlowId()), any());
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateOnUnsuccessfulInstallation.
@Test
public void shouldFailUpdateOnUnsuccessfulInstallation() throws RecoverableException, UnroutableFlowException, DuplicateKeyException, UnknownKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
FlowUpdateService service = makeService();
service.handleUpdateRequest(dummyRequestKey, commandContext, request);
verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
verifyNorthboundSuccessResponse(carrier);
FlowSegmentRequest speakerRequest;
while ((speakerRequest = requests.poll()) != null) {
if (speakerRequest.isInstallRequest()) {
service.handleAsyncResponse(dummyRequestKey, FlowErrorResponse.errorBuilder().messageContext(speakerRequest.getMessageContext()).errorCode(ErrorCode.UNKNOWN).description("Switch is unavailable").commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).build());
} else {
service.handleAsyncResponse(dummyRequestKey, SpeakerFlowSegmentResponse.builder().messageContext(speakerRequest.getMessageContext()).commandId(speakerRequest.getCommandId()).metadata(speakerRequest.getMetadata()).switchId(speakerRequest.getSwitchId()).success(true).build());
}
}
Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
verifyNoPathReplace(origin, result);
}
Aggregations