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