-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
67 lines (58 loc) · 1.15 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"Saffron-Orchesator/manager"
"Saffron-Orchesator/node"
"Saffron-Orchesator/task"
"Saffron-Orchesator/worker"
"fmt"
"github.com/golang-collections/collections/queue"
"github.com/google/uuid"
"time"
)
func main() {
t := task.Task{
ID: uuid.New(),
Name: "Task-1",
State: task.Pending,
Image: "Image-1",
Memory: 1024,
Disk: 1,
}
te := task.TaskEvent{
ID: uuid.New(),
State: task.Pending,
Timestamp: time.Now(),
Task: t,
}
fmt.Printf("task: %v\n", t)
fmt.Printf("task event: %v\n", te)
w := worker.Worker{
Name: "worker-1",
Queue: *queue.New(),
Db: make(map[uuid.UUID]*task.Task),
}
fmt.Printf("worker: %v\n", w)
w.CollectStats()
w.RunTask()
w.StartTask()
w.StopTask()
m := manager.Manager{
Pending: *queue.New(),
TaskDb: make(map[string][]*task.Task),
EventDb: make(map[string][]*task.TaskEvent),
Workers: []string{w.Name},
}
fmt.Printf("manager: %v\n", m)
m.SelectWorker()
m.UpdateTasks()
m.SendWork()
n := node.Node{
Name: "Node-1",
Ip: "192.168.1.1",
Cores: 4,
Memory: 1024,
Disk: 25,
Role: "worker",
}
fmt.Printf("node: %v\n", n)
}