Jonathan Hart | 6df9017 | 2014-04-03 10:13:11 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.datagrid; |
Pavlin Radoslavov | 7940b65 | 2014-02-13 19:42:05 -0800 | [diff] [blame] | 2 | |
| 3 | import java.util.Collection; |
| 4 | |
| 5 | /** |
| 6 | * Event Channel Interface. |
| 7 | */ |
| 8 | public 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 Hart | 14c4a76 | 2014-04-15 10:35:57 -0700 | [diff] [blame] | 27 | boolean verifyKeyValueTypes(Class<?> typeK, Class<?> typeV); |
Pavlin Radoslavov | 7940b65 | 2014-02-13 19:42:05 -0800 | [diff] [blame] | 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 Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 46 | * @param key the key of the entry to add. |
Pavlin Radoslavov | 7940b65 | 2014-02-13 19:42:05 -0800 | [diff] [blame] | 47 | * @param value the value of the entry to add. |
| 48 | */ |
| 49 | void addEntry(K key, V value); |
| 50 | |
| 51 | /** |
Pavlin Radoslavov | bcf1433 | 2014-03-27 18:15:30 -0700 | [diff] [blame] | 52 | * Add a transient entry to the channel. |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 53 | * <p/> |
Pavlin Radoslavov | bcf1433 | 2014-03-27 18:15:30 -0700 | [diff] [blame] | 54 | * The added entry is transient and will automatically timeout after 1ms. |
| 55 | * |
Ray Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 56 | * @param key the key of the entry to add. |
Pavlin Radoslavov | bcf1433 | 2014-03-27 18:15:30 -0700 | [diff] [blame] | 57 | * @param value the value of the entry to add. |
| 58 | */ |
| 59 | void addTransientEntry(K key, V value); |
| 60 | |
| 61 | /** |
Pavlin Radoslavov | 7940b65 | 2014-02-13 19:42:05 -0800 | [diff] [blame] | 62 | * 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 Milkey | 9c8a213 | 2014-04-02 15:16:42 -0700 | [diff] [blame] | 71 | * @param key the key of the entry to update. |
Pavlin Radoslavov | 7940b65 | 2014-02-13 19:42:05 -0800 | [diff] [blame] | 72 | * @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 Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 82 | // TODO - this is intended to be refactored and removed |
Pavlin Radoslavov | 7940b65 | 2014-02-13 19:42:05 -0800 | [diff] [blame] | 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 | */ |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 90 | // TODO - this is intended to be refactored and removed |
Pavlin Radoslavov | 7940b65 | 2014-02-13 19:42:05 -0800 | [diff] [blame] | 91 | Collection<V> getAllEntries(); |
| 92 | |
| 93 | /** |
| 94 | * Remove all entries in the channel. |
| 95 | */ |
Ray Milkey | ff73514 | 2014-05-22 19:06:02 -0700 | [diff] [blame] | 96 | // TODO - this is intended to be refactored and removed |
Pavlin Radoslavov | 7940b65 | 2014-02-13 19:42:05 -0800 | [diff] [blame] | 97 | void removeAllEntries(); |
| 98 | } |