// weights.put(Distribution.BEG, new BeginWeight()); // weights.put(Distribution.END, new EndWeight()); // weights.put(Distribution.MID, new MidWeight()); /// <summary>Determines how many initial operations a given operation data should have /// </summary> /// <param name="totalAm">the total amount of operations allowed</param> /// <param name="opData">the given operation information (with a valid percentage >= 0) /// </param> /// <returns>the number of items to allow to run</returns> /// <exception cref="System.ArgumentException">if negative operations are determined</exception> internal static int DetermineHowMany(int totalAm, OperationData opData, Constants.OperationType type) { if (totalAm <= 0) { return(0); } int amLeft = (int)Math.Floor(opData.GetPercent() * totalAm); if (amLeft < 0) { throw new ArgumentException("Invalid amount " + amLeft + " determined for operation type " + type.ToString()); } return(amLeft); }
public _Observer_138(WeightSelector _enclosing, Constants.OperationType type) { this._enclosing = _enclosing; this.type = type; }
/// <summary>Gets an operation instance (cached) for a given operation type</summary> /// <param name="type">the operation type to fetch for</param> /// <returns>Operation operation instance or null if it can not be fetched.</returns> internal virtual Operation GetOperation(Constants.OperationType type) { Operation op = typedOperations[type]; if (op != null) { return(op); } switch (type) { case Constants.OperationType.Read: { op = new ReadOp(this.config, rnd); break; } case Constants.OperationType.Ls: { op = new ListOp(this.config, rnd); break; } case Constants.OperationType.Mkdir: { op = new MkdirOp(this.config, rnd); break; } case Constants.OperationType.Append: { op = new AppendOp(this.config, rnd); break; } case Constants.OperationType.Rename: { op = new RenameOp(this.config, rnd); break; } case Constants.OperationType.Delete: { op = new DeleteOp(this.config, rnd); break; } case Constants.OperationType.Create: { op = new CreateOp(this.config, rnd); break; } case Constants.OperationType.Truncate: { op = new TruncateOp(this.config, rnd); break; } } typedOperations[type] = op; return(op); }