public Shard CreateShard(ShardCreationInfo shardCreationArgs)
        {
            ExceptionUtils.DisallowNullArgument(shardCreationArgs, "shardCreationArgs");

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

                Stopwatch stopwatch = Stopwatch.StartNew();

                Shard shard = _defaultMapper.Add(
                    new Shard(
                        this.Manager,
                        this,
                        shardCreationArgs));

                stopwatch.Stop();

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

                return(shard);
            }
        }
예제 #2
0
        /// <summary>
        /// Constructs a Shard given shard creation arguments.
        /// </summary>
        /// <param name="manager">Owning ShardMapManager.</param>
        /// <param name="shardMap">Owning shard map.</param>
        /// <param name="creationInfo">Shard creation information.</param>
        internal Shard(
            ShardMapManager manager,
            ShardMap shardMap,
            ShardCreationInfo creationInfo)
        {
            Debug.Assert(manager != null);
            Debug.Assert(shardMap != null);
            Debug.Assert(creationInfo != null);

            this.Manager  = manager;
            this.ShardMap = shardMap;

            this.StoreShard = new DefaultStoreShard(
                Guid.NewGuid(),
                Guid.NewGuid(),
                shardMap.Id,
                creationInfo.Location,
                (int)creationInfo.Status);

            _hashCode = this.CalculateHashCode();
        }