Example #1
0
 /// <summary>
 /// Performs the LSM operation on the source shard.
 /// </summary>
 /// <param name="ts">Transaction scope.</param>
 /// <returns>Result of the operation.</returns>
 public override IStoreResults DoLocalSourceExecute(IStoreTransactionScope ts)
 {
     return(ts.ExecuteOperation(
                StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal,
                StoreOperationRequestBuilder.ReplaceShardMappingsLocal(
                    this.Id,
                    false,
                    _shardMap,
                    _mappingsSource.Select(m => m.Item1).ToArray(),
                    _mappingsTarget.Select(m => m.Item1).ToArray())));
 }
Example #2
0
        /// <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)
        {
            IEnumerable <IStoreMapping> mappingsToRemove = this.GetMappingsToPurge(ts);

            return(ts.ExecuteOperation(
                       StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal,
                       StoreOperationRequestBuilder.ReplaceShardMappingsLocal(
                           Guid.NewGuid(), // Create a new Guid so that this operation forces over-writes.
                           false,
                           _shardMap,
                           mappingsToRemove.ToArray(),
                           _mappingsToAdd.ToArray())));
        }
Example #3
0
        /// <summary>
        /// Performs the undo of LSM operation on the source shard.
        /// </summary>
        /// <param name="ts">Transaction scope.</param>
        /// <returns>Result of the operation.</returns>
        public override IStoreResults UndoLocalSourceExecute(IStoreTransactionScope ts)
        {
            DefaultStoreShard dssOriginal = new DefaultStoreShard(
                _mappingsSource[0].Item1.StoreShard.Id,
                this.OriginalShardVersionAdds,
                _mappingsSource[0].Item1.ShardMapId,
                _mappingsSource[0].Item1.StoreShard.Location,
                _mappingsSource[0].Item1.StoreShard.Status);

            DefaultStoreMapping dsmSource = new DefaultStoreMapping(
                _mappingsSource[0].Item1.Id,
                _mappingsSource[0].Item1.ShardMapId,
                dssOriginal,
                _mappingsSource[0].Item1.MinValue,
                _mappingsSource[0].Item1.MaxValue,
                _mappingsSource[0].Item1.Status,
                _mappingsSource[0].Item2);

            DefaultStoreMapping dsmTarget = new DefaultStoreMapping(
                _mappingsTarget[0].Item1.Id,
                _mappingsTarget[0].Item1.ShardMapId,
                dssOriginal,
                _mappingsTarget[0].Item1.MinValue,
                _mappingsTarget[0].Item1.MaxValue,
                _mappingsTarget[0].Item1.Status,
                _mappingsTarget[0].Item2);

            IStoreMapping[] ms = new[] { dsmSource };
            IStoreMapping[] mt = new[] { dsmTarget };

            return(ts.ExecuteOperation(
                       StoreOperationRequestBuilder.SpBulkOperationShardMappingsLocal,
                       StoreOperationRequestBuilder.ReplaceShardMappingsLocal(
                           this.Id,
                           true,
                           _shardMap,
                           mt.Concat(_mappingsTarget.Skip(1).Select(m => m.Item1)).ToArray(),
                           ms.Concat(_mappingsSource.Skip(1).Select(m => m.Item1)).ToArray())));
        }