-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathframework.go
68 lines (55 loc) · 1.84 KB
/
framework.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
68
package mesos
import (
"strings"
"fmt"
)
type Framework struct {
Id string `json:"id"`
Name string `json:"name"`
Active bool `json:"active"`
HostName string `json:"hostname"`
Resources *Resource `json:"resources"`
OfferedResources *Resource `json:"offered_resources"`
UsedResources *Resource `json:"used_resources"`
Tasks []*Task `json:"tasks"`
CompletedTasks []*Task `json:"completed_tasks"`
Executors []*Executor `json:"executors"`
}
type Executor struct {
Id string `json:"id"`
Name string `json:"name"`
SlaveId string `json:"slave_id"`
State string `json:"state"`
Container string `json:"container"`
Resources *Resource `json:"resources"`
Tasks []*Task `json:"tasks"`
}
type Task struct {
Id string `json:"id"`
Name string `json:"name"`
Resources *Resource `json:"resources"`
SlaveId string `json:"slave_id"`
State string `json:"state"`
Statuses []*Status `json:"statuses"`
}
type Status struct {
State string `json:"state"`
Timestamp float64 `json:"timestamp"`
}
type Resource struct {
Cpus float32 `json:"cpus"`
Disk float32 `json:"disk"`
Mem float32 `json:"mem"`
Ports string `json:"ports"`
}
func (e *Executor) RegisteredContainerName(t *Task) (string) {
return fmt.Sprintf("mesos-%s.%s", t.SlaveId, e.Container)
}
func (t *Task) AppId() (string) {
idParts := strings.Split(t.Name, ".")
for i, j := 0, len(idParts)-1; i < j; i, j = i+1, j-1 {
idParts[i], idParts[j] = idParts[j], idParts[i]
}
id := strings.Join(idParts, "/")
return fmt.Sprintf("/%s", id)
}