private void RetrieveKeySpaces() { RetrieveKeySpacesCommand retrieveKeySpaceCommand = new RetrieveKeySpacesCommand(); DescribeKeySpaceCommand describeKeySpaceCommand = new DescribeKeySpaceCommand(); using (DefaultAquilesConnection connection = new DefaultAquilesConnection(this)) { // i open the conection myself in order not to let the DefaultConnection change the endpoint connection.Open(); connection.Execute(retrieveKeySpaceCommand); HashSet<string>.Enumerator keySpaceIterator = retrieveKeySpaceCommand.KeySpaces.GetEnumerator(); while (keySpaceIterator.MoveNext()) { describeKeySpaceCommand.KeySpace = keySpaceIterator.Current; connection.Execute(describeKeySpaceCommand); this.AddKeySpaceDescription(this.BuildKeySpace(keySpaceIterator.Current, describeKeySpaceCommand.ColumnFamilies)); } connection.Close(); } }
private void CheckNodesPointsToSameCluster() { CassandraClient client = null; HashSet<CassandraEndpoint> usedEndpoints = new HashSet<CassandraEndpoint>(); FakedConnectionPool fakedConnectionPool = new FakedConnectionPool() { EndpointManager = this.endpointManager }; FakedCluster fakedCluster = new FakedCluster() { FriendlyName = this.FriendlyName, ConnectionPool = fakedConnectionPool }; CassandraEndpoint endpoint = this.endpointManager.Retrieve(); while (endpoint != null && !usedEndpoints.Contains(endpoint)) { client = this.connectionFactory.Create(endpoint); fakedConnectionPool.InjectedClient = client; RetrieveClusterNameCommand cmd = new RetrieveClusterNameCommand(); using (DefaultAquilesConnection connection = new DefaultAquilesConnection(fakedCluster)) { // i open the conection myself in order not to let the DefaultConnection change the endpoint connection.Open(); connection.Execute(cmd); connection.Close(); } if (String.IsNullOrEmpty(this.ClusterName)) { this.ClusterName = cmd.ClusterName; } else if (this.ClusterName.CompareTo(cmd.ClusterName) != 0) { throw new AquilesException(String.Format(CultureInfo.CurrentCulture, "Endpoint '{0}' points to '{1}' instead of '{2}'.", endpoint.ToString(), cmd.ClusterName, this.ClusterName)); } usedEndpoints.Add(endpoint); endpoint = this.endpointManager.Retrieve(); } }