Vxlan/Gre co-existence,Alarms,tunnelstate,TR fixes
[vpnservice.git] / itm / itm-impl / src / main / java / org / opendaylight / vpnservice / itm / impl / ItmCache.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.vpnservice.itm.impl;
10
11 import java.util.Collection;
12 import java.util.HashMap;
13 import java.util.Map;
14 import java.util.concurrent.ConcurrentHashMap;
15
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnel;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnel;
19
20 public class ItmCache {
21     private ConcurrentHashMap<String, Interface> interfaces = null;
22     private ConcurrentHashMap<String, ExternalTunnel> externalTunnels = null;
23     private ConcurrentHashMap<String, InternalTunnel> internalTunnels = null;
24
25     public ItmCache() {
26         this.interfaces = new ConcurrentHashMap<>();
27         this.internalTunnels = new ConcurrentHashMap<>();
28         this.externalTunnels = new ConcurrentHashMap<>();
29     }
30
31     public void addInterface(Interface iface) {
32         this.interfaces.put(iface.getName(), iface);
33     }
34
35     public Interface getInterface(String name) {
36         return this.interfaces.get(name);
37     }
38
39     public Interface removeInterface(String name) {
40         return this.interfaces.remove(name);
41     }
42
43     public Collection<Interface> getAllInterfaces() {
44         return this.interfaces.values();
45     }
46
47     public void addExternalTunnel(ExternalTunnel tunnel) {
48         this.externalTunnels.put(tunnel.getTunnelInterfaceName(), tunnel);
49     }
50
51     public ExternalTunnel getExternalTunnel(String name) {
52         return this.externalTunnels.get(name);
53     }
54
55     public ExternalTunnel removeExternalTunnel(String name) {
56         return this.externalTunnels.remove(name);
57     }
58
59     public void addInternalTunnel(InternalTunnel tunnel) {
60         this.internalTunnels.put(tunnel.getTunnelInterfaceName(), tunnel);
61     }
62
63     public InternalTunnel getInternalTunnel(String name) {
64         return this.internalTunnels.get(name);
65     }
66
67     public InternalTunnel removeInternalTunnel(String name) {
68         return this.internalTunnels.remove(name);
69     }
70
71 }