Goals
Enable client code (and Terracotta internal code) to have visibility on which nodes are participating in the Terracotta cluster. (Jira ticket: https://jira.terracotta.org/jira/browse/CDV-54
)
Requirements
- Raise events when nodes join and/or leave the cluster
- Enable clients to receive and act on the above events
- Enable clients to build higher-level business logic based on the cluster membership information including:
- ability to provide and access meta information about nodes
- ability to do cluster-wide or point-to-point communication
- ability to detect when a node joins the cluster
- ability to detect when a node leaves the cluster because of client- or server-initiated disconnect
- ability to detect when a node re-joins the cluster
- Overhaul Distributed Method Invocation implementation based on Cluster Membership Events
High Level Implementation Proposal
- L2 is always aware of cluster membership and will send custom network messages to alert nodes of relevant changes. These messages include:
- nodeConnected is sent to all nodes already in the cluster when a new node connects. The message will contain the clientId if the newly connected node.
- nodeDisconnected is sent to all nodes that are still in the cluster when a node disconnects. The message will contain the clientId if the disconnected node.
- L2 will provide a newly connected node with its clientId and clientId's of other nodes currently in the cluster. This might be a custom new message or part of the handshake sequence.
- L1 will maintain a special internal data-structure to represent cluster membership information received in the above messages
- Client will be able to specify in configuration an instance that will receive method calls when cluster membership changes. This will be similar to DSO Root specification. The names of methods to call are pre-defined (see below). All methods are optional.
- Possible callbacks are:
- void nodeConnected(String nodeId) - called when a new node joins the cluster
- void nodeDisconnected(String nodeId) - called when a node disconnects from the cluster
- void thisNodeConnected(String thisNodeId, String[] nodesCurrentlyInTheCluster) - called when this node connects, or re-connects, to the cluster
- void thisNodeDisconnected(String thisNodeId) - called when this nodes disconnects from the cluster
- These callback methods will be called by a special thread. Exception thrown by the client code in these callbacks will be caught and logged.
- Given these callbacks clients can maintain a (possibly DSO-shared) data structure with node meta information, per-node messages queues, etc. In the future, Terracotta provide an optional library with sample implementation of such data structure.
High Level Tasks And Status
TBD
Repository
Currently this work is done in https://svn.terracotta.org/repo/tc/dso/branches/cluster-events