Exemplo n.º 1
0
func chooseStrategy(generator writestrategies.MessageGenerator, writer writestrategies.MessageWriter, writeRate int, burstDelay time.Duration) experiment.WriteStrategy {
	if burstDelay > 0 {
		params := writestrategies.BurstParameters{
			Minimum:   writeRate,
			Maximum:   writeRate,
			Frequency: burstDelay,
		}
		return writestrategies.NewBurstWriteStrategy(generator, writer, params)
	}
	return writestrategies.NewConstantWriteStrategy(generator, writer, writeRate)
}
Exemplo n.º 2
0
			var (
				writer        mockWriter
				stopChan      chan struct{}
				writeStrategy *writestrategies.BurstWriteStrategy
				params        writestrategies.BurstParameters
			)

			BeforeEach(func() {
				writer = mockWriter{}
				stopChan = make(chan struct{})
				params = writestrategies.BurstParameters{
					Minimum:   10,
					Maximum:   100,
					Frequency: 900 * time.Millisecond,
				}
				writeStrategy = writestrategies.NewBurstWriteStrategy(&mockGenerator{}, &writer, params)
			})

			It("writes messages in bursts", func() {
				go writeStrategy.StartWriter(stopChan)
				defer close(stopChan)

				writes := func() uint32 {
					return atomic.LoadUint32(&writer.count)
				}
				Eventually(writes).Should(BeNumerically(">=", params.Minimum))
				Eventually(writes).Should(BeNumerically("<=", params.Maximum))
			})

			It("stops writing after the stoChan is closed", func() {
				go writeStrategy.StartWriter(stopChan)
Exemplo n.º 3
0
			reportResults(firehoseReader, metronStreamWriter.Writes, b)
			Expect(float64(firehoseReader.MetronSentMessageCount)).To(BeNumerically(">", writeRatePerSecond))
		}, 1)

		Measure("dropsonde metrics being passed from metron to the firehose nozzle in burst sequence", func(b Benchmarker) {
			metronStreamWriter := endtoend.NewMetronStreamWriter()
			firehoseReader := endtoend.NewFirehoseReader()

			params := writestrategies.BurstParameters{
				Minimum:   10,
				Maximum:   100,
				Frequency: time.Second,
			}

			generator := messagegenerator.NewValueMetricGenerator()
			writeStrategy := writestrategies.NewBurstWriteStrategy(generator, metronStreamWriter, params)
			ex := experiment.NewExperiment(firehoseReader)
			ex.AddWriteStrategy(writeStrategy)

			ex.Warmup()

			go stopExperimentAfterTimeout(ex)
			b.Time("runtime", func() {
				ex.Start()
			})

			reportResults(firehoseReader, metronStreamWriter.Writes, b)
		}, 1)
	}

	Context("Metron UDP, Doppler UDP", func() {