Exemplo n.º 1
0
func (self *Engine) HandleEventMachineRemoved(event registry.Event) {
	machName := event.Payload.(string)
	for _, j := range self.registry.GetAllJobs() {
		tgt := self.registry.GetJobTarget(j.Name)
		if tgt == nil || tgt.BootId != machName {
			continue
		}

		log.V(1).Infof("EventMachineRemoved(%s): cancelling Job(%s)", machName, j.Name)
		self.registry.CancelJob(j.Name)

		offer := job.NewOfferFromJob(j)
		log.V(1).Infof("EventMachineRemoved(%s): re-publishing JobOffer(%s)", machName, offer.Job.Name)
		self.registry.CreateJobOffer(offer)
	}
}
Exemplo n.º 2
0
func (self *Engine) HandleEventJobCreated(event registry.Event) {
	j := event.Payload.(job.Job)
	log.V(1).Infof("EventJobCreated(%s): Job=%s", j.Name, j.String())

	log.V(1).Infof("EventJobCreated(%s): attempting to claim Job", j.Name)
	if !self.claimJob(j.Name) {
		log.V(1).Infof("EventJobCreated(%s): unable to claim Job", j.Name)
		return
	} else {
		log.V(1).Infof("EventJobCreated(%s): claimed Job", j.Name)
	}

	offer := job.NewOfferFromJob(j)
	log.V(1).Infof("EventJobCreated(%s): created JobOffer(%s)", j.Name, offer.Job.Name)

	log.Infof("EventJobCreated(%s): publishing JobOffer(%s)", j.Name, offer.Job.Name)
	self.registry.CreateJobOffer(offer)
}