Ejemplo n.º 1
0
        public void ExecuteRead(ReadExecutor readExecutor)
        {
            Log.Debug($"Requesting Read({readExecutor.Tuple}) to Tuple Space.");
            TupleSpace.Tuple readTuple = this.replicaState.TupleSpace.Read(readExecutor.Tuple);

            // increment commit number
            int commitNumber = this.replicaState.IncrementCommitNumber();
            int viewNumber   = this.replicaState.ViewNumber;

            ClientResponse clientResponse;

            if (readTuple == null)
            {
                clientResponse = new ClientResponse(commitNumber, viewNumber, null);
            }
            else
            {
                clientResponse = new ClientResponse(commitNumber, viewNumber, readTuple.ToString());
            }
            // update client table
            lock (this.replicaState) {
                this.replicaState.ClientTable[readExecutor.ClientId] =
                    new Tuple <int, ClientResponse>(readExecutor.RequestNumber, clientResponse);
            }

            // Signal waiting thread that the execution is done
            readExecutor.Executed.Set();
            this.replicaState.HandlersCommits.Set();
            this.replicaState.HandlersCommits.Reset();

            // commit execution
            this.SendCommit(viewNumber, commitNumber);
        }
Ejemplo n.º 2
0
        public void ExecuteRead(ReadExecutor readExecutor)
        {
            Log.Debug($"Requesting Read({readExecutor.Tuple}) to Tuple Space.");
            TupleSpace.Tuple readTuple = this.replicaState.TupleSpace.Read(readExecutor.Tuple);

            int viewNumber = this.replicaState.ViewNumber;

            string tuple = null;

            if (readTuple != null)
            {
                tuple = readTuple.ToString();
            }
            ClientResponse clientResponse = new ClientResponse(readExecutor.RequestNumber, viewNumber, tuple);

            // update client table
            this.UpdateClientTable(readExecutor, clientResponse);
            this.replicaState.IncrementCommitNumber();
        }