Exemple #1
0
        /// <summary>
        /// Returns the proper ShardManagementException corresponding to given error code in
        /// <paramref name="result"/> for ShardMapper operations.
        /// </summary>
        /// <param name="result">Operation result object.</param>
        /// <param name="shardMapName">Name of shard map.</param>
        /// <param name="operationName">Operation being performed.</param>
        /// <param name="storedProcName">Stored procedure being executed.</param>
        /// <returns></returns>
        internal static ShardManagementException OnShardSchemaInfoErrorGlobal(
            IStoreResults result,
            string shardMapName,
            string operationName,
            string storedProcName)
        {
            switch (result.Result)
            {
            case StoreResult.SchemaInfoNameConflict:
                throw new SchemaInfoException(
                          SchemaInfoErrorCode.SchemaInfoNameConflict,
                          Errors._Store_SchemaInfo_NameConflict,
                          shardMapName);

            case StoreResult.SchemaInfoNameDoesNotExist:
                throw new SchemaInfoException(
                          SchemaInfoErrorCode.SchemaInfoNameDoesNotExist,
                          Errors._Store_SchemaInfo_NameDoesNotExist,
                          operationName,
                          shardMapName);

            case StoreResult.StoreVersionMismatch:
            case StoreResult.MissingParametersForStoredProcedure:
            default:
                return(StoreOperationErrorHandler.OnCommonErrorGlobal(
                           result,
                           operationName,
                           storedProcName));
            }
        }
        /// <summary>
        /// Refreshes the cache on successful commit of the GSM operation.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalUpdateCachePost(IStoreResults result)
        {
            Debug.Assert(result.Result == StoreResult.Success);

            // Add cache entry.
            _shardMapManager.Cache.AddOrUpdateShardMap(_shardMap);
        }
Exemple #3
0
        /// <summary>
        /// Returns the proper ShardManagementException corresponding to given common error code
        /// in <paramref name="result"/>.
        /// </summary>
        /// <param name="result">Operation result object.</param>
        /// <param name="operationName">Operation being performed.</param>
        /// <param name="storedProcName">Stored procedure being executed.</param>
        /// <returns>ShardManagementException to be raised.</returns>
        internal static ShardManagementException OnCommonErrorGlobal(
            IStoreResults result,
            string operationName,
            string storedProcName)
        {
            switch (result.Result)
            {
            case StoreResult.StoreVersionMismatch:
                return(new ShardManagementException(
                           ShardManagementErrorCategory.Validation,
                           ShardManagementErrorCode.GlobalStoreVersionMismatch,
                           Errors._Store_UnsupportedLibraryVersionGlobal,
                           (result.StoreVersion != null) ? result.StoreVersion.Version.ToString() : "",
                           GlobalConstants.GsmVersionClient,
                           (result.StoreVersion != null) ? (result.StoreVersion.Version > GlobalConstants.GsmVersionClient ? "library" : "store") : "store"));

            case StoreResult.MissingParametersForStoredProcedure:
                return(new ShardManagementException(
                           ShardManagementErrorCategory.Validation,
                           ShardManagementErrorCode.GlobalStoreOperationInsufficientParameters,
                           Errors._Store_MissingSprocParametersGlobal,
                           operationName,
                           storedProcName));

            default:
                Debug.Fail("Unexpected error code found.");
                return(new ShardManagementException(
                           ShardManagementErrorCategory.General,
                           ShardManagementErrorCode.UnexpectedError,
                           Errors._Store_UnexpectedErrorGlobal));
            }
        }
Exemple #4
0
        /// <summary>
        /// Refreshes the cache on successful commit of the GSM operation.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalUpdateCachePost(IStoreResults result)
        {
            Debug.Assert(result.Result == StoreResult.Success);

            // Add cache entry.
            _shardMapManager.Cache.AddOrUpdateShardMap(_shardMap);
        }
        /// <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
                          );
            }
        }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     if (_ssmCurrent == null)
     {
         // Possible errors are:
         // StoreResult.StoreVersionMismatch
         // StoreResult.MissingParametersForStoredProcedure
         throw StoreOperationErrorHandler.OnShardMapManagerErrorGlobal(
                   result,
                   null,
                   this.OperationName,
                   StoreOperationRequestBuilder.SpGetAllShardMapsGlobal);
     }
     else
     {
         if (result.Result != StoreResult.ShardMapDoesNotExist)
         {
             // Possible errors are:
             // StoreResult.StoreVersionMismatch
             // StoreResult.MissingParametersForStoredProcedure
             throw StoreOperationErrorHandler.OnShardMapperErrorGlobal(
                       result,
                       _ssmCurrent,
                       null, // shard
                       ShardManagementErrorCategory.ShardMapManager,
                       this.OperationName,
                       StoreOperationRequestBuilder.SpGetAllShardMappingsGlobal);
         }
     }
 }
Exemple #7
0
        /// <summary>
        /// Returns the proper ShardManagementException corresponding to given error code in
        /// <paramref name="result"/> for ShardMap operations.
        /// </summary>
        /// <param name="result">Operation result object.</param>
        /// <param name="shardMap">Shard map object.</param>
        /// <param name="location">Location of operation.</param>
        /// <param name="errorCategory">Error category to use for raised errors.</param>
        /// <param name="operationName">Operation being performed.</param>
        /// <param name="storedProcName">Stored procedure being executed.</param>
        /// <returns>ShardManagementException to be raised.</returns>
        internal static ShardManagementException OnRecoveryErrorLocal(
            IStoreResults result,
            IStoreShardMap shardMap,
            ShardLocation location,
            ShardManagementErrorCategory errorCategory,
            string operationName,
            string storedProcName)
        {
            switch (result.Result)
            {
            case StoreResult.ShardMapDoesNotExist:
                return(new ShardManagementException(
                           errorCategory,
                           ShardManagementErrorCode.ShardMapDoesNotExist,
                           Errors._Store_ShardMap_DoesNotExistLocal,
                           shardMap.Name,
                           location,
                           storedProcName,
                           operationName));

            case StoreResult.StoreVersionMismatch:
            case StoreResult.MissingParametersForStoredProcedure:
            default:
                return(StoreOperationErrorHandler.OnCommonErrorLocal(
                           result,
                           location,
                           operationName,
                           storedProcName));
            }
        }
Exemple #8
0
        /// <summary>
        /// Handles errors from the GSM operation after the LSM operations.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void HandleDoGlobalExecuteError(IStoreResults result)
        {
            if (result.Result == StoreResult.ShardMapDoesNotExist)
            {
                // Remove shard map from cache.
                _shardMapManager.Cache.DeleteShardMap(_shardMap);
            }

            if (result.Result == StoreResult.MappingDoesNotExist)
            {
                Debug.Assert(_mapping != null);

                // Remove mapping from cache.
                _shardMapManager.Cache.DeleteMapping(_mapping);
            }

            // Possible errors are:
            // StoreResult.ShardMapDoesNotExist
            // StoreResult.MappingDoesNotExist
            // StoreResult.MappingAlreadyLocked
            // StoreResult.MappingLockOwnerIdMismatch
            // StoreResult.StoreVersionMismatch
            // StoreResult.MissingParametersForStoredProcedure
            throw StoreOperationErrorHandler.OnShardMapperErrorGlobal(
                      result,
                      _shardMap,
                      _mapping == null ? null : _mapping.StoreShard,
                      _errorCategory,
                      this.OperationName,
                      StoreOperationRequestBuilder.SpLockOrUnLockShardMappingsGlobal);
        }
        /// <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(_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,
                      result.Result == StoreResult.MappingRangeAlreadyMapped ?
                      _mappingTarget.StoreShard :
                      _mappingSource.StoreShard,
                      _errorCategory,
                      StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
                      StoreOperationRequestBuilder.SpBulkOperationShardMappingsGlobalBegin);
        }
 /// <summary>
 /// Invalidates the cache on unsuccessful commit of the GSM operation.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void DoGlobalUpdateCachePre(IStoreResults result)
 {
     if (result.Result == StoreResult.ShardMapDoesNotExist)
     {
         // Remove cache entry.
         _shardMapManager.Cache.DeleteShardMap(_shardMap);
     }
 }
 /// <summary>
 /// Refreshes the cache on successful commit of the GSM operation.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void DoGlobalUpdateCachePost(IStoreResults result)
 {
     Debug.Assert(result.Result == StoreResult.Success);
     foreach (IStoreMapping sm in result.StoreMappings)
     {
         _manager.Cache.AddOrUpdateMapping(sm, CacheStoreMappingUpdatePolicy.OverwriteExisting);
     }
 }
 /// <summary>
 /// Invalidates the cache on unsuccessful commit of the GSM operation.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void DoGlobalUpdateCachePre(IStoreResults result)
 {
     if (result.Result == StoreResult.ShardMapDoesNotExist)
     {
         // Remove cache entry.
         _shardMapManager.Cache.DeleteShardMap(_shardMap);
     }
 }
        /// <summary>
        /// Refreshes the cache on successful commit of the final GSM operation after the LSM operations.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalPostLocalUpdateCache(IStoreResults result)
        {
            // Remove from cache.
            this.Manager.Cache.DeleteMapping(_mappingSource);

            // Add to cache.
            this.Manager.Cache.AddOrUpdateMapping(_mappingTarget, CacheStoreMappingUpdatePolicy.OverwriteExisting);
        }
 public override void HandleDoLocalExecuteError(IStoreResults result)
 {
     throw new ShardManagementException(
               ShardManagementErrorCategory.ShardMapManager,
               ShardManagementErrorCode.StorageOperationFailure,
               Errors._Store_SqlExceptionLocal,
               OperationName
               );
 }
Exemple #15
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);
 }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     if (_throwOnFailure)
     {
         throw new ShardManagementException(
             ShardManagementErrorCategory.ShardMapManagerFactory,
             ShardManagementErrorCode.ShardMapManagerStoreDoesNotExist,
             Errors._Store_ShardMapManager_DoesNotExistGlobal);
     }
 }
Exemple #17
0
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     if (_throwOnFailure)
     {
         throw new ShardManagementException(
                   ShardManagementErrorCategory.ShardMapManagerFactory,
                   ShardManagementErrorCode.ShardMapManagerStoreDoesNotExist,
                   Errors._Store_ShardMapManager_DoesNotExistGlobal);
     }
 }
        /// <summary>
        /// Refreshes the cache on successful commit of the GSM operation.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalUpdateCachePost(IStoreResults result)
        {
            Debug.Assert(result.Result == StoreResult.Success ||
                         result.Result == StoreResult.ShardMapDoesNotExist);

            if (result.Result == StoreResult.Success)
            {
                // Remove cache entry.
                _shardMapManager.Cache.DeleteShardMap(_shardMap);
            }
        }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // Expected errors are:
     // StoreResult.MissingParametersForStoredProcedure:
     // StoreResult.StoreVersionMismatch:
     throw StoreOperationErrorHandler.OnShardSchemaInfoErrorGlobal(
         result,
         "*",
         this.OperationName,
         StoreOperationRequestBuilder.SpGetAllShardingSchemaInfosGlobal);
 }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // Expected errors are:
     // StoreResult.MissingParametersForStoredProcedure:
     // StoreResult.StoreVersionMismatch:
     throw StoreOperationErrorHandler.OnShardSchemaInfoErrorGlobal(
               result,
               "*",
               this.OperationName,
               StoreOperationRequestBuilder.SpGetAllShardingSchemaInfosGlobal);
 }
 /// <summary>
 /// Performs undo of LSM operation on the target shard.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleUndoLocalTargetExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnShardMapperErrorLocal(
               result,
               _mappingSource.StoreShard.Location,
               StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
               StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal);
 }
        /// <summary>
        /// Execute the operation against LSM in the current transaction scope.
        /// </summary>
        /// <param name="ts">Transaction scope.</param>
        /// <returns>
        /// Results of the operation.
        /// </returns>
        public override IStoreResults DoLocalExecute(IStoreTransactionScope ts)
        {
            TraceHelper.Tracer.TraceInfo(
                TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                this.OperationName,
                "Started upgrading Local Shard Map structures at location {0}", base.Location);

            Stopwatch stopwatch = Stopwatch.StartNew();

            IStoreResults checkResult = ts.ExecuteCommandSingle(SqlUtils.CheckIfExistsLocalScript.Single());

            if (checkResult.StoreVersion == null)
            {
                // DEVNOTE(apurvs): do we want to throw here if LSM is not already deployed?
                // deploy initial version of LSM, if not found.
                ts.ExecuteCommandBatch(SqlUtils.CreateLocalScript);
            }

            if (checkResult.StoreVersion == null || checkResult.StoreVersion.Version < _targetVersion)
            {
                if (checkResult.StoreVersion == null)
                {
                    ts.ExecuteCommandBatch(SqlUtils.FilterUpgradeCommands(SqlUtils.UpgradeLocalScript, _targetVersion));
                }
                else
                {
                    ts.ExecuteCommandBatch(SqlUtils.FilterUpgradeCommands(SqlUtils.UpgradeLocalScript, _targetVersion, checkResult.StoreVersion.Version));
                }

                // Read LSM version again after upgrade.
                checkResult = ts.ExecuteCommandSingle(SqlUtils.CheckIfExistsLocalScript.Single());

                stopwatch.Stop();

                TraceHelper.Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                    this.OperationName,
                    "Finished upgrading store at location {0}. Duration: {1}",
                    base.Location,
                    stopwatch.Elapsed);
            }
            else
            {
                TraceHelper.Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManagerFactory,
                    this.OperationName,
                    "Local Shard Map at location {0} has version {1} equal to or higher than Client library version {2}, skipping upgrade.",
                    base.Location,
                    checkResult.StoreVersion,
                    GlobalConstants.GsmVersionClient);
            }

            return(checkResult);
        }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnShardMapManagerErrorGlobal(
               result,
               null,
               this.OperationName,
               StoreOperationRequestBuilder.SpFindShardMapByNameGlobal);
 }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnShardMapManagerErrorGlobal(
         result,
         null,
         this.OperationName,
         StoreOperationRequestBuilder.SpFindShardMapByNameGlobal);
 }
Exemple #25
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.OnShardMapErrorLocal(
               result,
               _shardMap,
               _shard.Location,
               ShardManagementErrorCategory.ShardMap,
               StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
               StoreOperationRequestBuilder.SpAddShardLocal);
 }
Exemple #26
0
 /// <summary>
 /// Handles errors from the LSM operation.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoLocalExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnRecoveryErrorLocal(
               result,
               _shardMap,
               this.Location,
               ShardManagementErrorCategory.Recovery,
               this.OperationName,
               StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal);
 }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnRecoveryErrorGlobal(
               result,
               null,
               null,
               ShardManagementErrorCategory.Recovery,
               this.OperationName,
               StoreOperationRequestBuilder.SpDetachShardGlobal);
 }
 /// <summary>
 /// Handles errors from the LSM operation.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoLocalExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnRecoveryErrorLocal(
         result,
         null,
         this.Location,
         ShardManagementErrorCategory.Recovery,
         this.OperationName,
         StoreOperationRequestBuilder.SpGetAllShardsLocal);
 }
        /// <summary>
        /// Invalidates the cache on unsuccessful commit of the GSM operation.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalUpdateCachePre(IStoreResults result)
        {
            if (result.Result == StoreResult.ShardMapDoesNotExist)
            {
                // Remove shard map from cache.
                _manager.Cache.DeleteShardMap(_shardMap);
            }

            if (result.Result == StoreResult.MappingDoesNotExist)
            {
                // Remove mapping from cache.
                _manager.Cache.DeleteMapping(_mapping);
            }
        }
Exemple #30
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 #31
0
        /// <summary>
        /// Refreshes the cache on successful commit of the final GSM operation after the LSM operations.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalPostLocalUpdateCache(IStoreResults result)
        {
            // Remove from cache.
            foreach (Tuple <IStoreMapping, Guid> ssm in _mappingsSource)
            {
                this.Manager.Cache.DeleteMapping(ssm.Item1);
            }

            // Add to cache.
            foreach (Tuple <IStoreMapping, Guid> ssm in _mappingsTarget)
            {
                this.Manager.Cache.AddOrUpdateMapping(ssm.Item1, CacheStoreMappingUpdatePolicy.OverwriteExisting);
            }
        }
        /// <summary>
        /// Invalidates the cache on unsuccessful commit of the GSM operation.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalUpdateCachePre(IStoreResults result)
        {
            if (result.Result == StoreResult.ShardMapDoesNotExist)
            {
                // Remove shard map from cache.
                _manager.Cache.DeleteShardMap(_shardMap);
            }

            if (result.Result == StoreResult.MappingDoesNotExist)
            {
                // Remove mapping from cache.
                _manager.Cache.DeleteMapping(_mapping);
            }
        }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // SchemaInfoNameDoesNotExist is handled by the callers i.e. Get vs TryGet.
     if (result.Result != StoreResult.SchemaInfoNameDoesNotExist)
     {
         // Expected errors are:
         // StoreResult.MissingParametersForStoredProcedure:
         // StoreResult.StoreVersionMismatch:
         throw StoreOperationErrorHandler.OnShardSchemaInfoErrorGlobal(
                   result,
                   _schemaInfoName,
                   this.OperationName,
                   StoreOperationRequestBuilder.SpFindShardingSchemaInfoByNameGlobal);
     }
 }
Exemple #34
0
        /// <summary>
        /// Refreshes the cache on successful commit of the GSM operation.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalUpdateCachePost(IStoreResults result)
        {
            Debug.Assert(
                result.Result == StoreResult.Success ||
                result.Result == StoreResult.MappingNotFoundForKey ||
                result.Result == StoreResult.ShardMapDoesNotExist);

            if (result.Result == StoreResult.Success && _cacheResults)
            {
                foreach (IStoreMapping sm in result.StoreMappings)
                {
                    _manager.Cache.AddOrUpdateMapping(sm, _policy);
                }
            }
        }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     if (result.Result != StoreResult.ShardMapDoesNotExist)
     {
         // Possible errors are:
         // StoreResult.ShardMapHasShards
         // StoreResult.StoreVersionMismatch
         // StoreResult.MissingParametersForStoredProcedure
         throw StoreOperationErrorHandler.OnShardMapManagerErrorGlobal(
                   result,
                   _shardMap,
                   this.OperationName,
                   StoreOperationRequestBuilder.SpRemoveShardMapGlobal);
     }
 }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // SchemaInfoNameDoesNotExist is handled by the callers i.e. Get vs TryGet.
     if (result.Result != StoreResult.SchemaInfoNameDoesNotExist)
     {
         // Expected errors are:
         // StoreResult.MissingParametersForStoredProcedure:
         // StoreResult.StoreVersionMismatch:
         throw StoreOperationErrorHandler.OnShardSchemaInfoErrorGlobal(
             result,
             _schemaInfoName,
             this.OperationName,
             StoreOperationRequestBuilder.SpFindShardingSchemaInfoByNameGlobal);
     }
 }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     if (result.Result != StoreResult.ShardMapDoesNotExist)
     {
         // Possible errors are:
         // StoreResult.ShardMapHasShards
         // StoreResult.StoreVersionMismatch
         // StoreResult.MissingParametersForStoredProcedure
         throw StoreOperationErrorHandler.OnShardMapManagerErrorGlobal(
             result,
             _shardMap,
             this.OperationName,
             StoreOperationRequestBuilder.SpRemoveShardMapGlobal);
     }
 }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.ShardMapDoesNotExist
     // StoreResult.MappingDoesNotExist
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnShardMapperErrorGlobal(
               result,
               _shardMap,
               _mapping.StoreShard, // shard
               _errorCategory,
               this.OperationName,
               StoreOperationRequestBuilder.SpFindShardMappingByIdGlobal);
 }
        /// <summary>
        /// Refreshes the cache on successful commit of the GSM operation.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalUpdateCachePost(IStoreResults result)
        {
            Debug.Assert(result.Result == StoreResult.Success ||
                         result.Result == StoreResult.ShardMapDoesNotExist);

            // Add shard maps and mappings to cache.
            foreach (LoadResult loadResult in _loadResults)
            {
                _shardMapManager.Cache.AddOrUpdateShardMap(loadResult.ShardMap);

                foreach (IStoreMapping sm in loadResult.Mappings)
                {
                    _shardMapManager.Cache.AddOrUpdateMapping(sm, CacheStoreMappingUpdatePolicy.OverwriteExisting);
                }
            }
        }
        /// <summary>
        /// Handles errors from the GSM operation after the LSM operations.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void HandleDoGlobalExecuteError(IStoreResults result)
        {
            if (result.Result == StoreResult.ShardMapDoesNotExist)
            {
                // Remove shard map from cache.
                _shardMapManager.Cache.DeleteShardMap(_shardMap);
            }

            // Possible errors are:
            // StoreResult.ShardMapDoesNotExist
            // StoreResult.StoreVersionMismatch
            // StoreResult.MissingParametersForStoredProcedure
            throw StoreOperationErrorHandler.OnShardMapErrorGlobal(
                result,
                _shardMap,
                null, // shard
                ShardManagementErrorCategory.ShardMap,
                this.OperationName,
                StoreOperationRequestBuilder.SpGetAllShardsGlobal);
        }
        /// <summary>
        /// Returns the proper ShardManagementException corresponding to given error code in 
        /// <paramref name="result"/> for ShardMapManager operations.
        /// </summary>
        /// <param name="result">Operation result object.</param>
        /// <param name="shardMap">Shard map object.</param>
        /// <param name="operationName">Operation being performed.</param>
        /// <param name="storedProcName">Stored procedure being executed.</param>
        /// <returns>ShardManagementException to be raised.</returns>
        internal static ShardManagementException OnShardMapManagerErrorGlobal(
            IStoreResults result,
            IStoreShardMap shardMap,
            string operationName,
            string storedProcName)
        {
            switch (result.Result)
            {
                case StoreResult.ShardMapExists:
                    Debug.Assert(shardMap != null);
                    return new ShardManagementException(
                        ShardManagementErrorCategory.ShardMapManager,
                        ShardManagementErrorCode.ShardMapAlreadyExists,
                        Errors._Store_ShardMap_AlreadyExistsGlobal,
                        shardMap.Name,
                        storedProcName,
                        operationName);

                case StoreResult.ShardMapHasShards:
                    Debug.Assert(shardMap != null);
                    return new ShardManagementException(
                        ShardManagementErrorCategory.ShardMapManager,
                        ShardManagementErrorCode.ShardMapHasShards,
                        Errors._Store_ShardMap_ContainsShardsGlobal,
                        shardMap.Name,
                        storedProcName,
                        operationName);

                case StoreResult.StoreVersionMismatch:
                case StoreResult.MissingParametersForStoredProcedure:
                default:
                    return StoreOperationErrorHandler.OnCommonErrorGlobal(
                        result,
                        operationName,
                        storedProcName);
            }
        }
        /// <summary>
        /// Handles errors from the GSM operation after the LSM operations.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void HandleDoGlobalExecuteError(IStoreResults result)
        {
            if (result.Result == StoreResult.ShardMapDoesNotExist)
            {
                // Remove shard map from cache.
                _shardMapManager.Cache.DeleteShardMap(_shardMap);
            }

            if (result.Result == StoreResult.MappingDoesNotExist)
            {
                Debug.Assert(_mapping != null);

                // Remove mapping from cache.
                _shardMapManager.Cache.DeleteMapping(_mapping);
            }

            // Possible errors are:
            // StoreResult.ShardMapDoesNotExist
            // StoreResult.MappingDoesNotExist
            // StoreResult.MappingAlreadyLocked
            // StoreResult.MappingLockOwnerIdMismatch
            // StoreResult.StoreVersionMismatch
            // StoreResult.MissingParametersForStoredProcedure
            throw StoreOperationErrorHandler.OnShardMapperErrorGlobal(
                result,
                _shardMap,
                _mapping == null ? null : _mapping.StoreShard,
                _errorCategory,
                this.OperationName,
                StoreOperationRequestBuilder.SpLockOrUnLockShardMappingsGlobal);
        }
 /// <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);
 }
 /// <summary>
 /// Sets the stub of AddMappingOperation.HandleDoGlobalPreLocalExecuteError(IStoreResults result)
 /// </summary>
 public override void HandleDoGlobalPreLocalExecuteError(IStoreResults result)
 {
     Action<IStoreResults> action1 = this.HandleDoGlobalPreLocalExecuteErrorIStoreResults;
     if (action1 != null)
         action1(result);
     else if (this.___callBase)
         base.HandleDoGlobalPreLocalExecuteError(result);
     else
         this.InstanceBehavior.VoidResult<StubAddMappingOperation>(this, "HandleDoGlobalPreLocalExecuteError");
 }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // Recovery manager handles the ShardMapDoesNotExist error properly, so we don't interfere.
     if (!_ignoreFailure || result.Result != StoreResult.ShardMapDoesNotExist)
     {
         // Possible errors are:
         // StoreResult.ShardMapDoesNotExist
         // StoreResult.ShardDoesNotExist
         // StoreResult.ShardVersionMismatch
         // StoreResult.StoreVersionMismatch
         // StoreResult.MissingParametersForStoredProcedure
         throw StoreOperationErrorHandler.OnShardMapperErrorGlobal(
             result,
             _shardMap,
             _shard,
             _errorCategory,
             this.OperationName,
             StoreOperationRequestBuilder.SpGetAllShardMappingsGlobal);
     }
 }
 /// <summary>
 /// Refreshes the cache on successful commit of the GSM operation.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void DoGlobalUpdateCachePost(IStoreResults result)
 {
     if (result.Result == StoreResult.Success && _cacheResults)
     {
         foreach (IStoreMapping sm in result.StoreMappings)
         {
             _manager.Cache.AddOrUpdateMapping(sm, CacheStoreMappingUpdatePolicy.OverwriteExisting);
         }
     }
 }
 public virtual void HandleUndoLocalSourceExecuteError(IStoreResults result)
 {
     this.inner.HandleUndoLocalSourceExecuteError(result);
 }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // MappingNotFound for key is supposed to be handled in the calling layers 
     // so that TryLookup vs Lookup have proper behavior.
     if (result.Result != StoreResult.MappingNotFoundForKey)
     {
         // Recovery manager handles the ShardMapDoesNotExist error properly, so we don't interfere.
         if (!_ignoreFailure || result.Result != StoreResult.ShardMapDoesNotExist)
         {
             // Possible errors are:
             // StoreResult.ShardMapDoesNotExist
             // StoreResult.StoreVersionMismatch
             // StoreResult.MissingParametersForStoredProcedure
             throw StoreOperationErrorHandler.OnShardMapperErrorGlobal(
                 result,
                 _shardMap,
                 null, // shard
                 _errorCategory,
                 this.OperationName,
                 StoreOperationRequestBuilder.SpFindShardMappingByKeyGlobal);
         }
     }
 }
 /// <summary>
 /// Sets the stub of StoreOperation.HandleUndoLocalTargetExecuteError(IStoreResults result)
 /// </summary>
 public override void HandleUndoLocalTargetExecuteError(IStoreResults result)
 {
     Action<IStoreResults> action1 = this.HandleUndoLocalTargetExecuteErrorIStoreResults;
     if (action1 != null)
         action1(result);
     else if (this.___callBase)
         base.HandleUndoLocalTargetExecuteError(result);
     else
         this.InstanceBehavior.VoidResult<StubReplaceMappingsOperation>(this, "HandleUndoLocalTargetExecuteError");
 }
 /// <summary>
 /// Sets the stub of ReplaceMappingsOperation.DoGlobalPostLocalUpdateCache(IStoreResults result)
 /// </summary>
 public override void DoGlobalPostLocalUpdateCache(IStoreResults result)
 {
     Action<IStoreResults> action1 = this.DoGlobalPostLocalUpdateCacheIStoreResults;
     if (action1 != null)
         action1(result);
     else if (this.___callBase)
         base.DoGlobalPostLocalUpdateCache(result);
     else
         this.InstanceBehavior.VoidResult<StubReplaceMappingsOperation>(this, "DoGlobalPostLocalUpdateCache");
 }
 public virtual void HandleDoLocalTargetExecuteError(IStoreResults result)
 {
     this.inner.HandleDoLocalTargetExecuteError(result);
 }
 /// <summary>
 /// Handles errors from the GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoGlobalExecuteError(IStoreResults result)
 {
     // Possible errors are:
     // StoreResult.ShardMapDoesNotExist
     // StoreResult.StoreVersionMismatch
     // StoreResult.MissingParametersForStoredProcedure
     throw StoreOperationErrorHandler.OnRecoveryErrorGlobal(
         result,
         _shardMap,
         _shard,
         ShardManagementErrorCategory.Recovery,
         this.OperationName,
         StoreOperationRequestBuilder.SpReplaceShardMappingsGlobal);
 }
 public virtual void HandleUndoGlobalPostLocalExecuteError(IStoreResults result)
 {
     this.inner.HandleUndoGlobalPostLocalExecuteError(result);
 }
        /// <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.OnShardMapperErrorGlobal(
                result,
                _shardMap,
                _mapping.StoreShard,
                _errorCategory,
                StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
                StoreOperationRequestBuilder.SpBulkOperationShardMappingsGlobalEnd);
        }
 /// <summary>
 /// Refreshes the cache on successful commit of the final GSM operation after the LSM operations.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void DoGlobalPostLocalUpdateCache(IStoreResults result)
 {
     // Add mapping to cache.
     this.Manager.Cache.AddOrUpdateMapping(_mapping, CacheStoreMappingUpdatePolicy.OverwriteExisting);
 }
 public virtual void DoGlobalPostLocalUpdateCache(IStoreResults result)
 {
     this.inner.DoGlobalPostLocalUpdateCache(result);
 }
 /// <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,
         _mapping.StoreShard.Location,
         StoreOperationErrorHandler.OperationNameFromStoreOperationCode(this.OperationCode),
         StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal);
 }
        /// <summary>
        /// Refreshes the cache on successful commit of the GSM operation.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalUpdateCachePost(IStoreResults result)
        {
            Debug.Assert(
                result.Result == StoreResult.Success ||
                result.Result == StoreResult.MappingNotFoundForKey ||
                result.Result == StoreResult.ShardMapDoesNotExist);

            if (result.Result == StoreResult.Success && _cacheResults)
            {
                foreach (IStoreMapping sm in result.StoreMappings)
                {
                    _manager.Cache.AddOrUpdateMapping(sm, _policy);
                }
            }
        }
        /// <summary>
        /// Refreshes the cache on successful commit of the GSM operation.
        /// </summary>
        /// <param name="result">Operation result.</param>
        public override void DoGlobalUpdateCachePost(IStoreResults result)
        {
            Debug.Assert(result.Result == StoreResult.Success ||
                         result.Result == StoreResult.ShardMapDoesNotExist);

            if (result.Result == StoreResult.Success)
            {
                // Remove cache entry.
                _shardMapManager.Cache.DeleteShardMap(_shardMap);
            }
        }
 /// <summary>
 /// Handles errors from the LSM operation.
 /// </summary>
 /// <param name="result">Operation result.</param>
 public override void HandleDoLocalExecuteError(IStoreResults result)
 {
     if (!_ignoreFailure || result.Result != StoreResult.ShardMapDoesNotExist)
     {
         // Possible errors are:
         // StoreResult.ShardMapDoesNotExist
         // StoreResult.StoreVersionMismatch
         // StoreResult.MissingParametersForStoredProcedure
         throw StoreOperationErrorHandler.OnRecoveryErrorLocal(
             result,
             _shardMap,
             this.Location,
             ShardManagementErrorCategory.Recovery,
             this.OperationName,
             StoreOperationRequestBuilder.SpGetAllShardMappingsLocal);
     }
 }