Merge ".gitignore .factorypath created by m2e-apt"
[ovsdb.git] / hwvtepsouthbound / hwvtepsouthbound-impl / src / main / java / org / opendaylight / ovsdb / hwvtepsouthbound / HwvtepDeviceInfo.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.ovsdb.hwvtepsouthbound;
10
11 import java.util.HashMap;
12 import java.util.Map;
13
14 import org.opendaylight.ovsdb.lib.notation.UUID;
15 import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
16 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
17 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
18
19 /*
20  * HwvtepDeviceInfo is used to store some of the table entries received
21  * in updates from a Hwvtep device. There will be one instance of this per
22  * Hwvtep device connected. Table entries are stored in a map keyed by
23  * uuids of respective rows.
24  *
25  * Purpose of this class is to provide data present in tables which
26  * were updated in a previous transaction and are not available in
27  * current updatedRows. This allows us to handle updates for Tables
28  * which reference other tables and need information in those tables
29  * to add data to Operational data store.
30  *
31  * e.g. Mac-entries in data store use logical-switch-ref as one of the
32  * keys. Mac-entry updates from switch rarely contain Logical_Switch
33  * table entries. To add mac-entries we need table entries from
34  * Logical_Switch table which were created in an earlier update.
35  *
36  */
37 public class HwvtepDeviceInfo {
38     private Map<UUID, LogicalSwitch> logicalSwitches = null;
39     private Map<UUID, PhysicalSwitch> physicalSwitches = null;
40     private Map<UUID, PhysicalLocator> physicalLocators = null;
41     private Map<UUID, UUID> mapTunnelToPhysicalSwitch = null;
42
43     public HwvtepDeviceInfo() {
44         this.logicalSwitches = new HashMap<>();
45         this.physicalSwitches = new HashMap<>();
46         this.physicalLocators = new HashMap<>();
47         this.mapTunnelToPhysicalSwitch = new HashMap<>();
48     }
49
50     public void putLogicalSwitch(UUID uuid, LogicalSwitch lSwitch) {
51         logicalSwitches.put(uuid, lSwitch);
52     }
53
54     public LogicalSwitch getLogicalSwitch(UUID uuid) {
55         return logicalSwitches.get(uuid);
56     }
57
58     public LogicalSwitch removeLogicalSwitch(UUID uuid) {
59         return logicalSwitches.remove(uuid);
60     }
61
62     public Map<UUID, LogicalSwitch> getLogicalSwitches() {
63         return logicalSwitches;
64     }
65
66     public void putPhysicalSwitch(UUID uuid, PhysicalSwitch pSwitch) {
67         physicalSwitches.put(uuid, pSwitch);
68     }
69
70     public PhysicalSwitch getPhysicalSwitch(UUID uuid) {
71         return physicalSwitches.get(uuid);
72     }
73
74     public PhysicalSwitch removePhysicalSwitch(UUID uuid) {
75         return physicalSwitches.remove(uuid);
76     }
77
78     public Map<UUID, PhysicalSwitch> getPhysicalSwitches() {
79         return physicalSwitches;
80     }
81
82     public void putPhysicalLocator(UUID uuid, PhysicalLocator pLocator) {
83         physicalLocators.put(uuid, pLocator);
84     }
85
86     public PhysicalLocator getPhysicalLocator(UUID uuid) {
87         return physicalLocators.get(uuid);
88     }
89
90     public PhysicalLocator removePhysicalLocator(UUID uuid) {
91         return physicalLocators.remove(uuid);
92     }
93
94     public Map<UUID, PhysicalLocator> getPhysicalLocators() {
95         return physicalLocators;
96     }
97
98     public void putPhysicalSwitchForTunnel(UUID uuid, UUID psUUID) {
99         mapTunnelToPhysicalSwitch.put(uuid, psUUID);
100     }
101
102     public PhysicalSwitch getPhysicalSwitchForTunnel(UUID uuid) {
103         return physicalSwitches.get(mapTunnelToPhysicalSwitch.get(uuid));
104     }
105
106     public void removePhysicalSwitchForTunnel(UUID uuid) {
107         mapTunnelToPhysicalSwitch.remove(uuid);
108     }
109
110     public Map<UUID, UUID> getPhysicalSwitchesForTunnels() {
111         return mapTunnelToPhysicalSwitch;
112     }
113
114 }