Bug-2827: role switch proposal
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / md / core / session / SessionContext.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.session;
10
11 import java.util.List;
12 import java.util.Map;
13 import java.util.Map.Entry;
14 import java.util.Set;
15
16 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
17 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationEnqueuer;
18 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
19 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper;
20 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
24 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
25
26 /**
27  * @author mirehak
28  */
29 public interface SessionContext {
30
31     /**
32      * @return primary connection wrapper
33      */
34     ConnectionConductor getPrimaryConductor();
35
36     /**
37      * @return the features of corresponding switch
38      */
39     GetFeaturesOutput getFeatures();
40
41     /**
42      * @param auxiliaryKey
43      *            key under which the auxiliary conductor is stored
44      * @return list of auxiliary connection wrappers
45      */
46     ConnectionConductor getAuxiliaryConductor(
47             SwitchConnectionDistinguisher auxiliaryKey);
48
49     /**
50      * @return entries of all auxiliary connections wrapped in conductors in this session
51      */
52     Set<Entry<SwitchConnectionDistinguisher, ConnectionConductor>> getAuxiliaryConductors();
53
54     /**
55      * register new auxiliary connection wrapped in {@link ConnectionConductor}
56      *
57      * @param auxiliaryKey
58      * @param conductor
59      */
60     void addAuxiliaryConductor(SwitchConnectionDistinguisher auxiliaryKey,
61             ConnectionConductor conductor);
62
63     /**
64      * @param connectionCookie
65      * @return removed connectionConductor
66      */
67     ConnectionConductor removeAuxiliaryConductor(
68             SwitchConnectionDistinguisher connectionCookie);
69
70     /**
71      * @return true if this session is valid
72      */
73     boolean isValid();
74
75     /**
76      * @param valid the valid to set
77      */
78     void setValid(boolean valid);
79
80     /**
81      * @return the sessionKey
82      */
83     SwitchSessionKeyOF getSessionKey();
84
85     /**
86      * Returns a map containing all OFPhysicalPorts of this switch.
87      * @return The Map of OFPhysicalPort
88      */
89     Map<Long, PortGrouping> getPhysicalPorts();
90
91     /**
92      * Returns a map containing all bandwidths for all OFPorts of this switch.
93      * @return The Map of bandwidths for all OFPorts
94      */
95     Map<Long, Boolean> getPortsBandwidth();
96
97     /**
98      * Returns a Set containing all port IDs of this switch.
99      * @return The Set of port ID
100      */
101     Set<Long> getPorts();
102
103     /**
104      * Returns OFPhysicalPort of the specified portNumber of this switch.
105      * @param portNumber The port ID
106      * @return OFPhysicalPort for the specified PortNumber
107      */
108     PortGrouping getPhysicalPort(Long portNumber);
109
110     /**
111      * Returns the bandwidth of the specified portNumber of this switch.
112      * @param portNumber the port ID
113      * @return bandwidth
114      */
115     Boolean getPortBandwidth(Long portNumber);
116
117     /**
118      * Returns True if the port is enabled,
119      * @param portNumber
120      * @return True if the port is enabled
121      */
122     boolean isPortEnabled(long portNumber);
123
124     /**
125      * Returns True if the port is enabled.
126      * @param port
127      * @return True if the port is enabled
128      */
129     boolean isPortEnabled(PortGrouping port);
130
131     /**
132      * Returns a list containing all enabled ports of this switch.
133      * @return List containing all enabled ports of this switch
134      */
135     List<PortGrouping> getEnabledPorts();
136
137     // TODO:: add listeners here, manager will set them and conductor use them
138
139     /**
140      *  get message dispatch service to send the message to switch
141      *
142      * @return the message service
143      */
144     IMessageDispatchService getMessageDispatchService();
145
146    /**
147     * @return the unique xid for this session
148     */
149     Long getNextXid();
150
151     /**
152      * @param registration provider composite registration
153      */
154     void setProviderRegistration(CompositeObjectRegistration<ModelDrivenSwitch> registration);
155
156     /**
157      * @return provider composite registration
158      */
159     CompositeObjectRegistration<ModelDrivenSwitch> getProviderRegistration();
160
161     /**
162      * @return seed value for random operations
163      */
164     int getSeed();
165
166     /**
167      * @return (wrapped) notification enqueue service - {@link NotificationQueueWrapper}
168      */
169     NotificationEnqueuer getNotificationEnqueuer();
170
171     /**
172      * @param roleOnDevice
173      */
174     void setRoleOnDevice(ControllerRole roleOnDevice);
175
176     /**
177      * @return actual role
178      */
179     ControllerRole getRoleOnDevice();
180 }