From c3c505024150f1c6acf2c1db42f0b5479ad78e0a Mon Sep 17 00:00:00 2001 From: Martin Bobak Date: Wed, 20 May 2015 10:58:07 +0200 Subject: [PATCH] added packetIn filter counts to statistics Change-Id: Ifce135548ad1d2ecb9c4bc6ff15e922af771368f Signed-off-by: Michal Polkorab Signed-off-by: Michal Rehak (cherry picked from commit 25d95eb2be97152d7a459a12caa5e51a79556f58) --- .../openflowjava/protocol/impl/core/OFVersionDetector.java | 5 +++++ .../openflowjava/statistics/CounterEventTypes.java | 4 ++++ .../openflowjava/statistics/StatisticsCounters.java | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java index 083cf0ec..0142ebfd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFVersionDetector.java @@ -13,6 +13,8 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; import java.util.List; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.statistics.CounterEventTypes; +import org.opendaylight.openflowjava.statistics.StatisticsCounters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,6 +30,7 @@ public class OFVersionDetector extends ByteToMessageDecoder { private static final byte OF13_VERSION_ID = EncodeConstants.OF13_VERSION_ID; private static final short OF_PACKETIN = 10; private static final Logger LOGGER = LoggerFactory.getLogger(OFVersionDetector.class); + private final StatisticsCounters statisticsCounters; private volatile boolean filterPacketIns; /** @@ -35,6 +38,7 @@ public class OFVersionDetector extends ByteToMessageDecoder { */ public OFVersionDetector() { LOGGER.trace("Creating OFVersionDetector"); + statisticsCounters = StatisticsCounters.getInstance(); } public void setFilterPacketIns(final boolean enabled) { @@ -58,6 +62,7 @@ public class OFVersionDetector extends ByteToMessageDecoder { messageBuffer.retain(); } else { LOGGER.debug("dropped packetin"); + statisticsCounters.incrementCounter(CounterEventTypes.US_DROPPED_PACKET_IN); } } else { LOGGER.warn("detected version: {} - currently not supported", version); diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java index b021745d..60b1c6da 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java @@ -34,6 +34,10 @@ public enum CounterEventTypes { * flow-mod encoded and sent to downstream */ DS_FLOW_MODS_SENT, + /** + * packetIn message got dropped -filtering is active + */ + US_DROPPED_PACKET_IN, /** * receive message and pass to upstream */ diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java index f3566a09..3f900d80 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/StatisticsCounters.java @@ -11,7 +11,6 @@ import java.util.Map; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; - import org.opendaylight.openflowjava.protocol.spi.statistics.StatisticsHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,6 +45,7 @@ public final class StatisticsCounters implements StatisticsHandler { CounterEventTypes.DS_ENTERED_OFJAVA, CounterEventTypes.DS_FLOW_MODS_ENTERED, CounterEventTypes.DS_FLOW_MODS_SENT, + CounterEventTypes.US_DROPPED_PACKET_IN, CounterEventTypes.US_DECODE_FAIL, CounterEventTypes.US_DECODE_SUCCESS, CounterEventTypes.US_MESSAGE_PASS, -- 2.36.6