sessionManager proposal
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / session / SessionContextOFImpl.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.Iterator;
12 import java.util.concurrent.ConcurrentHashMap;
13
14 import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
15 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDestinguisher;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
17
18 /**
19  * @author mirehak
20  */
21 public class SessionContextOFImpl implements SessionContext {
22
23     private GetFeaturesOutput features;
24     private ConnectionConductor primaryConductor;
25     private ConcurrentHashMap<Object, ConnectionConductor> auxiliaryConductors;
26
27     /**
28      * default ctor
29      */
30     public SessionContextOFImpl() {
31         auxiliaryConductors = new ConcurrentHashMap<>();
32     }
33
34     @Override
35     public ConnectionConductor getPrimaryConductor() {
36         return primaryConductor;
37     }
38
39     @Override
40     public ConnectionConductor getAuxiliaryConductor(
41             SwitchConnectionDestinguisher auxiliaryKey) {
42         return auxiliaryConductors.get(auxiliaryKey);
43     }
44
45     @Override
46     public void addAuxiliaryConductor(
47             SwitchConnectionDestinguisher auxiliaryKey,
48             ConnectionConductor conductor) {
49         auxiliaryConductors.put(auxiliaryKey, conductor);
50     }
51
52     @Override
53     public Iterator<ConnectionConductor> getAuxiliaryConductors() {
54         return auxiliaryConductors.values().iterator();
55     }
56
57     @Override
58     public GetFeaturesOutput getFeatures() {
59         return features;
60     }
61
62     /**
63      * @param features
64      *            the features to set
65      */
66     public void setFeatures(GetFeaturesOutput features) {
67         this.features = features;
68     }
69
70     /**
71      * @param primaryConductor
72      *            the primaryConductor to set
73      */
74     public void setPrimaryConductor(ConnectionConductor primaryConductor) {
75         this.primaryConductor = primaryConductor;
76     }
77
78     @Override
79     public ConnectionConductor removeAuxiliaryConductor(
80             SwitchConnectionDestinguisher connectionCookie) {
81         return auxiliaryConductors.remove(connectionCookie);
82     }
83 }