Exemple #1
0
 /// <summary>
 /// Performs undo of the storage operation that is pending.
 /// </summary>
 /// <param name="logEntry">Log entry for the pending operation.</param>
 protected override void UndoPendingStoreOperations(IStoreLogEntry logEntry)
 {
     using (IStoreOperation op = _shardMapManager.StoreOperationFactory.FromLogEntry(_shardMapManager, logEntry))
     {
         op.Undo();
     }
 }
Exemple #2
0
        /// <summary>
        /// Performs the store operation.
        /// </summary>
        /// <returns>Results of the operation.</returns>
        public IStoreResults Do()
        {
            IStoreResults result;

            try
            {
                do
                {
                    result = this.Manager.RetryPolicy.ExecuteAction(() =>
                    {
                        IStoreResults r;

                        try
                        {
                            // Open connections & acquire the necessary app locks.
                            this.EstablishConnnections(false);

                            // Execute & commit the Global pre-Local operations.
                            r = this.DoGlobalPreLocal();

                            // If pending operation, we need to release the locks.
                            if (!r.StoreOperations.Any())
                            {
                                // Execute & commit the Local operations on source.
                                this.DoLocalSource();

                                // Execute & commit the Local operations on target.
                                this.DoLocalTarget();

                                // Execute & commit the Global post-Local operations.
                                r = this.DoGlobalPostLocal();

                                Debug.Assert(r != null);

                                _operationState = StoreOperationState.DoEnd;
                            }
                        }
                        finally
                        {
                            // Figure out the maximum of the progress made yet during Do operation.
                            if (_maxDoState < _operationState)
                            {
                                _maxDoState = _operationState;
                            }

                            // Close connections & release the necessary app locks.
                            this.TeardownConnections();
                        }

                        return(r);
                    });

                    // If pending operation, deserialize the pending operation and perform Undo.
                    if (result.StoreOperations.Any())
                    {
                        Debug.Assert(result.StoreOperations.Count() == 1);

                        using (IStoreOperation op = this.Manager.StoreOperationFactory.FromLogEntry(this.Manager, result.StoreOperations.Single()))
                        {
                            op.Undo();
                        }
                    }
                }while (result.StoreOperations.Any());
            }
            catch (StoreException se)
            {
                // If store exception was thrown, we will attempt to undo the current operation.
                this.AttemptUndo();

                throw this.OnStoreException(se, _operationState);
            }
            catch (ShardManagementException)
            {
                // If shard map manager exception was thrown, we will attempt to undo the operation.
                this.AttemptUndo();

                throw;
            }

            Debug.Assert(result != null);
            return(result);
        }