public class ClusterGraph extends Object
NodeConnectivity.ConnectionStatus
could be OK/FAILED:
{a -> {{a: OK}, {b: FAILED}, {c: OK}}}
{b -> {{a: FAILED}, {b: OK}, {c: FAILED}}}
{c -> {{a: OK}, {b: false}, {c: OK}}}
This class represents a cluster as a graph, it allows to:
- find fully connected node: node that connected to all other nodes exclude unresponsive nodes.
- find a decision maker: a node which should decide to add failed node to the unresponsive list.
The decision maker is an optimization technique, needed to reduce parallel updates of the cluster state.
Still, each node can choose its own decision maker. See this#getDecisionMaker()
for details
- find a node which should be healed and excluded from the unresponsive list
- transform all asymmetric failures to a symmetric ones. If there is an asymmetric failure
(node B can connect to node B, but node B can not connect to node A) between two nodes
then make it symmetric which means neither node A nor B can connect to each other.
Modifier and Type | Class and Description |
---|---|
static class |
ClusterGraph.ClusterGraphHelper
Helper provides methods to build cluster graph
|
Constructor and Description |
---|
ClusterGraph() |
Modifier and Type | Method and Description |
---|---|
FailureDetectorMetrics.ConnectivityGraph |
connectivityGraph()
Transform ClusterGraph to Connectivity graph
|
Optional<NodeRank> |
findFailedNode()
Find failed node in a graph.
|
Optional<NodeRank> |
findFullyConnectedNode(String endpoint,
List<String> unresponsiveNodes)
See if the node is fully connected.
|
Optional<NodeRank> |
getDecisionMaker()
Get a decision maker node to detect a failure.
|
NodeConnectivity |
getNodeConnectivity(String node)
Get node by name
|
int |
size()
Graph size
|
static ClusterGraph |
toClusterGraph(ClusterState cluster,
String localNode)
Transform a cluster state to the cluster graph.
|
String |
toJson() |
ClusterGraph |
toSymmetric()
Convert a cluster graph which could have asymmetric failures to a graph with symmetric failures between nodes.
|
public static ClusterGraph toClusterGraph(ClusterState cluster, String localNode)
cluster
- cluster statepublic ClusterGraph toSymmetric()
NodeConnectivity.ConnectionStatus
for OK/FAILED
For instance:
{a: [{a: OK, b: FAILED}]}
{b: [{a: OK, b: OK}]}
Node A believes that node B is disconnected
Node B believes that node A is connected.
The graph will be changed to:
{a: [{a: OK, b: FAILED}]}
{b: [{a: FAILED, b: OK}]}
Node B is not connected to node A anymore.public Optional<NodeRank> getDecisionMaker()
The decision maker is an optimization technique, needed to reduce parallel updates of the cluster state. Still, each node can choose its own decision maker. Note: it's not required to choose a particular one for entire cluster to add a node to unresponsive list. In a partitioned scenario, a minority side can choose to have a decision maker just that it's decisions will not be used as it does not have consensus The decision maker always exists. There is always at least the local node, it always has at least one successful connection to itself. We also have two additional checks to prevent all possible incorrect ways. Decision maker not found if: - ClusterGraph is empty, which is an invalid state. - the decision maker doesn't have connections, which is also impossible.
public Optional<NodeRank> findFailedNode()
public Optional<NodeRank> findFullyConnectedNode(String endpoint, List<String> unresponsiveNodes)
endpoint
- local node nameunresponsiveNodes
- list of unresponsive nodes in the layoutpublic NodeConnectivity getNodeConnectivity(String node)
node
- node namepublic int size()
public String toJson()
public FailureDetectorMetrics.ConnectivityGraph connectivityGraph()
Copyright © 2019 CorfuDB. All rights reserved.