Merge "Feature/Bug#2774: Decrease verbosity of flow hash duplicate."
authormichal rehak <mirehak@cisco.com>
Fri, 27 Mar 2015 14:05:41 +0000 (14:05 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 27 Mar 2015 14:05:42 +0000 (14:05 +0000)
applications/statistics-manager/src/main/java/org/opendaylight/openflowplugin/applications/statistics/manager/impl/StatListenCommitFlow.java

index db2b41002334c9eebbde3400df7c5a6246622b24..9d8230c61193376810ea66f50a40c9a57d1d75a1 100644 (file)
@@ -89,6 +89,7 @@ public class StatListenCommitFlow extends StatAbstractListenCommit<Flow, Openday
     private static final String ALIEN_SYSTEM_FLOW_ID = "#UF$TABLE*";
 
     private static final Integer REMOVE_AFTER_MISSING_COLLECTION = 1;
+    private static final int TRUNCATED_LOG_MESSAGE_LENGTH = 30;
 
     private final AtomicInteger unaccountedFlowsCounter = new AtomicInteger(0);
 
@@ -330,8 +331,18 @@ public class StatListenCommitFlow extends StatAbstractListenCommit<Flow, Openday
                         try {
                             flowIdByHash.put(flowHashId.getKey(), flowHashId.getFlowId());
                         } catch (final Exception e) {
-                            LOG.warn("flow hashing hit a duplicate for {} -> {}. Exception was raised: {}",
-                                    flowHashId.getKey(), flowHashId.getFlowId(), e.getMessage());
+                            //flowHashId.getKey() too verbose for standard log.
+                            if(LOG.isDebugEnabled()) {
+                                final FlowId currData = flowIdByHash.get(flowHashId.getKey());
+                                LOG.debug("flow hashing hit a duplicate for {} -> {}. Curr value: {} Equals:{}. Exception was raised:",
+                                    flowHashId.getKey(), flowHashId.getFlowId(), currData, flowHashId.getFlowId().equals(currData), e);
+                            }
+                            else
+                            {
+                                LOG.warn("flow hashing hit a duplicate {}. Exception was raised: {}. Enable DEBUG for more detail.",
+                                    flowHashId.getFlowId().toString().substring(0, Math.min(TRUNCATED_LOG_MESSAGE_LENGTH,flowHashId.getFlowId().toString().length())), 
+                                    e.getMessage().substring(0,Math.min(TRUNCATED_LOG_MESSAGE_LENGTH,e.getMessage().length())));
+                            }
                         }
                     }
                 }