Merge "Device Info API"
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / connection / ConnectionContext.java
index 025fc8bebc592e9879140671a59012b717496334..4a9cb65d282dab97ef6bad347aa3d7ee5fc49781 100644 (file)
@@ -2,13 +2,16 @@
  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
- * terms of the Eclipse License v1.0 which accompanies this distribution,
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
 package org.opendaylight.openflowplugin.api.openflow.connection;
 
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
@@ -18,10 +21,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * Each OpenFlow session is tracked by a Connection Context. These attach to a particular Device Context in such a way,
  * that there is at most one primary session associated with a Device Context.
  * </p>
- * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
  */
 public interface ConnectionContext {
 
+    /**
+     * @param handshakeContext corresponding handshake context used upon this connection
+     */
+    void setHandshakeContext(HandshakeContext handshakeContext);
+
     /**
      * distinguished connection states
      */
@@ -63,20 +70,24 @@ public interface ConnectionContext {
      */
     ConnectionAdapter getConnectionAdapter();
 
-
     /**
-     * Method returns current connection state.
+     * Returns reference to OFJava outbound queue provider. Outbound queue is used for outbound messages processing.
      *
-     * @return {@link ConnectionContext.CONNECTION_STATE}
+     * @return
      */
-    CONNECTION_STATE getConnectionState();
+    OutboundQueue getOutboundQueueProvider();
 
     /**
-     * Method sets connection state of current context.
+     * Method sets reference to OFJava outbound queue provider.
+     */
+    void setOutboundQueueProvider(OutboundQueueProvider outboundQueueProvider);
+
+    /**
+     * Method returns current connection state.
      *
-     * @param connectionState
+     * @return {@link ConnectionContext.CONNECTION_STATE}
      */
-    void setConnectionState(CONNECTION_STATE connectionState);
+    CONNECTION_STATE getConnectionState();
 
     /**
      * @param featuresReply as received from device during handshake
@@ -95,8 +106,40 @@ public interface ConnectionContext {
      */
     void setDeviceDisconnectedHandler(DeviceDisconnectedHandler deviceDisconnectedHandler);
 
+    void setOutboundQueueHandleRegistration(OutboundQueueHandlerRegistration<OutboundQueueProvider> outboundQueueHandlerRegistration);
+
+    /**
+     * actively drop associated connection
+     *
+     * @param propagate true if event need to be propagated to higher contexts (device, stats, rpc..)
+     *                  or false if invoked from higher context
+     * @see ConnectionAdapter#disconnect()
+     */
+    void closeConnection(boolean propagate);
+
+    /**
+     * cleanup context upon connection closed event (by device)
+     */
+    void onConnectionClosed();
+
+    /**
+     * change internal state to {@link ConnectionContext.CONNECTION_STATE#HANDSHAKING}
+     */
+    void changeStateToHandshaking();
+
+    /**
+     * change internal state to {@link ConnectionContext.CONNECTION_STATE#TIMEOUTING}
+     */
+    void changeStateToTimeouting();
+
+    /**
+     * change internal state to {@link ConnectionContext.CONNECTION_STATE#WORKING}
+     */
+    void changeStateToWorking();
+
     /**
-     * Method provides propagates info about closed connection to handler for handling closing connections.
+     * Create and return basic device info
+     * @return
      */
-    void propagateClosingConnection();
+    DeviceInfo gainDeviceInfo();
 }