protected static EndPointCollection ParseSentinelEndPoints(params string[] sentinelHosts) { if (sentinelHosts == null || sentinelHosts.Length == 0) { return(null); } var sentinelEndPoints = new EndPointCollection(); for (var i = 0; i < sentinelHosts.Length; i++) { var sentinelHost = sentinelHosts[i]; var hostPortArr = sentinelHost.Split(':'); if (hostPortArr.Length > 2) { continue; //invalid hostAndPort string } if (hostPortArr.Length == 1) { sentinelHost = string.Format("{0}:{1}", hostPortArr[0], defaultSentinelPort); } sentinelEndPoints.Add(sentinelHost); } return(sentinelEndPoints); }
protected static EndPointCollection ParseSlaveEndPoints(params KeyValuePair <string, string>[][] slaveInfos) { if (slaveInfos == null || slaveInfos.Length == 0) { return(null); } var slaveEndPoints = new EndPointCollection(); string ip, port, flags; foreach (var slaveInfo in slaveInfos.Select(m => m.ToDictionary())) { slaveInfo.TryGetValue("flags", out flags); slaveInfo.TryGetValue("ip", out ip); slaveInfo.TryGetValue("port", out port); if (!string.IsNullOrEmpty(ip) && !string.IsNullOrEmpty(port) && !flags.Contains("s_down") && !flags.Contains("o_down")) { slaveEndPoints.Add(string.Format("{0}:{1}", ip, port)); } } return(slaveEndPoints); }
private static ConfigurationOptions CreateEndpointConfiguration() { ConfigurationOptions configuration = new ConfigurationOptions(); configuration.AllowAdmin = true; configuration.SyncTimeout = 10000; EndPointCollection endPointCollection = configuration.EndPoints; string cacheServiceAddresses = String.Empty; cacheServiceAddresses = appSettingsReader.GetValue("CacheServiceAddress", typeof(string)).ToString(); string[] cacheServiceAddressesSplit = cacheServiceAddresses.Split(','); int defaultConnectionPort = 6379; try { defaultConnectionPort = Int32.Parse(appSettingsReader.GetValue("ConnectionPort", typeof(string)).ToString()); } catch (Exception ex) { defaultConnectionPort = 6379; } foreach (string cacheServiceAddress in cacheServiceAddressesSplit) { endPointCollection.Add(cacheServiceAddress, defaultConnectionPort); } var randomIndex = rand.Next(0, endPointCollection.Count); randomIndex = rand.Next(0, endPointCollection.Count); var tempEndpoint = endPointCollection[randomIndex]; endPointCollection.RemoveAt(randomIndex); endPointCollection.Add(tempEndpoint); return(configuration); }
private void SetEndPoints(ConfigurationOptions options) { var endPoints = new EndPointCollection(); BedrockConfiguration.Cache.Redis.EndPoints.Each(ep => endPoints.Add(ep.Host, ep.Port)); options .GetType() .GetField("endpoints", BindingFlags.Instance | BindingFlags.NonPublic) .SetValue(options, endPoints); }
/// <summary> /// Output the endpoint. /// </summary> /// <param name="e">The e.</param> internal static void OutputEndPoint(Edge e) { if (!triangulate && plot) { clip_line(e); } if (!triangulate && !plot) { Console.Write(String.Format("endpoint edgeNumber: {0} ", e.edgeNumber)); Console.Write("left: "); Console.Write(e.EndPoints[EndPoint.Left] != null ? e.EndPoints[EndPoint.Left].SiteNumber : -1); Console.Write(" right: "); Console.WriteLine(e.EndPoints[EndPoint.Right] != null ? e.EndPoints[EndPoint.Right].SiteNumber : -1); } EndPointCollection.Add(e); }
internal void AddEndPoints(EndPointCollection result, string endpoints) { if (string.IsNullOrEmpty(endpoints)) { return; } endpoints = endpoints.Trim(); if (!string.IsNullOrEmpty(endpoints)) { string[] points = endpoints.Split(COMMA); if (points.Length > 0) { foreach (string point in points) { EndPoint p = TryParseEndPoint(point); if (p != null) { result.Add(p); } } } } }