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) { var 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(); }
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) { var 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(); }
public static void SequoiadbCleamUp() { // check whether it is in the cluster environment or not if (!Constants.isClusterEnv(sdb)) { return; } group = sdb.GetReplicaGroup(groupName); if (null != group) { // 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); } } create_node_flag = false; create_node2_flag = false; // disconnect sdb.Disconnect(); }
public static void SequoiadbInitialize(TestContext testContext) { if (config == null) { config = new Config(); } sdb = new Sequoiadb(config.conf.Coord.Address); sdb.Connect(config.conf.UserName, config.conf.Password); // check whether it is in the cluster environment or not if (!Constants.isClusterEnv(sdb)) { return; } // argument groupName = config.conf.Groups[3].GroupName; hostName = config.conf.Groups[3].Nodes[0].HostName; port = config.conf.Groups[3].Nodes[0].Port; dbpath = config.conf.Groups[3].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_rg_flag = true; // create a node BsonDocument options = new BsonDocument(); options.Add("logfilenum", 1); node = group.CreateNode(hostName, port, dbpath, options); Assert.IsNotNull(node); node.Start(); create_node_flag = true; }
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) { var nd = group.GetMaster(); var 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(); }