Fixed result processing in several services. 80/20880/2
authorMartin Bobak <mbobak@cisco.com>
Thu, 21 May 2015 09:23:07 +0000 (11:23 +0200)
committerMartin Bobak <mbobak@cisco.com>
Thu, 21 May 2015 10:31:23 +0000 (12:31 +0200)
- statistics gathering service doesn't set result to req. context
  on future's success that's multi message collector's job
- SalTableService doesn't use settable future instead of request
  context's future
- added missing statistics counter to salFlowService

Change-Id: If2107099602abb935f91c5f65bd84e079316798a
Signed-off-by: Martin Bobak <mbobak@cisco.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalTableServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/dedicated/StatisticsGatheringService.java

index d5d8605d240c68a33ecad96beeb8297f23620598..8342730fad7fe764fd6c6534974ab39f0cfae19c 100644 (file)
@@ -246,6 +246,7 @@ public class SalFlowServiceImpl extends CommonService implements SalFlowService
 
             @Override
             public void onFailure(final Throwable throwable) {
+                getMessageSpy().spyMessage(FlowModInput.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
                 RpcResultBuilder<T> rpcResultBuilder = RpcResultBuilder.<T>failed().withError(ErrorType.APPLICATION, throwable.getMessage(), throwable);
                 requestContext.setResult(rpcResultBuilder.build());
 
index d4a9d36c94e008f7ac4d48dc4fb0a3a41c05af27..a3edaf028d81bdb1ec40f3ad329f034cb1493792 100644 (file)
@@ -93,7 +93,6 @@ public class SalTableServiceImpl extends CommonService implements SalTableServic
                 mprInput.setMultipartRequestBody(caseBuilder.build());
                 final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
 
-                final SettableFuture<RpcResult<List<MultipartReply>>> settableFuture = SettableFuture.create();
                 final MultiMsgCollector multiMsgCollector = getDeviceContext().getMultiMsgCollector();
                 multiMsgCollector.registerMultipartRequestContext(requestContext);
 
@@ -112,7 +111,6 @@ public class SalTableServiceImpl extends CommonService implements SalTableServic
                             }
                         }
                         getMessageSpy().spyMessage(multipartRequestInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-                        settableFuture.set(RpcResultBuilder.<List<MultipartReply>>success().build());
                     }
 
                     @Override
@@ -121,10 +119,9 @@ public class SalTableServiceImpl extends CommonService implements SalTableServic
                         RequestContextUtil.closeRequstContext(requestContext);
                         multiMsgCollector.registerMultipartRequestContext(requestContext);
                         getMessageSpy().spyMessage(multipartRequestInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-                        settableFuture.set(rpcResultBuilder.build());
                     }
                 });
-                return settableFuture;
+                return requestContext.getFuture();
             }
         }
 
index 7710ce620e6facfda3c0147fb4e1835c09f1da5c..15f5650d5fffd7d1810771a4bf9ec2a4b54f24dd 100644 (file)
@@ -64,13 +64,16 @@ public class StatisticsGatheringService extends CommonService {
                                              public void onSuccess(final OfHeader ofHeader) {
                                                  if (ofHeader instanceof MultipartReply) {
                                                      final MultipartReply multipartReply = (MultipartReply) ofHeader;
-                                                     requestContext.setResult(RpcResultBuilder.<List<MultipartReply>>success().build());
                                                      multiMsgCollector.addMultipartMsg(multipartReply);
                                                  } else {
                                                      if (null != ofHeader) {
                                                          LOG.info("Unexpected response type received {}.", ofHeader.getClass());
+                                                         RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, String.format("Unexpected response type received %s.", ofHeader.getClass()));
+                                                         requestContext.setResult(rpcResultBuilder.build());
                                                      } else {
                                                          LOG.info("Ofheader was null.");
+                                                         RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, "OfHeader was null");
+                                                         requestContext.setResult(rpcResultBuilder.build());
                                                      }
                                                  }
                                              }
@@ -79,7 +82,6 @@ public class StatisticsGatheringService extends CommonService {
                                              public void onFailure(final Throwable throwable) {
                                                  RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage());
                                                  requestContext.setResult(rpcResultBuilder.build());
-
                                                  RequestContextUtil.closeRequstContext(requestContext);
                                              }
                                          });