示例#1
0
        public object Clone()
        {
            BrokenConnectionInfo clone = new BrokenConnectionInfo();

            clone.BrokenAddress = BrokenAddress;
            clone.SessionType   = SessionType;
            return(clone);
        }
示例#2
0
 public void UnregisterListener(BrokenConnectionInfo entryKey)
 {
     if (_brokenConnections != null)
     {
         IList <BrokenConnectionEntry> brokenConnList = _brokenConnections.ToList();
         foreach (var entry in brokenConnList)
         {
             if (entry.ConnectionInfo.BrokenAddress.Equals(entryKey.BrokenAddress))
             {
                 UnregisterListener(entry);
             }
         }
     }
 }
示例#3
0
        public void RegisterListener(BrokenConnectionInfo entryKey, IConnectionRestorationListener listener, string shardName)
        {
            LoggerManager.Instance.SetThreadContext(new LoggerContext()
            {
                ShardName = shardName != null ? shardName : "", DatabaseName = ""
            });
            BrokenConnectionEntry entry = new BrokenConnectionEntry();

            entry.CRetryInfo = new BrokenConnectionEntry.RetryInfo();
            entry.CRetryInfo.LastRetryTimestamp = DateTime.Now;
            entry.CRetryInfo.RetryInterval      = _basicRetryInterval;

            entry.ConnectionRestorationListener = listener;
            if (_context != null)
            {
                entry.Channel = new DualChannel(entryKey.BrokenAddress.IpAddress.ToString(), entryKey.BrokenAddress.Port, _context.LocalAddress.IpAddress.ToString(), entryKey.SessionType, new TraceProvider(), new ShardChannelFormatter());
            }

            entry.ConnectionInfo = entryKey;
            if (_brokenConnections == null)
            {
                _brokenConnections = new List <BrokenConnectionEntry>();
                this.Start();
            }
            lock (_mutex)
            {
                if (!_brokenConnections.Contains(entry))
                {
                    if (LoggerManager.Instance.ShardLogger != null && LoggerManager.Instance.ShardLogger.IsInfoEnabled)
                    {
                        LoggerManager.Instance.ShardLogger.Info("ConnRestorationMgr.RegisterListener()", entry.ToString());
                    }
                    _brokenConnections.Add(entry);
                }
                if (_brokenConnections.Count == 1 && IsPaused)
                {
                    this.Resume();
                }
            }
        }
示例#4
0
 public bool Equals(BrokenConnectionInfo obj)
 {
     return(this.BrokenAddress == obj.BrokenAddress && this.SessionType == obj.SessionType);
 }