internal void UpdateSentinelAddressList(string serviceName) { var firstCompleteRequest = GetServerSnapshot() .ToArray() .Where(s => s.ServerType == ServerType.Sentinel) .AsParallel() .Select(s => { try { return(GetServer(s.EndPoint).SentinelGetSentinelAddresses(serviceName)); } catch { return(null); } }) .FirstOrDefault(r => r != null); // Ignore errors, as having an updated sentinel list is not essential if (firstCompleteRequest == null) { return; } bool hasNew = false; foreach (EndPoint newSentinel in firstCompleteRequest.Where(x => !EndPoints.Contains(x))) { hasNew = true; EndPoints.TryAdd(newSentinel); } if (hasNew) { // Reconfigure the sentinel multiplexer if we added new endpoints ReconfigureAsync(first: false, reconfigureAll: true, null, EndPoints[0], "Updating Sentinel List", false).Wait(); } }
void OrderControlPoints() { if (OrderedControlPoints == null) { OrderedControlPoints = new List <Tuple>(); } foreach (var item in ControlPoints) { if (OrderedControlPoints.Find(tuple => tuple.Point.Id == item.Id) != null) { continue; } if (OrderedControlPoints.Count == 0) { OrderedControlPoints.Add(new Tuple(0, 0, item)); } else if (item.Point.X > OrderedControlPoints.Last().Point.Point.X) { OrderedControlPoints.Add(new Tuple(0, 0, item)); } else { for (int i = 0; i < OrderedControlPoints.Count; i++) { if (item.Point.X < OrderedControlPoints[i].Point.Point.X) { OrderedControlPoints.Insert(i, new Tuple(0, 0, item)); break; } } } } int t = 0; foreach (var item in OrderedControlPoints) { if (EndPoints.Contains(item.Point)) { item.LPath = t; t++; item.RPath = t; } else { item.LPath = t; item.RPath = t; } } }
private void DoParse(string configuration, bool ignoreUnknown) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (string.IsNullOrWhiteSpace(configuration)) { throw new ArgumentException("is empty", configuration); } Clear(); // break it down by commas var arr = configuration.Split(StringSplits.Comma); Dictionary <string, string> map = null; foreach (var paddedOption in arr) { var option = paddedOption.Trim(); if (string.IsNullOrWhiteSpace(option)) { continue; } // check for special tokens int idx = option.IndexOf('='); if (idx > 0) { var key = option.Substring(0, idx).Trim(); var value = option.Substring(idx + 1).Trim(); switch (OptionKeys.TryNormalize(key)) { case OptionKeys.SyncTimeout: SyncTimeout = OptionKeys.ParseInt32(key, value, minValue: 1); break; case OptionKeys.AsyncTimeout: AsyncTimeout = OptionKeys.ParseInt32(key, value, minValue: 1); break; case OptionKeys.AllowAdmin: AllowAdmin = OptionKeys.ParseBoolean(key, value); break; case OptionKeys.AbortOnConnectFail: AbortOnConnectFail = OptionKeys.ParseBoolean(key, value); break; case OptionKeys.ResolveDns: ResolveDns = OptionKeys.ParseBoolean(key, value); break; case OptionKeys.ServiceName: ServiceName = value; break; case OptionKeys.ClientName: ClientName = value; break; case OptionKeys.ChannelPrefix: ChannelPrefix = value; break; case OptionKeys.ConfigChannel: ConfigurationChannel = value; break; case OptionKeys.KeepAlive: KeepAlive = OptionKeys.ParseInt32(key, value); break; case OptionKeys.ConnectTimeout: ConnectTimeout = OptionKeys.ParseInt32(key, value); break; case OptionKeys.ConnectRetry: ConnectRetry = OptionKeys.ParseInt32(key, value); break; case OptionKeys.ConfigCheckSeconds: ConfigCheckSeconds = OptionKeys.ParseInt32(key, value); break; case OptionKeys.Version: DefaultVersion = OptionKeys.ParseVersion(key, value); break; case OptionKeys.Password: Password = value; break; case OptionKeys.TieBreaker: TieBreaker = value; break; case OptionKeys.Ssl: Ssl = OptionKeys.ParseBoolean(key, value); break; case OptionKeys.SslHost: SslHost = value; break; case OptionKeys.HighPrioritySocketThreads: HighPrioritySocketThreads = OptionKeys.ParseBoolean(key, value); break; case OptionKeys.WriteBuffer: #pragma warning disable CS0618 // Type or member is obsolete WriteBuffer = OptionKeys.ParseInt32(key, value); #pragma warning restore CS0618 // Type or member is obsolete break; case OptionKeys.Proxy: Proxy = OptionKeys.ParseProxy(key, value); break; case OptionKeys.ResponseTimeout: #pragma warning disable CS0618 // Type or member is obsolete ResponseTimeout = OptionKeys.ParseInt32(key, value, minValue: 1); #pragma warning restore CS0618 // Type or member is obsolete break; case OptionKeys.DefaultDatabase: DefaultDatabase = OptionKeys.ParseInt32(key, value); break; case OptionKeys.PreserveAsyncOrder: break; case OptionKeys.SslProtocols: SslProtocols = OptionKeys.ParseSslProtocols(key, value); break; default: if (!string.IsNullOrEmpty(key) && key[0] == '$') { var cmdName = option.Substring(1, idx - 1); if (Enum.TryParse(cmdName, true, out RedisCommand cmd)) { if (map == null) { map = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); } map[cmdName] = value; } } else { if (!ignoreUnknown) { OptionKeys.Unknown(key); } } break; } } else { var ep = Format.TryParseEndPoint(option); if (ep != null && !EndPoints.Contains(ep)) { EndPoints.Add(ep); } } } if (map != null && map.Count != 0) { CommandMap = CommandMap.Create(map); } }