示例#1
0
func (m *JobExecutor) WalkPlanAll(p plan.Task) (Task, error) {
	root, err := m.WalkPlanTask(p)
	if err != nil {
		u.Errorf("all damn %v err=%v", p, err)
		return nil, err
	}
	if len(p.Children()) > 0 {
		dagRoot := m.NewTask(p)
		//u.Debugf("sequential?%v  parallel?%v", p.IsSequential(), p.IsParallel())
		err = dagRoot.Add(root)
		if err != nil {
			u.Errorf("Could not add root: %v", err)
			return nil, err
		}
		return dagRoot, m.WalkChildren(p, dagRoot)
	}
	//u.Debugf("got root? %T for %T", root, p)
	//u.Debugf("len=%d  for children:%v", len(p.Children()), p.Children())
	return root, m.WalkChildren(p, root)
}
示例#2
0
// WalkChildren walk dag of plan taasks creating execution tasks
func (m *JobExecutor) WalkChildren(p plan.Task, root Task) error {
	for _, t := range p.Children() {
		//u.Debugf("parent: %T  walk child %p %T  %#v", p, t, t, p.Children())
		et, err := m.WalkPlanTask(t)
		if err != nil {
			u.Errorf("could not create task %#v err=%v", t, err)
		}
		if len(t.Children()) == 0 {
			err = root.Add(et)
			if err != nil {
				return err
			}
		} else {
			childRoot := m.Executor.NewTask(t)
			err = root.Add(childRoot)
			if err != nil {
				return err
			}
			err = childRoot.Add(et)
			if err != nil {
				return err
			}
			//u.Warnf("has children but not handled %#v", t)
			for _, c := range t.Children() {
				//u.Warnf("\tchild task %#v", c)
				ct, err := m.WalkPlanTask(c)
				if err != nil {
					u.Errorf("could not create child task %#v err=%v", c, err)
					return err
				}
				if err = childRoot.Add(ct); err != nil {
					u.Errorf("Could not add task %v", err)
					return err
				}
			}
		}
	}
	return nil
}