public void Launch(ManageSites sites, string orderingPolicy, string routingPolicy, string logPolicy) { //Class name should be: Launch..... string processType = this.GetType().Name.Substring(6); string args = string.Join(" ", Port, Name, orderingPolicy, routingPolicy, logPolicy, Util.MakeUrl("tcp", Util.GetLocalIPAddress() , Util.PUPPET_MASTER_PORT.ToString(), Util.PUPPET_MASTER_NAME)); LaunchProcess(processType, args); }
/// <summary> /// Launch all the system processes in corresponding nodes. /// </summary> /// <param name="sites"> Tree topography and information </param> /// <param name="worker"></param> public void LaunchAllProcesses(ManageSites sites, BackgroundWorker worker) { int l = 1, percentageCompleted = 0, totalNodes = launchNodes.Count; foreach (LaunchNode node in launchNodes) { node.Launch(sites, OrderingPolicy, RoutingPolicy, LogLevel); } foreach (LaunchNode node in launchNodes) { worker.ReportProgress(percentageCompleted, "Initializing"); node.InitializeProcess(sites); percentageCompleted += (int)Math.Ceiling(((double)1 / (double)totalNodes) * 100); percentageCompleted = (percentageCompleted > 100) ? 100 : percentageCompleted; l++; } worker.ReportProgress(percentageCompleted, string.Empty); }
public override void InitializeProcess(ManageSites sites) { (Activator.GetObject(typeof(IGeneralControlServices), Util.MakeUrl("tcp", Ip, Port, "sub")) as IGeneralControlServices).Init(sites.GetSite(Site).GetSiteDTO()); }
public void LaunchConfigurationFile(string filePath) { ManageSites sites = new ManageSites(); ProcessLauncher launcher = new ProcessLauncher(); string[] tokens = null, lines = File.ReadAllLines(filePath); int l = 1; logServer.LogFile = "Log" + Path.GetFileName(filePath); File.CreateText(LOG_FILES_DIRECTORY + logServer.LogFile).Close(); parentForm.ReloadLogFiles(); foreach (string line in lines) { if (Regex.IsMatch(line, ParseUtil.SITE)) { tokens = Regex.Split(line, ParseUtil.SPACE); if (!tokens[3].Equals("none")) sites.CreateSiteWithParent(tokens[1], tokens[3]); sites.CreateSite(tokens[1]); } else if (Regex.IsMatch(line, ParseUtil.PROCESS)) { tokens = Regex.Split(line, ParseUtil.SPACE); string processType = tokens[3]; string port = ParseUtil.ExtractPortFromURL(tokens[7]); processes.Add(tokens[1], tokens[7]); parentForm.Invoke(new AddProcess(parentForm.AddToGenericProcesses), tokens[1]); if (processType.Equals("publisher")) { parentForm.Invoke(new AddProcess(parentForm.AddToPublishersProcesses), tokens[1]); launcher.AddNode(new LaunchPublisher(tokens[1], ParseUtil.ExtractIPFromURL(tokens[7]), port, tokens[5])); } else if (processType.Equals("subscriber")) { parentForm.Invoke(new AddProcess(parentForm.AddToSubscribersProcesses), tokens[1]); launcher.AddNode(new LaunchSubscriber(tokens[1], ParseUtil.ExtractIPFromURL(tokens[7]), port, tokens[5])); } else if (processType.Equals("broker")) { sites.AddBrokerUrlToSite(tokens[5], tokens[7],tokens[1]); launcher.AddNode(new LaunchBroker(tokens[1], ParseUtil.ExtractIPFromURL(tokens[7]), port, tokens[5])); } } else if (Regex.IsMatch(line, ParseUtil.ROUTING)) { tokens = Regex.Split(line, ParseUtil.SPACE); launcher.RoutingPolicy = tokens[1]; } else if (Regex.IsMatch(line, ParseUtil.ORDERING)) { tokens = Regex.Split(line, ParseUtil.SPACE); launcher.OrderingPolicy = tokens[1]; } else if (Regex.IsMatch(line, ParseUtil.LOGGING_LEVEL)) { tokens = Regex.Split(line, ParseUtil.SPACE); launcher.LogLevel = tokens[1]; } else if(line != string.Empty) //Syntax error in a script instruction. Abort. { processes.Clear(); File.Delete(LOG_FILES_DIRECTORY + logServer.LogFile); parentForm.ReloadLogFiles(); MessageBox.Show("Syntax Error at line " + l + " :" + Environment.NewLine + Environment.NewLine + line , "Script Abort", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } l++; } //Execute Asynchronous Launching... ExecuteBackgroundTask task = new ExecuteBackgroundTask("Booting System"," Initializing", "LaunchAllProcesses", sites, launcher); task.ShowDialog(); }
public abstract void InitializeProcess(ManageSites sites);
public void LaunchConfigurationFile(string filePath) { ManageSites sites = new ManageSites(); ProcessLauncher launcher = new ProcessLauncher(); string[] tokens = null, lines = File.ReadAllLines(filePath); int l = 1; logServer.LogFile = "Log" + Path.GetFileName(filePath); File.CreateText(LOG_FILES_DIRECTORY + logServer.LogFile).Close(); parentForm.ReloadLogFiles(); foreach (string line in lines) { if (Regex.IsMatch(line, ParseUtil.SITE)) { tokens = Regex.Split(line, ParseUtil.SPACE); if (!tokens[3].Equals("none")) { sites.CreateSiteWithParent(tokens[1], tokens[3]); } sites.CreateSite(tokens[1]); } else if (Regex.IsMatch(line, ParseUtil.PROCESS)) { tokens = Regex.Split(line, ParseUtil.SPACE); string processType = tokens[3]; string port = ParseUtil.ExtractPortFromURL(tokens[7]); processes.Add(tokens[1], tokens[7]); parentForm.Invoke(new AddProcess(parentForm.AddToGenericProcesses), tokens[1]); if (processType.Equals("publisher")) { parentForm.Invoke(new AddProcess(parentForm.AddToPublishersProcesses), tokens[1]); launcher.AddNode(new LaunchPublisher(tokens[1], ParseUtil.ExtractIPFromURL(tokens[7]), port, tokens[5])); } else if (processType.Equals("subscriber")) { parentForm.Invoke(new AddProcess(parentForm.AddToSubscribersProcesses), tokens[1]); launcher.AddNode(new LaunchSubscriber(tokens[1], ParseUtil.ExtractIPFromURL(tokens[7]), port, tokens[5])); } else if (processType.Equals("broker")) { sites.AddBrokerUrlToSite(tokens[5], tokens[7], tokens[1]); launcher.AddNode(new LaunchBroker(tokens[1], ParseUtil.ExtractIPFromURL(tokens[7]), port, tokens[5])); } } else if (Regex.IsMatch(line, ParseUtil.ROUTING)) { tokens = Regex.Split(line, ParseUtil.SPACE); launcher.RoutingPolicy = tokens[1]; } else if (Regex.IsMatch(line, ParseUtil.ORDERING)) { tokens = Regex.Split(line, ParseUtil.SPACE); launcher.OrderingPolicy = tokens[1]; } else if (Regex.IsMatch(line, ParseUtil.LOGGING_LEVEL)) { tokens = Regex.Split(line, ParseUtil.SPACE); launcher.LogLevel = tokens[1]; } else if (line != string.Empty) //Syntax error in a script instruction. Abort. { processes.Clear(); File.Delete(LOG_FILES_DIRECTORY + logServer.LogFile); parentForm.ReloadLogFiles(); MessageBox.Show("Syntax Error at line " + l + " :" + Environment.NewLine + Environment.NewLine + line, "Script Abort", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } l++; } //Execute Asynchronous Launching... ExecuteBackgroundTask task = new ExecuteBackgroundTask("Booting System", " Initializing", "LaunchAllProcesses", sites, launcher); task.ShowDialog(); }
public override void InitializeProcess(ManageSites sites) { (Activator.GetObject(typeof(IGeneralControlServices), Util.MakeUrl("tcp", Ip, Port, "broker")) as IGeneralControlServices).Init(sites.GetSite(Site).GetSiteDTO()); }
/// <summary> /// Launch all the system processes in corresponding nodes. /// </summary> /// <param name="sites"> Tree topography and information </param> /// <param name="worker"></param> public void LaunchAllProcesses(ManageSites sites, BackgroundWorker worker) { int l = 1, percentageCompleted = 0, totalNodes = launchNodes.Count; foreach(LaunchNode node in launchNodes) { node.Launch(sites, OrderingPolicy, RoutingPolicy, LogLevel); } foreach (LaunchNode node in launchNodes) { worker.ReportProgress(percentageCompleted, "Initializing"); node.InitializeProcess(sites); percentageCompleted += (int)Math.Ceiling(((double)1 / (double)totalNodes) * 100); percentageCompleted = (percentageCompleted > 100) ? 100 : percentageCompleted; l++; } worker.ReportProgress(percentageCompleted, string.Empty); }