Пример #1
0
        /// <summary>
        /// This recovers the Fail and Freeze servers.
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static bool Recover(string url)
        {
            //TODO: recover the Freeze and Fail.
            PADI_Worker worker             = (PADI_Worker)Activator.GetObject(typeof(PADI_Worker), url);
            bool        hasRecoveredServer = worker.Recover();

            coordinator.RecoverOperations();
            Console.WriteLine("Server recovered, Status = " + hasRecoveredServer);



            //Failed recsover

            /* info.ObjectServerMap = master.FailServerList.ToArray();
             *  foreach (var server in info.ObjectServerMap)
             *  {
             *      if (server.TcpUrl == url)
             *      {
             *          master.WorkerServerList.Add(server);
             *          master.UpdateRecoverList(server);
             *          Console.WriteLine("Server Recovered; server url: {0}, server name: {1}", server.TcpUrl, server.ServerName);
             *      }
             *      else
             *          Console.WriteLine("OOPs the specified server could not be found");
             *  }*/
            return(true);
        }
Пример #2
0
 public ServerPadInt(int uid, PADI_Worker worker)
 {
     this.uid      = uid;
     this.WriteTS  = 0;
     ReadTSList    = new List <long>();
     TentativeList = new List <TentativePadInt>();
     this.worker   = worker;
     IsCommited    = false;
 }
Пример #3
0
 public ServerPadInt(int uid, PADI_Worker worker, long writeTS, List <long> readTSList, List <TentativePadInt> tentativeList, bool isCommitted, int value)
 {
     this.uid           = uid;
     this.WriteTS       = writeTS;
     this.ReadTSList    = new List <long>(readTSList);
     this.TentativeList = new List <TentativePadInt>(tentativeList);
     this.worker        = worker;
     this.IsCommited    = isCommitted;
     this.Value         = value;
 }
Пример #4
0
        /// <summary>
        /// This method makes the server at URL stop responding to external calls
        /// but it maintains all calls for later reply, as if the communication to that server were
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static bool Freeze(string url)
        {
            //TODO: this method makes the server at URL stop responding to external calls but it maintains all calls for later reply, as if the communication to that server were
            //only delayed.
            PADI_Worker worker    = (PADI_Worker)Activator.GetObject(typeof(PADI_Worker), url);
            bool        isFreezed = worker.Freeze();

            Console.WriteLine("Server Freezed. Status = " + isFreezed);
            return(isFreezed);
        }
Пример #5
0
        /// <summary>
        /// This method makes the server at the URL stop responding to external calls except for a Recover call
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static bool Fail(string url)
        {
            //TODO: this method makes the server at the URL stop responding to external calls except for a Recover call
            bool hasFailed = false;

            try
            {
                PADI_Worker worker = (PADI_Worker)Activator.GetObject(typeof(PADI_Worker), url);
                hasFailed = worker.Fail();
                Console.WriteLine("Wait until master detects failure");
                Thread.Sleep(17000);
                Console.WriteLine("Server Failed, Status " + hasFailed);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Source : at Client.Fail.." + ex.Message);
            }
            return(hasFailed);
        }