标签:sed 结构 led 配置文件 context 6.2 triple 追踪 als
public static void getClusterInfo() throws Exception{ String url = "http://10.3.242.99:8088/ws/v1/cluster"; InputStream response = new URL(url).openStream(); Scanner scanner = new Scanner(response); String responseBody = scanner.useDelimiter("\\A").next(); System.out.println(responseBody); }
返回Json:
{ "clusterInfo": { "id": 1497756603270, "startedOn": 1497756603270, "state": "STARTED", "haState": "ACTIVE", "rmStateStoreName": "org.apache.hadoop.yarn.server.resourcemanager.recovery.NullRMStateStore", "resourceManagerVersion": "2.6.2", "resourceManagerBuildVersion": "2.6.2 from 0cfd050febe4a30b1ee1551dcc527589509fb681 by jenkins source checksum d07deb9ef36deb791d0e2451db849d", "resourceManagerVersionBuiltOn": "2015-10-22T00:49Z", "hadoopVersion": "2.6.2", "hadoopBuildVersion": "2.6.2 from 0cfd050febe4a30b1ee1551dcc527589509fb681 by jenkins source checksum f9ebb94bf5bf9bec892825ede28baca", "hadoopVersionBuiltOn": "2015-10-22T00:42Z", "haZooKeeperConnectionState": "ResourceManager HA is not enabled." } }
【TBD:haStatus,关于RM的HA。】
public static void getClusterMetrics() throws Exception{ String url = "http://10.3.242.99:8088/ws/v1/cluster/metrics"; InputStream response = new URL(url).openStream(); Scanner scanner = new Scanner(response); String responseBody = scanner.useDelimiter("\\A").next(); System.out.println(responseBody); }
return json:
{ "clusterMetrics": { "appsSubmitted": 0, "appsCompleted": 0, "appsPending": 0, "appsRunning": 0, "appsFailed": 0, "appsKilled": 0, "reservedMB": 0, "availableMB": 32768, "allocatedMB": 0, "reservedVirtualCores": 0, "availableVirtualCores": 8, "allocatedVirtualCores": 0, "containersAllocated": 0, "containersReserved": 0, "containersPending": 0, "totalMB": 32768, "totalVirtualCores": 8, "totalNodes": 1, "lostNodes": 0, "unhealthyNodes": 0, "decommissionedNodes": 0, "rebootedNodes": 0, "activeNodes": 1 } }
String clusterSchedulerUrl = "http://10.3.242.99:8088/ws/v1/cluster/scheduler"; YarnRestAPI.httpGet(clusterSchedulerUrl);
return json:
{ "scheduler": { "schedulerInfo": { "type": "capacityScheduler", "capacity": 100, "usedCapacity": 0, "maxCapacity": 100, "queueName": "root", "queues": { "queue": [ { "type": "capacitySchedulerLeafQueueInfo", "capacity": 100, "usedCapacity": 0, "maxCapacity": 100, "absoluteCapacity": 100, "absoluteMaxCapacity": 100, "absoluteUsedCapacity": 0, "numApplications": 0, "queueName": "default", "state": "RUNNING", "resourcesUsed": { "memory": 0, "vCores": 0 }, "hideReservationQueues": false, "nodeLabels": [ "*" ], "numActiveApplications": 0, "numPendingApplications": 0, "numContainers": 0, "maxApplications": 10000, "maxApplicationsPerUser": 10000, "userLimit": 100, "users": null, "userLimitFactor": 1, "aMResourceLimit": { "memory": 4096, "vCores": 1 }, "userAMResourceLimit": { "memory": 4096, "vCores": 1 } } ] } } } }
从返回的json可以看到,使用的capacityScheduler,其内有一个queues数组。
String clusterAppUrl = "http://10.3.242.99:8088/ws/v1/cluster/apps"; YarnRestAPI.httpGet(clusterAppUrl);
return json:
{ "apps": { "app": [ { "id": "application_1497756603270_0002", "user": "root", "name": "word count", "queue": "default", "state": "FINISHED", "finalStatus": "SUCCEEDED", "progress": 100, "trackingUI": "History", "trackingUrl": "http://host99:8088/proxy/application_1497756603270_0002/", "diagnostics": "", "clusterId": 1497756603270, "applicationType": "MAPREDUCE", "applicationTags": "", "startedTime": 1497784937984, "finishedTime": 1497784954421, "elapsedTime": 16437, "amContainerLogs": "http://host99:8042/node/containerlogs/container_1497756603270_0002_01_000001/root", "amHostHttpAddress": "host99:8042", "allocatedMB": 2048, "allocatedVCores": 1, "runningContainers": 1, "memorySeconds": 239770, "vcoreSeconds": 29, "preemptedResourceMB": 0, "preemptedResourceVCores": 0, "numNonAMContainerPreempted": 0, "numAMContainerPreempted": 0 }, { "id": "application_1497756603270_0001", "user": "root", "name": "word count", "queue": "default", "state": "FINISHED", "finalStatus": "SUCCEEDED", "progress": 100, "trackingUI": "History", "trackingUrl": "http://host99:8088/proxy/application_1497756603270_0001/", "diagnostics": "", "clusterId": 1497756603270, "applicationType": "MAPREDUCE", "applicationTags": "", "startedTime": 1497784895511, "finishedTime": 1497784913807, "elapsedTime": 18296, "amContainerLogs": "http://host99:8042/node/containerlogs/container_1497756603270_0001_01_000001/root", "amHostHttpAddress": "host99:8042", "allocatedMB": -1, "allocatedVCores": -1, "runningContainers": -1, "memorySeconds": 255182, "vcoreSeconds": 34, "preemptedResourceMB": 0, "preemptedResourceVCores": 0, "numNonAMContainerPreempted": 0, "numAMContainerPreempted": 0 } ] } }
String appMetricsUrl = "http://10.3.242.99:8088/ws/v1/cluster/appstatistics"; YarnRestAPI.httpGet(appMetricsUrl);
return json:
{ "appStatInfo": { "statItem": [ { "state": "RUNNING", "type": "*", "count": 0 }, { "state": "ACCEPTED", "type": "*", "count": 0 }, { "state": "NEW_SAVING", "type": "*", "count": 0 }, { "state": "NEW", "type": "*", "count": 0 }, { "state": "KILLED", "type": "*", "count": 0 }, { "state": "FINISHED", "type": "*", "count": 2 }, { "state": "FAILED", "type": "*", "count": 0 }, { "state": "SUBMITTED", "type": "*", "count": 0 } ] } }
String appUrl = "http://10.3.242.99:8088/ws/v1/cluster/apps/application_1497756603270_0002"; YarnRestAPI.httpGet(appUrl);
return json:
{ "app": { "id": "application_1497756603270_0002", "user": "root", "name": "word count", "queue": "default", "state": "FINISHED", "finalStatus": "SUCCEEDED", "progress": 100, "trackingUI": "History", "trackingUrl": "http://host99:8088/proxy/application_1497756603270_0002/", "diagnostics": "", "clusterId": 1497756603270, "applicationType": "MAPREDUCE", "applicationTags": "", "startedTime": 1497784937984, "finishedTime": 1497784954421, "elapsedTime": 16437, "amContainerLogs": "http://host99:8042/node/containerlogs/container_1497756603270_0002_01_000001/root", "amHostHttpAddress": "host99:8042", "allocatedMB": -1, "allocatedVCores": -1, "runningContainers": -1, "memorySeconds": 241431, "vcoreSeconds": 30, "preemptedResourceMB": 0, "preemptedResourceVCores": 0, "numNonAMContainerPreempted": 0, "numAMContainerPreempted": 0 } }
<YaRN><Official doc><RM REST API's>
标签:sed 结构 led 配置文件 context 6.2 triple 追踪 als
原文地址:http://www.cnblogs.com/wttttt/p/7045107.html