blob: 89a51e8daa99180cdbb3505047d69514355f0b81 [file] [log] [blame]
Madan Jampani94c23532015-02-05 17:40:01 -08001package org.onosproject.store.consistent.impl;
2
3import java.util.Collection;
4import java.util.List;
5import java.util.Map.Entry;
6import java.util.Set;
7
8import net.kuujo.copycat.state.Command;
9import net.kuujo.copycat.state.Initializer;
10import net.kuujo.copycat.state.Query;
11import net.kuujo.copycat.state.StateContext;
12
13/**
14 * Database state.
15 *
16 */
17public interface DatabaseState<K, V> {
18
19 /**
20 * Initializes the database state.
21 *
22 * @param context The map state context.
23 */
24 @Initializer
25 public void init(StateContext<DatabaseState<K, V>> context);
26
27 @Query
28 int size(String tableName);
29
30 @Query
31 boolean isEmpty(String tableName);
32
33 @Query
34 boolean containsKey(String tableName, K key);
35
36 @Query
37 boolean containsValue(String tableName, V value);
38
39 @Query
40 Versioned<V> get(String tableName, K key);
41
42 @Command
43 Versioned<V> put(String tableName, K key, V value);
44
45 @Command
46 Versioned<V> remove(String tableName, K key);
47
48 @Command
49 void clear(String tableName);
50
51 @Query
52 Set<K> keySet(String tableName);
53
54 @Query
55 Collection<Versioned<V>> values(String tableName);
56
57 @Query
58 Set<Entry<K, Versioned<V>>> entrySet(String tableName);
59
60 @Command
61 Versioned<V> putIfAbsent(String tableName, K key, V value);
62
63 @Command
64 boolean remove(String tableName, K key, V value);
65
66 @Command
67 boolean remove(String tableName, K key, long version);
68
69 @Command
70 boolean replace(String tableName, K key, V oldValue, V newValue);
71
72 @Command
73 boolean replace(String tableName, K key, long oldVersion, V newValue);
74
75 @Command
76 boolean batchUpdate(List<UpdateOperation<K, V>> updates);
77}