Beispiel #1
0
        public void createProcess(TreeNode site, string role, string name, string s, string url)
        {

            string aux = "LocalPMcreateProcess @ url -> " + url + " site -> " + s;
            Console.WriteLine(aux);
            if (role.Equals("broker"))
            {
                Broker b = new Broker(url, name, s);
                site.setBroker(b);

                string port = (portCounter++).ToString();

                //Process.Start()
                ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\DAD\PubSub_v3.1\Broker\bin\Debug\Broker.exe");
                string[] args = { port, url, name, s };
                startInfo.Arguments = String.Join(";", args);

                Process p = new Process();
                p.StartInfo = startInfo;

                p.Start();
            }
            if (role.Equals("subscriber"))
            {
                Subscriber sub = new Subscriber(url, name, s);
                //site.addSubscriber(sub);

                string port = (portCounter++).ToString();

                ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\DAD\PubSub_v3.1\Subscriber\bin\Debug\Subscriber.exe");
                string[] args = { port, url, name, s };
                startInfo.Arguments = String.Join(";", args);

                Process p = new Process();
                p.StartInfo = startInfo;

                p.Start();
            }
            if (role.Equals("publisher"))
            {
                Publisher p = new Publisher(url, name, s/*, site.getBroker()*/);
                //site.addPublisher(p);

                string port = (portCounter++).ToString();

                ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\DAD\PubSub_v3.1\Publisher\bin\Debug\Publisher.exe");
                string[] args = { port, url, name, s };
                startInfo.Arguments = String.Join(";", args);

                Process pro = new Process();
                pro.StartInfo = startInfo;

                pro.Start();
            }

        }
Beispiel #2
0
 public void createProcess(TreeNode site, string role, string name, string s, string url)
 {
     string aux = "PMcreateProcess @ " + site.ID + " role " + role;
     MessageBox.Show(aux);
     if (role.Equals("broker")) {
         Broker b = new Broker(url, name, s);
         site.setBroker(b);
     }
     if (role.Equals("subscriber"))
     {
         Subscriber sub = new Subscriber(url, name, s);
         site.addSubscriber(sub);
     }
     if (role.Equals("publisher"))
     {
         Publisher p = new Publisher(url, name, s,site.getBroker());
         site.addPublisher(p);
     }
 }
Beispiel #3
0
 public void addPublisher(Publisher p)
 {
     lstPubs.Add(p);
 }
Beispiel #4
0
        //actualiza node_broker + site_name
        public List<MyProcess> fillProcessList(string v, TreeNode root)
        {
            PuppetInterface myremote;

            string[] lines = System.IO.File.ReadAllLines(v);
            List<MyProcess> res = new List<MyProcess>();

            foreach (string line in lines)
            {
                if (line.Contains("Is broker"))
                {
                    string[] words = line.Split(' '); //words[1]-name, words[5]-site, words[7]-url
                    TreeNode t = site_treeNode[words[5]];

                    string urlService = words[7].Substring(0, words[7].Length - 6);
                    
                    myremote = (PuppetInterface)Activator.GetObject(typeof(PuppetInterface),urlService+"PuppetMasterURL");
                    myremote.createProcess(t, "broker", words[1], words[5], words[7]);

                    //actualizar estruturas
                    Broker aux = new Broker(words[1], words[5], words[7]);
                    t.setBroker(aux);
                    pname_site.Add(words[1], words[5]);
                    node_broker.Add(t, aux);
                    res.Add(aux);
                }
                if (line.Contains("Is publisher"))
                {
                    string[] words = line.Split(' '); //words[1]-name, words[5]-site, words[7]-url
                    TreeNode t = site_treeNode[words[5]];

                    string urlService = words[7].Substring(0, words[7].Length - 9);

                    myremote = (PuppetInterface)Activator.GetObject(typeof(PuppetInterface), urlService + "PuppetMasterURL");
                    myremote.createProcess(t,"publisher", words[1], words[5], words[7]);

                    //actualizar
                    //Broker b = findBroker(words[5]);
                    Publisher aux = new Publisher(words[1], words[5], words[7]/*, b*/);
                    //t.addPublisher(aux);
                    pname_site.Add(words[1], words[5]);
                    res.Add(aux);
                }
                if (line.Contains("Is subscriber"))
                {
                    string[] words = line.Split(' '); //words[1]-name, words[5]-site, words[7]-url
                    TreeNode t = site_treeNode[words[5]];

                    string urlService = words[7].Substring(0, words[7].Length - 10);

                    myremote = (PuppetInterface)Activator.GetObject(typeof(PuppetInterface), urlService + "PuppetMasterURL");
                    myremote.createProcess(t,"subscriber", words[1], words[5], words[7]);

                    //actualizar
                    Subscriber aux = new Subscriber(words[1], words[5], words[7]);
                    //t.addSubscriber(aux);
                    pname_site.Add(words[1], words[5]);
                    res.Add(aux);
                }
            }
            return res;
        }