Ejemplo n.º 1
0
 public void CollectionTest()
 {
     string csName = "testCS1";
     string clName = "testCL1";
     CollectionSpace cs = null;
     Sequoiadb sdb = new Sequoiadb(config.conf.Coord.Address);
     sdb.Connect(config.conf.UserName, config.conf.Password);
     if(sdb.IsCollectionSpaceExist(csName))
         cs = sdb.GetCollecitonSpace(csName);
     else
         cs = sdb.CreateCollectionSpace(csName);
     if (!cs.IsCollectionExist(clName))
         cs.CreateCollection(clName);
     cs.DropCollection(clName);
     Assert.IsFalse(cs.IsCollectionExist(clName));
     sdb.DropCollectionSpace(csName);
     sdb.Disconnect();
 }
Ejemplo n.º 2
0
        public void ConnectWithSSLTest()
        {
            ConfigOptions cfgOpt = null ;
            CollectionSpace cs2 = null;
            DBCollection coll2 = null;
            Sequoiadb sdb2 = new Sequoiadb(config.conf.Coord.Address);
            System.Console.WriteLine(config.conf.Coord.Address.ToString());

            // set connect using ssl
            cfgOpt = new ConfigOptions();
            cfgOpt.UseSSL = true;

            // connect to database
            sdb2.Connect("", "", cfgOpt);
            if (true == sdb2.IsCollectionSpaceExist("testSSL"))
                cs2 = sdb2.GetCollecitonSpace("testSSL");
            else
                cs2 = sdb2.CreateCollectionSpace("testSSL");
            if (true == cs2.IsCollectionExist("testSSL"))
                coll2 = cs2.GetCollection("testSSL");
            else
                coll2 = cs2.CreateCollection("testSSL");

            sdb2.DropCollectionSpace("testSSL");
        }
Ejemplo n.º 3
0
        // get collection space, if the collection space does not exist it will try to create one
        public static CollectionSpace GetCollecitonSpace(Sequoiadb sdb, string csName)
        {
            CollectionSpace cs = null;
            try
            {
                cs = sdb.GetCollecitonSpace(csName);
            }
            catch (BaseException e)
            {
                // verify whether the collection space exists
                if ("SDB_DMS_CS_NOTEXIST" == e.ErrorType)
                {
                    // if the collection space does not exist, we are going to create one
                    cs = CreateCollecitonSpace(sdb, csName);
                }
                else
                {
                    Console.WriteLine("Failed to get collection space {0},ErrorType = {1}", csName, e.ErrorType);
                    Environment.Exit(0);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Environment.Exit(0);
            }

            return cs;
        }