blob: 23b7be945f3a045ef73982d509e91a072161870e [file] [log] [blame]
Jonathan Hart6df90172014-04-03 10:13:11 -07001package net.onrc.onos.core.datagrid;
Pavlin Radoslavov7940b652014-02-13 19:42:05 -08002
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 */
Jonathan Hart14c4a762014-04-15 10:35:57 -070027 boolean verifyKeyValueTypes(Class<?> typeK, Class<?> typeV);
Pavlin Radoslavov7940b652014-02-13 19:42:05 -080028
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 */
Ray Milkeyff735142014-05-22 19:06:02 -070082 // TODO - this is intended to be refactored and removed
Pavlin Radoslavov7940b652014-02-13 19:42:05 -080083 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 */
Ray Milkeyff735142014-05-22 19:06:02 -070090 // TODO - this is intended to be refactored and removed
Pavlin Radoslavov7940b652014-02-13 19:42:05 -080091 Collection<V> getAllEntries();
92
93 /**
94 * Remove all entries in the channel.
95 */
Ray Milkeyff735142014-05-22 19:06:02 -070096 // TODO - this is intended to be refactored and removed
Pavlin Radoslavov7940b652014-02-13 19:42:05 -080097 void removeAllEntries();
98}