Пример #1
0
 protected internal RedisManagedServer(RedisAsyncClient client, RedisConnectionSettings settings, RedisRole role,
                                       Action <object, RedisCardioPulseStatus> onPulseStateChange)
     : base(client, settings)
 {
     Role = role;
     m_OnPulseStateChange = onPulseStateChange;
 }
        public RedisManagedSentinelListener(RedisConnectionSettings settings,
                                            Action <object, RedisCardioPulseStatus> onPulseStateChange)
            : base(settings)
        {
            m_OnPulseStateChange = onPulseStateChange;

            m_Client = new RedisAsyncClient(settings);
            Init(settings, m_Client);
        }
Пример #3
0
        public RedisAsyncServer(RedisConnectionSettings settings)
        {
            if (settings == null)
            {
                throw new RedisFatalException(new ArgumentNullException("settings"), RedisErrorCode.MissingParameter);
            }

            Init(settings);
        }
Пример #4
0
        public RedisAsyncClient(RedisConnectionSettings settings)
        {
            m_Settings            = settings;
            m_ReceiveTimeout      = settings.ReceiveTimeout;
            m_UseBackgroundThread = settings.UseBackgroundThread;

            Initialize(true, false);
            m_Constructed = true;
        }
Пример #5
0
        public RedisEndPointResolver(string name, RedisConnectionSettings settings)
        {
            if (settings == null)
            {
                throw new RedisFatalException(new ArgumentNullException("settings"), RedisErrorCode.MissingParameter);
            }

            m_Name     = name;
            m_Settings = settings;
        }
        private void Init(RedisConnectionSettings settings, RedisAsyncClient client)
        {
            m_Executer = new RedisAsyncCommandExecuter(client, RedisConstants.UninitializedDbIndex);
            if (IsHeartBeatEnabled(settings))
            {
                m_HeartBeatProbe = new RedisHeartBeatProbe(settings, this, null);
                m_HeartBeatProbe.SetOnPulseStateChange(OnPulseStateChange);

                m_HeartBeatProbe.AttachToCardio();
            }
        }
Пример #7
0
        private void Init(RedisConnectionSettings settings)
        {
            m_Settings    = settings;
            m_ClientCount = settings.ConnectionCount;
            m_Clients     = new RedisAsyncClient[m_ClientCount];

            if (IsHeartBeatEnabled(settings))
            {
                m_HeartBeatProbe = new RedisHeartBeatProbe(settings, this, null);
                m_HeartBeatProbe.SetOnPulseStateChange(OnPulseStateChange);

                m_HeartBeatProbe.AttachToCardio();
            }
        }
Пример #8
0
        protected Tuple <RedisRole, RedisEndPoint[], RedisAsyncClient> DiscoverNode(RedisConnectionSettings settings)
        {
            var client = NewClient(settings);

            var nodeInfo = GetNodeInfo(settings.MasterName, client);

            if (!(nodeInfo == null || nodeInfo.Role == RedisRole.Undefined))
            {
                var role             = nodeInfo.Role;
                var siblingEndPoints = nodeInfo.Siblings;

                return(new Tuple <RedisRole, RedisEndPoint[], RedisAsyncClient>(role, siblingEndPoints, client));
            }
            return(null);
        }
Пример #9
0
        protected internal RedisAsyncServer(RedisAsyncClient client, RedisConnectionSettings settings)
        {
            if (client == null)
            {
                throw new RedisFatalException(new ArgumentNullException("client"), RedisErrorCode.MissingParameter);
            }

            settings = settings ?? client.Settings;

            Init(settings);
            if (client.IsAlive())
            {
                m_Clients[0] = client;
            }
        }
        protected internal RedisManagedSentinelListener(RedisAsyncClient client,
                                                        RedisConnectionSettings settings, Action <object, RedisCardioPulseStatus> onPulseStateChange)
            : base(settings ?? client.Settings)
        {
            if (client == null)
            {
                throw new RedisFatalException(new ArgumentNullException("client"), RedisErrorCode.MissingParameter);
            }

            m_OnPulseStateChange = onPulseStateChange;

            settings = settings ?? client.Settings;

            m_Client = client.Disposed ? new RedisAsyncClient(settings) : client;
            Init(settings, m_Client);
        }
Пример #11
0
 internal RedisMonitorChannel(RedisConnectionSettings settings)
     : base(settings)
 {
 }
Пример #12
0
        private Tuple <RedisRole, RedisAsyncClient>[] CreateNodes(HashSet <IPEndPoint> discoveredEndPoints, RedisConnectionSettings settings)
        {
            try
            {
                if (Disposed)
                {
                    return(null);
                }

                var endPoints = settings.EndPoints;
                if (endPoints.IsEmpty())
                {
                    return(null);
                }

                var ipAddresses = endPoints[0].ResolveHost();
                if (ipAddresses.IsEmpty())
                {
                    return(null);
                }

                var nodeEndPoint = new IPEndPoint(ipAddresses[0], endPoints[0].Port);
                if (discoveredEndPoints.Contains(nodeEndPoint))
                {
                    return(null);
                }

                discoveredEndPoints.Add(nodeEndPoint);

                var nodeInfo = DiscoverNode(settings);

                if (nodeInfo != null)
                {
                    var role             = nodeInfo.Item1;
                    var siblingEndPoints = nodeInfo.Item2;
                    var client           = nodeInfo.Item3;

                    var list = new List <Tuple <RedisRole, RedisAsyncClient> >();
                    if (client != null)
                    {
                        list.Add(new Tuple <RedisRole, RedisAsyncClient>(role, client));
                    }

                    if (role != RedisRole.Undefined && !siblingEndPoints.IsEmpty())
                    {
                        foreach (var siblingEndPoint in siblingEndPoints)
                        {
                            try
                            {
                                if (!Disposed && !ReferenceEquals(siblingEndPoint, null) && !siblingEndPoint.Host.IsEmpty())
                                {
                                    var siblingSettings = (RedisConnectionSettings)settings.Clone(siblingEndPoint.Host, siblingEndPoint.Port);

                                    var otherNodes = CreateNodes(discoveredEndPoints, siblingSettings);
                                    if (otherNodes != null)
                                    {
                                        list.AddRange(otherNodes);
                                    }
                                }
                            }
                            catch (Exception)
                            { }
                        }
                    }

                    return(list.ToArray());
                }
            }
            catch (Exception)
            { }
            return(null);
        }
Пример #13
0
 public RedisHeartBeatProbe(RedisConnectionSettings settings, IRedisPingable client, Action <object, RedisCardioPulseStatus> onPulseStateChange)
 {
     m_Client             = client;
     m_Settings           = settings;
     m_OnPulseStateChange = onPulseStateChange;
 }
Пример #14
0
 protected override bool IsHeartBeatEnabled(RedisConnectionSettings settings)
 {
     return(false);
 }
Пример #15
0
 protected virtual bool IsHeartBeatEnabled(RedisConnectionSettings settings)
 {
     return(settings != null && settings.HeartBeatEnabled);
 }
 protected virtual bool IsHeartBeatEnabled(RedisConnectionSettings settings)
 {
     return(false);
 }
Пример #17
0
 internal RedisPubSubChannel(RedisConnectionSettings settings)
     : base(settings)
 {
 }
Пример #18
0
 protected virtual RedisAsyncClient NewClient(RedisConnectionSettings settings)
 {
     return(new RedisAsyncClient(settings));
 }