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)); }
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); }
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; }
public abstract IEnumerable <LoadEntity> GetEntities(LoadContainer targetContainer);
public LoadPartition(LoadContainer root, string constraintSetIdentity) { this.Root = root; this.ConstraintSetIdentity = constraintSetIdentity; }
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; }
public virtual EntitySelector GetSelector(LoadContainer container, string constraintSetIdentity, long units) { return(new NullEntitySelector()); }
public bool Visit(LoadContainer container) { this.PopulateDirectoryObjectFromIdentity(container); return(true); }