public OutputOperatorDTO(string operatorId, List <string> replicasUrl, RoutingPolicy routingPolicy, int hashingField) { this.operatorId = operatorId; ReplicasUrl = replicasUrl; RoutingPolicy = routingPolicy; HashingField = hashingField; }
public ConfigurationData(LoggingLevel logging = LoggingLevel.Light, RoutingPolicy routing = RoutingPolicy.Flooding, Ordering ordering = Ordering.Fifo, string pupIP = "localhost") { this.logging = logging; this.routing = routing; this.ordering = ordering; this.PuppetMasterIP = pupIP; }
protected BaseProcess(string processName, string processUrl, string puppetMasterUrl, string siteName) { ProcessName = processName; Url = processUrl; SiteName = siteName; // connects to this site's puppetMaster ConnectToPuppetMaster(puppetMasterUrl); this.LoggingLevel = PuppetMaster.GetLoggingLevel(); this.OrderingGuarantee = PuppetMaster.GetOrderingGuarantee(); this.RoutingPolicy = PuppetMaster.GetRoutingPolicy(); }
public Operator(string id, List <string> inputs, int replicationFactor, RoutingPolicy routingPolicy, int hashingField, List <string> replicaURLs, string operatorSpec, List <string> operatorSpecArgs) { this.id = id; this.inputs = inputs; this.replicationFactor = replicationFactor; this.routingPolicy = routingPolicy; this.HashingField = hashingField; this.replicaURLs = replicaURLs; this.operatorSpec = operatorSpec; this.operatorSpecArgs = operatorSpecArgs; Outputs = new List <OutputOperatorDTO>(); inputFiles = new List <string>(); }
private static ITupleRoutingStrategy RoutingPolicyToStrategy(RoutingPolicy routingPolicy, int hashingField) { switch (routingPolicy) { case RoutingPolicy.Primary: return(new PrimaryRoutingStrategy()); case RoutingPolicy.Random: return(new RandomRoutingStrategy()); case RoutingPolicy.Hashing: return(new HashingRoutingStrategy(hashingField)); default: throw new ArgumentOutOfRangeException(); } }
public static ConfigurationData ReadConfigurationFile(string filename) { string[] lines = null; // Read file try { lines = System.IO.File.ReadAllLines(filename); } catch (FileNotFoundException fnfe) { Console.WriteLine("Configuration file not found."); return(null); } catch (Exception e) { Console.WriteLine("Error while reading from configuration file."); return(null); } // Parse content //Puppet Master ip string pupIP = "localhost"; // Logging Level LoggingLevel level = LoggingLevel.Light; // Routing policy RoutingPolicy routing = RoutingPolicy.Flooding; // Ordering Ordering ordering = Ordering.Fifo; List <Site> sites = new List <Site>(); List <Process> processes = new List <Process>(); foreach (string line in lines) { if (line.StartsWith("LoggingLevel")) { Regex pattern = new Regex(@"LoggingLevel (?<type>(full|light))"); Match match = pattern.Match(line); if (match.Success) { string type = match.Groups["type"].Value; level = (type == "full" ? LoggingLevel.Full : LoggingLevel.Light); } } else if (line.StartsWith("RoutingPolicy")) { Regex pattern = new Regex(@"RoutingPolicy (?<type>(flooding|filter))"); Match match = pattern.Match(line); if (match.Success) { string type = match.Groups["type"].Value; routing = (type == "flooding" ? RoutingPolicy.Flooding : RoutingPolicy.Filter); } } else if (line.StartsWith("Ordering")) { Regex pattern = new Regex(@"Ordering (?<type>(NO|FIFO|TOTAL))"); Match match = pattern.Match(line); if (match.Success) { string type = match.Groups["type"].Value; if (type == "FIFO") { ordering = Ordering.Fifo; } else if (type == "TOTAL") { ordering = Ordering.Total; } else if (type == "NO") { ordering = Ordering.No; } } } else if (line.StartsWith("Site")) { Regex pattern = new Regex(@"Site (?<name>\w+) Parent (?<parent>(none|\w+))"); Match match = pattern.Match(line); if (match.Success) { string name = match.Groups["name"].Value; string parent = match.Groups["parent"].Value; Site parentSite = null; if (parent != "none") { parentSite = sites.Find(n => n.name == parent); } sites.Add(new Site(name, parentSite)); } } else if (line.StartsWith("Process")) { Regex pattern = new Regex(@"Process (?<name>\w+) [Ii][Ss] (?<type>(broker|publisher|subscriber)) On (?<site>\w+) URL (?<url>[\w.:/-]+)"); Match match = pattern.Match(line); if (match.Success) { string name = match.Groups["name"].Value; string type = match.Groups["type"].Value; string sitename = match.Groups["site"].Value; string url = match.Groups["url"].Value; ProcessType pType = ProcessType.Broker; if (type == "broker") { pType = ProcessType.Broker; } else if (type == "publisher") { pType = ProcessType.Publisher; } else if (type == "subscriber") { pType = ProcessType.Subscriber; } Site site = sites.Find(n => n.name == sitename); if (site == null) { return(null); } Process process = new Process(name, url, site, pType); processes.Add(process); if (type == "broker") { site.broker = process; } else if (type == "publisher") { site.publishers.Add(process); } else if (type == "subscriber") { site.subscribers.Add(process); } } } else if (line.StartsWith("PMIP")) { Regex pattern = new Regex(@"PMIP (?<ip>.*)"); Match match = pattern.Match(line); if (match.Success) { pupIP = match.Groups["ip"].Value; } } } ConfigurationData data = new ConfigurationData(level, routing, ordering, pupIP); foreach (Site site in sites) { data.AddSite(site); } foreach (Process process in processes) { data.AddProcess(process); } return(data); }
public ConfigurationData( LoggingLevel logging = LoggingLevel.Light, RoutingPolicy routing = RoutingPolicy.Flooding, Ordering ordering = Ordering.Fifo, string pupIP = "localhost") { this.logging = logging; this.routing = routing; this.ordering = ordering; this.PuppetMasterIP = pupIP; }
public BrokerRemote(PuppetMaster pm, string uri, string name, string site, string addr) { _uri = uri; _serviceName = name; _pm = pm; _site = site; _orderingPolicy = OrderingPolicy.fifo; _routingPolicy = RoutingPolicy.flooding; seq = 0; _coordinatorURI = addr; // c = (ICoordinator)Activator.GetObject(typeof(ICoordinator), addr); }
public void setRoutingPolicy(RoutingPolicy p) { _routingPolicy = p; }
public StreamEngine(IList <StreamInput> i, StreamOperator o, RoutingPolicy r) { inputs = i; op = o; route = r; }
void IProcess.DeliverSetting(string settingType, string settingValue) { switch (settingType) { case "RoutingPolicy": if (settingValue.Equals("Flood")) this.RoutingPolicy = RoutingPolicy.Flood; else if (settingValue.Equals("Filter")) this.RoutingPolicy = RoutingPolicy.Filter; else { Console.Out.WriteLine("Unknown setting for Routing Policy"); return; } break; case "LoggingLevel": if (settingValue.Equals("Full")) this.LoggingLevel = LoggingLevel.Full; else if (settingValue.Equals("Light")) this.LoggingLevel = LoggingLevel.Light; else { Console.Out.WriteLine("Unknown setting for Logging Level"); return; } break; case "OrderingGuarantee": if (settingValue.Equals("No")) this.OrderingGuarantee = OrderingGuarantee.No; else if (settingValue.Equals("Fifo")) this.OrderingGuarantee = OrderingGuarantee.Fifo; else if (settingValue.Equals("Total")) this.OrderingGuarantee = OrderingGuarantee.Total; else { Console.Out.WriteLine("Unknown setting for Ordering Guarantee"); return; } break; } Console.Out.WriteLine(settingType + " set to " + settingValue); }
private void button1_Click(object sender, EventArgs e) { if (ConfigurationManager.AppSettings["faultTolerance"] == "false") faultTolerance = false; else if (ConfigurationManager.AppSettings["faultTolerance"] == "true") faultTolerance = true; else MessageBox.Show("Error on fault config"); StreamWriter writetext = new StreamWriter(ConfigurationManager.AppSettings["logs"], false); writetext.Write(""); writetext.Close(); myaddr = ConfigurationManager.AppSettings["myaddr"]; int myport = Int32.Parse(parseURI(myaddr)[2]); TcpChannel channel = new TcpChannel(myport); ChannelServices.RegisterChannel(channel, true); CoordinatorRem c = new CoordinatorRem(this); RemotingServices.Marshal(c, "CoordinatorRem", typeof(CoordinatorRem)); site_site = new Dictionary<string, Site>(); site_parents = new Dictionary<string, string>(); site_childs = new Dictionary<string, List<string>>(); site_brokers = new Dictionary<String, List<Broker>>(); site_publishers = new Dictionary<String, List<Publisher>>(); site_subscribers = new Dictionary<String, List<Subscriber>>(); all_brokers = new Dictionary<String, Broker>(); all_publishers = new Dictionary<String, Publisher>(); all_subscribers = new Dictionary<String, Subscriber>(); uri_processname = new Dictionary<String, String>(); rout = RoutingPolicy.flooding; ord = OrderingPolicy.fifo; log = LoggingLevel.light; //load proxyies of pms getPMs(); string configFile = ConfigurationManager.AppSettings["config"]; if (!File.Exists(configFile)) { MessageBox.Show("config.file not found " + Path.GetFullPath(configFile)); return; } string[] lines = System.IO.File.ReadAllLines(configFile); foreach (string line in lines) { if (line.StartsWith("//")) continue; string[] keywords = line.Split(' '); var type = keywords[0]; if (type == "RoutingPolicy" && keywords.Length >= 2) { if (keywords[1] == "filter") rout = RoutingPolicy.filter; else if (keywords[1] == "flooding") { } else MessageBox.Show("Wrong Routing format!"); } else if (type == "LoggingLevel" && keywords.Length >= 2) { if (keywords[1] == "full") log = LoggingLevel.full; else if (keywords[1] == "light") { } else MessageBox.Show("Wrong Logging format!"); } else if (type == "Ordering" && keywords.Length >= 2) { if (keywords[1] == "NO") ord = OrderingPolicy.no; else if (keywords[1] == "TOTAL") ord = OrderingPolicy.total; else if (keywords[1] == "FIFO") { } else MessageBox.Show("Wrong Ordering format!"); } else if (type == "Site" && keywords.Length >= 4) { //Example "Site site0 Parent none" //"Site site1 Parent site0" var parent_site = keywords[3]; var site_name = keywords[1]; if (parent_site == "none") { site_root = site_name; } else { site_parents.Add(site_name, parent_site); if (!site_childs.ContainsKey(parent_site)) site_childs.Add(parent_site, new List<string>()); site_childs[parent_site].Add(site_name); } } else if (type == "Process" && keywords.Length >= 8) { //Process subscriber0 Is subscriber On site0 URL tcp://localhost:3337/sub string uri = keywords[7]; string ip = parseURI(uri)[1]; string port = parseURI(uri)[2]; string serviceName = parseURI(uri)[3]; string process_type = keywords[3]; string site = keywords[5]; string processName = keywords[1]; switch (process_type) { case "publisher": //create Publisher p = pms[ip].createPublisher(processName, serviceName, site, Int32.Parse(port), myaddr); //associate all_publishers.Add(processName, p); //add it to site publishers if (!site_publishers.ContainsKey(site)) site_publishers.Add(site, new List<Publisher>()); site_publishers[site].Add(p); if (ip == "localhost") uri = uri.Replace("localhost", LocalIPAddress().ToString()); uri_processname.Add(uri, processName); break; case "broker": Broker b = pms[ip].createBroker(processName, serviceName, site, Int32.Parse(port), myaddr); List<Broker> temp = new List<Broker>() { b }; if (faultTolerance) { Broker b1 = pms[ip].createBroker(processName + "_1", serviceName, site, Int32.Parse(port) + 500, myaddr); temp.Add(b1); Broker b2 = pms[ip].createBroker(processName + "_2", serviceName, site, Int32.Parse(port) + 600, myaddr); temp.Add(b2); } all_brokers.Add(processName, b); site_brokers.Add(site, temp); site_site.Add(site, new Site() { name = site, brokers = temp }); if (ip == "localhost") uri = uri.Replace("localhost", LocalIPAddress().ToString()); uri_processname.Add(uri, processName); break; case "subscriber": Subscriber s = pms[ip].createSubscriber(processName, serviceName, site, Int32.Parse(port), myaddr); all_subscribers.Add(processName, s); if (!site_subscribers.ContainsKey(site)) site_subscribers.Add(site, new List<Subscriber>()); site_subscribers[site].Add(s); if (ip == "localhost") uri = uri.Replace("localhost", LocalIPAddress().ToString()); uri_processname.Add(uri, processName); break; default: MessageBox.Show("Error parsing config.file!"); break; } } else MessageBox.Show("Error parsing config.file! at line:\n" + string.Format("'{0}'", line)); } foreach (KeyValuePair<string, List<Broker>> entry in site_brokers) { foreach (Broker b in entry.Value) { b.setRoutingPolicy(rout); b.setOrderingPolicy(ord); b.setLoggingLevel(log); } } foreach (KeyValuePair<string, Subscriber> entry in all_subscribers) { entry.Value.setOrderingPolicy(ord); } foreach (var entry in all_publishers) { entry.Value.setOrderingPolicy(ord); } foreach (Broker b in site_brokers[site_root]) { b.setIsRoot(); b.setMySite(site_site[site_root]); } //Set publishers brokers foreach (KeyValuePair<string, List<Publisher>> entry in site_publishers) { foreach (Broker b in site_brokers[entry.Key]) b.setPublishers(entry.Value); foreach (Publisher p in entry.Value) p.setSite(site_site[entry.Key]); } // Set subscriber brokers foreach (KeyValuePair<string, List<Subscriber>> entry in site_subscribers) { foreach (Broker b in site_brokers[entry.Key]) b.setSubscribers(entry.Value); foreach (Subscriber s in entry.Value) s.setSite(site_site[entry.Key]); } //Set parents and childs foreach (KeyValuePair<string, List<Broker>> entry in site_brokers) { string site = entry.Key; foreach (Broker b in entry.Value) { if (site_childs.ContainsKey(site)) { List<Site> childs = new List<Site>(); foreach (string str in site_childs[site]) { if (site_site.ContainsKey(str)) // empty sites childs.Add(site_site[str]); } b.setChildren(childs); } if (site != site_root) { string ps = site_parents[site]; b.setParent(site_site[ps]); } } } }
public BrokerRemote(BrokerForm form, PuppetMaster pm, string uri, string name, string site, string addr, string processName) { _form = form; _uri = uri; _serviceName = name; _site = site; _orderingPolicy = OrderingPolicy.fifo; _routingPolicy = RoutingPolicy.flooding; _coordinatorURI = addr; _processName = processName; }