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