Exemple #1
0
// driver runs on local, controlling all tasks
func (fcd *FlowContextDriver) Run(fc *flow.FlowContext) {

	taskGroups := scheduler.GroupTasks(fc)
	if fcd.option.PlotOutput {
		scheduler.PlotGraph(taskGroups, fc)
		return
	}

	rsyncServer, err := rsync.NewRsyncServer(os.Args[0], fcd.option.RelatedFileNames())
	if err != nil {
		log.Fatalf("Failed to start local server: %v", err)
	}
	rsyncServer.Start()

	sched := scheduler.NewScheduler(
		fcd.option.Leader,
		&scheduler.SchedulerOption{
			DataCenter:     fcd.option.DataCenter,
			Rack:           fcd.option.Rack,
			TaskMemoryMB:   fcd.option.TaskMemoryMB,
			DriverPort:     rsyncServer.Port,
			Module:         fcd.option.Module,
			ExecutableFile: os.Args[0],
		},
	)
	defer fcd.Cleanup(sched, fc, taskGroups)

	go sched.EventLoop()

	// schedule to run the steps
	var wg sync.WaitGroup
	for _, taskGroup := range taskGroups {
		wg.Add(1)
		sched.EventChan <- scheduler.SubmitTaskGroup{
			FlowContext: fc,
			TaskGroup:   taskGroup,
			Bid:         fcd.option.FlowBid / float64(len(taskGroups)),
			WaitGroup:   &wg,
		}
	}
	go sched.Market.FetcherLoop()

	wg.Wait()

	fcd.CloseOutputChannels(fc)

}
Exemple #2
0
func (fcd *FlowContextDriver) Plot(fc *flow.FlowContext) {
	taskGroups := scheduler.GroupTasks(fc)
	scheduler.PlotGraph(taskGroups, fc)
}