Instruction experimenterId fix
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / OFDecoder.java
index 6cf140503a62e8df93aa63cc9d112c5f890e74a3..386caa3442c85b7469f913644146c00db9a9390b 100644 (file)
@@ -14,6 +14,8 @@ import io.netty.handler.codec.MessageToMessageDecoder;
 import java.util.List;
 
 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory;
+import org.opendaylight.openflowjava.statistics.CounterEventTypes;
+import org.opendaylight.openflowjava.statistics.StatisticsCounters;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.slf4j.Logger;
@@ -27,17 +29,19 @@ public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(OFDecoder.class);
     private DeserializationFactory deserializationFactory;
-
+    private StatisticsCounters statisticsCounter;
     /**
      * Constructor of class
      */
     public OFDecoder() {
         LOGGER.trace("Creating OF 1.3 Decoder");
+        statisticsCounter = StatisticsCounters.getInstance();
     }
 
     @Override
     protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg,
             List<Object> out) throws Exception {
+        statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA);
         if (LOGGER.isDebugEnabled()) {
             LOGGER.debug("VersionMessageWrapper received");
             LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer()));
@@ -49,14 +53,15 @@ public class OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> {
                     msg.getVersion());
             if (dataObject == null) {
                 LOGGER.warn("Translated POJO is null");
+                statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL);
             } else {
                 out.add(dataObject);
+                statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_SUCCESS);
             }
         } catch(Exception e) {
             LOGGER.warn("Message deserialization failed");
             LOGGER.warn(e.getMessage(), e);
-            // TODO: delegate exception to allow easier deserialization
-            // debugging / deserialization problem awareness
+            statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL);
         } finally {
             msg.getMessageBuffer().release();
         }