public void Register(string msg)
 {
     string[] URL = msg.Split('$');
     Console.WriteLine("Register " + URL[0]);
     TP.RM newRM = (TP.RM)Activator.GetObject(typeof(TP.RM), URL[0]);
     try
     {
         newRM.SetName(URL[1]);
     }
     catch (RemotingException e)
     {
         Console.WriteLine(e.ToString());
     }
     lock (_resourceManagers)
     {
         _resourceManagers[newRM.GetName()] = newRM;
     }
 }
Exemple #2
0
        /// <summary>
        /// Called by RM to register it's URL with the TM.
        /// </summary>
        /// <param name="msg"></param>
        public void Register(string msg)
        {
            string[] URL = msg.Split('$');
            Console.WriteLine("Register " + URL[0]);

            TP.RM newRM = (TP.RM)System.Activator.GetObject(typeof(TP.RM), URL[0]);
            try
            {
                newRM.SetName(URL[1]);
            }
            catch (RemotingException e)
            {
                Console.WriteLine(e.ToString());
            }

            // check and see if this RM is currently involved in any active
            // transactions and remove all those from the active list next
            // operation on that transaction will cause an abort
            lock (this.activeTransactions)
            {
                foreach (Transaction context in this.activeTransactions.Keys)
                {
                    if (!this.activeTransactions[context].Contains(newRM.GetName()))
                    {
                        continue;
                    }

                    // remove the transaction from the active list
                    this.activeTransactions.Remove(context);
                }
            }

            // add the new RM to the list
            lock (this.resourceManagers)
            {
                // add the new RM
                this.resourceManagers[newRM.GetName()] = newRM;
            }
        }
Exemple #3
0
        /// <summary>

        /*  WC runs as a separate process looping forever,
         *  waiting for the calls from other processes */
        /// </summary>
        static void Main(string[] args)
        {
            WCParser parser = new WCParser();

            if (!parser.Parse(args))
            {
                return;
            }

            //string rmFlightsURL = parser["f"];
            //string rmRoomsURL = parser["r"];
            //string rmCarsURL = parser["c"];
            string tmPort   = parser["tmp"];
            string tmServer = parser["tms"];
            string tmURL    = tmServer + ":" + tmPort + "/TM.soap";

            while (TransactionManager == null)
            {
                try
                {
                    TransactionManager = (TP.TM)Activator.GetObject(typeof(TP.TM), tmServer + ":" + tmPort + "/TM.soap");
                    Transaction tid = TransactionManager.Start();
                    TransactionManager.Abort(tid);
                }
                catch (RemotingException)
                {
                    TransactionManager = null;
                    Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", tmURL);
                    System.Threading.Thread.Sleep(1000);
                }
            }


            Console.WriteLine("Transaction Manager retrieved at {0}", tmURL);
            while (Flights == null || Rooms == null || Cars == null)
            {
                if (Flights == null)
                {
                    Flights = TransactionManager.GetResourceMananger("flight");
                }
                if (Rooms == null)
                {
                    Rooms = TransactionManager.GetResourceMananger("room");
                }
                if (Cars == null)
                {
                    Cars = TransactionManager.GetResourceMananger("car");
                }
            }
            if (Flights != null)
            {
                Console.WriteLine("Got RM with the name:" + Flights.GetName());
            }
            if (Rooms != null)
            {
                Console.WriteLine("Got RM with the name:" + Rooms.GetName());
            }
            if (Cars != null)
            {
                Console.WriteLine("Got RM with the name:" + Cars.GetName());
            }

            HttpChannel httpChannel = new HttpChannel(Int32.Parse(parser["p"]));

            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(httpChannel, false);
            System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType
                (Type.GetType("MyWC.MyWC")                              // Assembly name
                , "WC.soap"                                             // URI
                , System.Runtime.Remoting.WellKnownObjectMode.Singleton // Instancing mode
                );

            Console.WriteLine("Staring Workflow Controller on port {0}", parser["p"]);


            while (true)
            {
                System.Threading.Thread.Sleep(100000);
            }
        }
 public static void StaticRegister(TP.RM rm)
 {
     _resourceManagers[rm.GetName()] = rm;
     Console.WriteLine("Re-Register " + rm.GetName());
 }
 //TODO: REFACTOR THIS FOR TESTING
 public void Register(TP.RM rm)
 {
     _resourceManagers[rm.GetName()] = rm;
 }
Exemple #6
0
        /// <summary>
        /*  WC runs as a separate process looping forever,
            waiting for the calls from other processes */
        /// </summary>
        static void Main(string[] args)
        {
            WCParser parser = new WCParser();
            if (!parser.Parse(args))
            {
                return;
            }

            //string rmFlightsURL = parser["f"];
            //string rmRoomsURL = parser["r"];
            //string rmCarsURL = parser["c"];
            string tmPort = parser["tmp"];
            string tmServer = parser["tms"];
            string tmURL = tmServer + ":" + tmPort + "/TM.soap";

            while (TransactionManager == null)
            {
                try
                {
                    TransactionManager = (TP.TM)Activator.GetObject(typeof(TP.TM), tmServer + ":" + tmPort + "/TM.soap");
                    Transaction tid = TransactionManager.Start();
                    TransactionManager.Abort(tid);
                }
                catch (RemotingException)
                {
                    TransactionManager = null;
                    Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", tmURL);
                    System.Threading.Thread.Sleep(1000);
                }
            }

            Console.WriteLine("Transaction Manager retrieved at {0}", tmURL);
            while (Flights == null || Rooms == null || Cars == null)
            {
                if(Flights == null)
                    Flights = TransactionManager.GetResourceMananger("flight");
                if (Rooms == null)
                    Rooms = TransactionManager.GetResourceMananger("room");
                if (Cars == null)
                    Cars = TransactionManager.GetResourceMananger("car");
            }
            if (Flights != null)
                Console.WriteLine("Got RM with the name:" + Flights.GetName());
            if (Rooms != null)
                Console.WriteLine("Got RM with the name:" + Rooms.GetName());
            if (Cars != null)
                Console.WriteLine("Got RM with the name:" + Cars.GetName());

            HttpChannel httpChannel = new HttpChannel(Int32.Parse(parser["p"]));
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(httpChannel, false);
            System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType
                (Type.GetType("MyWC.MyWC")							    // Assembly name
                , "WC.soap"												// URI
                , System.Runtime.Remoting.WellKnownObjectMode.Singleton	// Instancing mode
            );

            Console.WriteLine("Staring Workflow Controller on port {0}", parser["p"]);

            while (true)
            {
                System.Threading.Thread.Sleep(100000);
            }
        }