public static PcsManager GetInstance() { if (_instance == null) { _instance = new PcsManager(); } return(_instance); }
private void ExecuteLine(string cmd) { PuppetMaster.GetInstance().Log("Running config file command: " + cmd); if (cmd.StartsWith(" ")) { MessageBox.Show("Invalid line to be processed!"); } else if (cmd.StartsWith("Semantics")) { string[] pieces = cmd.Split(' '); if (pieces.Length == 2) { _sematic = pieces[1]; } } else if (cmd.StartsWith("LoggingLevel")) { string[] pieces = cmd.Split(' '); if (pieces.Length == 2 && pieces[1].Equals("full")) { _isLogFull = true; } } else if (cmd.StartsWith("OP")) { // Operators setup string[] res = cmd.Split(' '); int opId = int.Parse(res[0].Substring(2)); List <string> listUrls = new List <string>(); for (int i = 10; i < res.Length && res[i].StartsWith("tcp://"); i++) { listUrls.Add(res[i].Replace(",", string.Empty)); } string ip = GetOwnIp(); string myLogUrl = "tcp://" + ip + ":" + PuppetMaster.Port + "/" + PuppetMaster.RemoteName; PuppetMaster.GetInstance().Log("IP Sent for PCS: " + myLogUrl); if (_sematic.Equals(String.Empty)) { _sematic = "at-most-once"; } ConnectionPack thingsToSend = new ConnectionPack(cmd, _isLogFull, listUrls, myLogUrl, _sematic); _whatShouldISentToOperators.Add(opId, thingsToSend); if (res[3].StartsWith("OP") && !res[3].EndsWith(".dat")) { // Put in connection pack of the previous operator the urls of this one. So he can direct its output int op2Id = int.Parse(res[3].Substring(2)); _whatShouldISentToOperators[op2Id].ReplicaUrlsOutput = listUrls; _whatShouldISentToOperators[op2Id].RoutingType = res[8]; } if (res[0].Equals("OP1")) { _whatShouldISentToOperators[opId].RoutingTypeToReadFromFile = res[8]; } PuppetMaster.GetInstance().CreateOperator(opId, listUrls); } else { // Commands to operators // Send every creation command to the operators if (!_wereOperatorsCreated) { PuppetMaster.GetInstance().Log("Creating operators..."); foreach (KeyValuePair <int, ConnectionPack> entry in _whatShouldISentToOperators) { PcsManager.GetInstance().SendCommand(entry.Value); } _wereOperatorsCreated = true; } ParseCommand(cmd); } }