2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.core;
11 import java.util.concurrent.TimeUnit;
13 import io.netty.channel.ChannelHandlerContext;
14 import io.netty.handler.timeout.IdleState;
15 import io.netty.handler.timeout.IdleStateEvent;
16 import io.netty.handler.timeout.IdleStateHandler;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
23 * Detects idle state of switch and informs upper layers
24 * @author michal.polkorab
26 public class IdleHandler extends IdleStateHandler{
28 private static final Logger LOGGER = LoggerFactory.getLogger(IdleHandler.class);
31 * @param readerIdleTime
32 * @param writerIdleTime
36 public IdleHandler(long readerIdleTime, long writerIdleTime,
37 long allIdleTime, TimeUnit unit) {
38 super(readerIdleTime, writerIdleTime, allIdleTime, unit);
42 protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt)
44 if ((evt.state() == IdleState.READER_IDLE) && (evt.isFirst())) {
45 LOGGER.info("Switch idle");
46 SwitchIdleEventBuilder builder = new SwitchIdleEventBuilder();
47 builder.setInfo("Switch idle");
48 ctx.fireChannelRead(builder.build());