/// <summary> /// Does a sentinel check for masters and slaves and either sets up or fails over to the new config /// </summary> internal SentinelInfo ConfigureRedisFromSentinel() { var sentinelInfo = GetSentinelInfo(); if (redisManager == null) { Log.Info("Configuring initial Redis Clients: {0}".Fmt(sentinelInfo)); redisManager = redisSentinel.RedisManagerFactory.Create( redisSentinel.ConfigureHosts(sentinelInfo.RedisMasters), redisSentinel.ConfigureHosts(sentinelInfo.RedisSlaves)); var canFailover = redisManager as IRedisFailover; if (canFailover != null && this.redisSentinel.OnFailover != null) { canFailover.OnFailover.Add(this.redisSentinel.OnFailover); } } else { Log.Info("Failing over to Redis Clients: {0}".Fmt(sentinelInfo)); ((IRedisFailover)redisManager).FailoverTo( redisSentinel.ConfigureHosts(sentinelInfo.RedisMasters), redisSentinel.ConfigureHosts(sentinelInfo.RedisSlaves)); } return(sentinelInfo); }
/// <summary> /// Does a sentinel check for masters and slaves and either sets up or fails over to the new config /// </summary> internal SentinelInfo ConfigureRedisFromSentinel() { var sentinelInfo = new SentinelInfo( ConvertMasterArrayToList(this.sentinelClient.Sentinel("master", this.sentinelName)), ConvertSlaveArrayToList(this.sentinelClient.Sentinel("slaves", this.sentinelName))); if (redisManager == null) { Log.Info("Configuring initial Redis Clients: {0}".Fmt(sentinelInfo)); redisManager = redisSentinel.RedisManagerFactory.Create( redisSentinel.ConfigureHosts(sentinelInfo.RedisMasters), redisSentinel.ConfigureHosts(sentinelInfo.RedisSlaves)); var canFailover = redisManager as IRedisFailover; if (canFailover != null && this.redisSentinel.OnFailover != null) { canFailover.OnFailover.Add(this.redisSentinel.OnFailover); } } else { Log.Info("Failing over to Redis Clients: {0}".Fmt(sentinelInfo)); ((IRedisFailover)redisManager).FailoverTo( redisSentinel.ConfigureHosts(sentinelInfo.RedisMasters), redisSentinel.ConfigureHosts(sentinelInfo.RedisSlaves)); } return(sentinelInfo); }