Package com.illumon.iris.controller
Class ControllerHashtable
java.lang.Object
com.illumon.iris.controller.ControllerHashtable
- All Implemented Interfaces:
ControllerHashtableEventSource
,Map<Long,
PersistentQueryInfo>
- Direct Known Subclasses:
ControllerHashtableServer
,PersistentQueryControllerClient
public abstract class ControllerHashtable
extends Object
implements Map<Long,PersistentQueryInfo>, ControllerHashtableEventSource
This class provides a base for a Controller hash table.
The server maintains the authoritative version of the map. Clients can connect to the server and listen to the updates to which they subscribe. Clients can also send the server their update requests, via a separate Comm channel.
Threading rules:
- All methods are already appropriately synchronized, so you do not need any further synchronization for most tasks.
- To gain exclusive access to the data (for example, while
iterating over the entries in the map), synchronize on the object
returned by
getData()
. - The ControllerHashtable itself is not the lock for the map data!
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final io.deephaven.hash.KeyedLongObjectHashMap<PersistentQueryInfo>
protected final CopyOnWriteArrayList<ControllerHashtableEventHandler>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Subscribe to events.void
Subscribe to events with an initial snapshot of the data.void
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
Note that the returned set is a view and should be synchronized when accessed.final io.deephaven.hash.KeyedLongObjectHashMap<PersistentQueryInfo>
getData()
Get the internal data map for this client.boolean
isEmpty()
keySet()
protected void
put
(Long key, PersistentQueryInfo value) void
putAll
(Map<? extends Long, ? extends PersistentQueryInfo> t) void
Unsubscribe the supplied handler from further events.int
size()
values()
Note that this breaks the contract ofMap
because the values are copied.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
handlers
-
data
-
-
Constructor Details
-
ControllerHashtable
public ControllerHashtable()
-
-
Method Details
-
addEventHandlerAndGetData
Description copied from interface:ControllerHashtableEventSource
Subscribe to events with an initial snapshot of the data.- Specified by:
addEventHandlerAndGetData
in interfaceControllerHashtableEventSource
- Parameters:
handler
- the handler for ControllerHashTableEvents
-
addEventHandler
Description copied from interface:ControllerHashtableEventSource
Subscribe to events.- Specified by:
addEventHandler
in interfaceControllerHashtableEventSource
- Parameters:
handler
- the handler for ControllerHashTableEvents
-
removeEventHandler
Description copied from interface:ControllerHashtableEventSource
Unsubscribe the supplied handler from further events.- Specified by:
removeEventHandler
in interfaceControllerHashtableEventSource
- Parameters:
handler
- the handler to unsubscribe
-
notifyHandlers
-
getData
Get the internal data map for this client.- Returns:
- the internal map of queries.
-
get
- Specified by:
get
in interfaceMap<Long,
PersistentQueryInfo>
-
put
- Specified by:
put
in interfaceMap<Long,
PersistentQueryInfo>
-
clear
public void clear()- Specified by:
clear
in interfaceMap<Long,
PersistentQueryInfo>
-
remove
- Specified by:
remove
in interfaceMap<Long,
PersistentQueryInfo>
-
size
public int size()- Specified by:
size
in interfaceMap<Long,
PersistentQueryInfo>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceMap<Long,
PersistentQueryInfo>
-
containsKey
- Specified by:
containsKey
in interfaceMap<Long,
PersistentQueryInfo>
-
containsValue
- Specified by:
containsValue
in interfaceMap<Long,
PersistentQueryInfo>
-
values
Note that this breaks the contract ofMap
because the values are copied.- Specified by:
values
in interfaceMap<Long,
PersistentQueryInfo>
-
putAll
- Specified by:
putAll
in interfaceMap<Long,
PersistentQueryInfo>
-
entrySet
Note that the returned set is a view and should be synchronized when accessed.- Specified by:
entrySet
in interfaceMap<Long,
PersistentQueryInfo> - Returns:
-
keySet
- Specified by:
keySet
in interfaceMap<Long,
PersistentQueryInfo>
-