use of org.opendaylight.yangtools.yang.common.RpcError in project controller by opendaylight.
the class RpcErrorsException method getRpcErrors.
public Collection<RpcError> getRpcErrors() {
final Collection<RpcError> rpcErrors = new ArrayList<>();
for (final RpcErrorData ed : rpcErrorDataList) {
final RpcError rpcError = ed.severity == ErrorSeverity.ERROR ? RpcResultBuilder.newError(ed.errorType, ed.tag, ed.message, ed.applicationTag, ed.info, ed.cause) : RpcResultBuilder.newWarning(ed.errorType, ed.tag, ed.message, ed.applicationTag, ed.info, ed.cause);
rpcErrors.add(rpcError);
}
return rpcErrors;
}
use of org.opendaylight.yangtools.yang.common.RpcError in project controller by opendaylight.
the class ClusterAdminRpcServiceTest method verifyFailedRpcResult.
private static void verifyFailedRpcResult(RpcResult<?> rpcResult) {
assertFalse("RpcResult", rpcResult.isSuccessful());
assertEquals("RpcResult errors size", 1, rpcResult.getErrors().size());
RpcError error = Iterables.getFirst(rpcResult.getErrors(), null);
assertNotNull("RpcResult error message null", error.getMessage());
}
use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.
the class HandshakeManagerImpl method sendHelloMessage.
/**
* send hello reply without versionBitmap.
*
* @param helloVersion initial hello version for openflow connection negotiation
* @param helloXid transaction id
*/
private ListenableFuture<Void> sendHelloMessage(Short helloVersion, final Long helloXid) throws Exception {
HelloInput helloInput = MessageFactory.createHelloInput(helloVersion, helloXid, versionOrder);
final SettableFuture<Void> resultFtr = SettableFuture.create();
LOG.debug("sending hello message: version{}, xid={}, version bitmap={}", helloVersion, helloXid, MessageFactory.digVersions(helloInput.getElements()));
Future<RpcResult<Void>> helloResult = connectionAdapter.hello(helloInput);
ListenableFuture<RpcResult<Void>> rpcResultListenableFuture = JdkFutureAdapters.listenInPoolThread(helloResult);
Futures.addCallback(rpcResultListenableFuture, new FutureCallback<RpcResult<Void>>() {
@Override
public void onSuccess(@Nonnull RpcResult<Void> result) {
if (result.isSuccessful()) {
LOG.debug("hello successfully sent, xid={}, addr={}", helloXid, connectionAdapter.getRemoteAddress());
resultFtr.set(null);
} else {
for (RpcError error : result.getErrors()) {
LOG.debug("hello sending failed [{}]: i:{} s:{} m:{}, addr:{}", helloXid, error.getInfo(), error.getSeverity(), error.getMessage(), connectionAdapter.getRemoteAddress());
if (error.getCause() != null) {
LOG.trace("DETAIL of sending hello failure", error.getCause());
}
}
resultFtr.cancel(false);
handshakeListener.onHandshakeFailure();
}
}
@Override
public void onFailure(Throwable throwable) {
LOG.warn("sending of hello failed seriously [{}, addr:{}]: {}", helloXid, connectionAdapter.getRemoteAddress(), throwable.getMessage());
LOG.trace("DETAIL of sending of hello failure:", throwable);
resultFtr.cancel(false);
handshakeListener.onHandshakeFailure();
}
}, MoreExecutors.directExecutor());
LOG.trace("sending hello message [{}] - result hooked ..", helloXid);
return resultFtr;
}
use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.
the class MultipartRequestOnTheFlyCallbackTest method testOnSuccessWithNotMultiNoMultipart.
@Test
public void testOnSuccessWithNotMultiNoMultipart() throws Exception {
final HelloMessage mockedHelloMessage = mock(HelloMessage.class);
multipartRequestOnTheFlyCallback.onSuccess(mockedHelloMessage);
final RpcResult<List<MultipartReply>> expectedRpcResult = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, String.format("Unexpected response type received: %s.", mockedHelloMessage.getClass())).build();
final RpcResult<List<MultipartReply>> actualResult = dummyRequestContext.getFuture().get();
assertNotNull(actualResult.getErrors());
assertEquals(1, actualResult.getErrors().size());
final RpcError actualError = actualResult.getErrors().iterator().next();
assertEquals(actualError.getMessage(), String.format("Unexpected response type received: %s.", mockedHelloMessage.getClass()));
assertEquals(actualError.getErrorType(), RpcError.ErrorType.APPLICATION);
assertEquals(expectedRpcResult.getResult(), actualResult.getResult());
assertEquals(expectedRpcResult.isSuccessful(), actualResult.isSuccessful());
Mockito.verify(mockedDeviceContext, Mockito.never()).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier>any(), Matchers.<DataObject>any());
Mockito.verify(mockedDeviceContext).submitTransaction();
}
use of org.opendaylight.yangtools.yang.common.RpcError in project openflowplugin by opendaylight.
the class OpendaylightDirectStatisticsServiceImplTest method testGetFlowStatisticsFail.
@Test
public void testGetFlowStatisticsFail() throws Exception {
RpcResult<GetFlowStatisticsOutput> result = emptyService.getFlowStatistics(getFlowStatisticsInput).get();
assertFalse(result.isSuccessful());
for (RpcError error : result.getErrors()) {
assertTrue(error.getMessage().contains(AbstractFlowDirectStatisticsService.class.getSimpleName()));
}
verify(flowDirectStatisticsService, times(0)).handleAndReply(getFlowStatisticsInput);
}
Aggregations