Hadoop YARN自带了一系列的web service REST API,我们可以通过这些web service访问集群(cluster)、节点(nodes)、应用(application)以及应用的历史信息。根据API返回的类型,这些URL源归会类到不同的组。一些API返回collector类型的,有些返回singleton类型。这些web service REST API的语法如下:
1
|
http:
//{http address of service}/ws/{version}/{resourcepath}
|
其中,{http address of service}是我们需要获取信息的服务器地址,目前支持访问ResourceManager, NodeManager,MapReduce application master, and history server;{version}是这些API的版本,目前只支持v1;{resourcepath}定义singleton资源或者collection资源的路径.
下面举例说明这些web service怎么用。
假设你有一个application_1388830974669_1540349作业,并且运行完了。可以通过下面的命令得到这个作业的一些信息:
1
2
|
$ curl --compressed -H
"Accept: application/json"
-X \
GET
"http://host.domain.com:8088/ws/v1/cluster/apps/application_1326821518301_0010"
|
上面的运行结果是返回一个Json格式的,如下:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
|
{
"app"
: {
"finishedTime"
:
0
,
"amContainerLogs"
:
"http://host.domain.com:8042/node/containerlogs/container_1326821518301_0010_01_000001"
,
"trackingUI"
:
"ApplicationMaster"
,
"state"
:
"RUNNING"
,
"user"
:
"user1"
,
"id"
:
"application_1326821518301_0010"
,
"clusterId"
:
1326821518301
,
"finalStatus"
:
"UNDEFINED"
,
"amHostHttpAddress"
:
"host.domain.com:8042"
,
"progress"
:
82.44703
,
"name"
:
"Sleep job"
,
"startedTime"
:
1326860715335
,
"elapsedTime"
:
31814
,
"diagnostics"
:
""
,
"trackingUrl"
:
"http://host.domain.com:8088/proxy/application_1326821518301_0010/"
,
"queue"
:
"a1"
}
}
|
根据这些信息,用户可以获取到更多关于application_1326821518301_0010的信息,比如大家可以通过上面Json中的trackingUrl从ResourceManage中得到更进一步的信息:
01
02
03
04
05
06
07
08
09
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
|
$ curl --compressed -H
"Accept: application/json"
-X \
GET
"http://host.domain.com:8088/proxy/application_1326821518301_0010/ws/v1/mapreduce/jobs"
{
"jobs"
: {
"job"
: [
{
"runningReduceAttempts"
:
1
,
"reduceProgress"
:
72.104515
,
"failedReduceAttempts"
:
0
,
"newMapAttempts"
:
0
,
"mapsRunning"
:
0
,
"state"
:
"RUNNING"
,
"successfulReduceAttempts"
:
0
,
"reducesRunning"
:
1
,
"acls"
: [
{
"value"
:
" "
,
"name"
:
"mapreduce.job.acl-modify-job"
},
{
"value"
:
" "
,
"name"
:
"mapreduce.job.acl-view-job"
}
],
"reducesPending"
:
0
,
"user"
:
"user1"
,
"reducesTotal"
:
1
,
"mapsCompleted"
:
1
,
"startTime"
:
1326860720902
,
"id"
:
"job_1326821518301_10_10"
,
"successfulMapAttempts"
:
1
,
"runningMapAttempts"
:
0
,
"newReduceAttempts"
:
0
,
"name"
:
"Sleep job"
,
"mapsPending"
:
0
,
"elapsedTime"
:
64432
,
"reducesCompleted"
:
0
,
"mapProgress"
:
100
,
"diagnostics"
:
""
,
"failedMapAttempts"
:
0
,
"killedReduceAttempts"
:
0
,
"mapsTotal"
:
1
,
"uberized"
:
false
,
"killedMapAttempts"
:
0
,
"finishTime"
:
0
}
]
}
}
|
如果用户希望得到上述job id为job_1326821518301_10_10作业的一些task信息可以用下面命令执行:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
$ curl --compressed -H
"Accept: application/json"
-X \
GET
"http://host.domain.com:8088/proxy/application_1326821518301_0010/ws/v1/mapreduce/jobs/job_1326821518301_10_10/tasks"
输出:
{
"tasks"
: {
"task"
: [
{
"progress"
:
100
,
"elapsedTime"
:
5059
,
"state"
:
"SUCCEEDED"
,
"startTime"
:
1326860725014
,
"id"
:
"task_1326821518301_10_10_m_0"
,
"type"
:
"MAP"
,
"successfulAttempt"
:
"attempt_1326821518301_10_10_m_0_0"
,
"finishTime"
:
1326860730073
},
{
"progress"
:
72.104515
,
"elapsedTime"
:
0
,
"state"
:
"RUNNING"
,
"startTime"
:
1326860732984
,
"id"
:
"task_1326821518301_10_10_r_0"
,
"type"
:
"REDUCE"
,
"successfulAttempt"
:
""
,
"finishTime"
:
0
}
]
}
}
|
送上面可以看出,map任务已经完成了,但是reduce任务还在跑。如果用户需要看一下task_1326821518301_10_10_r_0 task的信息,可以用下面的命令:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
$ curl --compressed -X \
GET "http:
//host.domain.com:8088/proxy/application_1326821518301_0010/ws/v1/ \
mapreduce/jobs/job_1326821518301_10_10/tasks/task_1326821518301_10_10_r_0/attempts"
输出:
{
"taskAttempts"
: {
"taskAttempt"
: [
{
"elapsedMergeTime"
:
158
,
"shuffleFinishTime"
:
1326860735378
,
"assignedContainerId"
:
"container_1326821518301_0010_01_000003"
,
"progress"
:
72.104515
,
"elapsedTime"
:
0
,
"state"
:
"RUNNING"
,
"elapsedShuffleTime"
:
2394
,
"mergeFinishTime"
:
1326860735536
,
"rack"
:
"/10.10.10.0"
,
"elapsedReduceTime"
:
0
,
"nodeHttpAddress"
:
"host.domain.com:8042"
,
"type"
:
"REDUCE"
,
"startTime"
:
1326860732984
,
"id"
:
"attempt_1326821518301_10_10_r_0_0"
,
"finishTime"
:
0
}
]
}
}
|
reduce attempt 还在运行,如果用户需要查看对应的attempt当前的counter values,可以用下面命令:
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
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
154
155
156
157
158
159
160
161
|
$ curl --compressed -H
"Accept: application/json"
-X GET \
"http:
//host.domain.com:8088/proxy/application_1326821518301_0010/ws/v1/mapreduce \
/jobs/job_1326821518301_10_10/tasks/task_1326821518301_10_10_r_0/attempts \
/attempt_1326821518301_10_10_r_0_0/counters"
输出:
{
"JobTaskAttemptCounters"
: {
"taskAttemptCounterGroup"
: [
{
"counterGroupName"
:
"org.apache.hadoop.mapreduce.FileSystemCounter"
,
"counter"
: [
{
"value"
:
4216
,
"name"
:
"FILE_BYTES_READ"
},
{
"value"
:
77151
,
"name"
:
"FILE_BYTES_WRITTEN"
},
{
"value"
:
0
,
"name"
:
"FILE_READ_OPS"
},
{
"value"
:
0
,
"name"
:
"FILE_LARGE_READ_OPS"
},
{
"value"
:
0
,
"name"
:
"FILE_WRITE_OPS"
},
{
"value"
:
0
,
"name"
:
"HDFS_BYTES_READ"
},
{
"value"
:
0
,
"name"
:
"HDFS_BYTES_WRITTEN"
},
{
"value"
:
0
,
|