blob: 3d8ef7a8f5689274ea785403cbd0159201751df9 [file] [log] [blame]
alshabibab984662014-12-04 18:56:18 -08001/*
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.store.service;
Madan Jampani08822c42014-11-04 17:17:46 -080017
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080018import java.util.Collection;
Yuta HIGUCHIf0f2dfc2014-11-26 13:59:07 -080019import java.util.Optional;
Madan Jampanif5d263b2014-11-13 10:04:40 -080020import java.util.Set;
Madan Jampani08822c42014-11-04 17:17:46 -080021
Brian O'Connorabafb502014-12-02 22:26:20 -080022import org.onosproject.cluster.ControllerNode;
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080023
Madan Jampani08822c42014-11-04 17:17:46 -080024/**
Madan Jampani37c2e702014-11-04 18:11:10 -080025 * Service interface for running administrative tasks on a Database.
Madan Jampani08822c42014-11-04 17:17:46 -080026 */
27public 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 Jampanidef2c652014-11-12 13:50:10 -080039 * 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 Jampani08822c42014-11-04 17:17:46 -080049 * Lists all the tables in the database.
Madan Jampanif5d263b2014-11-13 10:04:40 -080050 * @return set of table names.
Madan Jampani08822c42014-11-04 17:17:46 -080051 */
Madan Jampanif5d263b2014-11-13 10:04:40 -080052 public Set<String> listTables();
Madan Jampani08822c42014-11-04 17:17:46 -080053
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 HIGUCHI60731cb2014-11-11 01:34:46 -080064
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 HIGUCHIf0f2dfc2014-11-26 13:59:07 -080086
87 /**
88 * Returns the current Leader of the default Tablet.
89 *
90 * @return leader node
91 */
92 public Optional<ControllerNode> leader();
Madan Jampani08822c42014-11-04 17:17:46 -080093}