Device*Registry quickfix - add failed 31/43131/3
authorAndrej Leitner <andrej.leitner@pantheon.tech>
Thu, 4 Aug 2016 15:47:49 +0000 (17:47 +0200)
committerAndrej Leitner <andrej.leitner@pantheon.tech>
Fri, 5 Aug 2016 07:34:56 +0000 (09:34 +0200)
 - remove *Descriptor from cache if add* request failed
 [*-Flow/Group/Meter]

Change-Id: I7b88db179c54de9670e2f7ecb4903074aa4dc6a9
Signed-off-by: Andrej Leitner <andrej.leitner@pantheon.tech>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalFlowServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalGroupServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalMeterServiceImpl.java

index c0ab557425994f2d06426f6820db02fdbb4099ab..8975de138a5631e7915858f8383dde0005a7fdee 100644 (file)
@@ -106,8 +106,10 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                         itemLifecycleListener.onAdded(flowPath, flowBuilder.build());
                     }
                 } else {
-                LOG.error("flow add failed for id={}, errors={}", flowId.getValue(), errorsToString(rpcResult.getErrors()));
-            }
+                    deviceContext.getDeviceFlowRegistry().markToBeremoved(flowRegistryKey);
+                    LOG.error("flow add failed for id={}, errors={}", flowId.getValue(),
+                            errorsToString(rpcResult.getErrors()));
+                }
             }
 
             @Override
index cdbc10b6f08f0083cf503a734154994c0ca60c6a..b9fa43a523dd87d5a5e2f768381fbb720e84d717 100644 (file)
@@ -59,7 +59,7 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
 
     @Override
     public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
-        addGroup.getDeviceRegistry().getDeviceGroupRegistry().store(input.getGroupId());
+        deviceContext.getDeviceGroupRegistry().store(input.getGroupId());
         final ListenableFuture<RpcResult<AddGroupOutput>> resultFuture = addGroup.handleServiceCall(input);
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<AddGroupOutput>>() {
             @Override
@@ -70,15 +70,16 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
                     }
                     addIfNecessaryToDS(input.getGroupId(), input);
                 } else {
-                LOG.error("group add with id={} failed, errors={}", input.getGroupId().getValue(),
-                        errorsToString(result.getErrors()));
-                 }
+                    deviceContext.getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
+                    LOG.error("group add with id={} failed, errors={}", input.getGroupId().getValue(),
+                            errorsToString(result.getErrors()));
+                }
             }
 
             @Override
             public void onFailure(Throwable t) {
-                LOG.error("Service call for group add failed for id={}. Exception: {}",
-                        input.getGroupId().getValue(), t);
+                deviceContext.getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
+                LOG.error("Service call for group add failed for id={}. Exception: {}", input.getGroupId().getValue(), t);
             }
         });
 
index b053d99cb8fc361361d93ccbebe1d0be955b5f36..5a5552e55a0c8fe4628aefeea5163007ad2ba692 100644 (file)
@@ -59,11 +59,9 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
 
     @Override
     public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
-        addMeter.getDeviceRegistry().getDeviceMeterRegistry().store(input.getMeterId());
-
+        deviceContext.getDeviceMeterRegistry().store(input.getMeterId());
         final ListenableFuture<RpcResult<AddMeterOutput>> resultFuture = addMeter.handleServiceCall(input);
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<AddMeterOutput>>() {
-
             @Override
             public void onSuccess(@Nullable RpcResult<AddMeterOutput> result) {
                 if (result.isSuccessful()) {
@@ -71,7 +69,8 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
                         LOG.debug("Meter add finished without error, id={}", input.getMeterId());
                     }
                     addIfNecessaryToDS(input.getMeterId(),input);
-                }else{
+                } else {
+                    deviceContext.getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
                     LOG.error("Meter add with id {} failed with error {}", input.getMeterId(),
                             errorsToString(result.getErrors()));
                 }
@@ -79,6 +78,7 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
 
             @Override
             public void onFailure(Throwable t) {
+                deviceContext.getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
                 LOG.error("Meter add failed for id={}. Exception {}", input.getMeterId(), t);
             }
         });