Bug 6176 - Decrease logging level in Sal-F/G/M-Service and use synchronized BiMap 68/44868/5
authorAndrej Leitner <andrej.leitner@pantheon.tech>
Tue, 30 Aug 2016 15:09:28 +0000 (17:09 +0200)
committerAndrej Leitner <andrej.leitner@pantheon.sk>
Wed, 31 Aug 2016 20:41:51 +0000 (20:41 +0000)
 - decrease logging level to prevent overloading of netty
   thread with logging errors (seen in troughput test)
 - despite the fact that unsuccesful RPCresult brings errors
   from device there is no reason for throwing error since
   it is not error of karaf ot OFP itself (therefore debug)
 - change BiMap to synchronized because of ConcurrentModificationException
   seen in tests

Change-Id: Ia37212647a9c119ecd51d6685ea8fffb8ee94a39
Signed-off-by: Andrej Leitner <andrej.leitner@pantheon.tech>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java
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
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/ErrorUtil.java [new file with mode: 0644]

index 6d30a9da53d040553f3717b57f73f9dbdce148ee..257c5187a64544bbdf7125ae7f26a2a7b29b0d8f 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import com.google.common.collect.BiMap;
 import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Maps;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -46,7 +47,7 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
     private static final String ALIEN_SYSTEM_FLOW_ID = "#UF$TABLE*";
     private static final AtomicInteger UNACCOUNTED_FLOWS_COUNTER = new AtomicInteger(0);
 
-    private final BiMap<FlowRegistryKey, FlowDescriptor> flowRegistry = HashBiMap.create();
+    private final BiMap<FlowRegistryKey, FlowDescriptor> flowRegistry = Maps.synchronizedBiMap(HashBiMap.create());
     private final DataBroker dataBroker;
     private final KeyedInstanceIdentifier<Node, NodeKey> instanceIdentifier;
     private final List<ListenableFuture<List<Optional<FlowCapableNode>>>> lastFillFutures = new ArrayList<>();
@@ -162,28 +163,24 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
 
     @Override
     public void store(final FlowRegistryKey flowRegistryKey, final FlowDescriptor flowDescriptor) {
-        synchronized (flowRegistryKey) {
-            try {
-                LOG.trace("Storing flowDescriptor with table ID : {} and flow ID : {} for flow hash : {}",
-                        flowDescriptor.getTableKey().getId(), flowDescriptor.getFlowId().getValue(), flowRegistryKey.hashCode());
-                flowRegistry.put(flowRegistryKey, flowDescriptor);
-            } catch (IllegalArgumentException ex) {
-                LOG.error("Flow with flowId {} already exists in table {}", flowDescriptor.getFlowId().getValue(),
-                        flowDescriptor.getTableKey().getId());
-                final FlowId newFlowId = createAlienFlowId(flowDescriptor.getTableKey().getId());
-                final FlowDescriptor newFlowDescriptor = FlowDescriptorFactory.
-                        create(flowDescriptor.getTableKey().getId(), newFlowId);
-                flowRegistry.put(flowRegistryKey, newFlowDescriptor);
-            }
+        try {
+          LOG.trace("Storing flowDescriptor with table ID : {} and flow ID : {} for flow hash : {}",
+                    flowDescriptor.getTableKey().getId(), flowDescriptor.getFlowId().getValue(), flowRegistryKey.hashCode());
+          flowRegistry.put(flowRegistryKey, flowDescriptor);
+        } catch (IllegalArgumentException ex) {
+          LOG.error("Flow with flowId {} already exists in table {}", flowDescriptor.getFlowId().getValue(),
+                    flowDescriptor.getTableKey().getId());
+          final FlowId newFlowId = createAlienFlowId(flowDescriptor.getTableKey().getId());
+          final FlowDescriptor newFlowDescriptor = FlowDescriptorFactory.
+            create(flowDescriptor.getTableKey().getId(), newFlowId);
+          flowRegistry.put(flowRegistryKey, newFlowDescriptor);
         }
     }
 
     @Override
     public void update(final FlowRegistryKey newFlowRegistryKey, final FlowDescriptor flowDescriptor) {
-        synchronized (newFlowRegistryKey) {
-            LOG.trace("Updating the entry with hash: {}", newFlowRegistryKey.hashCode());
-            flowRegistry.forcePut(newFlowRegistryKey, flowDescriptor);
-        }
+        LOG.trace("Updating the entry with hash: {}", newFlowRegistryKey.hashCode());
+        flowRegistry.forcePut(newFlowRegistryKey, flowDescriptor);
     }
 
     @Override
@@ -210,10 +207,8 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
 
     @Override
     public void removeDescriptor(final FlowRegistryKey flowRegistryKey) {
-        synchronized (flowRegistryKey) {
-            LOG.trace("Removing flow descriptor for flow hash : {}", flowRegistryKey.hashCode());
-            flowRegistry.remove(flowRegistryKey);
-        }
+        LOG.trace("Removing flow descriptor for flow hash : {}", flowRegistryKey.hashCode());
+        flowRegistry.remove(flowRegistryKey);
     }
 
     @Override
index 4531a0756bc5fcd11f55bb3ef5a679822727d41c..730997cb9576b602eab3fc986489d3f6355ddc1e 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.Future;
@@ -26,6 +25,7 @@ import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory;
 import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
+import org.opendaylight.openflowplugin.impl.util.ErrorUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
@@ -50,7 +50,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -81,31 +80,17 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
         final ListenableFuture<RpcResult<AddFlowOutput>> future =
                 flowAdd.processFlowModInputBuilders(flowAdd.toFlowModInputs(input));
         Futures.addCallback(future, new AddFlowCallback(input, flowRegistryKey));
-
         return future;
     }
 
     @Override
     public Future<RpcResult<RemoveFlowOutput>> removeFlow(final RemoveFlowInput input) {
-        LOG.trace("Calling remove flow for flow with ID ={}.", input.getFlowRef());
-
         final ListenableFuture<RpcResult<RemoveFlowOutput>> future =
                 flowRemove.processFlowModInputBuilders(flowRemove.toFlowModInputs(input));
         Futures.addCallback(future, new RemoveFlowCallback(input));
-
         return future;
     }
 
-    private final String errorsToString(final Collection<RpcError> rpcErrors) {
-        final StringBuilder errors = new StringBuilder();
-        if ((null != rpcErrors) && (rpcErrors.size() > 0)) {
-            for (final RpcError rpcError : rpcErrors) {
-                errors.append(rpcError.getMessage());
-            }
-        }
-        return errors.toString();
-    }
-
     @Override
     public Future<RpcResult<UpdateFlowOutput>> updateFlow(final UpdateFlowInput input) {
         final UpdatedFlow updated = input.getUpdatedFlow();
@@ -135,7 +120,7 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
     }
 
     @VisibleForTesting
-    static KeyedInstanceIdentifier<Flow, FlowKey> createFlowPath(FlowDescriptor flowDescriptor,
+    private static KeyedInstanceIdentifier<Flow, FlowKey> createFlowPath(FlowDescriptor flowDescriptor,
                                                                  KeyedInstanceIdentifier<Node, NodeKey> nodePath) {
         return nodePath.augmentation(FlowCapableNode.class)
                 .child(Table.class, flowDescriptor.getTableKey())
@@ -166,7 +151,9 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                     flowDescriptor = FlowDescriptorFactory.create(input.getTableId(), flowId);
                 }
 
-                LOG.debug("flow add with id={},finished without error,", flowDescriptor.getFlowId().getValue());
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Flow add with id={} finished without error", flowDescriptor.getFlowId().getValue());
+                }
 
                 if (itemLifecycleListener != null) {
                     KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
@@ -175,13 +162,16 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                     itemLifecycleListener.onAdded(flowPath, flowBuilder.build());
                 }
             } else {
-                LOG.error("flow add failed for flow={}, errors={}", input.toString(), errorsToString(rpcResult.getErrors()));
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Flow add failed for flow={}, errors={}", input,
+                            ErrorUtil.errorsToString(rpcResult.getErrors()));
+                }
             }
         }
 
         @Override
         public void onFailure(final Throwable throwable) {
-            LOG.error("Service call for adding flow={} failed, reason {} .", input.toString(), throwable);
+            LOG.warn("Service call for adding flow={} failed, reason: {}", input, throwable);
         }
     }
 
@@ -195,11 +185,12 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
         @Override
         public void onSuccess(final RpcResult<RemoveFlowOutput> result) {
             if (result.isSuccessful()) {
-                if(LOG.isDebugEnabled()) {
-                    LOG.debug("flow removed finished without error,");
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Flow remove finished without error for flow={}", input);
                 }
                 FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(input);
                 deviceContext.getDeviceFlowRegistry().removeDescriptor(flowRegistryKey);
+
                 if (itemLifecycleListener != null) {
                     final FlowDescriptor flowDescriptor =
                             deviceContext.getDeviceFlowRegistry().retrieveIdForFlow(flowRegistryKey);
@@ -210,13 +201,16 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                     }
                 }
             } else {
-                LOG.error("Flow remove failed with errors : {}",errorsToString(result.getErrors()));
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Flow remove failed for flow={}, errors={}", input,
+                            ErrorUtil.errorsToString(result.getErrors()));
+                }
             }
         }
 
         @Override
         public void onFailure(final Throwable throwable) {
-            LOG.error("Service call for removing flow with id {} failed ,reason {}",input.getFlowRef().getValue(), throwable);
+            LOG.warn("Service call for removing flow={} failed, reason: {}", input, throwable);
         }
     }
 
@@ -274,7 +268,7 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
 
         @Override
         public void onFailure(final Throwable throwable) {
-            LOG.error("Service call for updating flow failed, reason{}", throwable);
+            LOG.warn("Service call for updating flow={} failed, reason: {}", input, throwable);
         }
     }
 }
\ No newline at end of file
index 1e1ff0e9f5e53f2adb583902da28d68f488b4779..a6264a1ba704c68f552197d76712a3970a092121 100644 (file)
@@ -10,13 +10,13 @@ package org.opendaylight.openflowplugin.impl.services;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Collection;
 import java.util.concurrent.Future;
 import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
+import org.opendaylight.openflowplugin.impl.util.ErrorUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
@@ -33,7 +33,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -65,23 +64,24 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
             @Override
             public void onSuccess(RpcResult<AddGroupOutput> result) {
                 if (result.isSuccessful()) {
-                    if(LOG.isDebugEnabled()) {
-                        LOG.debug("group add with id={} finished without error", input.getGroupId().getValue());
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Group add with id={} finished without error", input.getGroupId().getValue());
                     }
                     deviceContext.getDeviceGroupRegistry().store(input.getGroupId());
                     addIfNecessaryToDS(input.getGroupId(), input);
                 } else {
-                    LOG.error("group add with id={} failed, errors={}", input.getGroupId().getValue(),
-                            errorsToString(result.getErrors()));
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Group add with id={} failed, errors={}", input.getGroupId().getValue(),
+                                ErrorUtil.errorsToString(result.getErrors()));
+                    }
                 }
             }
 
             @Override
             public void onFailure(Throwable t) {
-                LOG.error("Service call for group add failed for id={}. Exception: {}", input.getGroupId().getValue(), t);
+                LOG.warn("Service call for adding group={} failed, reason: {}", input.getGroupId().getValue(), t);
             }
         });
-
         return resultFuture;
     }
 
@@ -93,20 +93,23 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
             @Override
             public void onSuccess(@Nullable RpcResult<UpdateGroupOutput> result) {
                 if (result.isSuccessful()) {
-                    if(LOG.isDebugEnabled()) {
-                        LOG.debug("Group update for original id {} succeded", input.getOriginalGroup().getGroupId().getValue());
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Group update with original id={} finished without error",
+                                input.getOriginalGroup().getGroupId().getValue());
                     }
                     removeIfNecessaryFromDS(input.getOriginalGroup().getGroupId());
                     addIfNecessaryToDS(input.getUpdatedGroup().getGroupId(), input.getUpdatedGroup());
-                }else{
-                    LOG.error("group update failed with id={}, errors={}", input.getOriginalGroup().getGroupId(),
-                            errorsToString(result.getErrors()));
+                } else {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Group update with original id={} failed, errors={}",
+                                input.getOriginalGroup().getGroupId(), ErrorUtil.errorsToString(result.getErrors()));
+                    }
                 }
             }
 
             @Override
             public void onFailure(Throwable t) {
-                LOG.error("Service call for group  update failed for id={}. Exception: {}",
+                LOG.warn("Service call for updating group={} failed, reason: {}",
                         input.getOriginalGroup().getGroupId(), t);
             }
         });
@@ -120,20 +123,22 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
             @Override
             public void onSuccess(@Nullable RpcResult<RemoveGroupOutput> result) {
                 if (result.isSuccessful()) {
-                    if(LOG.isDebugEnabled()) {
-                        LOG.debug("Group remove for id {} succeded", input.getGroupId().getValue());
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Group remove with id={} finished without error", input.getGroupId().getValue());
                     }
                     removeGroup.getDeviceRegistry().getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
                     removeIfNecessaryFromDS(input.getGroupId());
-                }else{
-                    LOG.error("group remove failed with id={}, errors={}", input.getGroupId().getValue(),
-                            errorsToString(result.getErrors()));
+                } else {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Group remove with id={} failed, errors={}", input.getGroupId().getValue(),
+                                ErrorUtil.errorsToString(result.getErrors()));
+                    }
                 }
             }
 
             @Override
             public void onFailure(Throwable t) {
-                LOG.error("Service call for group remove failed for id={}. Exception: {}",
+                LOG.warn("Service call for removing group={} failed, reason: {}",
                         input.getGroupId().getValue(), t);
             }
         });
@@ -158,19 +163,9 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
         }
     }
 
-    static KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group, GroupKey>
+    private static KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group, GroupKey>
     createGroupPath(final GroupId groupId, final KeyedInstanceIdentifier<Node, NodeKey> nodePath) {
         return nodePath.augmentation(FlowCapableNode.class).
                 child(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group.class, new GroupKey(groupId));
     }
-
-    private final String errorsToString(final Collection<RpcError> rpcErrors) {
-        final StringBuilder errors = new StringBuilder();
-        if ((null != rpcErrors) && (rpcErrors.size() > 0)) {
-            for (final RpcError rpcError : rpcErrors) {
-                errors.append(rpcError.getMessage());
-            }
-        }
-        return errors.toString();
-    }
 }
\ No newline at end of file
index d96e2190120bf5812059096991907e7e8f8683a1..02f72dc6ab8195da6c55f43f32682d7580ca5960 100644 (file)
@@ -10,13 +10,13 @@ package org.opendaylight.openflowplugin.impl.services;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Collection;
 import java.util.concurrent.Future;
 import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
+import org.opendaylight.openflowplugin.impl.util.ErrorUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
@@ -33,7 +33,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.Upd
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -60,29 +59,29 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
 
     @Override
     public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
-
         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()) {
-                        LOG.debug("Meter add finished without error, id={}", input.getMeterId());
+                   if (LOG.isDebugEnabled()) {
+                        LOG.debug("Meter add with id={} finished without error", input.getMeterId());
                     }
                     deviceContext.getDeviceMeterRegistry().store(input.getMeterId());
                     addIfNecessaryToDS(input.getMeterId(),input);
                 } else {
-                    LOG.error("Meter add with id {} failed with error {}", input.getMeterId(),
-                            errorsToString(result.getErrors()));
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Meter add with id={} failed, errors={}", input.getMeterId(),
+                                ErrorUtil.errorsToString(result.getErrors()));
+                    }
                 }
             }
 
             @Override
             public void onFailure(Throwable t) {
-                 LOG.error("Meter add failed for id={}. Exception {}", input.getMeterId(), t);
+                 LOG.warn("Service call for adding meter={} failed, reason: {}", input.getMeterId(), t);
             }
         });
-
         return resultFuture;
     }
 
@@ -94,22 +93,24 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
             @Override
             public void onSuccess(@Nullable RpcResult<UpdateMeterOutput> result) {
                 if (result.isSuccessful()) {
-                    if(LOG.isDebugEnabled()) {
-                        LOG.debug("Meter update finished without error, id={}", input.getOriginalMeter().getMeterId());
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Meter update with id={} finished without error", input.getOriginalMeter().getMeterId());
                     }
                     if (itemLifecycleListener != null) {
                         removeIfNecessaryFromDS(input.getOriginalMeter().getMeterId());
                         addIfNecessaryToDS(input.getUpdatedMeter().getMeterId(),input.getUpdatedMeter());
                     }
-                }else{
-                    LOG.error("Meter update with id {} failed with error {}", input.getOriginalMeter().getMeterId(),
-                            errorsToString(result.getErrors()));
+                } else {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Meter update with id={} failed, errors={}", input.getOriginalMeter().getMeterId(),
+                                ErrorUtil.errorsToString(result.getErrors()));
+                    }
                 }
             }
 
             @Override
             public void onFailure(Throwable t) {
-                LOG.error("Service call for meter update failed. for id={}. Exception {}.",
+                LOG.warn("Service call for updating meter={} failed, reason: {}",
                         input.getOriginalMeter().getMeterId(),t);
             }
         });
@@ -121,34 +122,33 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
         removeMeter.getDeviceRegistry().getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
         final ListenableFuture<RpcResult<RemoveMeterOutput>> resultFuture = removeMeter.handleServiceCall(input);
         Futures.addCallback(resultFuture, new FutureCallback<RpcResult<RemoveMeterOutput>>() {
-
             @Override
             public void onSuccess(@Nullable RpcResult<RemoveMeterOutput> result) {
                 if (result.isSuccessful()) {
-                    if(LOG.isDebugEnabled()) {
-                        LOG.debug("Meter remove finished without error, id={}", input.getMeterId());
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Meter remove with id={} finished without error", input.getMeterId());
                     }
                     removeIfNecessaryFromDS(input.getMeterId());
-                }else{
-                    LOG.error("Meter remove with id {} failed with error {}", input.getMeterId(),
-                            errorsToString(result.getErrors()));
+                } else {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Meter remove with id={} failed, errors={}", input.getMeterId(),
+                                ErrorUtil.errorsToString(result.getErrors()));
+                    }
                 }
             }
 
             @Override
             public void onFailure(Throwable t) {
-                LOG.error("Service call for meter remove failed for id={}. Exception {}",input.getMeterId(),t);
+                LOG.warn("Service call for removing meter={} failed, reason: {}",input.getMeterId(),t);
             }
         });
-
         return resultFuture;
     }
 
     private void removeIfNecessaryFromDS(final MeterId meterId) {
         if (itemLifecycleListener != null) {
             KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> meterPath
-                    = createMeterPath(meterId,
-                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
+                    = createMeterPath(meterId, deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
             itemLifecycleListener.onRemoved(meterPath);
         }
     }
@@ -156,23 +156,12 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
     private void addIfNecessaryToDS(final MeterId meterId, final Meter data) {
         if (itemLifecycleListener != null) {
             KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> groupPath
-                    = createMeterPath(meterId,
-                    deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
+                    = createMeterPath(meterId, deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
             itemLifecycleListener.onAdded(groupPath, new MeterBuilder(data).build());
         }
     }
 
-    static KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> createMeterPath(final MeterId meterId, final KeyedInstanceIdentifier<Node, NodeKey> nodePath) {
+    private static KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> createMeterPath(final MeterId meterId, final KeyedInstanceIdentifier<Node, NodeKey> nodePath) {
         return nodePath.augmentation(FlowCapableNode.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter.class, new MeterKey(meterId));
     }
-
-    private final String errorsToString(final Collection<RpcError> rpcErrors) {
-        final StringBuilder errors = new StringBuilder();
-        if ((null != rpcErrors) && (rpcErrors.size() > 0)) {
-            for (final RpcError rpcError : rpcErrors) {
-                errors.append(rpcError.getMessage());
-            }
-        }
-        return errors.toString();
-    }
 }
\ No newline at end of file
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/ErrorUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/ErrorUtil.java
new file mode 100644 (file)
index 0000000..11ed189
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+ * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.impl.util;
+
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.common.RpcError;
+
+/**
+ * Util class for {@link RpcError}.
+ */
+public final class ErrorUtil {
+
+    private ErrorUtil() {
+        throw new IllegalStateException("This class should not be instantiated.");
+    }
+
+    public static final String errorsToString(final Collection<RpcError> rpcErrors) {
+        final StringBuilder errors = new StringBuilder();
+        if ((null != rpcErrors) && (rpcErrors.size() > 0)) {
+            for (final RpcError rpcError : rpcErrors) {
+                errors.append(rpcError.getMessage());
+            }
+        }
+        return errors.toString();
+    }
+
+}