|
|
@ -7,7 +7,7 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
type EventManager struct {
|
|
|
|
type EventManager struct {
|
|
|
|
dag_nodes map[string]Resource
|
|
|
|
dag_nodes map[string]Resource
|
|
|
|
root_event Event
|
|
|
|
Root Event
|
|
|
|
aborts []chan error
|
|
|
|
aborts []chan error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -16,7 +16,7 @@ func NewEventManager(root_event Event, dag_nodes []Resource) * EventManager {
|
|
|
|
|
|
|
|
|
|
|
|
manager := &EventManager{
|
|
|
|
manager := &EventManager{
|
|
|
|
dag_nodes: map[string]Resource{},
|
|
|
|
dag_nodes: map[string]Resource{},
|
|
|
|
root_event: nil,
|
|
|
|
Root: nil,
|
|
|
|
aborts: []chan error{},
|
|
|
|
aborts: []chan error{},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -49,21 +49,21 @@ func (manager * EventManager) Run() error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}(abort, manager)
|
|
|
|
}(abort, manager)
|
|
|
|
|
|
|
|
|
|
|
|
err := LockResources(manager.root_event)
|
|
|
|
err := LockResources(manager.Root)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Logf("manager", "MANAGER_LOCK_ERR: %s", err)
|
|
|
|
log.Logf("manager", "MANAGER_LOCK_ERR: %s", err)
|
|
|
|
abort <- nil
|
|
|
|
abort <- nil
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = RunEvent(manager.root_event)
|
|
|
|
err = RunEvent(manager.Root)
|
|
|
|
abort <- nil
|
|
|
|
abort <- nil
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Logf("manager", "MANAGER_RUN_ERR: %s", err)
|
|
|
|
log.Logf("manager", "MANAGER_RUN_ERR: %s", err)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = FinishEvent(manager.root_event)
|
|
|
|
err = FinishEvent(manager.Root)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Logf("manager", "MANAGER_FINISH_ERR: %s", err)
|
|
|
|
log.Logf("manager", "MANAGER_FINISH_ERR: %s", err)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -83,7 +83,7 @@ func (manager * EventManager) FindResource(id string) Resource {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (manager * EventManager) FindEvent(id string) Event {
|
|
|
|
func (manager * EventManager) FindEvent(id string) Event {
|
|
|
|
event := FindChild(manager.root_event, id)
|
|
|
|
event := FindChild(manager.Root, id)
|
|
|
|
|
|
|
|
|
|
|
|
return event
|
|
|
|
return event
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -176,19 +176,19 @@ func (manager * EventManager) AddEvent(parent Event, child Event, info EventInfo
|
|
|
|
|
|
|
|
|
|
|
|
manager.AddDoneResources(child)
|
|
|
|
manager.AddDoneResources(child)
|
|
|
|
|
|
|
|
|
|
|
|
if manager.root_event == nil {
|
|
|
|
if manager.Root == nil {
|
|
|
|
if parent != nil {
|
|
|
|
if parent != nil {
|
|
|
|
return fmt.Errorf("EventManager has no root, so can't add event to parent")
|
|
|
|
return fmt.Errorf("EventManager has no root, so can't add event to parent")
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
manager.root_event = child
|
|
|
|
manager.Root = child
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if parent == nil {
|
|
|
|
if parent == nil {
|
|
|
|
return fmt.Errorf("Replacing root event not implemented")
|
|
|
|
return fmt.Errorf("Replacing root event not implemented")
|
|
|
|
} else if FindChild(manager.root_event, parent.ID()) == nil {
|
|
|
|
} else if FindChild(manager.Root, parent.ID()) == nil {
|
|
|
|
return fmt.Errorf("Parent does not exists in event tree")
|
|
|
|
return fmt.Errorf("Parent does not exists in event tree")
|
|
|
|
} else if FindChild(manager.root_event, child.ID()) != nil {
|
|
|
|
} else if FindChild(manager.Root, child.ID()) != nil {
|
|
|
|
return fmt.Errorf("Child already exists in event tree")
|
|
|
|
return fmt.Errorf("Child already exists in event tree")
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
AddChild(parent, child, info)
|
|
|
|
AddChild(parent, child, info)
|
|
|
|