Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        internal SentinelInfo GetSentinelInfo()
        {
            var sentinelInfo = new SentinelInfo(
                ConvertMasterArrayToList(this.sentinelClient.Sentinel("master", this.sentinelName)),
                ConvertSlaveArrayToList(this.sentinelClient.Sentinel("slaves", this.sentinelName)));

            return(sentinelInfo);
        }
Exemplo n.º 3
0
        internal SentinelInfo GetSentinelInfo()
        {
            var sentinelInfo = new SentinelInfo(
                sentinel.MasterName,
                new[] { GetMasterHost(sentinel.MasterName) },
                GetSlaveHosts(sentinel.MasterName));

            return(sentinelInfo);
        }
        internal SentinelInfo GetSentinelInfo()
        {
            var sentinelInfo = new SentinelInfo(
                sentinel.MasterName,
                new[] { GetMasterHost(sentinel.MasterName) },
                GetSlaveHosts(sentinel.MasterName));

            return sentinelInfo;
        }
        internal SentinelInfo GetSentinelInfo()
        {
            var masterHost = GetMasterHostInternal(sentinel.MasterName);
            if (masterHost == null)
                throw new RedisException("Redis Sentinel is reporting no master is available");

            var sentinelInfo = new SentinelInfo(
                sentinel.MasterName,
                new[] { masterHost },
                GetSlaveHosts(sentinel.MasterName));

            return sentinelInfo;
        }
        private IRedisClientsManager CreateRedisManager(SentinelInfo sentinelInfo)
        {
            var masters      = ConfigureHosts(sentinelInfo.RedisMasters);
            var slaves       = ConfigureHosts(sentinelInfo.RedisSlaves);
            var redisManager = RedisManagerFactory(masters, slaves);

            var hasRedisResolver = (IHasRedisResolver)redisManager;

            hasRedisResolver.RedisResolver = new RedisSentinelResolver(this, masters, slaves);

            if (redisManager is IRedisFailover canFailover && this.OnFailover != null)
            {
                canFailover.OnFailover.Add(this.OnFailover);
            }
            return(redisManager);
        }
        internal SentinelInfo GetSentinelInfo()
        {
            var masterHost = GetMasterHostInternal(sentinel.MasterName);

            if (masterHost == null)
            {
                throw new RedisException("Redis Sentinel is reporting no master is available");
            }

            var sentinelInfo = new SentinelInfo(
                sentinel.MasterName,
                new[] { masterHost },
                GetReplicaHosts(sentinel.MasterName));

            return(sentinelInfo);
        }
        private IRedisClientsManager CreateRedisManager(SentinelInfo sentinelInfo)
        {
            var masters = ConfigureHosts(sentinelInfo.RedisMasters);
            var slaves = ConfigureHosts(sentinelInfo.RedisSlaves);
            var redisManager = RedisManagerFactory(masters, slaves);

            var hasRedisResolver = (IHasRedisResolver)redisManager;
            hasRedisResolver.RedisResolver = new RedisSentinelResolver(this, masters, slaves);

            var canFailover = redisManager as IRedisFailover;
            if (canFailover != null && this.OnFailover != null)
            {
                canFailover.OnFailover.Add(this.OnFailover);
            }
            return redisManager;
        }
 internal SentinelInfo GetSentinelInfo()
 {
     var sentinelInfo = new SentinelInfo(
         redisSentinel.MasterName,
         ConvertMasterArrayToList(this.sentinelClient.Sentinel("master", this.masterName)),
         ConvertSlaveArrayToList(this.sentinelClient.Sentinel("slaves", this.masterName)));
     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;
        }