public IDistributionStrategy AddShard(string shard, IDistributionConfiguration configuration, Boolean needTransfer)
        {
            if (string.IsNullOrEmpty(shard))
            {
                throw new Exception("Shard Name cannot be null or empty. Failed to configure distribution");
            }
            _syncLock.AcquireWriterLock(Timeout.Infinite);
            try
            {
                shard = shard.ToLower();
                if (_shards.Count < 1)
                {
                    _shards.Add(shard);
                    _nonShardedDistribution = new NonShardedDistribution(shard);
                    return(this);
                }

                if (_shards.Contains(shard))
                {
                    throw new Exception("Shard '" + shard + "' already Exists");
                }

                _shards.Add(shard);
                return(this);
            }
            finally
            {
                _syncLock.ReleaseWriterLock();
            }
        }
 public void Deserialize(Common.Serialization.IO.CompactReader reader)
 {
     _shards = Common.Util.SerializationUtility.DeserializeList <string>(reader);
     _name   = reader.ReadObject() as string;
     _nonShardedDistribution = reader.ReadObject() as NonShardedDistribution;
     _bucketsStats           = reader.ReadObject() as BucketStatistics;
     _syncLock = new ReaderWriterLock();
 }
Exemple #3
0
        public object Clone()
        {
            NonShardedDistribution clone = new NonShardedDistribution();

            clone._bucket = _bucket != null?_bucket.Clone() as HashMapBucket : null;

            clone._distributionSequence = _distributionSequence;
            clone._name = _name;

            return(clone);
        }