public void ExecuteTake(TakeExecutor takeExecutor) { Log.Debug($"Requesting Take({takeExecutor.Tuple}) to Tuple Space."); TupleSpace.Tuple takeTuple = this.replicaState.TupleSpace.Take(takeExecutor.Tuple); // increment commit number int commitNumber = this.replicaState.IncrementCommitNumber(); int viewNumber = this.replicaState.ViewNumber; ClientResponse clientResponse; if (takeTuple == null) { clientResponse = new ClientResponse(commitNumber, viewNumber, null); } else { clientResponse = new ClientResponse(commitNumber, viewNumber, takeTuple.ToString()); } // update client table lock (this.replicaState) { this.replicaState.ClientTable[takeExecutor.ClientId] = new Tuple <int, ClientResponse>(takeExecutor.RequestNumber, clientResponse); } // Signal waiting thread that the execution is done takeExecutor.Executed.Set(); this.replicaState.HandlersCommits.Set(); this.replicaState.HandlersCommits.Reset(); // commit execution this.SendCommit(viewNumber, commitNumber); }
public void ExecuteTake(TakeExecutor takeExecutor) { Log.Debug($"Requesting Take({takeExecutor.Tuple}) to Tuple Space."); this.replicaState.TupleSpace.UnlockAndTake(takeExecutor.ClientId, takeExecutor.Tuple); int viewNumber = this.replicaState.ViewNumber; ClientResponse clientResponse = new ClientResponse( takeExecutor.RequestNumber, viewNumber, takeExecutor.Tuple); // update client table this.UpdateClientTable(takeExecutor, clientResponse); this.replicaState.IncrementCommitNumber(); }