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 io.netty.channel.ChannelHandlerContext;
12 import io.netty.handler.timeout.ReadTimeoutHandler;
14 import java.util.concurrent.TimeUnit;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * Detects idle state of switch and informs upper layers
22 * @author michal.polkorab
24 public class IdleHandler extends ReadTimeoutHandler {
26 private static final Logger LOG = LoggerFactory.getLogger(IdleHandler.class);
27 private boolean first = true;
30 * @param readerIdleTime
33 public IdleHandler(final long readerIdleTime, final TimeUnit unit) {
34 super(readerIdleTime, unit);
38 public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
39 super.channelRead(ctx, msg);
44 protected void readTimedOut(final ChannelHandlerContext ctx) throws Exception {
46 LOG.debug("Switch idle");
47 SwitchIdleEventBuilder builder = new SwitchIdleEventBuilder();
48 builder.setInfo("Switch idle");
49 ctx.fireChannelRead(builder.build());