/// <summary> /// /// </summary> /// <param name="raftNodeSettings"></param> /// <param name="udpPort">e.g. 47777 </param> /// <param name="verboseNode">Will call VerbosePrint on true</param> public RaftNodeUdp(RaftNodeSettings raftNodeSettings, int udpPort, bool verboseNode) { try { TM = new TimeMaster(this); udpSocket = new UdpSocketListener(TM, this); UdpPort = udpPort; rn = new RaftNode(raftNodeSettings, this, this); rn.Verbose = verboseNode; rn.NodeAddress.IsMe = true; //Can be increased on the hot system later. rn.SetNodesQuantityInTheCluster(raftNodeSettings.InitialQuantityOfRaftNodesInTheCluster); //Supplied by emulator for VerbosePrints rn.NodeAddress.NodeAddressId = raftNodeSettings.RaftNodeIdExternalForEmulator; } catch (Exception ex) { this.LogError(new WarningLogEntry() { Exception = ex, Method = "Raft.RaftNodeUdp.RaftNodeUdp" }); } }
/// <summary> /// /// </summary> /// <param name="settings"></param> /// <param name="dbreezePath"></param> /// <param name="raftSender"></param> /// <param name="log"></param> /// <param name="OnCommit"></param> public RaftNode(RaftNodeSettings settings, string dbreezePath, IRaftComSender raftSender, IWarningLog log, Func <string, ulong, byte[], bool> OnCommit) { this.Log = log ?? throw new Exception("Raft.Net: ILog is not supplied"); this.OnCommit = OnCommit ?? throw new Exception("Raft.Net: OnCommit can'T be null"); Sender = raftSender; nodeSettings = settings; //Starting time master this.TM = new TimeMaster(log); //Starting state logger NodeStateLog = new StateLog(dbreezePath, this); }