bbbffdc0f2d196a70b4778661af7f13942edc59d
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / connection / ConnectionContext.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowplugin.api.openflow.connection;
10
11 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
12 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
13 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
14 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
17
18 /**
19  * <p>
20  * Each OpenFlow session is tracked by a Connection Context. These attach to a particular Device Context in such a way,
21  * that there is at most one primary session associated with a Device Context.
22  * </p>
23  * Created by Martin Bobak &lt;mbobak@cisco.com&gt; on 25.2.2015.
24  */
25 public interface ConnectionContext extends AutoCloseable {
26
27     /**
28      * distinguished connection states
29      */
30     enum CONNECTION_STATE {
31         /**
32          * initial phase of talking to switch
33          */
34         HANDSHAKING,
35         /**
36          * standard phase - interacting with switch
37          */
38         WORKING,
39         /**
40          * connection is idle, waiting for echo reply from switch
41          */
42         TIMEOUTING,
43         /**
44          * talking to switch is over - resting in pieces
45          */
46         RIP
47     }
48
49     /**
50      * setter for nodeId
51      *
52      * @param nodeId
53      */
54     void setNodeId(NodeId nodeId);
55
56     /**
57      * Method returns identifier of device whic connection represents this context.
58      *
59      * @return {@link org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId}
60      */
61     NodeId getNodeId();
62
63     /**
64      * @return the connectionAdapter
65      */
66     ConnectionAdapter getConnectionAdapter();
67
68     /**
69      * Returns reference to OFJava outbound queue provider. Outbound queue is used for outbound messages processing.
70      *
71      * @return
72      */
73     OutboundQueue getOutboundQueueProvider();
74     /**
75      * Method sets reference to OFJava outbound queue provider.
76      *
77      */
78     void setOutboundQueueProvider(OutboundQueueProvider  outboundQueueProvider);
79
80     /**
81      * Method returns current connection state.
82      *
83      * @return {@link ConnectionContext.CONNECTION_STATE}
84      */
85     CONNECTION_STATE getConnectionState();
86
87     /**
88      * Method sets connection state of current context.
89      *
90      * @param connectionState
91      */
92     void setConnectionState(CONNECTION_STATE connectionState);
93
94     /**
95      * @param featuresReply as received from device during handshake
96      */
97     void setFeatures(FeaturesReply featuresReply);
98
99     /**
100      * @return featureReply as received from device during handshake
101      */
102     FeaturesReply getFeatures();
103
104     /**
105      * Method sets handler for handling closing connections.
106      *
107      * @param deviceDisconnectedHandler
108      */
109     void setDeviceDisconnectedHandler(DeviceDisconnectedHandler deviceDisconnectedHandler);
110
111     /**
112      * Method provides propagates info about closed connection to handler for handling closing connections.
113      */
114     void propagateClosingConnection();
115
116     void setOutboundQueueHandleRegistration(OutboundQueueHandlerRegistration<OutboundQueueProvider> outboundQueueHandlerRegistration);
117
118     @Override
119     void close();
120 }