...
When a client connects to the server with subscription enabled flag, an HARegionQueue for that client-proxy is created on the server side.
Class Diagrams
PlantUML |
---|
skinparam dpi 80
@startuml
hide empty members
title Server to Client Queues - Class Diagram
class CacheClientNotifier {
Singleton for a Cache.
}
class CacheClientProxy {
One for each client.
Keeps track of a the subscriptions for the client.
}
class MessageDispatcher {
Thread that reads events from the queue.
}
class HARegionQueue {
Holds the list of events to
dispatch to a single client.
}
class HAContainerMap {
Holds the actual values for events to dispatch.
Used to store only a single copy of each value
across all queues.
}
interface HAContainerMap
CacheClientNotifier o-- CacheClientProxy
CacheClientProxy o-- MessageDispatcher
CacheClientNotifier o-- HAContainerMap
MessageDispatcher o-- HARegionQueue
HARegionQueue --> HAContainerMap
HARegionQueue o-- HARegion
@enduml |
Sequence Diagrams
PlantUML |
---|
skinparam dpi 80
title Put into Queue (for Partitioned Regions)
actor user
user -> "PR Primary" : put
"PR Primary" -> "PR Secondary" : UpdateMessage
"PR Primary" -> "Adjunct Receiver": PutMessage
note right
The primary notifies all members that have
clients with interest
end note
"PR Primary" -> CacheClientNotifier: notifyClients()
"Adjunct Receiver" -> CacheClientNotifier: notifyClients()
note right
All members with interest
call notifyClients locally
end note
"PR Secondary" -> CacheClientNotifier: notifyClients()
CacheClientNotifier -> CacheClientProxy: deliverMessage()
CacheClientProxy -> MessageDispatcher : enqueueMessage()
MessageDispatcher -> HARegionQueue: basicPut()
|
Adding events to HARegionQueue:
...
Based on the interest satisfied by the client, the ClientMessage is created and added to the HARegionQueue of the interested client (“CacheClientProxy.enqueueMessage()”). Once the event is added to the HARegionQueue the cache operation thread returns to the caller.
There are cases where the events are not simply added to the HARegionQueue. Specifically, there currently are two cases where the event is put into a temporary queue.
1. The server is providing an initial image to a performed (see HARegionQueue.giiQueue)
2. The server is initializing the message dispatcher as part of cliesnt queue initialization logic (see CacheClientProxy.queuedEvents)
After these operations are completed, the temporary queues are drained and the event is added to the HARegionQueue. The diagrams below show the different put paths in detail.
Delivering/Dispatching Events to Client:
...
After the events are delivered and removed from the primary queue (node), it sends the “QueueRemovalMessage” to secondary queues (nodes); as part of message processing each secondary queue removes events from its queue(“QueueRemovalMessage.process().removeDispatchedEvents()”.
The diagram below shows a simplified view of the queue removal logic.
Memory Optimization:
...