예제 #1
0
            public bool doCommit(int TxId)
            {
                lock (_stateLockObj) {
                    if (isFail)
                    {
                        Console.WriteLine("[!doCommit] Error: DataServer " + name + " is set to [Fail] mode!");
                        Console.WriteLine("---");
                        while (true)
                        {
                            ;
                        }
                    }
                    else if (isFreeze)
                    {
                        lock (SingletonCounter.Instance) {
                            SingletonCounter.Instance.incrementLockCounter();
                            Monitor.Wait(SingletonCounter.Instance);
                        }
                    }
                }
                Console.WriteLine("[doCommit] Master Request with id " + TxId);
                Console.WriteLine("---");
                if (!this.Transactions.ContainsKey(TxId))
                {
                    Console.WriteLine("Error transaction not found : " + TxId);
                    return(false);
                }
                ServerTransaction transaction = transactions[TxId];

                if (_isPrimary)
                {
                    transaction.updatetobackup();
                    SerializableDictionary <int, int> updates = new SerializableDictionary <int, int>();
                    updates = transaction.Valuestobackup;
                    _slaveServer.receiveupdatefromprimary(updates, TxId);
                }
                //transaction.
                //Let's release the locks (reverse order?)
                _lockManager.unLock(TxId);
                return(true);
            }