Exemple #1
0
        public void backupUncommitedPadint(int tid, int uid, DSPadint padint)
        {
            this.checkFailOrFreeze();

            if (!this.backedUpUncommitedChanges.ContainsKey(tid))
            {
                this.backedUpUncommitedChanges.Add(tid, new Dictionary<int, DSPadint>());
            }

            this.backedUpUncommitedChanges[tid][uid] = padint;
        }
Exemple #2
0
 public void addBackupPadInt(int uid, DSPadint padint)
 {
     this.checkFailOrFreeze();
     this.backupPadints.Add(uid, padint);
 }
Exemple #3
0
        public int Read(int tid, int uid)
        {
            this.checkFailOrFreeze();

            if (!primaryPadints.ContainsKey(uid))
            {
                throw new InexistentPadIntException(uid);
            }

            if (this.uncommitedChanges.ContainsKey(tid))
            {
                if (this.uncommitedChanges[tid].ContainsKey(uid))
                {
                    return this.uncommitedChanges[tid][uid].Value;
                }
                else
                {
                    DSPadint padint = null;
                    lock (primaryPadints[uid])
                    {
                        padint = new DSPadint(primaryPadints[uid].Value, primaryPadints[uid].Timestamp);
                    }

                    this.uncommitedChanges[tid].Add(uid, padint);

                    if (backupServer != null)
                        backupServer.backupUncommitedPadint(tid, uid, padint);

                    return padint.Value;
                }
            }
            else
            {
                DSPadint padint = null;
                lock (primaryPadints[uid])
                {
                    padint = new DSPadint(primaryPadints[uid].Value, primaryPadints[uid].Timestamp);
                }

                Dictionary<int, DSPadint> changedPadInts = new Dictionary<int, DSPadint>();
                changedPadInts.Add(uid, padint);

                this.uncommitedChanges.Add(tid, changedPadInts);

                if (backupServer != null)
                    backupServer.backupUncommitedPadint(tid, uid, padint);

                return padint.Value;
            }
        }