Exemple #1
0
        public BrokerForm(string[] args)
        {
            InitializeComponent();
            logFormat("Started Process, pid=\"{0}\"", Process.GetCurrentProcess().Id);
            Text = "Broker ";
            int nargs = 6;
            if (args.Length != nargs)
            {
                logFormat("Expected {0} arguments, got {1}", nargs, args.Length);
                return;
            }
            string puppetMasterURI = args[0];
            string name = args[1];
            string site = args[2];
            int port = int.Parse(args[3]);
            string coordinatorURI = args[4];
            string processName = args[5];
            Text = string.Format("{0} {1}",processName,site);

            string channelURI = Utility.setupChannel(port);

            // get the puppetMaster that started this process
            PuppetMaster pm = (PuppetMaster)Activator.GetObject(typeof(PuppetMaster), puppetMasterURI);
            string uri = string.Format("{0}/{1}", channelURI, name);
            BrokerRemote broker = new BrokerRemote(this, pm, uri, name, site, coordinatorURI, processName);
            //we need to register each remote object
            ObjRef o = RemotingServices.Marshal(broker, name, typeof(Broker));
            log(broker.ToString());
            //now that broker is created and marshalled
            //send remote to puppetMaster which is Monitor.waiting for the remote
            pm.registerBroker(broker);
            logFormat("registered at puppetMaster");
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Started Broker process, pid=\"{0}\"", Process.GetCurrentProcess().Id);
            int nargs = 6;
            if (args.Length != nargs)
            {
                Console.WriteLine("Expected {0} arguments, got {1}", nargs, args.Length);
                Console.Read();
                return;
            }
            string puppetMasterURI = args[0];
            string name = args[1];
            string site = args[2];
            int port = int.Parse(args[3]);
            string coordinatorURI = args[4];
            string processName = args[5];
            _processName = processName;

            string channelURI = Utility.setupChannel(port);

            // get the puppetMaster that started this process
            PuppetMaster pm = (PuppetMaster)Activator.GetObject(typeof(PuppetMaster), puppetMasterURI);
            string uri = string.Format("{0}/{1}", channelURI, name);
            BrokerRemote broker = new BrokerRemote(pm, uri, name, site, coordinatorURI);
            //we need to register each remote object
            ObjRef o = RemotingServices.Marshal(broker, name, typeof(Broker));
            Console.WriteLine("Instanciated Broker name:'{0}' site:'{1}' uri:'{2}'", name, site, uri);

            //now that broker is created and marshalled
            //send remote to puppetMaster which is Monitor.waiting for the remote
            pm.registerBroker(broker);
            Console.WriteLine("Just registered at puppetMaster");
            Console.WriteLine("Press key to leave");
            Console.Read();
        }