blob: ef7ea6748374d651f28352379c59152e532a513c [file] [log] [blame]
Madan Jampani08822c42014-11-04 17:17:46 -08001package org.onlab.onos.store.service;
2
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -08003import java.util.Collection;
Yuta HIGUCHIf0f2dfc2014-11-26 13:59:07 -08004import java.util.Optional;
Madan Jampanif5d263b2014-11-13 10:04:40 -08005import java.util.Set;
Madan Jampani08822c42014-11-04 17:17:46 -08006
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -08007import org.onlab.onos.cluster.ControllerNode;
8
Madan Jampani08822c42014-11-04 17:17:46 -08009/**
Madan Jampani37c2e702014-11-04 18:11:10 -080010 * Service interface for running administrative tasks on a Database.
Madan Jampani08822c42014-11-04 17:17:46 -080011 */
12public interface DatabaseAdminService {
13
14 /**
15 * Creates a new table.
16 * Table creation is idempotent. Attempting to create a table
17 * that already exists will be a noop.
18 * @param name table name.
19 * @return true if the table was created by this call, false otherwise.
20 */
21 public boolean createTable(String name);
22
23 /**
Madan Jampanidef2c652014-11-12 13:50:10 -080024 * Creates a new table where last update time will be used to track and expire old entries.
25 * Table creation is idempotent. Attempting to create a table
26 * that already exists will be a noop.
27 * @param name table name.
28 * @param ttlMillis total duration in millis since last update time when entries will be expired.
29 * @return true if the table was created by this call, false otherwise.
30 */
31 public boolean createTable(String name, int ttlMillis);
32
33 /**
Madan Jampani08822c42014-11-04 17:17:46 -080034 * Lists all the tables in the database.
Madan Jampanif5d263b2014-11-13 10:04:40 -080035 * @return set of table names.
Madan Jampani08822c42014-11-04 17:17:46 -080036 */
Madan Jampanif5d263b2014-11-13 10:04:40 -080037 public Set<String> listTables();
Madan Jampani08822c42014-11-04 17:17:46 -080038
39 /**
40 * Deletes a table from the database.
41 * @param name name of the table to delete.
42 */
43 public void dropTable(String name);
44
45 /**
46 * Deletes all tables from the database.
47 */
48 public void dropAllTables();
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080049
50
51 /**
52 * Add member to default Tablet.
53 *
54 * @param node to add
55 */
56 public void addMember(ControllerNode node);
57
58 /**
59 * Remove member from default Tablet.
60 *
61 * @param node node to remove
62 */
63 public void removeMember(ControllerNode node);
64
65 /**
66 * List members forming default Tablet.
67 *
68 * @return Copied collection of members forming default Tablet.
69 */
70 public Collection<ControllerNode> listMembers();
Yuta HIGUCHIf0f2dfc2014-11-26 13:59:07 -080071
72 /**
73 * Returns the current Leader of the default Tablet.
74 *
75 * @return leader node
76 */
77 public Optional<ControllerNode> leader();
Madan Jampani08822c42014-11-04 17:17:46 -080078}