Integration test, SimpleClient bundle
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / core / IdleHandler.java
1 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
2 package org.opendaylight.openflowjava.protocol.impl.core;
3
4 import java.util.concurrent.TimeUnit;
5
6 import io.netty.channel.ChannelHandlerContext;
7 import io.netty.handler.timeout.IdleState;
8 import io.netty.handler.timeout.IdleStateEvent;
9 import io.netty.handler.timeout.IdleStateHandler;
10
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 public class IdleHandler extends IdleStateHandler{
16     
17     public IdleHandler(long readerIdleTime, long writerIdleTime,
18             long allIdleTime, TimeUnit unit) {
19         super(readerIdleTime, writerIdleTime, allIdleTime, unit);
20     }
21
22
23     private static final Logger LOGGER = LoggerFactory.getLogger(IdleHandler.class);
24
25     
26     @Override
27     protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt)
28             throws Exception {
29         if ((evt.state() == IdleState.READER_IDLE) && (evt.isFirst())) {
30             LOGGER.info("Switch idle");
31             SwitchIdleEventBuilder builder = new SwitchIdleEventBuilder();
32             builder.setInfo("Switch idle");
33             ctx.fireChannelRead(builder.build());
34         }
35     }
36
37 }