protected BandRandomEntitySelector(Band band, LoadContainer sourceContainer, string constraintSetIdentity)
 {
     AnchorUtil.ThrowOnNullArgument(band, "band");
     AnchorUtil.ThrowOnNullArgument(sourceContainer, "sourceContainer");
     this.band           = band;
     this.SourceEntities = (from x in sourceContainer.Children
                            where x.DirectoryObjectIdentity.Name == constraintSetIdentity
                            select x).Cast <LoadContainer>().SelectMany((LoadContainer x) => x.Children).Where(new Func <LoadEntity, bool>(this.IsAcceptedEntity));
 }
Esempio n. 2
0
        public override LoadEntity ToSerializationFormat(bool convertBandToBandData)
        {
            LoadContainer shallowCopy = this.GetShallowCopy();

            shallowCopy.ConsumedLoad.ConvertToSerializationMetrics(convertBandToBandData);
            shallowCopy.ReusableCapacity.ConvertToSerializationMetrics(convertBandToBandData);
            shallowCopy.MaximumLoad.ConvertToSerializationMetrics(convertBandToBandData);
            shallowCopy.CommittedLoad.ConvertToSerializationMetrics(convertBandToBandData);
            foreach (LoadEntity loadEntity in this.Children)
            {
                shallowCopy.AddChild(loadEntity.ToSerializationFormat(convertBandToBandData));
            }
            return(shallowCopy);
        }
Esempio n. 3
0
        public LoadContainer GetShallowCopy()
        {
            LoadContainer loadContainer = new LoadContainer(base.DirectoryObject, this.ContainerType);

            loadContainer.MaximumLoad            = new LoadMetricStorage(this.MaximumLoad);
            loadContainer.ConsumedLoad           = new LoadMetricStorage(base.ConsumedLoad);
            loadContainer.ReusableCapacity       = new LoadMetricStorage(this.ReusableCapacity);
            loadContainer.CommittedLoad          = new LoadMetricStorage(this.CommittedLoad);
            loadContainer.RelativeLoadWeight     = this.RelativeLoadWeight;
            loadContainer.DataRetrievedTimestamp = this.DataRetrievedTimestamp;
            loadContainer.CanAcceptBalancingLoad = this.CanAcceptBalancingLoad;
            loadContainer.CanAcceptRegularLoad   = this.CanAcceptRegularLoad;
            loadContainer.Constraint             = this.Constraint.CloneForContainer(loadContainer);
            return(loadContainer);
        }
        public override IEnumerable <LoadEntity> GetEntities(LoadContainer targetContainer)
        {
            List <LoadEntity>     list  = new List <LoadEntity>(base.SourceEntities);
            List <LoadEntity>     list2 = new List <LoadEntity>();
            IAllocationConstraint allocationConstraint = targetContainer.Constraint ?? new AnyLoadConstraint();
            Random random = new Random();

            while (list.Count > 0 && (long)list2.Count < this.totalNumberOfEntities)
            {
                int        index      = random.Next(list.Count);
                LoadEntity loadEntity = list[index];
                if (allocationConstraint.Accept(loadEntity))
                {
                    list2.Add(loadEntity);
                }
                list.RemoveAt(index);
            }
            return(list2);
        }
		public override IEnumerable<LoadEntity> GetEntities(LoadContainer targetContainer)
		{
			IAllocationConstraint allocationConstraint = targetContainer.Constraint ?? new AnyLoadConstraint();
			List<LoadEntity> list = new List<LoadEntity>(base.SourceEntities);
			List<LoadEntity> list2 = new List<LoadEntity>();
			ByteQuantifiedSize value = ByteQuantifiedSize.FromBytes(0UL);
			Random random = new Random();
			while (list.Count > 0 && value < this.totalSize)
			{
				int index = random.Next(list.Count);
				LoadEntity loadEntity = list[index];
				if (allocationConstraint.Accept(loadEntity))
				{
					ByteQuantifiedSize byteQuantifiedSize = value + loadEntity.ConsumedLoad.GetSizeMetric(PhysicalSize.Instance);
					if (byteQuantifiedSize < this.totalSize)
					{
						list2.Add(loadEntity);
						value = byteQuantifiedSize;
					}
				}
				list.RemoveAt(index);
			}
			return list2;
		}
Esempio n. 6
0
 public abstract IEnumerable <LoadEntity> GetEntities(LoadContainer targetContainer);
Esempio n. 7
0
 public LoadPartition(LoadContainer root, string constraintSetIdentity)
 {
     this.Root = root;
     this.ConstraintSetIdentity = constraintSetIdentity;
 }
Esempio n. 8
0
 public override IEnumerable <LoadEntity> GetEntities(LoadContainer targetContainer)
 {
     yield break;
 }
		public TotalSizeEntitySelector(Band band, ByteQuantifiedSize targetSize, LoadContainer container, string constraintSetIdentity) : base(band, container, constraintSetIdentity)
		{
			this.totalSize = targetSize;
		}
 public NumberOfEntitiesSelector(Band band, long numberOfEntities, LoadContainer sourceContainer, string constraintSetIdentity) : base(band, sourceContainer, constraintSetIdentity)
 {
     this.totalNumberOfEntities = numberOfEntities;
 }
Esempio n. 11
0
 public virtual EntitySelector GetSelector(LoadContainer container, string constraintSetIdentity, long units)
 {
     return(new NullEntitySelector());
 }
Esempio n. 12
0
 public bool Visit(LoadContainer container)
 {
     this.PopulateDirectoryObjectFromIdentity(container);
     return(true);
 }