コード例 #1
0
        public TSpaceState GetTSpaceState(string Url)
        {

            TSpaceState xl = new TSpaceState();

            TSpaceManager.RWL.AcquireWriterLock(Timeout.Infinite);


            xl.LockedTuplesKeys = TSLockHandler.GetKeys();
            xl.LockedTuplesValues = TSLockHandler.GetValues();


            this.UpdateView(Url);

            TSMan.AddToView(Url);

            xl.ServerView = TSMan.GetTotalView();

            xl.ProcessedRequests = TSpaceManager.ProcessedRequests;
            xl.TupleSpace = TSMan.GetTuples();


            TSpaceManager.RWL.ReleaseWriterLock();

            return xl;
        }
コード例 #2
0
        public TSpaceState GetTSpaceState(string Url)
        {
            TSpaceState smr = new TSpaceState();

            TSpaceManager.RWL.AcquireWriterLock(Timeout.Infinite);


            smr.MessageQueue   = MessageQueue;
            smr.SequenceNumber = SequenceNumber;



            this.UpdateView(Url);

            TSMan.AddToView(Url);

            smr.ServerView = TSMan.GetTotalView();

            smr.ProcessedRequests = TSpaceManager.ProcessedRequests; //its static, cant be accessed with instance
            smr.TupleSpace        = TSMan.GetTuples();


            TSpaceManager.RWL.ReleaseWriterLock();

            return(smr);
        }
コード例 #3
0
 public void SetTSpaceState(TSpaceState smr)
 {
     lock (TSpaceAdvManager.ProcessedRequests)
     {
         TSpaceAdvManager.ProcessedRequests = smr.ProcessedRequests;
         TSMan.setView(smr.ServerView);
         TSMan.SetTuples(smr.TupleSpace);
         TSLockHandler.SetContent(smr.LockedTuplesKeys, smr.LockedTuplesValues);
         Console.WriteLine("Starting with view: " + smr.ServerView.ID);
     }
 }
コード例 #4
0
        /// <summary>
        /// Gets the tuple space state
        /// </summary>
        /// <param name="Url">url of the server requesting the state</param>        /// <returns></returns>
        public TSpaceState GetTSpaceState(string Url)
        {
            TSpaceState smr = new TSpaceState();
            //Create operationID
            string id = TSMan.URL + "_" + (ViewUpdateCounter++);

            int seqNum;

            lock (AddingToView)
            {
                seqNum = GetSequenceNumber(id, null);
                AddingToView.Add(Url, seqNum);
            }


            //Wait to be head of queue
            WaitTurn(id);

            TSpaceAdvManager.RWL.AcquireWriterLock(Timeout.Infinite);

            //Get current list of servers
            List <string> serversUrl = TSMan.ServerView.DeepUrlsCopy();

            //Copy state

            smr.SequenceNumber = SequenceNumber;


            //its static, cant be accessed with instance
            smr.ProcessedRequests = TSpaceAdvManager.ProcessedRequests;
            smr.TupleSpace        = TSMan.GetTuples();

            //Send update view to all servers
            UpdateView(Url, id, serversUrl, AddingToView[Url], true);


            RemoveFromQueue(id);

            smr.MessageQueue = new List <Message>();

            foreach (Message msg2 in MessageQueue)
            {
                smr.MessageQueue.Add(Message.DeepClone(msg2));
            }

            TSMan.AddToView(Url);
            smr.ServerView = TSMan.GetTotalView();

            AddingToView.Remove(Url);
            TSpaceAdvManager.RWL.ReleaseWriterLock();

            return(smr);
        }
コード例 #5
0
 public void SetTSpaceState(TSpaceState smr)
 {
     lock (TSpaceManager.ProcessedRequests)
     {
         MessageQueue = smr.MessageQueue;
         TSpaceManager.ProcessedRequests = smr.ProcessedRequests;
         TSMan.setView(smr.ServerView);
         TSMan.SetTuples(smr.TupleSpace);
         SequenceNumber = smr.SequenceNumber;
         Console.WriteLine("Starting with view: " + smr.ServerView.ID);
     }
 }
コード例 #6
0
        /// <summary>
        /// Initializes the tuple space state
        /// </summary>
        /// <param name="smr">state</param>

        public void SetTSpaceState(TSpaceState smr)
        {
            Console.WriteLine("started setting state");
            lock (TSpaceAdvManager.ProcessedRequests)
            {
                MessageQueue = smr.MessageQueue;

                TSpaceAdvManager.ProcessedRequests = smr.ProcessedRequests;
                TSMan.setView(smr.ServerView);
                TSMan.SetTuples(smr.TupleSpace);
                SequenceNumber = smr.SequenceNumber;
                Console.WriteLine("Starting with view: " + smr.ServerView);
                Console.WriteLine("Start in queue: " + MessageQueue.Count);
            }
        }
コード例 #7
0
        private TSpaceState CopyState(string Url)
        {
            TSpaceState xl = new TSpaceState();


            xl.LockedTuplesKeys   = TSLockHandler.GetKeys();
            xl.LockedTuplesValues = TSLockHandler.GetValues();

            TSMan.AddToView(Url);

            xl.ServerView = TSMan.GetTotalView();

            xl.ProcessedRequests = TSpaceAdvManager.ProcessedRequests; //its static, cant be accessed with instance
            xl.TupleSpace        = TSMan.GetTuples();

            return(xl);
        }
コード例 #8
0
        public TSpaceState GetTSpaceState(string Url)
        {
            //Acquire the lock to stop the server from processing requests
            TSpaceAdvManager.RWL.AcquireWriterLock(Timeout.Infinite);
            Console.WriteLine("Getting state for: " + Url);

            //Copy State
            TSpaceState xl = CopyState(Url);

            //Propagate add server to all
            UpdateAll(Url, "AddToView");

            Console.WriteLine("Return state to: " + Url);

            // Release lock allowing the server to process requests
            TSpaceAdvManager.RWL.ReleaseWriterLock();

            return(xl);
        }