blob: c76c7a6b9e78ba4b253f37e4729fa2aaea384b75 [file] [log] [blame]
Pavlin Radoslavov7940b652014-02-13 19:42:05 -08001package net.onrc.onos.datagrid;
2
3import java.util.Collection;
4
5/**
6 * Event Channel Interface.
7 */
8public interface IEventChannel<K, V> {
9 /**
10 * Startup the channel operation.
11 */
12 void startup();
13
14 /**
15 * Shutdown the channel operation.
16 */
17 void shutdown();
18
19 /**
20 * Verify the key and value types of a channel.
21 *
22 * @param typeK the type of the key to verify.
23 * @param typeV the type of the value to verify.
24 * @return true if the key and value types of the channel match,
25 * otherwise false.
26 */
27 boolean verifyKeyValueTypes(Class typeK, Class typeV);
28
29 /**
30 * Add event channel listener.
31 *
32 * @param listener the listener to add.
33 */
34 void addListener(IEventChannelListener<K, V> listener);
35
36 /**
37 * Remove event channel listener.
38 *
39 * @param listener the listener to remove.
40 */
41 void removeListener(IEventChannelListener<K, V> listener);
42
43 /**
44 * Add an entry to the channel.
45 *
Ray Milkey9c8a2132014-04-02 15:16:42 -070046 * @param key the key of the entry to add.
Pavlin Radoslavov7940b652014-02-13 19:42:05 -080047 * @param value the value of the entry to add.
48 */
49 void addEntry(K key, V value);
50
51 /**
Pavlin Radoslavovbcf14332014-03-27 18:15:30 -070052 * Add a transient entry to the channel.
Ray Milkey9c8a2132014-04-02 15:16:42 -070053 * <p/>
Pavlin Radoslavovbcf14332014-03-27 18:15:30 -070054 * The added entry is transient and will automatically timeout after 1ms.
55 *
Ray Milkey9c8a2132014-04-02 15:16:42 -070056 * @param key the key of the entry to add.
Pavlin Radoslavovbcf14332014-03-27 18:15:30 -070057 * @param value the value of the entry to add.
58 */
59 void addTransientEntry(K key, V value);
60
61 /**
Pavlin Radoslavov7940b652014-02-13 19:42:05 -080062 * Remove an entry from the channel.
63 *
64 * @param key the key of the entry to remove.
65 */
66 void removeEntry(K key);
67
68 /**
69 * Update an entry in the channel.
70 *
Ray Milkey9c8a2132014-04-02 15:16:42 -070071 * @param key the key of the entry to update.
Pavlin Radoslavov7940b652014-02-13 19:42:05 -080072 * @param value the value of the entry to update.
73 */
74 void updateEntry(K key, V value);
75
76 /**
77 * Get an entry from the channel.
78 *
79 * @param key the key of the entry to get.
80 * @return the entry if found, otherwise null.
81 */
82 @Deprecated
83 V getEntry(K key);
84
85 /**
86 * Get all entries in the channel.
87 *
88 * @return all entries that are currently in the channel.
89 */
90 @Deprecated
91 Collection<V> getAllEntries();
92
93 /**
94 * Remove all entries in the channel.
95 */
96 @Deprecated
97 void removeAllEntries();
98}