/// <summary> /// /// </summary> public void Dispose() { if (System.Threading.Interlocked.CompareExchange(ref disposed, 1, 0) != 0) { return; } this.NodeStop(); this.timerLoop.Dispose(); this.NodeStateLog.Dispose(); this.NodeStateLog = null; }
/// <summary> /// /// </summary> /// <param name="settings"></param> /// <param name="dbEngine"></param> /// <param name="raftSender"></param> /// <param name="log"></param> /// <param name="OnCommit"></param> public RaftStateMachine(RaftEntitySettings settings, string workPath, IPeerConnector raftSender, IWarningLog log, IBusinessHandler handler) { this.Log = log ?? throw new Exception("Raft.Net: ILog is not supplied"); network = raftSender; entitySettings = settings; //Starting time master var TM = new TimeMaster(log); this.timerLoop = new StateMachineTimerLoop(TM, settings, this); //Starting state logger NodeStateLog = StateLogFactory.GetLog(this, workPath); this.logHandler = new StateMachineLogHandler(this, NodeStateLog, handler); //Adding AddLogEntryAsync cleanup this.timerLoop.StartClearup(); }
public StateMachineLogHandler(RaftStateMachine stateMachine, IStateLog log, IBusinessHandler handler) { this.stateMachine = stateMachine; this.log = log; this.businessLogicHandler = handler; }