blob: 0117beab3d40ab6edeb88dd875e5af4c16f80333 [file] [log] [blame]
YuanyouZhangd06bb6b2015-08-05 16:59:07 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
YuanyouZhangd06bb6b2015-08-05 16:59:07 +08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.ovsdb.controller;
17
18import java.util.concurrent.ConcurrentMap;
19
20import com.google.common.collect.Maps;
21
22/**
23 * The cache for local ovsdb database.
24 */
25public class OvsdbStore {
26
27 private final ConcurrentMap<String, OvsdbTableStore> ovsdbStore = Maps.newConcurrentMap();
28
29 /**
30 * Gets the OvsdbTableStore.
31 *
32 * @param dbName ovsdb database name
33 * @return tableStore OvsdbTableStore
34 */
35 public OvsdbTableStore getOvsdbTableStore(String dbName) {
36 OvsdbTableStore tableStore = ovsdbStore.get(dbName);
37 if (tableStore == null) {
38 return null;
39 }
40 return tableStore;
41 }
42
43 /**
44 * Create or Update a value to ovsdbStore.
45 *
46 * @param dbName ovsdb database name
47 * @param tableStore a database tableStore.
48 */
49 public void createOrUpdateOvsdbStore(String dbName, OvsdbTableStore tableStore) {
50 ovsdbStore.put(dbName, tableStore);
51 }
52
53 /**
54 * Drops a value to rowStore.
55 *
56 * @param dbName ovsdb database name
57 */
58 public void dropOvsdbStore(String dbName) {
59 ovsdbStore.remove(dbName);
60 }
61
62 /**
63 * Gets the ovsdbStore.
64 *
65 * @return ovsdbStore
66 */
67 public ConcurrentMap<String, OvsdbTableStore> getOvsdbStore() {
68 return ovsdbStore;
69 }
70
71}