public static SimulacronCluster CreateNew(SimulacronOptions options) { var simulacronManager = SimulacronManager.Instance; simulacronManager.Start(); var path = string.Format(CreateClusterPathFormat, options.Nodes, options.GetCassandraVersion(), options.GetDseVersion(), options.Name, options.ActivityLog, options.NumberOfTokens); var data = TaskHelper.WaitToComplete(Post(path, null)); var cluster = new SimulacronCluster(data["id"].ToString()); cluster.Data = data; cluster.DataCenters = new List <SimulacronDataCenter>(); var dcs = (JArray)cluster.Data["data_centers"]; foreach (var dc in dcs) { var dataCenter = new SimulacronDataCenter(cluster.Id + "/" + dc["id"]); cluster.DataCenters.Add(dataCenter); dataCenter.Nodes = new List <SimulacronNode>(); var nodes = (JArray)dc["nodes"]; foreach (var nodeJObject in nodes) { var node = new SimulacronNode(dataCenter.Id + "/" + nodeJObject["id"]); dataCenter.Nodes.Add(node); node.ContactPoint = nodeJObject["address"].ToString(); } } return(cluster); }
private static SimulacronCluster CreateFromData(SimulacronManager simulacronManager, dynamic data) { var cluster = new SimulacronCluster(data["id"].ToString(), simulacronManager) { Data = data, DataCenters = new List <SimulacronDataCenter>() }; var dcs = (JArray)cluster.Data["data_centers"]; foreach (var dc in dcs) { var dataCenter = new SimulacronDataCenter(cluster.Id + "/" + dc["id"], simulacronManager); cluster.DataCenters.Add(dataCenter); dataCenter.Nodes = new List <SimulacronNode>(); var nodes = (JArray)dc["nodes"]; foreach (var nodeJObject in nodes) { var node = new SimulacronNode(dataCenter.Id + "/" + nodeJObject["id"], simulacronManager); dataCenter.Nodes.Add(node); node.ContactPoint = nodeJObject["address"].ToString(); } } return(cluster); }