Esempio n. 1
0
// Submit a bid for the given Job
func (a *Agent) bid(jobName string) {
	log.Infof("Submitting JobBid for Job(%s)", jobName)

	jb := job.NewBid(jobName, a.Machine.State().ID)
	a.registry.SubmitJobBid(jb)

	a.state.TrackBid(jb.JobName)
}
Esempio n. 2
0
// Submit a bid for the given Job
func (a *Agent) Bid(jobName string) {
	log.Infof("Submitting JobBid for Job(%s)", jobName)

	jb := job.NewBid(jobName, a.machine.State().BootID)
	a.registry.SubmitJobBid(jb)

	a.state.Lock()
	defer a.state.Unlock()

	a.state.TrackBid(jb.JobName)
}
Esempio n. 3
0
// Bids returns a list of JobBids that have been submitted for the given JobOffer
func (r *EtcdRegistry) Bids(jo *job.JobOffer) ([]job.JobBid, error) {
	var bids []job.JobBid

	key := path.Join(r.keyPrefix, offerPrefix, jo.Job.Name, "bids")
	resp, err := r.etcd.Get(key, false, true)
	if err != nil {
		if isKeyNotFound(err) {
			return bids, nil
		}
		return nil, err
	}

	for _, node := range resp.Node.Nodes {
		machID := path.Base(node.Key)
		jb := job.NewBid(jo.Job.Name, machID)
		bids = append(bids, *jb)
	}

	return bids, nil
}
Esempio n. 4
0
func filterEventJobBidSubmitted(resp *etcd.Response) *event.Event {
	if resp.Action != "set" {
		return nil
	}

	dir, machID := path.Split(resp.Node.Key)
	dir, prefix := path.Split(strings.TrimSuffix(dir, "/"))

	if prefix != "bids" {
		return nil
	}

	dir, jobName := path.Split(strings.TrimSuffix(dir, "/"))
	prefix = path.Base(strings.TrimSuffix(dir, "/"))

	if prefix != offerPrefix {
		return nil
	}

	jb := job.NewBid(jobName, machID)
	return &event.Event{"EventJobBidSubmitted", *jb, nil}
}