X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fcore%2FIdleHandler.java;h=9b6e863def3c8d52d59c6fbf0f1b92daee8bcdba;hb=6af0ea88a438a5132590be1bbe66c5a76b2765ac;hp=65af251677882578339809afe7c1d07d8778f99a;hpb=0d942e8fb70b2c21f97eea3ed8904336ab5c54a4;p=openflowjava.git diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandler.java index 65af2516..9b6e863d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/IdleHandler.java @@ -8,12 +8,10 @@ package org.opendaylight.openflowjava.protocol.impl.core; -import java.util.concurrent.TimeUnit; - import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.timeout.IdleState; -import io.netty.handler.timeout.IdleStateEvent; -import io.netty.handler.timeout.IdleStateHandler; +import io.netty.handler.timeout.ReadTimeoutHandler; + +import java.util.concurrent.TimeUnit; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder; import org.slf4j.Logger; @@ -23,30 +21,33 @@ import org.slf4j.LoggerFactory; * Detects idle state of switch and informs upper layers * @author michal.polkorab */ -public class IdleHandler extends IdleStateHandler{ +public class IdleHandler extends ReadTimeoutHandler { private static final Logger LOGGER = LoggerFactory.getLogger(IdleHandler.class); + private boolean first = true; /** * @param readerIdleTime - * @param writerIdleTime - * @param allIdleTime * @param unit */ - public IdleHandler(long readerIdleTime, long writerIdleTime, - long allIdleTime, TimeUnit unit) { - super(readerIdleTime, writerIdleTime, allIdleTime, unit); + public IdleHandler(final long readerIdleTime, final TimeUnit unit) { + super(readerIdleTime, unit); } @Override - protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) - throws Exception { - if ((evt.state() == IdleState.READER_IDLE) && (evt.isFirst())) { - LOGGER.info("Switch idle"); + public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { + super.channelRead(ctx, msg); + first = true; + } + + @Override + protected void readTimedOut(final ChannelHandlerContext ctx) throws Exception { + if (first) { + LOGGER.debug("Switch idle"); SwitchIdleEventBuilder builder = new SwitchIdleEventBuilder(); builder.setInfo("Switch idle"); ctx.fireChannelRead(builder.build()); + first = false; } } - }