func (d *Director) Start() {
	rng := state.NewRand("director")

	// Set up directories
	d.agents.Prepare()

	// Populate initial link latencies
	for _, link := range d.net.Links() {
		link.SetLatency(d.makeLatency(rng, 1))
		link.SetJitter(d.makeJitter(rng, 1))
	}
	d.net.Start()
	d.agents.Start()
}
func (h *Harness) queryGenerator() {
	rng := state.NewRand("querier")
	for i := 1; true; i++ {
		query := h.generateQuery(rng)

		agentNo := rng.Intn(len(h.agents))
		node := h.agents[agentNo]
		h.request <- &request{
			id:    i,
			node:  node,
			query: query,
		}
		state.SetLastGeneratedRequest(i)
	}
}
func (h *Harness) boot() bool {
	rng := state.NewRand("boot")
	bootQuery := h.generateInitialQuery()
	i := rng.Intn(len(h.agents))
	node := h.agents[i]

	for !h.issueQuery(0, node, bootQuery) {
		time.Sleep(100 * time.Millisecond)
		select {
		case <-state.WaitGroup().Quit:
			return false
		default:
		}
	}
	return true
}
Exemple #4
0
func (d *Director) spawn(name string) {
	rng := state.NewRand("monkey " + name)

	c := d.config[name]
	monkey := d.monkey(name)

	start := time.Now()
	keep_going := true
	time.Sleep(c.offset)

	for keep_going {
		time.Sleep(time.Duration(rng.ExpFloat64() * float64(c.frequency)))
		dt := time.Now().Sub(start)
		intensity := (1 - math.Cos(float64(dt)/MONKEY_PERIOD)) / 2
		keep_going = monkey(rng, intensity)
	}
}