This repository has been archived by the owner on Mar 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
job.go
132 lines (112 loc) · 3.27 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
package main
import "time"
type jobConf struct {
Conf conf `json:"conf"`
ID string `json:"id"`
Name string `json:"name"`
}
// Avoid adding additional exported fields
// as event streaming can overwhelm clients
type job struct {
Details jobDetail `json:"details"`
Counters []counter `json:"counters"`
conf conf
Tasks tasks `json:"tasks"`
running bool
partial bool
updated time.Time
Cluster string `json:"cluster"`
ResourceManagerURL string `json:"resourceManagerUrl"`
JobHistoryURL string `json:"jobHistoryUrl"`
// http://docs.cascading.org/cascading/1.2/javadoc/cascading/flow/Flow.html
FlowID *string `json:"flowID"`
}
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 counter struct {
Name string `json:"name"`
Total int `json:"total"`
Map int `json:"map"`
Reduce int `json:"reduce"`
}
type appsDetailList struct {
App []jobDetail `json:"app"`
}
type appsResp struct {
Apps appsDetailList `json:"apps"`
}
type jobsDetailList struct {
Job []jobDetail `json:"job"`
}
type jobsResp struct {
Jobs jobsDetailList `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"`
}