YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.ovsdb.controller; |
| 17 | |
| 18 | import java.util.concurrent.ConcurrentMap; |
| 19 | |
| 20 | import com.google.common.collect.Maps; |
| 21 | |
| 22 | /** |
| 23 | * The cache for local ovsdb database. |
| 24 | */ |
| 25 | public 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 | } |