2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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
8 package org.opendaylight.vpnservice.neutronvpn.api.l2gw.utils;
10 import java.util.concurrent.ConcurrentMap;
12 import org.opendaylight.vpnservice.neutronvpn.api.l2gw.L2GatewayDevice;
13 import org.opendaylight.vpnservice.utils.cache.CacheUtil;
15 public class L2GatewayCacheUtils {
16 public static final String L2GATEWAY_CACHE_NAME = "L2GW";
18 public static void createL2DeviceCache() {
19 if (CacheUtil.getCache(L2GatewayCacheUtils.L2GATEWAY_CACHE_NAME) == null) {
20 CacheUtil.createCache(L2GatewayCacheUtils.L2GATEWAY_CACHE_NAME);
24 public static void addL2DeviceToCache(String devicename, L2GatewayDevice l2GwDevice) {
25 ConcurrentMap<String, L2GatewayDevice> cachedMap = (ConcurrentMap<String, L2GatewayDevice>) CacheUtil
26 .getCache(L2GatewayCacheUtils.L2GATEWAY_CACHE_NAME);
27 cachedMap.put(devicename, l2GwDevice);
30 public static L2GatewayDevice removeL2DeviceFromCache(String devicename) {
31 ConcurrentMap<String, L2GatewayDevice> cachedMap = (ConcurrentMap<String, L2GatewayDevice>) CacheUtil
32 .getCache(L2GatewayCacheUtils.L2GATEWAY_CACHE_NAME);
33 return cachedMap.remove(devicename);
36 public static L2GatewayDevice getL2DeviceFromCache(String devicename) {
37 ConcurrentMap<String, L2GatewayDevice> cachedMap = (ConcurrentMap<String, L2GatewayDevice>) CacheUtil
38 .getCache(L2GatewayCacheUtils.L2GATEWAY_CACHE_NAME);
39 return cachedMap.get(devicename);
42 public static ConcurrentMap<String, L2GatewayDevice> getCache() {
43 return (ConcurrentMap<String, L2GatewayDevice>) CacheUtil
44 .getCache(L2GatewayCacheUtils.L2GATEWAY_CACHE_NAME);