public SessionSettings(Config config)
        {
            if (config == null) throw new ArgumentNullException("config");

            Builder = Cluster.Builder();
            
            // Get IP and port configuration
            int port = config.GetInt("port", 9042);
            IPEndPoint[] contactPoints = ParseContactPoints(config.GetStringList("contact-points"), port);
            Builder.AddContactPoints(contactPoints);

            // Support user/pass authentication
            if (config.HasPath("credentials"))
                Builder.WithCredentials(config.GetString("credentials.username"), config.GetString("credentials.password"));

            // Support SSL
            if (config.GetBoolean("ssl"))
                Builder.WithSSL();

            // Support compression
            string compressionTypeConfig = config.GetString("compression");
            if (compressionTypeConfig != null)
            {
                var compressionType = (CompressionType) Enum.Parse(typeof (CompressionType), compressionTypeConfig, true);
                Builder.WithCompression(compressionType);
            }
        }
Ejemplo n.º 2
0
 public Builder ApplyToBuilder(Builder builder)
 {
     builder.AddContactPoints(ContactPoints).WithPort(Port).WithDefaultKeyspace(DefaultKeyspace);
     if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
     {
         //Make sure the credentials are not null
         builder.WithCredentials(Username, Password);
     }
     return(builder);
 }
Ejemplo n.º 3
0
        public Builder ApplyToBuilder(Builder builder)
        {
            builder.AddContactPoints(ContactPoints).WithPort(Port).WithDefaultKeyspace(DefaultKeyspace);
            if (!String.IsNullOrEmpty(Username) && !String.IsNullOrEmpty(Password))
            {
                //Make sure the credentials are not null
                builder.WithCredentials(Username, Password);
            }

            if (!String.IsNullOrEmpty(LocalDC))
            {
                builder.WithLoadBalancingPolicy(new TokenAwarePolicy(new DCAwareRoundRobinPolicy(LocalDC)));
            }

            return(builder);
        }