示例#1
0
        public Dictionary <string, string> GetInformation(IInternalCluster cluster, IInternalSession session)
        {
            var antiPatterns = new Dictionary <string, string>();

            var resolvedContactPoints = cluster.Metadata.ResolvedContactPoints;

            var contactPointsEndPoints = resolvedContactPoints
                                         .Values
                                         .SelectMany(endPoints => endPoints)
                                         .Select(c => c.GetHostIpEndPointWithFallback())
                                         .ToList();

            var contactPointsHosts = cluster
                                     .AllHosts()
                                     .Where(host => (host.ContactPoint != null && resolvedContactPoints.ContainsKey(host.ContactPoint)) ||
                                            contactPointsEndPoints.Contains(host.Address))
                                     .ToList();

            if (contactPointsHosts.Select(c => c.Datacenter).Where(dc => dc != null).Distinct().Count() > 1)
            {
                antiPatterns["contactPointsMultipleDCs"] = "Contact points contain hosts from multiple data centers";
            }

            var loadBalancingPolicy = cluster.Configuration.Policies.LoadBalancingPolicy;

            antiPatterns = ConfigAntiPatternsInfoProvider.AddAntiPatterns(loadBalancingPolicy, antiPatterns);

            var retryPolicy = cluster.Configuration.Policies.RetryPolicy;

            antiPatterns = ConfigAntiPatternsInfoProvider.AddAntiPatterns(retryPolicy, antiPatterns);

            return(antiPatterns);
        }
        public HashSet <string> GetInformation(IInternalCluster cluster, IInternalSession session)
        {
            var dataCenters             = new HashSet <string>();
            var remoteConnectionsLength =
                cluster
                .Configuration
                .GetOrCreatePoolingOptions(cluster.Metadata.ControlConnection.ProtocolVersion)
                .GetCoreConnectionsPerHost(HostDistance.Remote);

            foreach (var h in cluster.AllHosts())
            {
                if (h.Datacenter == null)
                {
                    continue;
                }

                var distance = cluster.Configuration.Policies.LoadBalancingPolicy.Distance(h);
                if (distance == HostDistance.Local || (distance == HostDistance.Remote && remoteConnectionsLength > 0))
                {
                    dataCenters.Add(h.Datacenter);
                }
            }

            return(dataCenters);
        }
示例#3
0
        public bool SupportsInsights(IInternalCluster cluster)
        {
            var allHosts = cluster.AllHosts();

            return(allHosts.Count != 0 && allHosts.All(h => DseVersionSupportsInsights(h.DseVersion)));
        }