OF port deletion complete implementation
[genius.git] / interfacemanager / interfacemanager-impl / src / main / java / org / opendaylight / genius / interfacemanager / listeners / InternalTunnelCache.java
1 /*
2  * Copyright (c) 2020 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 package org.opendaylight.genius.interfacemanager.listeners;
9
10 import java.util.concurrent.ConcurrentHashMap;
11 import java.util.concurrent.ConcurrentMap;
12 import javax.inject.Singleton;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
14
15
16 @Singleton
17 public class InternalTunnelCache {
18
19     private volatile ConcurrentMap<String, Interface> internalTunnelCache = new ConcurrentHashMap<>();
20
21     public synchronized void add(String tunnelName, Interface iface) {
22         internalTunnelCache.putIfAbsent(tunnelName, iface);
23     }
24
25     public synchronized Interface get(String tunnelName) {
26         return internalTunnelCache.get(tunnelName);
27     }
28
29     public synchronized Interface remove(String tunnelName) {
30         return internalTunnelCache.remove(tunnelName);
31     }
32 }