/// <summary> /// This method breaks the generated fills collections to blocks of a configured size /// and feeds them (WriteMultiple) to the space by blocks. /// </summary> public void Feed() { try { //Stopwatch is used to measure feed time. var stopWatch = new Stopwatch(); var blocks = _fills.Length / _config.BlockSize; var buffer = new Data[_config.BlockSize]; stopWatch.Start(); for (int block = 0; block < blocks; block++) { //Copy the current fiils block int offset = block * _config.BlockSize; Array.Copy(_fills, offset, buffer, 0, buffer.Length); //Write the current block to the space _proxy.WriteMultiple(buffer); Thread.Sleep(_config.FeedingThrottle); if (!_continueFeeding) break; } stopWatch.Stop(); } catch { } }
public Data CreateData(Data data) { Thread.Sleep(WorkDuration); data.Content = string.Format("PROCESSED: {0}", data.RawContent); data.IsProcessed = true; return data; }
private void GenerateFills(Data[] fills) { Random rnd = new Random(DateTime.Now.GetHashCode()); for (int i = 0; i < fills.Length; i++) { var fill = new Data(); fill.Id = i.ToString(); fill.Type = Convert.ToInt64(rnd.Next()); fill.RawContent = "FEEDER: " + DateTime.UtcNow.Ticks; fill.IsProcessed = false; fills[i] = fill; } }