/// <summary> /// 10/20/2011 /// Initializes a new instance of the <see cref = "Site" /> class. /// </summary> /// <remarks> /// Side effects: lastFailed, lockManager, messageBuffQueue, status are all initialized /// </remarks> public Site() { lastFailed = new List<int>(); lockManager = new LockManager(); messageBuffQueue = new Queue<Operation>(); status = Enumerations.SiteStatus.Active; }
/// <summary> /// 11/20/2011 /// Simulates a site recovery by recovering the lock and data manager and changing the site status /// </summary> /// <remarks> /// Side effects: /// The site status is modified. /// The LM forgot all previous lock information and set "fake" locks on all replicated data items. /// The DM forgot all dirty writes. /// </remarks> public void Recover() { // Some assumptions: I have to protect the application from a user entering recover(i) if site i is not failed. // Because otherwise a user can wipe out all lock information and dirty writes at whim (i.e. without having to fail // the site). if (status != Enumerations.SiteStatus.Active) { status = Enumerations.SiteStatus.Active; // lock all replicated data items for reading lockManager.Recover(); // remove all uncommitted values from data manager dataManager.Recover(); } }
/// <summary> /// 11/20/2011 /// Simulates a site failure by changing the status of the site /// </summary> /// <param name = "ts">The timestamp at which this site has failed.</param> /// <remarks> /// Side effects: /// the site.status is modified, /// a new timestamp is added to lastFailed, /// the message buffer is cleared /// </remarks> public void Fail(int ts) { status = Enumerations.SiteStatus.Failed; lastFailed.Add(ts); messageBuffQueue.Clear(); }