alshabib | ab98466 | 2014-12-04 18:56:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.store.service; |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 17 | |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 18 | import java.util.Collection; |
Yuta HIGUCHI | f0f2dfc | 2014-11-26 13:59:07 -0800 | [diff] [blame] | 19 | import java.util.Optional; |
Madan Jampani | f5d263b | 2014-11-13 10:04:40 -0800 | [diff] [blame] | 20 | import java.util.Set; |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 21 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 22 | import org.onosproject.cluster.ControllerNode; |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 23 | |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 24 | /** |
Madan Jampani | 37c2e70 | 2014-11-04 18:11:10 -0800 | [diff] [blame] | 25 | * Service interface for running administrative tasks on a Database. |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 26 | */ |
| 27 | public interface DatabaseAdminService { |
| 28 | |
| 29 | /** |
| 30 | * Creates a new table. |
| 31 | * Table creation is idempotent. Attempting to create a table |
| 32 | * that already exists will be a noop. |
| 33 | * @param name table name. |
| 34 | * @return true if the table was created by this call, false otherwise. |
| 35 | */ |
| 36 | public boolean createTable(String name); |
| 37 | |
| 38 | /** |
Madan Jampani | def2c65 | 2014-11-12 13:50:10 -0800 | [diff] [blame] | 39 | * Creates a new table where last update time will be used to track and expire old entries. |
| 40 | * Table creation is idempotent. Attempting to create a table |
| 41 | * that already exists will be a noop. |
| 42 | * @param name table name. |
| 43 | * @param ttlMillis total duration in millis since last update time when entries will be expired. |
| 44 | * @return true if the table was created by this call, false otherwise. |
| 45 | */ |
| 46 | public boolean createTable(String name, int ttlMillis); |
| 47 | |
| 48 | /** |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 49 | * Lists all the tables in the database. |
Madan Jampani | f5d263b | 2014-11-13 10:04:40 -0800 | [diff] [blame] | 50 | * @return set of table names. |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 51 | */ |
Madan Jampani | f5d263b | 2014-11-13 10:04:40 -0800 | [diff] [blame] | 52 | public Set<String> listTables(); |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * Deletes a table from the database. |
| 56 | * @param name name of the table to delete. |
| 57 | */ |
| 58 | public void dropTable(String name); |
| 59 | |
| 60 | /** |
| 61 | * Deletes all tables from the database. |
| 62 | */ |
| 63 | public void dropAllTables(); |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 64 | |
| 65 | |
| 66 | /** |
| 67 | * Add member to default Tablet. |
| 68 | * |
| 69 | * @param node to add |
| 70 | */ |
| 71 | public void addMember(ControllerNode node); |
| 72 | |
| 73 | /** |
| 74 | * Remove member from default Tablet. |
| 75 | * |
| 76 | * @param node node to remove |
| 77 | */ |
| 78 | public void removeMember(ControllerNode node); |
| 79 | |
| 80 | /** |
| 81 | * List members forming default Tablet. |
| 82 | * |
| 83 | * @return Copied collection of members forming default Tablet. |
| 84 | */ |
| 85 | public Collection<ControllerNode> listMembers(); |
Yuta HIGUCHI | f0f2dfc | 2014-11-26 13:59:07 -0800 | [diff] [blame] | 86 | |
| 87 | /** |
| 88 | * Returns the current Leader of the default Tablet. |
| 89 | * |
| 90 | * @return leader node |
| 91 | */ |
| 92 | public Optional<ControllerNode> leader(); |
Madan Jampani | 08822c4 | 2014-11-04 17:17:46 -0800 | [diff] [blame] | 93 | } |