コード例 #1
0
 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();
     }
 }
コード例 #2
0
        //[TestMethod]
        //public void RetrieveKeySpacesWithSeveralConnections()
        //{
        //    RetrieveKeySpacesCommand retrieveKeySpacesCommand = new RetrieveKeySpacesCommand();
        //    using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1"),
        //        connection2 = AquilesHelper.RetrieveConnection("Keyspace1"),
        //        connection3 = AquilesHelper.RetrieveConnection("Keyspace1"),
        //        connection4 = AquilesHelper.RetrieveConnection("Keyspace1"))
        //    {
        //        connection.Open();
        //        connection2.Open();
        //        connection3.Open();
        //        connection4.Open();
        //        connection.Execute(retrieveKeySpacesCommand);
        //        connection2.Execute(retrieveKeySpacesCommand);
        //        connection3.Execute(retrieveKeySpacesCommand);
        //        connection4.Execute(retrieveKeySpacesCommand);
        //        connection.Close();
        //        connection2.Close();
        //        connection3.Close();
        //        connection4.Close();
        //    }
        //    Assert.IsNotNull(retrieveKeySpacesCommand.KeySpaces);
        //}
        //[TestMethod]
        public void ReuseConnectionsOnthePool()
        {
            RetrieveKeySpacesCommand retrieveKeySpacesCommand = new RetrieveKeySpacesCommand();
            using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1"))
            {
                connection.Open();
                connection.Execute(retrieveKeySpacesCommand);
                connection.Close();

            }

            using (IAquilesConnection connection = AquilesHelper.RetrieveConnection("Keyspace1"))
            {
                connection.Open();
                connection.Execute(retrieveKeySpacesCommand);
                connection.Close();

            }
        }