コード例 #1
0
        private IEnumerable <RedisServerInfo> GetServers(
            RedisConnectionInfo connectionInfo, RedisConnectionInfo oldConnectionInfo = null)
        {
            if (oldConnectionInfo == null)
            {
                oldConnectionInfo = connectionInfo;
            }

            var targets = connectionInfo.ConnectionString.Split(';', ',');

            for (int i = 0; i < targets.Length; i++)
            {
                var parts = targets[i].Split(':');
                var host  = parts[0];
                var port  = int.Parse(parts[1]);

                var endpoint = new DnsEndPoint(host, port);
                var server   = oldConnectionInfo.ServerInfos.FirstOrDefault(
                    s => s.EndPoint.Host == endpoint.Host && s.EndPoint.Port == endpoint.Port);

                if (server != null)
                {
                    yield return(new RedisServerInfo(server.Id, connectionInfo, endpoint));
                }
                else
                {
                    yield return(new RedisServerInfo(connectionInfo, endpoint));
                }
            }
        }
コード例 #2
0
 public ConnectionNodeAction(
     Guid id,
     RedisConnectionInfo connectionInfo)
 {
     Id             = id;
     ConnectionInfo = connectionInfo;
 }
コード例 #3
0
        private ConnectionNodeModel CreateConnectionNode(RedisConnectionInfo connectionInfo)
        {
            var node = new ConnectionNodeModel
            {
                ConnectionName   = connectionInfo.Name,
                ConnectionString = connectionInfo.ConnectionString,
                ConnectionInfo   = connectionInfo
            };

            foreach (var server in connectionInfo.ServerInfos)
            {
                var serverNode = CreateServerNode(server);
                node.Nodes.Add(serverNode);
            }

            if (connectionInfo.DatabaseInfos.Count > 0)
            {
                var databaseGroupNode = CreateDatabaseGroupNode(connectionInfo);
                node.Nodes.Add(databaseGroupNode);
            }

            if (node.Nodes.Count > 0)
            {
                node.IsExpanded = true;
                node.IsOpen     = true;
            }

            return(node);
        }
コード例 #4
0
 public Selected(
     RedisConnectionInfo connectionInfo,
     RedisServerInfo serverInfo,
     RedisDatabaseInfo databaseInfo)
 {
     ConnectionInfo = connectionInfo;
     ServerInfo     = serverInfo;
     DatabaseInfo   = databaseInfo;
 }
コード例 #5
0
        private void HandleUpdate(Guid id, RedisConnectionInfo connectionInfo)
        {
            var newConnectionNode = CreateConnectionNode(connectionInfo);
            var oldConnectionNode = _nodes.Items
                                    .OfType <ConnectionNodeModel>()
                                    .FirstOrDefault(node => node.ConnectionInfo.Id == id);

            _nodes.Replace(oldConnectionNode, newConnectionNode);
        }
コード例 #6
0
        public MockRedisForAccessTest(RedisConnectionInfo connectionInfo,
                                      Status statusGetA, Status statusModA, Status statusDelA)
            : base(connectionInfo)
        {
            _statusGetA = statusGetA;
            _statusModA = statusModA;
            _statusDelA = statusDelA;

            this.As.OnModifying += As_OnModifying;
            this.As.OnDeleting  += As_OnDeleting;
            this.As.OnGetting   += As_OnGetting;
        }
コード例 #7
0
        private DatabaseGroupNodeModel CreateDatabaseGroupNode(RedisConnectionInfo connectionInfo)
        {
            var node = new DatabaseGroupNodeModel();

            foreach (var database in connectionInfo.DatabaseInfos)
            {
                var databaseNode = CreateDatabaseNode(database);
                node.Nodes.Add(databaseNode);
            }

            return(node);
        }
コード例 #8
0
        private ServerGroupNodeModel CreateServerGroupNode(RedisConnectionInfo connectionInfo)
        {
            var node = new ServerGroupNodeModel();

            foreach (var server in connectionInfo.ServerInfos)
            {
                var serverNode = CreateServerNode(server);
                node.Nodes.Add(serverNode);
            }

            return(node);
        }
コード例 #9
0
        public IObservable <RedisConnectionInfo> Reconnect(
            RedisConnectionInfo oldConnectionInfo,
            string newConnectionName   = null,
            string newConnectionString = null)
        {
            return(Observable.Return(GetConnection(
                                         newConnectionName ?? oldConnectionInfo.Name,
                                         newConnectionString ?? oldConnectionInfo.ConnectionString,
                                         oldConnectionInfo.Id))
                   .SelectMany(connectionInfo =>
            {
                connectionInfo.ServerInfos.AddRange(GetServers(connectionInfo, oldConnectionInfo));

                return connectionInfo.ServerInfos
                .ToObservable()
                .SelectMany(s =>
                {
                    return _clientAccessor.Init(s)
                    .Catch <RedisClient, Exception>(
                        e => Observable.Return(default(RedisClient)));
                })
                .ToList()
                .Select(clients =>
                {
                    if (clients.Any(c => c.IsConnected))
                    {
                        connectionInfo.DatabaseInfos.AddRange(GetDatabases(connectionInfo, oldConnectionInfo));
                    }
                    else
                    {
                        connectionInfo.ServerInfos.Clear();
                    }

                    return connectionInfo;
                });
            })
                   .Do(async connectionInfo =>
            {
                int i = _connectionRegistry.IndexOf(oldConnectionInfo);
                _connectionRegistry[i] = connectionInfo;
                await _connectionStorage.UpdateAsync(new ConnectionEntity
                {
                    Id = oldConnectionInfo.Id,
                    Name = newConnectionName ?? oldConnectionInfo.Name,
                    ConnectionString = newConnectionString ?? oldConnectionInfo.ConnectionString
                });
                _broadcastService.Broadcast(
                    new ConnectionBroadcast(connectionInfo.Id, ConnectionBroadcastKind.Reconnect));
            }));
        }
コード例 #10
0
        private ConnectionItemModel CreateConnectionItem(
            RedisConnectionInfo connectionInfo)
        {
            var connectionName = string.IsNullOrWhiteSpace(connectionInfo.Name)
                ? connectionInfo.ConnectionString
                : connectionInfo.Name;

            var connectionString = string.IsNullOrWhiteSpace(connectionInfo.Name)
                ? null
                : $"({connectionInfo.ConnectionString})";

            return(new ConnectionItemModel
            {
                ConnectionString = connectionString,
                ConnectionName = connectionName,
                ConnectionInfo = connectionInfo
            });
        }
コード例 #11
0
        public IObservable <RedisConnectionInfo> Disconnect(
            RedisConnectionInfo oldConnectionInfo)
        {
            return(oldConnectionInfo.ServerInfos
                   .ToObservable()
                   .ToList()
                   .SelectMany(serverInfos =>
            {
                return serverInfos
                .ToObservable()
                .SelectMany(s => _clientAccessor.Release(s))
                .ToList();
            })
                   .Select(_ =>
            {
                _broadcastService.Broadcast(
                    new ConnectionBroadcast(oldConnectionInfo.Id, ConnectionBroadcastKind.Disconnect));

                return oldConnectionInfo;
            }));
        }
コード例 #12
0
        private IEnumerable <RedisDatabaseInfo> GetDatabases(
            RedisConnectionInfo connectionInfo, RedisConnectionInfo oldConnectionInfo = null)
        {
            if (oldConnectionInfo == null)
            {
                oldConnectionInfo = connectionInfo;
            }

            for (int i = 0; i < 16; i++)
            {
                if (i < oldConnectionInfo.DatabaseInfos.Count)
                {
                    yield return(new RedisDatabaseInfo(
                                     oldConnectionInfo.DatabaseInfos[i].Id, connectionInfo, i));
                }
                else
                {
                    yield return(new RedisDatabaseInfo(
                                     connectionInfo, i));
                }
            }
        }
コード例 #13
0
 public IObservable <RedisConnectionInfo> Close(
     RedisConnectionInfo oldConnectionInfo)
 {
     return(oldConnectionInfo.ServerInfos
            .ToObservable()
            .ToList()
            .SelectMany(serverInfos =>
     {
         return serverInfos
         .ToObservable()
         .SelectMany(s => _clientAccessor.Release(s))
         .ToList();
     })
            .Do(async _ =>
     {
         _connectionRegistry.Remove(oldConnectionInfo);
         await _connectionStorage.RemoveAsync(oldConnectionInfo.Id);
         _broadcastService.Broadcast(
             new ConnectionBroadcast(oldConnectionInfo.Id, ConnectionBroadcastKind.Close));
     })
            .Select(_ => oldConnectionInfo));
 }
コード例 #14
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RedisConnectionInfo redisInfo = Settings.Current.RedisConnectionInfo;

            if (Settings.Current.EnableSignalR && redisInfo != null)
            {
                var config = new RedisScaleoutConfiguration(redisInfo.Host, redisInfo.Port, redisInfo.Password, "exceptionless.signalr");
                GlobalHost.DependencyResolver.UseRedis(config);
            }

            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            AuthConfig.RegisterAuth();

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            AutoMapperConfig.CreateMappings();

            Trace.Listeners.Add(new NLogTraceListener());
            if (ExceptionlessClient.Current.Configuration.Enabled)
            {
                ExceptionlessClient.Current.Log = new NLogExceptionlessLog();
                ExceptionlessClient.Current.RegisterWebApi(GlobalConfiguration.Configuration);
                ExceptionlessClient.Current.UnhandledExceptionReporting += CurrentOnUnhandledExceptionReporting;
            }

            // startup the message queue
            JobManager.Current.JobManagerStarted += (sender, args) => JobManager.Current.RunJob("StartMq");

            // make the notification sender listen for messages
            var notificationSender = DependencyResolver.Current.GetService <NotificationSender>();

            notificationSender.Listen();
        }
コード例 #15
0
 public ConnectDialogModel(RedisConnectionInfo connectionInfo)
     : this()
 {
     ConnectionInfo = connectionInfo;
 }
コード例 #16
0
 public Add(Guid id, RedisConnectionInfo connectionInfo)
     : base(id, connectionInfo)
 {
 }
コード例 #17
0
 public Update(Guid id, RedisConnectionInfo connectionInfo)
     : base(id, connectionInfo)
 {
 }
コード例 #18
0
        private void HandleAdd(RedisConnectionInfo connectionInfo)
        {
            var connectionNode = CreateConnectionNode(connectionInfo);

            _nodes.Insert(_nodes.Count - 1, connectionNode);
        }
コード例 #19
0
ファイル: MockRedisContext.cs プロジェクト: pub-comp/no-sql
 public MockRedisContext(RedisConnectionInfo connectionInfo)
     : base(connectionInfo)
 {
 }
コード例 #20
0
 public Created(RedisConnectionInfo connectionInfo)
 {
     ConnectionInfo = connectionInfo;
 }