示例#1
0
        /// <summary>
        /// Returns the value of the PadInt when the transaction has the read/write lock.
        ///  Throws an exception if PadInt not found.
        /// </summary>
        /// <param name="tid">Transaction identifier</param>
        /// <param name="uid">PadInt identifier</param>
        /// <returns></returns>
        internal override int ReadPadInt(int tid, int uid)
        {
            Logger.Log(new String[] { "PrimaryServer", Server.ID.ToString(), "readPadInt ", "tid", tid.ToString(), "uid", uid.ToString() });

            try {
                /* Obtain the PadInt identified by uid */
                PadInt padInt = GetPadInt(uid);

                while (true)
                {
                    if (padInt.HasWriteLock(tid) || padInt.GetReadLock(tid))
                    {
                        /* updates the backup server */
                        backupReplyTimer.Start();
                        BackupServer.ReadPadInt(tid, uid);
                        backupReplyTimer.Stop();
                        return(padInt.ActualValue);
                    }
                }
            } catch (PadIntNotFoundException) {
                throw;
            } catch (AbortException) {
                throw;
            }
        }