Search in sources :

Example 1 with DeviceRequestFailedException

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());
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) RpcError(org.opendaylight.yangtools.yang.common.RpcError) DeviceRequestFailedException(org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ErrorMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage) Test(org.junit.Test)

Example 2 with DeviceRequestFailedException

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);
}
Also used : DeviceRequestFailedException(org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException) Error(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 3 with DeviceRequestFailedException

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);
}
Also used : Error(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error) DeviceRequestFailedException(org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException)

Aggregations

DeviceRequestFailedException (org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException)3 Error (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error)2 RpcError (org.opendaylight.yangtools.yang.common.RpcError)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Test (org.junit.Test)1 ErrorMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage)1 ErrorMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder)1