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