internal Shard UpdateShard(Shard currentShard, ShardUpdate update)
        {
            ExceptionUtils.DisallowNullArgument(currentShard, "currentShard");
            ExceptionUtils.DisallowNullArgument(update, "update");

            using (ActivityIdScope activityIdScope = new ActivityIdScope(Guid.NewGuid()))
            {
                Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMap,
                    "UpdateShard",
                    "Start; Shard: {0}",
                    currentShard.Location);

                Stopwatch stopwatch = Stopwatch.StartNew();

                Shard shard = _defaultMapper.UpdateShard(currentShard, update);

                stopwatch.Stop();

                Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMap,
                    "UpdateShard",
                    "Complete; Shard: {0}; Duration: {1}",
                    currentShard.Location,
                    stopwatch.Elapsed);

                return(shard);
            }
        }
        /// <summary>
        /// Allows for update to a shard with the updates provided in the <paramref name="update"/> parameter.
        /// </summary>
        /// <param name="currentShard">Shard to be updated.</param>
        /// <param name="update">Updated properties of the Shard.</param>
        /// <returns>New Shard instance with updated information.</returns>
        internal Shard UpdateShard(Shard currentShard, ShardUpdate update)
        {
            Debug.Assert(currentShard != null);
            Debug.Assert(update != null);

            ExceptionUtils.EnsureShardBelongsToShardMap(
                this.Manager,
                this.ShardMap,
                currentShard,
                "UpdateShard",
                "Shard");

            // CONSIDER(wbasheer): Have refresh semantics for trivial case when nothing is modified.
            if (!update.IsAnyPropertySet(ShardUpdatedProperties.All))
            {
                return(currentShard);
            }

            DefaultStoreShard sNew = new DefaultStoreShard(
                currentShard.Id,
                Guid.NewGuid(),
                currentShard.ShardMapId,
                currentShard.Location,
                update.IsAnyPropertySet(ShardUpdatedProperties.Status) ? (int)update.Status : currentShard.StoreShard.Status);

            using (IStoreOperation op = this.Manager.StoreOperationFactory.CreateUpdateShardOperation(
                       this.Manager,
                       this.ShardMap.StoreShardMap,
                       currentShard.StoreShard,
                       sNew))
            {
                op.Do();
            }

            return(new Shard(this.Manager, this.ShardMap, sNew));
        }