Merge "SONAR TD - Remove unused fields, fix naming" into stable/boron
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / SalMeterServiceImpl.java
index 2ed7df5f8441bb953abc7dba3ad208074647c786..d96e2190120bf5812059096991907e7e8f8683a1 100644 (file)
@@ -60,19 +60,18 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
 
     @Override
     public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
-        addMeter.getDeviceRegistry().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()) {
-                    if(LOG.isDebugEnabled()) {
+                   if(LOG.isDebugEnabled()) {
                         LOG.debug("Meter add finished without error, id={}", input.getMeterId());
                     }
+                    deviceContext.getDeviceMeterRegistry().store(input.getMeterId());
                     addIfNecessaryToDS(input.getMeterId(),input);
-                }else{
+                } else {
                     LOG.error("Meter add with id {} failed with error {}", input.getMeterId(),
                             errorsToString(result.getErrors()));
                 }
@@ -80,7 +79,7 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
 
             @Override
             public void onFailure(Throwable t) {
-                LOG.error("Meter add failed for id={}. Exception {}", input.getMeterId(), t);
+                 LOG.error("Meter add failed for id={}. Exception {}", input.getMeterId(), t);
             }
         });
 
@@ -90,7 +89,6 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
     @Override
     public Future<RpcResult<UpdateMeterOutput>> updateMeter(final UpdateMeterInput input) {
         final ListenableFuture<RpcResult<UpdateMeterOutput>> resultFuture = updateMeter.handleServiceCall(input.getUpdatedMeter());
-
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<UpdateMeterOutput>>() {
 
             @Override
@@ -177,4 +175,4 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
         }
         return errors.toString();
     }
-}
+}
\ No newline at end of file