public ClusterNode(NodeHeader header) { this.Header = header; nodeList = new NodeList(this); Console.WriteLine(header); Console.WriteLine(); }
public void ElectionResponse(NodeHeader node) { Node caller = nodeList.GetNode(node); if (caller != null) { caller.ResponseTickCount = Environment.TickCount; } }
public void ElectionResult(NodeHeader node) { lock (syncLock) { Header.State = NodeState.Follower; nodeList.SetLeader(node); leaderNode = nodeList.Leader; } }
public ClusterWelcomeMessage RegisterNode(NodeHeader node) { AddNode(node); ClusterWelcomeMessage message = new ClusterWelcomeMessage(); message.NodeID = Header; message.NodeList = nodeList.ToHeaderList(); return message; }
public DiscoveryService(NodeHeader header, NodeConfigCollection addresses) { this.header = header; this.nodes = new List<NodeConfigurationElement>(); for (int i = 0; i < addresses.Count; i++) { this.nodes.Add(addresses[i]); } }
public void ElectionRequest(NodeHeader node) { Node caller = nodeList.GetNode(node); if (caller != null) { caller.ElectionResponse(Header); } lock (syncLock) { if (Header.State == NodeState.Follower) { BroadcastElection(); } } }
static void Main(string[] args) { ProgramSettings.Cluster = (ClusterConfigurationSection)ConfigurationManager.GetSection("ClusterSettings/Cluster"); try { NodeHeader nodeId = new NodeHeader(Process.GetCurrentProcess().Id, ProgramSettings.Cluster.Endpoint); ServiceNode instance = new ServiceNode(nodeId); wcfServiceHost.StartPipeHost(instance, nodeId.NodeAddress); instance.JoinCluster(); } catch (Exception) { throw; } Console.Read(); }
public void ElectionResponse(NodeHeader node) { ChannelCheck(); channel.ElectionResponse(node); }
public void ElectionRequest(NodeHeader node) { ChannelCheck(); channel.ElectionRequest(node); }
public ClusterWelcomeMessage RegisterNode(NodeHeader node) { ChannelCheck(); return channel.RegisterNode(node); }
public ServiceNode(NodeHeader nodeID) : base(nodeID) { }
public void OnNodeRemoved(NodeHeader node) { Console.WriteLine("Removed: " + node.NodeAddress); }
public void OnNewLeader(NodeHeader node) { if (node.ID == Header.ID) { ConsoleColor c = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("**** LEADER ****"); Console.ForegroundColor = c; } else { Console.WriteLine("NOVO LEADER: " + node.NodeAddress); } }
public Node AddNode(NodeHeader nodeHeader) { Node newNode = null; try { newNode = nodeList.Find(x => x.Header.ID == nodeHeader.ID); if (newNode != null) { return newNode; } newNode = new Node(nodeHeader); nodeList.Add(newNode); newNode.Connect(nodeHeader.NodeAddress); OnNodeAdded(newNode.Header); } catch (Exception) { } return newNode; }
private void JoinCluster(NodeHeader networkNode) { Node node = AddNode(networkNode); if (node.Status == NodeStatus.Alive) { ClusterWelcomeMessage welcome = node.RegisterNode(Header); foreach (var item in welcome.NodeList) { if (item.ID == Header.ID) { continue; } Node hop = AddNode(item); if (hop.Status == NodeStatus.Alive) { hop.RegisterNode(Header); } } } leaderNode = nodeList.Leader; }