YuanyouZhang | d06bb6b | 2015-08-05 16:59:07 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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 class representing a database data. |
| 24 | */ |
| 25 | public class OvsdbTableStore { |
| 26 | |
| 27 | private final ConcurrentMap<String, OvsdbRowStore> tableStore = Maps.newConcurrentMap(); |
| 28 | |
| 29 | /** |
| 30 | * Gets the ovsdbRowStore. |
| 31 | * |
| 32 | * @param tableName a ovsdb table name |
| 33 | * @return OvsdbRowStore the data of the table |
| 34 | */ |
| 35 | public OvsdbRowStore getRows(String tableName) { |
| 36 | return tableStore.get(tableName); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Create or update a value to tableStore. |
| 41 | * |
| 42 | * @param tableName key of the tableName |
| 43 | * @param rowStore a row of the table |
| 44 | */ |
| 45 | public void createOrUpdateTable(String tableName, OvsdbRowStore rowStore) { |
| 46 | tableStore.put(tableName, rowStore); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Drops a value to table data. |
| 51 | * |
| 52 | * @param tableName key of the tableName |
| 53 | */ |
| 54 | public void dropTable(String tableName) { |
| 55 | tableStore.remove(tableName); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Gets the tableStore. |
| 60 | * |
| 61 | * @return tableStore |
| 62 | */ |
| 63 | public ConcurrentMap<String, OvsdbRowStore> getTableStore() { |
| 64 | return tableStore; |
| 65 | } |
| 66 | |
| 67 | } |