Example #1
0
 public void ChangeConfigOptions(ConfigOptions opts)
 {
     this.options = opts;
     Close();
     Connect();
 }
Example #2
0
 public void ChangeConfigOptions(ConfigOptions opts)
 {
     this.options = opts;
     Close();
     Connect();
 }
Example #3
0
 //private readonly Logger logger = new Logger("IConnectionICPImpl");
 public ConnectionTCPImpl(ServerAddress addr, ConfigOptions opts)
 {
     this.hostAddress = addr;
     this.options = opts;
 }
Example #4
0
        //private readonly Logger logger = new Logger("IConnectionICPImpl");

        public ConnectionTCPImpl(ServerAddress addr, ConfigOptions opts)
        {
            this.hostAddress = addr;
            this.options     = opts;
        }
Example #5
0
 /** \fn void Connect(string username, string password, ConfigOptions options)
  *  \brief Connect to remote Sequoiadb database server
  *  \username Sequoiadb connection user name
  *  \password Sequoiadb connection password
  *  \options The options for connection
  *  \return void
  *  \exception SequoiaDB.BaseException
  *  \exception System.Exception
  */
 public void Connect(string username, string password, ConfigOptions options)
 {
     ConfigOptions opts = options;
     if (username == null)
         username = "";
     if (password == null)
         password = "";
     this.userName = username;
     this.password = password;
     if (options == null)
         opts = new ConfigOptions();
     if (connection == null)
     {
         // single address
         if (serverAddress != null)
         {
             // connect
             try
             {
                 connection = new ConnectionTCPImpl(serverAddress, opts);
                 connection.Connect();
             }
             catch (System.Exception e)
             {
                 connection = null;
                 throw e;
             }
         }
         // several addresses
         else if (serverAddresses != null)
         {
             int size = serverAddresses.Length;
             Random random = new Random();
             int count = random.Next(size);
             int mark = count;
             do
             {
                 count = ++count % size;
                 try
                 {
                     ServerAddress conn = serverAddresses[count];
                     connection = new ConnectionTCPImpl(conn, opts);
                     connection.Connect();
                 }
                 catch (System.Exception)
                 {
                     if (mark == count)
                     {
                         throw new BaseException("SDB_NET_CANNOT_CONNECT");
                     }
                     continue;
                 }
                 break;
             } while(mark != count);
         }
         else
         {
             throw new BaseException("SDB_NET_CANNOT_CONNECT");
         }
         // get endian info
         isBigEndian = RequestSysInfo();
         // authentication
         try
         {
             Auth();
         }
         catch (BaseException e)
         {
             throw e;
         }
     }
 }
Example #6
0
 /** \fn void ChangeConnectionOptions(ConfigOptions opts)
  *  \brief Change the connection options
  *  \return void
  *  \param opts The connection options
  *  \exception System.Exception
  */
 public void ChangeConnectionOptions(ConfigOptions opts)
 {
     connection.ChangeConfigOptions(opts);
     try
     {
         Auth();
     }
     catch (BaseException e)
     {
         throw e;
     }
 }
Example #7
0
        public void Connect_With_Serval_Arg_Test()
        {
            List<string> list = new List<string>();

            list.Add("192.168.20.35:12340");
            list.Add("192.168.20.36:12340");
            list.Add("123:123");
            list.Add("");
            list.Add("192.168.20.40");
            list.Add("192.168.30.161:11810");
            list.Add("localhost:50000");
            list.Add("192.168.20.42:50000");
            list.Add("192.168.20.42:11810");
            list.Add("192.168.20.165:11810");
            list.Add("localhost:12340");
            list.Add("192.168.20.40:12340");

            ConfigOptions options = new ConfigOptions();
            options.MaxAutoConnectRetryTime = 0;
            options.ConnectTimeout = 100;
            // connect
            Sequoiadb sdb1 = new Sequoiadb(list);
            sdb1.Connect("", "", options);
            // set option and change the connect
            options.ConnectTimeout = 2000;
            sdb1.ChangeConnectionOptions(options);
            // check
            DBCursor cursor = sdb1.GetList(4, null, null, null);
            Assert.IsTrue(cursor != null);
            sdb1.Disconnect();
        }
Example #8
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");
        }