Esempio n. 1
0
 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;
     }
 }
Esempio n. 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;
            }
        }