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; }
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); }
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); } }
/// <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); }
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); } }
/// <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); } }
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); }
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); }