/// <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); } } }
/// <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> /// 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)); } }
/// <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 (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) { 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> /// 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> /// 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) { // Expected errors are: // StoreResult.MissingParametersForStoredProcedure: // StoreResult.StoreVersionMismatch: throw StoreOperationErrorHandler.OnShardSchemaInfoErrorGlobal( result, "*", this.OperationName, StoreOperationRequestBuilder.SpGetAllShardingSchemaInfosGlobal); }
/// <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 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.SpGetAllDistinctShardLocationsGlobal); }
/// <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> /// 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> /// 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); }
/// <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); }
/// <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) { // 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> /// 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 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); } }
/// <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="location">Location of LSM operation.</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 OnShardMapperErrorLocal( IStoreResults result, ShardLocation location, string operationName, string storedProcName) { switch (result.Result) { case StoreResult.StoreVersionMismatch: case StoreResult.MissingParametersForStoredProcedure: default: return(StoreOperationErrorHandler.OnCommonErrorLocal( result, location, operationName, storedProcName)); } }
/// <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 LSM 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 OnShardMapErrorLocal( IStoreResults result, IStoreShardMap shardMap, ShardLocation location, ShardManagementErrorCategory errorCategory, string operationName, string storedProcName) { switch (result.Result) { case StoreResult.UnableToKillSessions: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.MappingsKillConnectionFailure, Errors._Store_ShardMapper_UnableToKillSessions, location, shardMap.Name, operationName, storedProcName, location)); case StoreResult.StoreVersionMismatch: case StoreResult.MissingParametersForStoredProcedure: case StoreResult.ShardDoesNotExist: // ShardDoesNotExist on local shard map can only occur in Recovery scenario. // For normal UpdateShard operation, we will get this error from GSM operation first. return(new ShardManagementException( ShardManagementErrorCategory.Recovery, ShardManagementErrorCode.ShardDoesNotExist, Errors._Store_Validate_ShardDoesNotExist, location, shardMap.Name, operationName, storedProcName)); default: return(StoreOperationErrorHandler.OnCommonErrorLocal( result, location, operationName, storedProcName)); } }
/// <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); }
/// <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.SpFindShardByLocationGlobal); }
/// <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> /// 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="shard">Shard object.</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 OnRecoveryErrorGlobal( IStoreResults result, IStoreShardMap shardMap, IStoreShard shard, ShardManagementErrorCategory errorCategory, string operationName, string storedProcName) { switch (result.Result) { case StoreResult.ShardLocationExists: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardLocationAlreadyExists, Errors._Store_Shard_LocationAlreadyExistsGlobal, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.ShardMapExists: Debug.Assert(shardMap != null); return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardMapAlreadyExists, Errors._Store_ShardMap_AlreadyExistsGlobal, 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) { // 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> /// 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); } }); }
/// <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="shard">Shard object.</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 OnShardMapErrorGlobal( IStoreResults result, IStoreShardMap shardMap, IStoreShard shard, ShardManagementErrorCategory errorCategory, string operationName, string storedProcName) { switch (result.Result) { case StoreResult.ShardMapDoesNotExist: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardMapDoesNotExist, Errors._Store_ShardMap_DoesNotExistGlobal, shardMap.Name, storedProcName, operationName, shard != null ? shard.Location.ToString() : "*")); case StoreResult.ShardExists: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardAlreadyExists, Errors._Store_Shard_AlreadyExistsGlobal, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.ShardLocationExists: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardLocationAlreadyExists, Errors._Store_Shard_LocationAlreadyExistsGlobal, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.ShardDoesNotExist: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardDoesNotExist, Errors._Store_Shard_DoesNotExistGlobal, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.ShardVersionMismatch: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardVersionMismatch, Errors._Store_Shard_VersionMismatchGlobal, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.ShardHasMappings: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardHasMappings, Errors._Store_Shard_HasMappingsGlobal, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.StoreVersionMismatch: case StoreResult.MissingParametersForStoredProcedure: default: return(StoreOperationErrorHandler.OnCommonErrorGlobal( result, operationName, storedProcName)); } }
/// <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 LSM operation.</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 OnValidationErrorLocal( IStoreResults result, IStoreShardMap shardMap, ShardLocation location, string operationName, string storedProcName) { switch (result.Result) { case StoreResult.ShardMapDoesNotExist: return(new ShardManagementException( ShardManagementErrorCategory.Validation, ShardManagementErrorCode.ShardMapDoesNotExist, Errors._Store_Validate_ShardMapDoesNotExist, shardMap.Name, location, operationName, storedProcName)); case StoreResult.ShardDoesNotExist: return(new ShardManagementException( ShardManagementErrorCategory.Validation, ShardManagementErrorCode.ShardDoesNotExist, Errors._Store_Validate_ShardDoesNotExist, location, shardMap.Name, operationName, storedProcName)); case StoreResult.ShardVersionMismatch: return(new ShardManagementException( ShardManagementErrorCategory.Validation, ShardManagementErrorCode.ShardVersionMismatch, Errors._Store_Validate_ShardVersionMismatch, location, shardMap.Name, operationName, storedProcName)); case StoreResult.MappingDoesNotExist: return(new ShardManagementException( ShardManagementErrorCategory.Validation, ShardManagementErrorCode.MappingDoesNotExist, Errors._Store_Validate_MappingDoesNotExist, location, shardMap.Name, operationName, storedProcName)); case StoreResult.MappingIsOffline: return(new ShardManagementException( ShardManagementErrorCategory.Validation, ShardManagementErrorCode.MappingIsOffline, Errors._Store_Validate_MappingIsOffline, location, shardMap.Name, operationName, storedProcName)); case StoreResult.StoreVersionMismatch: case StoreResult.MissingParametersForStoredProcedure: default: return(StoreOperationErrorHandler.OnCommonErrorLocal( result, location, operationName, storedProcName)); } }
/// <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="shardMap">Shard map object.</param> /// <param name="shard">Shard object.</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 OnShardMapperErrorGlobal( IStoreResults result, IStoreShardMap shardMap, IStoreShard shard, ShardManagementErrorCategory errorCategory, string operationName, string storedProcName) { switch (result.Result) { case StoreResult.ShardMapDoesNotExist: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardMapDoesNotExist, Errors._Store_ShardMap_DoesNotExistGlobal, shardMap.Name, storedProcName, operationName, shard != null ? shard.Location.ToString() : "*")); case StoreResult.ShardDoesNotExist: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardDoesNotExist, Errors._Store_Shard_DoesNotExistGlobal, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.ShardVersionMismatch: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.ShardVersionMismatch, Errors._Store_Shard_VersionMismatchGlobal, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.MappingDoesNotExist: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.MappingDoesNotExist, Errors._Store_ShardMapper_MappingDoesNotExistGlobal, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.MappingRangeAlreadyMapped: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.MappingRangeAlreadyMapped, Errors._Store_ShardMapper_MappingPointOrRangeAlreadyMapped, shard.Location, shardMap.Name, "Range", storedProcName, operationName)); case StoreResult.MappingPointAlreadyMapped: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.MappingPointAlreadyMapped, Errors._Store_ShardMapper_MappingPointOrRangeAlreadyMapped, shard.Location, shardMap.Name, "Point", storedProcName, operationName)); case StoreResult.MappingNotFoundForKey: Debug.Fail("MappingNotFoundForKey should not be raised during SqlOperation."); return(new ShardManagementException( errorCategory, ShardManagementErrorCode.MappingNotFoundForKey, Errors._Store_ShardMapper_MappingNotFoundForKeyGlobal, shardMap.Name, storedProcName, operationName)); case StoreResult.MappingIsAlreadyLocked: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.MappingIsAlreadyLocked, Errors._Store_ShardMapper_LockMappingAlreadyLocked, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.MappingLockOwnerIdDoesNotMatch: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.MappingLockOwnerIdDoesNotMatch, Errors._Store_ShardMapper_LockOwnerDoesNotMatch, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.MappingIsNotOffline: return(new ShardManagementException( errorCategory, ShardManagementErrorCode.MappingIsNotOffline, Errors._Store_ShardMapper_MappingIsNotOffline, shard.Location, shardMap.Name, storedProcName, operationName)); case StoreResult.StoreVersionMismatch: case StoreResult.MissingParametersForStoredProcedure: default: return(StoreOperationErrorHandler.OnCommonErrorGlobal( result, operationName, storedProcName)); } }