Bug 1764 - moved Session related interfaces to openflowplugin-api
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / md / core / ConnectionConductor.java
1 /**
2  * Copyright (c) 2013 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 Public 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.md.core;
10
11 import java.util.List;
12 import java.util.concurrent.Future;
13
14 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
15 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
16 import org.opendaylight.openflowplugin.api.openflow.md.queue.QueueProcessor;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
18 import org.opendaylight.yangtools.yang.binding.DataObject;
19
20 import com.google.common.collect.Lists;
21
22
23 /**
24  * @author mirehak
25  */
26 public interface ConnectionConductor {
27
28     /** distinguished connection states */
29     public enum CONDUCTOR_STATE {
30         /** initial phase of talking to switch */
31         HANDSHAKING,
32         /** standard phase - interacting with switch */
33         WORKING,
34         /** connection is idle, waiting for echo reply from switch */
35         TIMEOUTING,
36         /** talking to switch is over - resting in pieces */
37         RIP
38     }
39
40     /** supported version ordered by height (highest version is at the beginning) */
41     public static final List<Short> versionOrder = Lists.newArrayList((short) 0x04, (short) 0x01);
42
43     /**
44      * initialize wiring around {@link #connectionAdapter}
45      */
46     public void init();
47
48     /**
49      * @return the negotiated version
50      */
51     public Short getVersion();
52
53     /**
54      * @return the state of conductor
55      */
56     public CONDUCTOR_STATE getConductorState();
57
58     /**
59      * @param conductorState
60      */
61     public void setConductorState(CONDUCTOR_STATE conductorState);
62
63     /**
64      * terminates owned connection
65      * @return future result of disconnect action
66      */
67     public Future<Boolean> disconnect();
68
69     /**
70      * assign corresponding {@link SessionContext} to this conductor (to handle disconnect caused by switch)
71      * @param context
72      */
73     public void setSessionContext(SessionContext context);
74
75     /**
76      * assign corresponding {@link org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher} to this conductor
77      * to handle disconnect caused by switch. This involves auxiliary conductors only.
78      * @param auxiliaryKey
79      */
80     public void setConnectionCookie(SwitchConnectionDistinguisher auxiliaryKey);
81
82     /**
83      * @return the sessionContext
84      */
85     public SessionContext getSessionContext();
86
87     /**
88      * @return the auxiliaryKey (null if this is a primary connection)
89      */
90     public SwitchConnectionDistinguisher getAuxiliaryKey();
91
92     /**
93      * @return the connectionAdapter
94      */
95     public ConnectionAdapter getConnectionAdapter();
96
97     /**
98      * assign global queueKeeper
99      * @param queueKeeper
100      */
101     void setQueueProcessor(QueueProcessor<OfHeader, DataObject> queueKeeper);
102
103     /**
104      * @param errorHandler for internal exception handling
105      */
106     void setErrorHandler(ErrorHandler errorHandler);
107
108     /**
109      * @param conductorId
110      */
111     void setId(int conductorId);
112
113 }