示例#1
0
 internal Node(ReplicaGroup group, string hostName, int port, int nodeID)
 {
     this.group       = group;
     this.hostName    = hostName;
     this.port        = port;
     this.nodeName    = hostName + SequoiadbConstants.NODE_NAME_SERVICE_SEP + port;
     this.nodeID      = nodeID;
     this.isBigEndian = group.isBigEndian;
 }
示例#2
0
 internal Node(ReplicaGroup group, string hostName, int port, int nodeID)
 {
     this.group = group;
     this.hostName = hostName;
     this.port = port;
     this.nodeName = hostName + SequoiadbConstants.NODE_NAME_SERVICE_SEP + port;
     this.nodeID = nodeID;
     this.isBigEndian = group.isBigEndian;
 }
示例#3
0
 public void MyTestCleanup()
 {
     // check whether it is in the cluster environment or not
     if (!Constants.isClusterEnv(sdb))
     {
         Console.WriteLine("removeRG is for cluster environment only.");
         return;
     }
     group = sdb.GetReplicaGroup(groupName);
     if (group != null)
     {
         // drop all the cs in current group, and then remove this group
         int nodeNum = group.GetNodeNum(SDBConst.NodeStatus.SDB_NODE_ALL);
         if (nodeNum > 0)
         {
             SequoiaDB.Node nd = group.GetMaster();
             Sequoiadb db = new Sequoiadb(nd.HostName, nd.Port);
             Assert.IsTrue(nd.Start());
             db.Connect(config.conf.UserName, config.conf.Password);
             DBCursor cursor = db.ListCollectionSpaces();
             while (cursor.Next() != null)
             {
                 BsonDocument obj = cursor.Current();
                 string temp = null;
                 if (obj.Contains("Name"))
                     temp = obj["Name"].AsString;
                 sdb.DropCollectionSpace(temp);
             }
             db.Disconnect();
         }
         Assert.IsTrue(group.Stop());
         // remove group
         try
         {
             sdb.RemoveReplicaGroup(group.GroupName);
         }
         catch (BaseException e)
         {
             string errInfo = e.Message;
             Console.WriteLine("Error code is: " + errInfo);
         }
     }
     sdb.Disconnect();
 }
示例#4
0
        public void RGTest()
        {
            // check whether it is in the cluster environment or not
            if (!Constants.isClusterEnv(sdb))
            {
                Console.WriteLine("removeRG is for cluster environment only.");
                return;
            }
            group = sdb.GetReplicaGroup(groupName);
            if (group == null)
                group = sdb.CreateReplicaGroup(groupName);
            ReplicaGroup group1 = sdb.GetReplicaGroup(group.GroupID);
            Assert.AreEqual(group.GroupName, group1.GroupName);
            ReplicaGroup group2 = sdb.GetReplicaGroup(1);
            Assert.IsNotNull(group2);
            node = group.GetNode(hostName, port);
            if (node == null)
            {
                string dbpath = config.conf.Groups[0].Nodes[0].DBPath;
                Dictionary<string, string> map = new Dictionary<string, string>();
                map.Add("diaglevel", config.conf.Groups[0].Nodes[0].DiagLevel);
                node = group.CreateNode(hostName, port, dbpath, map);
            }
            group.Start();
            int num = group.GetNodeNum(SDBConst.NodeStatus.SDB_NODE_ALL);
            Assert.IsTrue(num > 0);
            BsonDocument detail = group.GetDetail();
            string gn = detail["GroupName"].AsString;
            Assert.IsTrue(groupName.Equals(gn));
            SequoiaDB.Node master = group.GetMaster();
            Assert.IsNotNull(master);
            SequoiaDB.Node slave = group.GetSlave();
            Assert.IsNotNull(slave);
            Assert.IsTrue(node.Stop());
            Assert.IsTrue(node.Start());
            SDBConst.NodeStatus status = node.GetStatus();
            Assert.IsTrue(status == SDBConst.NodeStatus.SDB_NODE_ACTIVE);

            Sequoiadb db = node.Connect(config.conf.UserName, config.conf.Password);
            db.Disconnect();
            node.Stop();
            group.Stop();
        }
示例#5
0
        public void removeRG()
        {
            // check whether it is in the cluster environment or not
            if (!Constants.isClusterEnv(sdb))
            {
                Console.WriteLine("removeRG is for cluster environment only.");
                return;
            }
            // get rg
            group = sdb.GetReplicaGroup(groupName);
            if (group == null)
                group = sdb.CreateReplicaGroup(groupName);
            Assert.IsNotNull(group);
            // create node1
            string hostName1 = config.conf.Groups[1].Nodes[1].HostName;
            int port1 = config.conf.Groups[1].Nodes[1].Port;
            string dbPath1 = config.conf.Groups[1].Nodes[1].DBPath;
            Dictionary<string, string> map1 = new Dictionary<string, string>();
            map1.Add("diaglevel", config.conf.Groups[1].Nodes[1].DiagLevel);
            SequoiaDB.Node node1 = group.CreateNode(hostName1, port1, dbPath1, map1);
            Assert.IsNotNull(node1);
            // start node1
            Assert.IsTrue(node1.Start());

            // remove the newly build node
            try
            {
                group.RemoveNode(hostName1, port1, null);
            }
            catch (BsonException e)
            {
                string errInfo = e.Message;
                Console.WriteLine("Error code is: " + errInfo);
            }
            group.Stop();
        }
示例#6
0
 public void MyTestInitialize()
 {
     // check whether it is in the cluster environment or not
     if (!Constants.isClusterEnv(sdb))
     {
         Console.WriteLine("removeRG is for cluster environment only.");
         return;
     }
     // argument
     groupName = config.conf.Groups[0].GroupName;
     hostName = config.conf.Groups[0].Nodes[0].HostName;
     port = config.conf.Groups[0].Nodes[0].Port;
     dbpath = config.conf.Groups[0].Nodes[0].DBPath;
     // drop the exist group
     group = sdb.GetReplicaGroup(groupName);
     if (group != null)
     {
         // drop all the cs in current group, and then remove this group
         int nodeNum = group.GetNodeNum(SDBConst.NodeStatus.SDB_NODE_ALL);
         if (nodeNum > 0)
         {
             SequoiaDB.Node nd = group.GetMaster();
             Sequoiadb db = new Sequoiadb(nd.HostName, nd.Port);
             Assert.IsTrue(nd.Start());
             db.Connect(config.conf.UserName, config.conf.Password);
             DBCursor cursor = db.ListCollectionSpaces();
             while (cursor.Next() != null)
             {
                 BsonDocument obj = cursor.Current();
                 string temp = null;
                 if (obj.Contains("Name"))
                     temp = obj["Name"].AsString;
                 sdb.DropCollectionSpace(temp);
             }
             db.Disconnect();
         }
         try
         {
             sdb.RemoveReplicaGroup(group.GroupName);
         }
         catch (BaseException e)
         {
             string errInfo = e.Message;
             Console.WriteLine("Error code is: " + errInfo);
         }
     }
     // create a new group
     group = sdb.CreateReplicaGroup(groupName);
     Assert.IsTrue(groupName.Equals(group.GroupName));
     // create a node
     Dictionary<string, string> map = new Dictionary<string, string>();
     map.Add("diaglevel", config.conf.Groups[0].Nodes[0].DiagLevel);
     node = group.CreateNode(hostName, port, dbpath, map);
     Assert.IsNotNull(node);
     group.Start();
 }