/// <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); }
/// <summary> /// /// </summary> public void Dispose() { if (System.Threading.Interlocked.CompareExchange(ref disposed, 1, 0) != 0) { return; } this.NodeStop(); if (this.TM != null) { this.TM.Dispose(); } this.NodeStateLog.Dispose(); this.NodeStateLog = null; }
/// <summary> /// /// </summary> public void Dispose() { if (System.Threading.Interlocked.CompareExchange(ref disposed, 1, 0) != 0) { return; } this.NodeStop(); if (this.TM != null) { this.TM.Dispose(); } this.NodeStateLog.Dispose(); this.NodeStateLog = null; //if (db != null) //Is supplied from outside //{ // db.Dispose(); // db = null; //} }