use of org.openkilda.floodlight.error.SessionErrorResponseException in project open-kilda by telstra.
the class FlowSegmentReport method assembleResponse.
private SpeakerResponse assembleResponse() {
FlowErrorResponseBuilder errorResponse = makeErrorTemplate();
try {
raiseError();
return makeSuccessReply();
} catch (SwitchNotFoundException e) {
errorResponse.errorCode(ErrorCode.SWITCH_UNAVAILABLE);
} catch (SessionErrorResponseException e) {
decodeError(errorResponse, e.getErrorResponse());
} catch (SwitchMissingFlowsException e) {
errorResponse.errorCode(ErrorCode.MISSING_OF_FLOWS);
errorResponse.description(e.getMessage());
} catch (SwitchOperationException e) {
errorResponse.errorCode(ErrorCode.UNKNOWN);
errorResponse.description(e.getMessage());
} catch (Exception e) {
log.error(String.format("Unhandled exception while processing command %s", command), e);
errorResponse.errorCode(ErrorCode.UNKNOWN);
}
FlowErrorResponse response = errorResponse.build();
log.error("Command {} have failed - {} {}", command, response.getErrorCode(), response.getDescription());
return response;
}
use of org.openkilda.floodlight.error.SessionErrorResponseException in project open-kilda by telstra.
the class SpeakerCommand method setupErrorHandler.
protected CompletableFuture<Optional<OFMessage>> setupErrorHandler(CompletableFuture<Optional<OFMessage>> future, IOfErrorResponseHandler handler) {
CompletableFuture<Optional<OFMessage>> branch = new CompletableFuture<>();
future.whenComplete((response, error) -> {
if (error == null) {
branch.complete(response);
} else {
Throwable actualError = unwrapError(error);
if (actualError instanceof SessionErrorResponseException) {
OFErrorMsg errorResponse = ((SessionErrorResponseException) error).getErrorResponse();
propagateFutureResponse(branch, handler.handleOfError(errorResponse));
} else {
branch.completeExceptionally(actualError);
}
}
});
return branch;
}
use of org.openkilda.floodlight.error.SessionErrorResponseException in project open-kilda by telstra.
the class MeterInstallCommandTest method notConflictError.
@Test
public void notConflictError() throws Throwable {
switchFeaturesSetup(sw, true);
replayAll();
CompletableFuture<MeterInstallReport> result = command.execute(commandProcessor);
SessionWriteRecord write0 = getWriteRecord(0);
OFErrorMsg error = sw.getOFFactory().errorMsgs().buildBadRequestErrorMsg().setCode(OFBadRequestCode.BAD_LEN).build();
write0.getFuture().completeExceptionally(new SessionErrorResponseException(sw.getId(), error));
verifyErrorCompletion(result, SwitchErrorResponseException.class);
}
use of org.openkilda.floodlight.error.SessionErrorResponseException in project open-kilda by telstra.
the class MeterInstallCommandTest method processConflictError.
private CompletableFuture<MeterInstallReport> processConflictError() {
CompletableFuture<MeterInstallReport> result = command.execute(commandProcessor);
SessionWriteRecord write0 = getWriteRecord(0);
OFErrorMsg error = sw.getOFFactory().errorMsgs().buildMeterModFailedErrorMsg().setCode(OFMeterModFailedCode.METER_EXISTS).build();
write0.getFuture().completeExceptionally(new SessionErrorResponseException(sw.getId(), error));
return result;
}
use of org.openkilda.floodlight.error.SessionErrorResponseException in project open-kilda by telstra.
the class Session method handleResponse.
/**
* Handle switch response.
*
* <p>Lookup sent request by message Xid and mark it as completed(errored) if found. Return "true" if the
* session is completed and can be wiped, return "false" if the session need more responses.
*/
boolean handleResponse(OFMessage message) {
CompletableFuture<Optional<OFMessage>> future;
future = requestsByXid.get(message.getXid());
if (future == null) {
throw new IllegalArgumentException(String.format("%s must never route \"foreign\" response", group.getClass().getName()));
}
if (future.isDone()) {
// it can already be marked as failed by results of some session wide errors
return false;
}
// Setup correlationId (because this method called asynchronously by FL core).
try (CorrelationContext.CorrelationContextClosable closable = CorrelationContext.create(context.getCorrelationId())) {
if (OFType.ERROR == message.getType()) {
future.completeExceptionally(new SessionErrorResponseException(sw.getId(), (OFErrorMsg) message));
} else {
future.complete(Optional.of(message));
}
// check session completion (we have received all responses, if we got response for closing barrier request)
if (closingBarrier != null && closingBarrier.isDone()) {
incompleteRequestsStream().forEach(entry -> entry.complete(Optional.empty()));
return true;
}
return false;
}
}
Aggregations