2 * Copyright (c) 2015 Cisco Systems, Inc. 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
8 package org.opendaylight.openflowplugin.impl.connection.listener;
10 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
11 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
12 import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext;
13 import org.opendaylight.openflowplugin.openflow.md.core.HandshakeStepWrapper;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * oneshot listener - once connection is ready, initiate handshake (if not already started by device)
20 public class ConnectionReadyListenerImpl implements ConnectionReadyListener {
22 private static final Logger LOG = LoggerFactory.getLogger(ConnectionReadyListenerImpl.class);
24 private ConnectionContext connectionContext;
25 private HandshakeContext handshakeContext;
28 * @param connectionContext
29 * @param handshakeContext
31 public ConnectionReadyListenerImpl(ConnectionContext connectionContext,
32 HandshakeContext handshakeContext) {
33 this.connectionContext = connectionContext;
34 this.handshakeContext = handshakeContext;
38 public void onConnectionReady() {
39 LOG.debug("device is connected and ready-to-use (pipeline prepared): {}",
40 connectionContext.getConnectionAdapter().getRemoteAddress());
42 if (connectionContext.getConnectionState() == null) {
43 HandshakeStepWrapper handshakeStepWrapper = new HandshakeStepWrapper(
44 null, handshakeContext.getHandshakeManager(), connectionContext.getConnectionAdapter());
45 handshakeContext.getHandshakePool().execute(handshakeStepWrapper);
46 connectionContext.changeStateToHandshaking();
48 LOG.debug("already touched by hello message");