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 TypeMethodDescriptionvoidSubscribe to events.voidSubscribe to events with an initial snapshot of the data.voidclear()booleancontainsKey(Object key) booleancontainsValue(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.booleanisEmpty()keySet()protected voidput(Long key, PersistentQueryInfo value) voidputAll(Map<? extends Long, ? extends PersistentQueryInfo> t) voidUnsubscribe the supplied handler from further events.intsize()values()Note that this breaks the contract ofMapbecause the values are copied.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:ControllerHashtableEventSourceSubscribe to events with an initial snapshot of the data.- Specified by:
addEventHandlerAndGetDatain interfaceControllerHashtableEventSource- Parameters:
handler- the handler for ControllerHashTableEvents
-
addEventHandler
Description copied from interface:ControllerHashtableEventSourceSubscribe to events.- Specified by:
addEventHandlerin interfaceControllerHashtableEventSource- Parameters:
handler- the handler for ControllerHashTableEvents
-
removeEventHandler
Description copied from interface:ControllerHashtableEventSourceUnsubscribe the supplied handler from further events.- Specified by:
removeEventHandlerin 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:
getin interfaceMap<Long,PersistentQueryInfo>
-
put
- Specified by:
putin interfaceMap<Long,PersistentQueryInfo>
-
clear
public void clear()- Specified by:
clearin interfaceMap<Long,PersistentQueryInfo>
-
remove
- Specified by:
removein interfaceMap<Long,PersistentQueryInfo>
-
size
public int size()- Specified by:
sizein interfaceMap<Long,PersistentQueryInfo>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceMap<Long,PersistentQueryInfo>
-
containsKey
- Specified by:
containsKeyin interfaceMap<Long,PersistentQueryInfo>
-
containsValue
- Specified by:
containsValuein interfaceMap<Long,PersistentQueryInfo>
-
values
Note that this breaks the contract ofMapbecause the values are copied.- Specified by:
valuesin interfaceMap<Long,PersistentQueryInfo>
-
putAll
- Specified by:
putAllin interfaceMap<Long,PersistentQueryInfo>
-
entrySet
Note that the returned set is a view and should be synchronized when accessed.- Specified by:
entrySetin interfaceMap<Long,PersistentQueryInfo> - Returns:
-
keySet
- Specified by:
keySetin interfaceMap<Long,PersistentQueryInfo>
-