forked from stripe-archive/timberlake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjob.go
153 lines (127 loc) · 3.42 KB
/
job.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package main
import "time"
type job struct {
Details *jobDetail `json:"details"`
Counters []counter `json:"counters"`
Conf conf `json:"conf"`
Tasks *tasks `json:"tasks"`
host string
complete bool
updated time.Time
}
type jobDetail struct {
ID string `json:"id"`
Name string `json:"name"`
User string `json:"user"`
State string `json:"state"`
StartTime int64 `json:"startTime"`
FinishTime int64 `json:"finishTime"`
MapsTotal int `json:"mapsTotal"`
MapProgress float32 `json:"mapProgress"`
MapsCompleted int `json:"mapsCompleted"`
MapsPending int `json:"mapsPending"`
MapsRunning int `json:"mapsRunning"`
MapsFailed int `json:"failedMapAttempts"`
MapsKilled int `json:"killedMapAttempts"`
MapsTotalTime int64 `json:"mapsTotalTime"`
ReducesTotal int `json:"reducesTotal"`
ReduceProgress float32 `json:"reduceProgress"`
ReducesCompleted int `json:"reducesCompleted"`
ReducesPending int `json:"reducesPending"`
ReducesRunning int `json:"reducesRunning"`
ReducesFailed int `json:"failedReduceAttempts"`
ReducesKilled int `json:"killedReduceAttempts"`
ReducesTotalTime int64 `json:"reducesTotalTime"`
}
type jobDetails []jobDetail
func (ds jobDetails) Len() int {
return len(ds)
}
func (ds jobDetails) Swap(i, j int) {
ds[i], ds[j] = ds[j], ds[i]
}
func (ds jobDetails) Less(i, j int) bool {
return ds[i].FinishTime < ds[j].FinishTime
}
type conf struct {
Input string `json:"input"`
Output string `json:"output"`
name string
}
type counter struct {
Name string `json:"name"`
Total int `json:"total"`
Map int `json:"map"`
Reduce int `json:"reduce"`
}
type tasks struct {
Map [][]int64 `json:"maps"`
Reduce [][]int64 `json:"reduces"`
}
type taskListByStartTime [][]int64
func (ts taskListByStartTime) Len() int {
return len(ts)
}
func (ts taskListByStartTime) Swap(i, j int) {
ts[i], ts[j] = ts[j], ts[i]
}
func (ts taskListByStartTime) Less(i, j int) bool {
return ts[i][0] < ts[j][0]
}
type taskListByDuration [][]int64
func (ts taskListByDuration) Len() int {
return len(ts)
}
func (ts taskListByDuration) Swap(i, j int) {
ts[i], ts[j] = ts[j], ts[i]
}
func (ts taskListByDuration) Less(i, j int) bool {
return (ts[i][1] - ts[i][0]) < (ts[j][1] - ts[j][0])
}
type appsResp struct {
Apps struct {
App []jobDetail `json:"app"`
} `json:"apps"`
}
type jobResp struct {
Jobs struct {
Job []jobDetail `json:"job"`
} `json:"jobs"`
Job jobDetail `json:"job"`
}
type confResp struct {
Conf struct {
Property []struct {
Name string `json:"name"`
Value string `json:"value"`
} `json:"property"`
} `json:"conf"`
}
type countersResp struct {
JobCounters struct {
CounterGroups []struct {
Name string `json:"counterGroupName"`
Counters []struct {
Name string `json:"name"`
Total int `json:"totalCounterValue"`
Map int `json:"mapCounterValue"`
Reduce int `json:"reduceCounterValue"`
} `json:"counter"`
} `json:"counterGroup"`
} `json:"jobCounters"`
}
type tasksResp struct {
Tasks struct {
Task []struct {
StartTime int64 `json:"startTime"`
FinishTime int64 `json:"finishTime"`
Type string `json:"type"`
State string `json:"state"`
} `json:"task"`
} `json:"tasks"`
}
type clusterMetricsResp struct {
Metrics struct {
Containers int `json:"containersAllocated"`
} `json:"clusterMetrics"`
}