public TxException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { msg = info.GetString("msg"); remote = (IRemotePadInt)info.GetValue("remote", typeof(IRemotePadInt)); }
internal int Read(PadInt padInt) { if (State.Equals(TransactionState.ABORTED)) { // Some server failed Console.WriteLine("Trying to access padint uid=" + padInt.UID + " denied because of server failure"); return(-1); } string remotePadIntURL = padInt.URL + "RemotePadInt"; int uid = padInt.UID; freeze_lock.Add(uid, false); IRemotePadInt remote = (IRemotePadInt)Activator.GetObject( typeof(IRemotePadInt), remotePadIntURL); ReadAsyncDelegate RemoteDel = new ReadAsyncDelegate(remote.Read); AsyncCallback RemoteCallback = new AsyncCallback(ReadAsyncCallBack); try { IAsyncResult RemAr = RemoteDel.BeginInvoke(uid, TXID, PadiDstm.Client_Url, RemoteCallback, padInt); } catch (TxException t) { Console.WriteLine("TXEXCEPTION" + t.msg); } timerAlive(padInt.URL); while (!freeze_lock[uid]) { Thread.Sleep(1); } resetTimer(); lock (freeze_lock) { freeze_lock.Remove(uid); } if (State.Equals(TransactionState.ABORTED)) { // Some server failed Console.WriteLine("Trying to access padint uid=" + padInt.UID + " denied because of server failure"); return(-1); } return(values[uid]); }
internal void Write(PadInt padInt, int val) { if (State.Equals(TransactionState.ABORTED)) { Console.WriteLine("Write padint UID= " + padInt.UID + "denied because of server failer"); return; } string remotePadIntURL = padInt.URL + "RemotePadInt"; int uid = padInt.UID; IRemotePadInt remote = (IRemotePadInt)Activator.GetObject( typeof(IRemotePadInt), remotePadIntURL); write_lock = true; WriteAsyncDelegate RemoteDel = new WriteAsyncDelegate(remote.Write); AsyncCallback RemoteCallback = new AsyncCallback(WriteAsyncCallBack); IAsyncResult RemAr = RemoteDel.BeginInvoke(uid, TXID, val, PadiDstm.Client_Url, RemoteCallback, padInt); timerAlive(padInt.URL); while (write_lock) { Thread.Sleep(1); } resetTimer(); //lock (freeze_lock) { freeze_lock.Remove(uid); } if (State.Equals(TransactionState.ABORTED)) { Console.WriteLine("Write padint UID= " + padInt.UID + "denied because of server failer"); return; } // remote.Write(uid, TXID, val, PadiDstm.Client_Url); AddValue(uid, val); addAccessedServer(padInt.URL); }
// It should return an exception instead of carrying around bool values // Missing : add the uid object to the given transaction public bool createPadIntMaster(int txid, int uid, string client_url) { Console.WriteLine("Arrived at master with uid: " + uid); string worker_url; bool isAssigned = wm.assignWorker(uid); Console.WriteLine(isAssigned); if (isAssigned) { worker_url = wm.getWorkerUrl(uid); IRemotePadInt remote = (IRemotePadInt)Activator.GetObject( typeof(IRemotePadInt), worker_url); Console.WriteLine("createPadIntMaster txid: " + txid); wm.addTransactionUid(txid, uid); Console.WriteLine("Calling Worker Url: " + worker_url); remote.createPadIntWorker(uid, client_url); return(true); } return(false); }
public TxException(string msg, IRemotePadInt remote) { this.msg = msg; this.remote = remote; }