示例#1
0
文件: Connector.cs 项目: e2wugui/zeze
        public virtual void TryReconnect()
        {
            lock (this)
            {
                if (false == IsAutoReconnect ||
                    null != Socket ||
                    null != ReconnectTask)
                {
                    return;
                }

                if (ConnectDelay <= 0)
                {
                    ConnectDelay = 1000;
                }
                else
                {
                    ConnectDelay *= 2;
                    if (ConnectDelay > MaxReconnectDelay)
                    {
                        ConnectDelay = MaxReconnectDelay;
                    }
                }
                ReconnectTask = Util.Scheduler.Instance.Schedule((ThisTask) => Start(), ConnectDelay);;
            }
        }
示例#2
0
文件: Log.cs 项目: e2wugui/zeze
 public void StopSnapshotPerDayTimer()
 {
     lock (Raft)
     {
         SnapshotTimer?.Cancel();
         SnapshotTimer = null;
     }
 }
示例#3
0
文件: Connector.cs 项目: e2wugui/zeze
        public virtual void Start()
        {
            lock (this)
            {
                ReconnectTask?.Cancel();
                ReconnectTask = null;

                if (null != Socket)
                {
                    return;
                }

                IsConnected = false;
                HandshakeDoneEvent.Reset();
                Socket           = Service.NewClientSocket(HostNameOrAddress, Port);
                Socket.Connector = this;
            }
        }
示例#4
0
文件: Log.cs 项目: e2wugui/zeze
        public void StartSnapshotPerDayTimer()
        {
            lock (Raft)
            {
                if (null != SnapshotTimer)
                {
                    return;
                }

                if (Raft.RaftConfig.SnapshotHourOfDay >= 0 && Raft.RaftConfig.SnapshotHourOfDay < 24)
                {
                    var now       = DateTime.Now;
                    var firstTime = new DateTime(now.Year, now.Month, now.Day,
                                                 Raft.RaftConfig.SnapshotHourOfDay, Raft.RaftConfig.SnapshotMinute, 0);
                    if (firstTime.CompareTo(now) < 0)
                    {
                        firstTime = firstTime.AddDays(1);
                    }
                    var delay = Util.Time.DateTimeToUnixMillis(firstTime) - Util.Time.DateTimeToUnixMillis(now);
                    SnapshotTimer = Zeze.Util.Scheduler.Instance.Schedule(
                        (ThisTask) => StartSnapshot(false), delay, 20 * 3600 * 1000);
                }
            }
        }