示例#1
0
        /// <summary>
        /// Checks wether a node is in the discovery scope.
        /// </summary>
        /// <param name="reference">The reference node that is known to be in scope</param>
        /// <param name="target">The target node of which is checked wether it is in scope</param>
        /// <param name="discoveryScope">The discovery scope.</param>
        /// <returns></returns>
        private bool InDiscoveryScope(Node reference, Node target, DiscoveryScope discoveryScope)
        {
            //filter based on scope
            switch (discoveryScope)
            {
            case DiscoveryScope.None:
                //add if item is in configured list
                return(_config.NodeAddresses.Contains(target.Address));

            case DiscoveryScope.DataCenter:
                //add if in the same datacenter
                return(target.DataCenter.Equals(reference.DataCenter));

            case DiscoveryScope.Rack:
                //add if reference matches datacenter and rack
                return(target.DataCenter.Equals(reference.DataCenter) && target.Rack.Equals(reference.Rack));

            case DiscoveryScope.Cluster:
                //add all
                return(true);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Checks wether a node is in the discovery scope.
        /// </summary>
        /// <param name="reference">The reference node that is known to be in scope</param>
        /// <param name="target">The target node of which is checked wether it is in scope</param>
        /// <param name="discoveryScope">The discovery scope.</param>
        /// <returns></returns>
        private bool InDiscoveryScope(Node reference, Node target, DiscoveryScope discoveryScope)
        {
            //filter based on scope
            switch (discoveryScope)
            {
                case DiscoveryScope.None:
                    //add if item is in configured list
                    return _config.NodeAddresses.Contains(target.Address);

                case DiscoveryScope.DataCenter:
                    //add if in the same datacenter
                    return target.DataCenter.Equals(reference.DataCenter);

                case DiscoveryScope.Rack:
                    //add if reference matches datacenter and rack
                    return target.DataCenter.Equals(reference.DataCenter) && target.Rack.Equals(reference.Rack);

                case DiscoveryScope.Cluster:
                    //add all
                    return true;
            }

            return false;
        }
示例#3
0
        /// <summary>
        ///   Returns a <see cref="System.String" /> that represents this configuration. Usable as Connection String.
        /// </summary>
        /// <returns> A <see cref="System.String" /> that represents this instance. </returns>
        public override string ToString()
        {
            var builder = new StringBuilder();

            builder.Append("Servers=");
            builder.Append(string.Join(",", Nodes));
            builder.Append(";");

            if (Port != DefaultPort)
            {
                builder.Append("Port=");
                builder.Append(Port);
                builder.Append(";");
            }

            if (Username != null)
            {
                builder.Append("User="******";");
            }

            if (Password != null)
            {
                builder.Append("Password="******";");
            }

            if (!CqlVersion.Equals(DefaultCqlVersion))
            {
                builder.Append("CqlVersion=");
                builder.Append(CqlVersion);
                builder.Append(";");
            }

            if (!DiscoveryScope.Equals(DefaultDiscoveryScope))
            {
                builder.Append("DiscoveryScope=");
                builder.Append(DiscoveryScope);
                builder.Append(";");
            }

            if (!ConnectionStrategy.Equals(DefaultConnectionStrategy))
            {
                builder.Append("ConnectionStrategy=");
                builder.Append(ConnectionStrategy);
                builder.Append(";");
            }

            if (!NewConnectionTreshold.Equals(DefaultNewConnectionTreshold))
            {
                builder.Append("NewConnectionTreshold=");
                builder.Append(NewConnectionTreshold);
                builder.Append(";");
            }

            if (!MaxDownTime.Equals(DefaultMaxDownTime))
            {
                builder.Append("MaxDownTime=");
                builder.Append(MaxDownTime);
                builder.Append(";");
            }

            if (!MinDownTime.Equals(DefaultMinDownTime))
            {
                builder.Append("MinDownTime=");
                builder.Append(MinDownTime);
                builder.Append(";");
            }

            if (MaxConnections > 0)
            {
                builder.Append("MaxConnections=");
                builder.Append(MaxConnections);
                builder.Append(";");
            }

            if (!MaxConnectionsPerNode.Equals(DefaultMaxConnectionsPerNode))
            {
                builder.Append("MaxConnectionsPerNode=");
                builder.Append(MaxConnectionsPerNode);
                builder.Append(";");
            }

            if (MaxConcurrentQueries > 0)
            {
                builder.Append("MaxConcurrentQueries=");
                builder.Append(MaxConcurrentQueries);
                builder.Append(";");
            }

            if (MaxConnectionIdleTime != DefaultMaxConnectionIdleTime)
            {
                builder.Append("MaxConnectionIdleTime=");
                builder.Append(MaxConnectionIdleTime.TotalSeconds);
                builder.Append(";");
            }

            if (MaxQueryRetries != DefaultMaxQueryRetries)
            {
                builder.Append("MaxQueryRetries=");
                builder.Append(MaxQueryRetries);
                builder.Append(";");
            }

            if (UseBuffering != DefaultUseBuffering)
            {
                builder.Append("UseBuffering=");
                builder.Append(UseBuffering);
                builder.Append(";");
            }

            if (AllowCompression != DefaultAllowCompression)
            {
                builder.Append("AllowCompression=");
                builder.Append(AllowCompression);
                builder.Append(";");
            }

            if (AllowCompression && CompressionTreshold != DefaultCompressionTreshold)
            {
                builder.Append("CompressionTreshold=");
                builder.Append(CompressionTreshold);
                builder.Append(";");
            }

            if (!LoggerFactory.Equals(DefaultLoggerFactory, StringComparison.InvariantCultureIgnoreCase))
            {
                builder.Append("LoggerFactory=");
                builder.Append(LoggerFactory);
                builder.Append(";");
            }

            if (!LogLevel.Equals(DefaultLogLevel))
            {
                builder.Append("LogLevel=");
                builder.Append(LogLevel);
                builder.Append(";");
            }

            return(builder.ToString());
        }