2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.openflowplugin.openflow.md.core.session;
11 import java.util.Collections;
12 import java.util.Map.Entry;
14 import java.util.concurrent.ConcurrentHashMap;
15 import java.util.concurrent.atomic.AtomicLong;
17 import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
18 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
24 public class SessionContextOFImpl implements SessionContext {
26 private GetFeaturesOutput features;
27 private ConnectionConductor primaryConductor;
28 private ConcurrentHashMap<SwitchConnectionDistinguisher, ConnectionConductor> auxiliaryConductors;
29 private boolean valid;
30 private SwitchConnectionDistinguisher sessionKey;
31 private IMessageDispatchService mdService;
32 private final AtomicLong xid;
37 public SessionContextOFImpl() {
38 auxiliaryConductors = new ConcurrentHashMap<>();
39 mdService = new MessageDispatchServiceImpl(this);
40 xid = new AtomicLong();
44 public ConnectionConductor getPrimaryConductor() {
45 return primaryConductor;
49 public ConnectionConductor getAuxiliaryConductor(
50 SwitchConnectionDistinguisher auxiliaryKey) {
51 return auxiliaryConductors.get(auxiliaryKey);
55 public void addAuxiliaryConductor(
56 SwitchConnectionDistinguisher auxiliaryKey,
57 ConnectionConductor conductor) {
58 auxiliaryConductors.put(auxiliaryKey, conductor);
62 public Set<Entry<SwitchConnectionDistinguisher, ConnectionConductor>> getAuxiliaryConductors() {
63 return Collections.unmodifiableSet(auxiliaryConductors.entrySet());
67 public GetFeaturesOutput getFeatures() {
75 public void setFeatures(GetFeaturesOutput features) {
76 this.features = features;
80 * @param primaryConductor
81 * the primaryConductor to set
83 public void setPrimaryConductor(ConnectionConductor primaryConductor) {
84 this.primaryConductor = primaryConductor;
88 public ConnectionConductor removeAuxiliaryConductor(
89 SwitchConnectionDistinguisher connectionCookie) {
90 return auxiliaryConductors.remove(connectionCookie);
94 public boolean isValid() {
99 public void setValid(boolean valid) {
104 * @param sessionKey the sessionKey to set
106 public void setSessionKey(SwitchConnectionDistinguisher sessionKey) {
107 this.sessionKey = sessionKey;
111 public SwitchConnectionDistinguisher getSessionKey() {
116 public IMessageDispatchService getMessageDispatchService() {
121 public Long getNextXid() {
122 return xid.incrementAndGet();