Exemple #1
0
        /// <summary>
        /// Handles errors from the initial GSM operation prior to LSM operations.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void HandleDoGlobalPreLocalExecuteError(IStoreResults result)
        {
            if (result.Result == StoreResult.ShardMapDoesNotExist)
            {
                // Remove shard map from cache.
                this.Manager.Cache.DeleteShardMap(_shardMap);
            }

            if (result.Result == StoreResult.MappingDoesNotExist)
            {
                foreach (IStoreMapping mappingSource in _mappingsSource.Select(m => m.Item1))
                {
                    // Remove mapping from cache.
                    this.Manager.Cache.DeleteMapping(mappingSource);
                }
            }

            // Possible errors are:
            // StoreResult.ShardMapDoesNotExist
            // StoreResult.ShardDoesNotExist
            // StoreResult.MappingRangeAlreadyMapped
            // StoreResult.MappingDoesNotExist
            // StoreResult.MappingLockOwnerIdDoesNotMatch
            // StoreResult.MappingIsNotOffline
            // StoreResult.StoreVersionMismatch
            // StoreResult.MissingParametersForStoredProcedure
            throw StoreOperationErrorHandler.OnShardMapperErrorGlobal(
                      result,
                      _shardMap,
                      _mappingsSource[0].Item1.StoreShard,
                      ShardManagementErrorCategory.RangeShardMap,
                      StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
                      StoreOperationRequestBuilder.SpBulkOperationShardMappingsGlobalBegin);
        }
        /// <summary>
        /// Handles errors from the initial GSM operation prior to LSM operations.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void HandleDoGlobalPreLocalExecuteError(IStoreResults result)
        {
            if (result.Result == StoreResult.ShardMapDoesNotExist)
            {
                // Remove shard map from cache.
                this.Manager.Cache.DeleteShardMap(_shardMap);
            }

            if (result.Result == StoreResult.MappingDoesNotExist)
            {
                // Remove mapping from cache.
                this.Manager.Cache.DeleteMapping(_mapping);
            }

            // Possible errors are:
            // StoreResult.ShardMapDoesNotExist
            // StoreResult.ShardDoesNotExist
            // StoreShard.MappingDoesNotExist
            // StoreResult.MappingLockOwnerIdDoesNotMatch
            // StoreResult.MappingIsNotOffline
            // StoreResult.StoreVersionMismatch
            // StoreResult.MissingParametersForStoredProcedure
            throw StoreOperationErrorHandler.OnShardMapperErrorGlobal(
                      result,
                      _shardMap,
                      _mapping.StoreShard,
                      _errorCategory,
                      StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
                      StoreOperationRequestBuilder.SpBulkOperationShardMappingsGlobalBegin);
        }
        /// <summary>
        /// Handles errors from the the LSM operation on the source shard.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void HandleDoLocalSourceExecuteError(IStoreResults result)
        {
            // Possible errors from spUpdateShardLocal:
            // StoreResult.StoreVersionMismatch
            // StoreResult.MissingParametersForStoredProcedure
            // StoreResult.ShardDoesNotExist
            switch (result.Result)
            {
            case StoreResult.StoreVersionMismatch:
            case StoreResult.MissingParametersForStoredProcedure:
            case StoreResult.ShardDoesNotExist:
                throw StoreOperationErrorHandler.OnShardMapErrorLocal(
                          result,
                          _shardMap,
                          _shard.Location,
                          ShardManagementErrorCategory.ShardMap,
                          StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
                          StoreOperationRequestBuilder.SpUpdateShardLocal);

            default:
                throw new ShardManagementException(
                          ShardManagementErrorCategory.ShardMapManager,
                          ShardManagementErrorCode.StorageOperationFailure,
                          Errors._Store_SqlExceptionLocal,
                          OperationName
                          );
            }
        }
Exemple #4
0
 /// <summary>
 /// Handles errors from the undo of GSM operation prior to LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public virtual void HandleUndoGlobalPreLocalExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnCommonErrorGlobal(
               result,
               StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
               StoreOperationRequestBuilder.SpFindAndUpdateOperationLogEntryByIdGlobal);
 }
Exemple #5
0
 /// <summary>
 /// Handles errors from the undo of LSM operation on the source shard.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleUndoLocalSourceExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnShardMapperErrorLocal(
               result,
               _mappingsSource[0].Item1.StoreShard.Location,
               StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
               StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal);
 }
 /// <summary>
 /// Handles errors from the undo of LSM operation on the source shard.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleUndoLocalSourceExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnShardMapErrorLocal(
               result,
               _shardMap,
               _shard.Location,
               ShardManagementErrorCategory.ShardMap,
               StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
               StoreOperationRequestBuilder.SpAddShardLocal);
 }
Exemple #7
0
 /// <summary>
 /// Handles errors from the undo of LSM operation on the source shard.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleUndoLocalSourceExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     // Stored procedure can also return StoreResult.ShardDoesNotExist, but only for AttachShard operations
     throw StoreOperationErrorHandler.OnShardMapErrorLocal(
               result,
               _shardMap,
               _shardNew.Location,
               ShardManagementErrorCategory.ShardMap,
               StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
               StoreOperationRequestBuilder.SpUpdateShardLocal);
 }
Exemple #8
0
        /// <summary>
        /// Handles errors from the undo of GSM operation after LSM operations.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void HandleUndoGlobalPostLocalExecuteError(IStoreResults result)
        {
            if (result.Result == StoreResult.ShardMapDoesNotExist)
            {
                // Remove shard map from cache.
                this.Manager.Cache.DeleteShardMap(_shardMap);
            }

            // Possible errors are:
            // StoreResult.ShardMapDoesNotExist
            // StoreResult.StoreVersionMismatch
            // StoreResult.MissingParametersForStoredProcedure
            throw StoreOperationErrorHandler.OnShardMapErrorGlobal(
                      result,
                      _shardMap,
                      _shardOld,
                      ShardManagementErrorCategory.ShardMap,
                      StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
                      StoreOperationRequestBuilder.SpBulkOperationShardsGlobalEnd);
        }
Exemple #9
0
        /// <summary>
        /// Terminates connection on the source shard object.
        /// </summary>
        private void KillConnectionsOnSourceShard()
        {
            SqlUtils.WithSqlExceptionHandling(() =>
            {
                string sourceShardConnectionString = this.GetConnectionStringForShardLocation(_mappingSource.StoreShard.Location);

                IStoreResults result;

                using (IStoreConnection connectionForKill = this.Manager.StoreConnectionFactory.GetConnection(StoreConnectionKind.LocalSource, sourceShardConnectionString))
                {
                    connectionForKill.Open();

                    using (IStoreTransactionScope ts = connectionForKill.GetTransactionScope(StoreTransactionScopeKind.NonTransactional))
                    {
                        result = ts.ExecuteOperation(
                            StoreOperationRequestBuilder.SpKillSessionsForShardMappingLocal,
                            StoreOperationRequestBuilder.KillSessionsForShardMappingLocal(_patternForKill));
                    }
                }

                if (result.Result != StoreResult.Success)
                {
                    // Possible errors are:
                    // StoreResult.UnableToKillSessions
                    // StoreResult.StoreVersionMismatch
                    // StoreResult.MissingParametersForStoredProcedure
                    throw StoreOperationErrorHandler.OnShardMapErrorLocal(
                        result,
                        _shardMap,
                        _mappingSource.StoreShard.Location,
                        _errorCategory,
                        StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
                        StoreOperationRequestBuilder.SpKillSessionsForShardMappingLocal);
                }
            });
        }