//Iterates all padints created or acessed within a transaction and concatenates all reads and writes into a single //request list, it then sends this list to the available server. public static bool TxCommit() { try { List<Request> l = new List<Request>(); foreach (PadInt v in _acessedPadInts) { l.AddRange(v.getRequests()); } _curTrans.setRequests(l); _server = (RemoteServerInterface)Activator.GetObject( typeof(RemoteServerInterface), _curServer); _curTrans.setTicket(_master.getTicket()); return checkCommit(); } //TODO make this generic, accepting a set number of fails. catch (Exception e) { if (e is FreezeException || e is FailException || e is RemotingException || e is TxException) { try { //Warns master that this server is unavailable. if (_master.warnServ(_curServer, e)) { //Requests another available server. if (requestServer()) { _server = (RemoteServerInterface)Activator.GetObject( typeof(RemoteServerInterface), _curServer); checkCommit(); } else return false; } else return false; } catch (Exception ne) { Console.WriteLine("Failed on some exception on TxCommit"); throw ne; } } return false; } }
public static bool requestServer() { //Requests a free server. try { _curServer = _master.requestServer(); _server = (RemoteServerInterface)Activator.GetObject( typeof(RemoteServerInterface), _curServer); } catch (TxException e) { return false; } return true; }