Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
        /// <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;
            //}
        }