use of org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException in project openflowplugin by opendaylight.
the class AbstractRequestCallbackTest method testOnFailureWithDeviceRequestFailedException.
@Test
public void testOnFailureWithDeviceRequestFailedException() throws Exception {
ErrorMessage dummyErrorMessage = new ErrorMessageBuilder().build();
abstractRequestCallback.onFailure(new DeviceRequestFailedException(DUMMY_EXCEPTION_DESCRIPTION, dummyErrorMessage));
final ListenableFuture futureResult = dummyRequestContext.getFuture();
RpcError rpcError = provideRpcError(futureResult);
assertEquals("Device reported error type null code null", rpcError.getMessage());
}
use of org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException in project openflowplugin by opendaylight.
the class AbstractRequestCallback method onFailure.
@Override
public final void onFailure(@Nonnull final Throwable throwable) {
final RpcResultBuilder<T> builder;
if (null != eventIdentifier) {
EventsTimeCounter.markEnd(eventIdentifier);
}
if (throwable instanceof DeviceRequestFailedException) {
final Error err = ((DeviceRequestFailedException) throwable).getError();
final String errorString = String.format("Device reported error type %s code %s", err.getTypeString(), err.getCodeString());
builder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, errorString, throwable);
spyMessage(StatisticsGroup.TO_SWITCH_SUBMIT_FAILURE);
} else {
builder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
spyMessage(StatisticsGroup.TO_SWITCH_SUBMIT_ERROR);
}
context.setResult(builder.build());
RequestContextUtil.closeRequestContext(context);
}
use of org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException in project openflowplugin by opendaylight.
the class StackedSegment method completeEntry.
private static boolean completeEntry(final OutboundQueueEntry entry, final OfHeader response) {
if (response instanceof Error) {
final Error err = (Error) response;
LOG.debug("Device-reported request XID {} failed {}:{}", response.getXid(), err.getTypeString(), err.getCodeString());
entry.fail(new DeviceRequestFailedException("Device-side failure", err));
return true;
}
return entry.complete(response);
}
Aggregations