/// <summary> /// Creates and adds a point mapping to ShardMap. /// </summary> /// <param name="point">Point for which to create the mapping.</param> /// <param name="shard">Shard associated with the point mapping.</param> /// <returns>Newly created mapping.</returns> public PointMapping <TKey> CreatePointMapping(TKey point, Shard shard) { ExceptionUtils.DisallowNullArgument(shard, "shard"); using (ActivityIdScope activityIdScope = new ActivityIdScope(Guid.NewGuid())) { PointMappingCreationInfo <TKey> args = new PointMappingCreationInfo <TKey>(point, shard, MappingStatus.Online); string mappingKey = BitConverter.ToString(args.Key.RawValue); Tracer.TraceInfo(TraceSourceConstants.ComponentNames.ListShardMap, "CreatePointMapping", "Start; ShardMap name: {0}; Point Mapping: {1}", this.Name, mappingKey); Stopwatch stopwatch = Stopwatch.StartNew(); PointMapping <TKey> pointMapping = _lsm.Add(new PointMapping <TKey>(this.Manager, args)); stopwatch.Stop(); Tracer.TraceInfo(TraceSourceConstants.ComponentNames.ListShardMap, "CreatePointMapping", "Complete; ShardMap name: {0}; Point Mapping: {1}; Duration: {2}", this.Name, mappingKey, stopwatch.Elapsed); return(pointMapping); } }
/// <summary> /// Constructs a point mapping given mapping creation arguments. /// </summary> /// <param name="manager">Owning ShardMapManager.</param> /// <param name="creationInfo">Mapping creation information.</param> internal PointMapping(ShardMapManager manager, PointMappingCreationInfo <TKey> creationInfo) { Debug.Assert(manager != null); Debug.Assert(creationInfo != null); Debug.Assert(creationInfo.Shard != null); this.Manager = manager; _shard = creationInfo.Shard; this.StoreMapping = new DefaultStoreMapping( Guid.NewGuid(), creationInfo.Shard, creationInfo.Key.RawValue, null, (int)creationInfo.Status); this.Key = creationInfo.Key; this.Value = creationInfo.Value; }