YARN-4023. Publish Application Priority to TimelineServer. (Sunil G via rohithsharmaks)

(cherry picked from commit 1c12adb71f)
This commit is contained in:
rohithsharmaks 2015-08-12 14:45:41 +05:30
parent d53296281a
commit c5b20e0db6
12 changed files with 69 additions and 20 deletions

View File

@ -112,6 +112,9 @@ Release 2.8.0 - UNRELEASED
YARN-3887. Support changing Application priority during runtime. (Sunil G YARN-3887. Support changing Application priority during runtime. (Sunil G
via jianhe) via jianhe)
YARN-4023. Publish Application Priority to TimelineServer. (Sunil G
via rohithsharmaks)
IMPROVEMENTS IMPROVEMENTS
YARN-644. Basic null check is not performed on passed in arguments before YARN-644. Basic null check is not performed on passed in arguments before

View File

@ -92,7 +92,7 @@ public abstract class ApplicationReport {
long startTime, long finishTime, FinalApplicationStatus finalStatus, long startTime, long finishTime, FinalApplicationStatus finalStatus,
ApplicationResourceUsageReport appResources, String origTrackingUrl, ApplicationResourceUsageReport appResources, String origTrackingUrl,
float progress, String applicationType, Token amRmToken, float progress, String applicationType, Token amRmToken,
Set<String> tags, boolean unmanagedApplication) { Set<String> tags, boolean unmanagedApplication, Priority priority) {
ApplicationReport report = ApplicationReport report =
newInstance(applicationId, applicationAttemptId, user, queue, name, newInstance(applicationId, applicationAttemptId, user, queue, name,
host, rpcPort, clientToAMToken, state, diagnostics, url, startTime, host, rpcPort, clientToAMToken, state, diagnostics, url, startTime,
@ -100,6 +100,7 @@ public abstract class ApplicationReport {
applicationType, amRmToken); applicationType, amRmToken);
report.setApplicationTags(tags); report.setApplicationTags(tags);
report.setUnmanagedApp(unmanagedApplication); report.setUnmanagedApp(unmanagedApplication);
report.setPriority(priority);
return report; return report;
} }

View File

@ -104,7 +104,7 @@ public class TestYarnCLI {
"user", "queue", "appname", "host", 124, null, "user", "queue", "appname", "host", 124, null,
YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0, YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0,
FinalApplicationStatus.SUCCEEDED, usageReport, "N/A", 0.53789f, "YARN", FinalApplicationStatus.SUCCEEDED, usageReport, "N/A", 0.53789f, "YARN",
null, null, false); null, null, false, Priority.newInstance(0));
newApplicationReport.setLogAggregationStatus(LogAggregationStatus.SUCCEEDED); newApplicationReport.setLogAggregationStatus(LogAggregationStatus.SUCCEEDED);
newApplicationReport.setPriority(Priority.newInstance(0)); newApplicationReport.setPriority(Priority.newInstance(0));
when(client.getApplicationReport(any(ApplicationId.class))).thenReturn( when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(

View File

@ -22,6 +22,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.junit.Assert; import org.junit.Assert;
@ -59,7 +60,7 @@ public class TestApplicatonReport {
"appname", "host", 124, null, YarnApplicationState.FINISHED, "appname", "host", 124, null, YarnApplicationState.FINISHED,
"diagnostics", "url", 0, 0, FinalApplicationStatus.SUCCEEDED, null, "diagnostics", "url", 0, 0, FinalApplicationStatus.SUCCEEDED, null,
"N/A", 0.53789f, YarnConfiguration.DEFAULT_APPLICATION_TYPE, null, "N/A", 0.53789f, YarnConfiguration.DEFAULT_APPLICATION_TYPE, null,
null,false); null, false, Priority.newInstance(0));
return appReport; return appReport;
} }

View File

@ -251,6 +251,7 @@ public class ApplicationHistoryManagerOnTimelineStore extends AbstractService
long createdTime = 0; long createdTime = 0;
long finishedTime = 0; long finishedTime = 0;
float progress = 0.0f; float progress = 0.0f;
int applicationPriority = 0;
ApplicationAttemptId latestApplicationAttemptId = null; ApplicationAttemptId latestApplicationAttemptId = null;
String diagnosticsInfo = null; String diagnosticsInfo = null;
FinalApplicationStatus finalStatus = FinalApplicationStatus.UNDEFINED; FinalApplicationStatus finalStatus = FinalApplicationStatus.UNDEFINED;
@ -276,10 +277,11 @@ public class ApplicationHistoryManagerOnTimelineStore extends AbstractService
if (field == ApplicationReportField.USER_AND_ACLS) { if (field == ApplicationReportField.USER_AND_ACLS) {
return new ApplicationReportExt(ApplicationReport.newInstance( return new ApplicationReportExt(ApplicationReport.newInstance(
ConverterUtils.toApplicationId(entity.getEntityId()), ConverterUtils.toApplicationId(entity.getEntityId()),
latestApplicationAttemptId, user, queue, name, null, -1, null, state, latestApplicationAttemptId, user, queue, name, null, -1, null,
diagnosticsInfo, null, createdTime, finishedTime, finalStatus, null, state, diagnosticsInfo, null, createdTime, finishedTime,
null, progress, type, null, appTags, finalStatus, null, null, progress, type, null, appTags,
unmanagedApplication), appViewACLs); unmanagedApplication, Priority.newInstance(applicationPriority)),
appViewACLs);
} }
if (entityInfo.containsKey(ApplicationMetricsConstants.QUEUE_ENTITY_INFO)) { if (entityInfo.containsKey(ApplicationMetricsConstants.QUEUE_ENTITY_INFO)) {
queue = queue =
@ -303,6 +305,11 @@ public class ApplicationHistoryManagerOnTimelineStore extends AbstractService
ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO) ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO)
.toString()); .toString());
} }
if (entityInfo
.containsKey(ApplicationMetricsConstants.APPLICATION_PRIORITY_INFO)) {
applicationPriority = Integer.parseInt(entityInfo.get(
ApplicationMetricsConstants.APPLICATION_PRIORITY_INFO).toString());
}
if (entityInfo.containsKey(ApplicationMetricsConstants.APP_CPU_METRICS)) { if (entityInfo.containsKey(ApplicationMetricsConstants.APP_CPU_METRICS)) {
long vcoreSeconds=Long.parseLong(entityInfo.get( long vcoreSeconds=Long.parseLong(entityInfo.get(
ApplicationMetricsConstants.APP_CPU_METRICS).toString()); ApplicationMetricsConstants.APP_CPU_METRICS).toString());
@ -373,8 +380,10 @@ public class ApplicationHistoryManagerOnTimelineStore extends AbstractService
return new ApplicationReportExt(ApplicationReport.newInstance( return new ApplicationReportExt(ApplicationReport.newInstance(
ConverterUtils.toApplicationId(entity.getEntityId()), ConverterUtils.toApplicationId(entity.getEntityId()),
latestApplicationAttemptId, user, queue, name, null, -1, null, state, latestApplicationAttemptId, user, queue, name, null, -1, null, state,
diagnosticsInfo, null, createdTime, finishedTime, finalStatus, appResources, diagnosticsInfo, null, createdTime, finishedTime, finalStatus,
null, progress, type, null, appTags, unmanagedApplication), appViewACLs); appResources, null, progress, type, null, appTags,
unmanagedApplication, Priority.newInstance(applicationPriority)),
appViewACLs);
} }
private static ApplicationAttemptReport convertToApplicationAttemptReport( private static ApplicationAttemptReport convertToApplicationAttemptReport(

View File

@ -477,6 +477,8 @@ public class TestApplicationHistoryManagerOnTimelineStore {
entityInfo.put(ApplicationMetricsConstants.QUEUE_ENTITY_INFO, "test queue"); entityInfo.put(ApplicationMetricsConstants.QUEUE_ENTITY_INFO, "test queue");
entityInfo.put( entityInfo.put(
ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO, "false"); ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO, "false");
entityInfo.put(ApplicationMetricsConstants.APPLICATION_PRIORITY_INFO,
Priority.newInstance(0));
entityInfo.put(ApplicationMetricsConstants.SUBMITTED_TIME_ENTITY_INFO, entityInfo.put(ApplicationMetricsConstants.SUBMITTED_TIME_ENTITY_INFO,
Integer.MAX_VALUE + 1L); Integer.MAX_VALUE + 1L);
entityInfo.put(ApplicationMetricsConstants.APP_MEM_METRICS,123); entityInfo.put(ApplicationMetricsConstants.APP_MEM_METRICS,123);

View File

@ -77,4 +77,7 @@ public class ApplicationMetricsConstants {
public static final String UNMANAGED_APPLICATION_ENTITY_INFO = public static final String UNMANAGED_APPLICATION_ENTITY_INFO =
"YARN_APPLICATION_UNMANAGED_APPLICATION"; "YARN_APPLICATION_UNMANAGED_APPLICATION";
public static final String APPLICATION_PRIORITY_INFO =
"YARN_APPLICATION_PRIORITY";
} }

View File

@ -144,10 +144,10 @@ public class AppsBlock extends HtmlBlock {
TBODY<TABLE<Hamlet>> tbody = TBODY<TABLE<Hamlet>> tbody =
html.table("#apps").thead().tr().th(".id", "ID").th(".user", "User") html.table("#apps").thead().tr().th(".id", "ID").th(".user", "User")
.th(".name", "Name").th(".type", "Application Type") .th(".name", "Name").th(".type", "Application Type")
.th(".queue", "Queue").th(".starttime", "StartTime") .th(".queue", "Queue").th(".priority", "Application Priority")
.th(".finishtime", "FinishTime").th(".state", "State") .th(".starttime", "StartTime").th(".finishtime", "FinishTime")
.th(".finalstatus", "FinalStatus").th(".progress", "Progress") .th(".state", "State").th(".finalstatus", "FinalStatus")
.th(".ui", "Tracking UI")._()._().tbody(); .th(".progress", "Progress").th(".ui", "Tracking UI")._()._().tbody();
StringBuilder appsTableData = new StringBuilder("[\n"); StringBuilder appsTableData = new StringBuilder("[\n");
for (ApplicationReport appReport : appReports) { for (ApplicationReport appReport : appReports) {
@ -180,7 +180,9 @@ public class AppsBlock extends HtmlBlock {
.append("\",\"") .append("\",\"")
.append( .append(
StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app
.getQueue()))).append("\",\"").append(app.getStartedTime()) .getQueue()))).append("\",\"").append(String
.valueOf(app.getPriority()))
.append("\",\"").append(app.getStartedTime())
.append("\",\"").append(app.getFinishedTime()) .append("\",\"").append(app.getFinishedTime())
.append("\",\"") .append("\",\"")
.append(app.getAppState() == null ? UNAVAILABLE : app.getAppState()) .append(app.getAppState() == null ? UNAVAILABLE : app.getAppState())

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.metrics;
import java.util.Set; import java.util.Set;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.Priority;
public class ApplicationCreatedEvent extends public class ApplicationCreatedEvent extends
SystemMetricsEvent { SystemMetricsEvent {
@ -33,6 +34,7 @@ public class ApplicationCreatedEvent extends
private long submittedTime; private long submittedTime;
private Set<String> appTags; private Set<String> appTags;
private boolean unmanagedApplication; private boolean unmanagedApplication;
private Priority applicationPriority;
public ApplicationCreatedEvent(ApplicationId appId, public ApplicationCreatedEvent(ApplicationId appId,
String name, String name,
@ -42,7 +44,8 @@ public class ApplicationCreatedEvent extends
long submittedTime, long submittedTime,
long createdTime, long createdTime,
Set<String> appTags, Set<String> appTags,
boolean unmanagedApplication) { boolean unmanagedApplication,
Priority applicationPriority) {
super(SystemMetricsEventType.APP_CREATED, createdTime); super(SystemMetricsEventType.APP_CREATED, createdTime);
this.appId = appId; this.appId = appId;
this.name = name; this.name = name;
@ -52,6 +55,7 @@ public class ApplicationCreatedEvent extends
this.submittedTime = submittedTime; this.submittedTime = submittedTime;
this.appTags = appTags; this.appTags = appTags;
this.unmanagedApplication = unmanagedApplication; this.unmanagedApplication = unmanagedApplication;
this.applicationPriority = applicationPriority;
} }
@Override @Override
@ -90,4 +94,8 @@ public class ApplicationCreatedEvent extends
public boolean isUnmanagedApp() { public boolean isUnmanagedApp() {
return unmanagedApplication; return unmanagedApplication;
} }
public Priority getApplicationPriority() {
return applicationPriority;
}
} }

View File

@ -107,7 +107,8 @@ public class SystemMetricsPublisher extends CompositeService {
app.getQueue(), app.getQueue(),
app.getSubmitTime(), app.getSubmitTime(),
createdTime, app.getApplicationTags(), createdTime, app.getApplicationTags(),
app.getApplicationSubmissionContext().getUnmanagedAM())); app.getApplicationSubmissionContext().getUnmanagedAM(),
app.getApplicationSubmissionContext().getPriority()));
} }
} }
@ -257,6 +258,8 @@ public class SystemMetricsPublisher extends CompositeService {
entityInfo.put( entityInfo.put(
ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO, ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO,
event.isUnmanagedApp()); event.isUnmanagedApp());
entityInfo.put(ApplicationMetricsConstants.APPLICATION_PRIORITY_INFO,
event.getApplicationPriority().getPriority());
entity.setOtherInfo(entityInfo); entity.setOtherInfo(entityInfo);
TimelineEvent tEvent = new TimelineEvent(); TimelineEvent tEvent = new TimelineEvent();
tEvent.setEventType( tEvent.setEventType(

View File

@ -141,6 +141,11 @@ public class TestSystemMetricsPublisher {
entity.getOtherInfo().get( entity.getOtherInfo().get(
ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO)); ApplicationMetricsConstants.UNMANAGED_APPLICATION_ENTITY_INFO));
Assert.assertEquals(
app.getApplicationSubmissionContext().getPriority().getPriority(),
entity.getOtherInfo().get(
ApplicationMetricsConstants.APPLICATION_PRIORITY_INFO));
Assert Assert
.assertEquals( .assertEquals(
app.getUser(), app.getUser(),
@ -371,6 +376,7 @@ public class TestSystemMetricsPublisher {
when(app.getApplicationTags()).thenReturn(appTags); when(app.getApplicationTags()).thenReturn(appTags);
ApplicationSubmissionContext asc = mock(ApplicationSubmissionContext.class); ApplicationSubmissionContext asc = mock(ApplicationSubmissionContext.class);
when(asc.getUnmanagedAM()).thenReturn(false); when(asc.getUnmanagedAM()).thenReturn(false);
when(asc.getPriority()).thenReturn(Priority.newInstance(0));
when(app.getApplicationSubmissionContext()).thenReturn(asc); when(app.getApplicationSubmissionContext()).thenReturn(asc);
return app; return app;
} }

View File

@ -1088,7 +1088,8 @@ Response Body:
"startedTime":1430425001004, "startedTime":1430425001004,
"finishedTime":1430425008861, "finishedTime":1430425008861,
"elapsedTime":7857, "elapsedTime":7857,
"unmanagedApplication":"false"}, "unmanagedApplication":"false",
"applicationPriority":0},
{ {
"appId":"application_1430424020775_0003", "appId":"application_1430424020775_0003",
"currentAppAttemptId":"appattempt_1430424020775_0003_000001", "currentAppAttemptId":"appattempt_1430424020775_0003_000001",
@ -1108,7 +1109,8 @@ Response Body:
"startedTime":1430424956650, "startedTime":1430424956650,
"finishedTime":1430424963907, "finishedTime":1430424963907,
"elapsedTime":7257, "elapsedTime":7257,
"unmanagedApplication":"false"}, "unmanagedApplication":"false",
"applicationPriority":0},
{ {
"appId":"application_1430424020775_0002", "appId":"application_1430424020775_0002",
"currentAppAttemptId":"appattempt_1430424020775_0002_000001", "currentAppAttemptId":"appattempt_1430424020775_0002_000001",
@ -1128,7 +1130,8 @@ Response Body:
"startedTime":1430424769395, "startedTime":1430424769395,
"finishedTime":1430424776594, "finishedTime":1430424776594,
"elapsedTime":7199, "elapsedTime":7199,
"unmanagedApplication":"false"}, "unmanagedApplication":"false",
"applicationPriority":0},
{ {
"appId":"application_1430424020775_0001", "appId":"application_1430424020775_0001",
"currentAppAttemptId":"appattempt_1430424020775_0001_000001", "currentAppAttemptId":"appattempt_1430424020775_0001_000001",
@ -1149,7 +1152,8 @@ Response Body:
"finishedTime":1430424776594, "finishedTime":1430424776594,
"elapsedTime":18344, "elapsedTime":18344,
"applicationTags":"mrapplication,ta-example", "applicationTags":"mrapplication,ta-example",
"unmanagedApplication":"false" "unmanagedApplication":"false",
"applicationPriority":0
} }
] ]
} }
@ -1192,6 +1196,7 @@ Response Body:
<finishedTime>1430425008861</finishedTime> <finishedTime>1430425008861</finishedTime>
<elapsedTime>7857</elapsedTime> <elapsedTime>7857</elapsedTime>
<unmanagedApplication>false</unmanagedApplication> <unmanagedApplication>false</unmanagedApplication>
<applicationPriority>0</applicationPriority>
</app> </app>
<app> <app>
<appId>application_1430424020775_0003</appId> <appId>application_1430424020775_0003</appId>
@ -1213,6 +1218,7 @@ Response Body:
<finishedTime>1430424963907</finishedTime> <finishedTime>1430424963907</finishedTime>
<elapsedTime>7257</elapsedTime> <elapsedTime>7257</elapsedTime>
<unmanagedApplication>false</unmanagedApplication> <unmanagedApplication>false</unmanagedApplication>
<applicationPriority>0</applicationPriority>
</app> </app>
<app> <app>
<appId>application_1430424020775_0002</appId> <appId>application_1430424020775_0002</appId>
@ -1234,6 +1240,7 @@ Response Body:
<finishedTime>1430424776594</finishedTime> <finishedTime>1430424776594</finishedTime>
<elapsedTime>7199</elapsedTime> <elapsedTime>7199</elapsedTime>
<unmanagedApplication>false</unmanagedApplication> <unmanagedApplication>false</unmanagedApplication>
<applicationPriority>0</applicationPriority>
</app> </app>
<app> <app>
<appId>application_1430424020775_0001</appId> <appId>application_1430424020775_0001</appId>
@ -1256,6 +1263,7 @@ Response Body:
<elapsedTime>18344</elapsedTime> <elapsedTime>18344</elapsedTime>
<applicationTags>mrapplication,ta-example</applicationTags> <applicationTags>mrapplication,ta-example</applicationTags>
<unmanagedApplication>false</unmanagedApplication> <unmanagedApplication>false</unmanagedApplication>
<applicationPriority>0</applicationPriority>
</app> </app>
</apps> </apps>
@ -1307,6 +1315,7 @@ None
| `rpcPort` | int | The RPC port of the ApplicationMaster; zero if no IPC service declared | | `rpcPort` | int | The RPC port of the ApplicationMaster; zero if no IPC service declared |
| `applicationTags` | string | The application tags. | | `applicationTags` | string | The application tags. |
| `unmanagedApplication` | boolean | Is the application unmanaged. | | `unmanagedApplication` | boolean | Is the application unmanaged. |
| `applicationPriority` | int | Priority of the submitted application. |
### Response Examples: ### Response Examples:
@ -1345,6 +1354,7 @@ Response Body:
"elapsedTime": 18344, "elapsedTime": 18344,
"applicationTags": mrapplication,tag-example, "applicationTags": mrapplication,tag-example,
"unmanagedApplication":"false" "unmanagedApplication":"false"
"applicationPriority":0
} }
#### XML response #### XML response
@ -1384,6 +1394,7 @@ Response Body:
<elapsedTime>18344</elapsedTime> <elapsedTime>18344</elapsedTime>
<applicationTags>mrapplication,ta-example</applicationTags> <applicationTags>mrapplication,ta-example</applicationTags>
<unmanagedApplication>false</unmanagedApplication> <unmanagedApplication>false</unmanagedApplication>
<applicationPriority>0</applicationPriority>
</app> </app>
## <a name="REST_API_APPLICATION_ATTEMPT_LIST"></a>Application Attempt List ## <a name="REST_API_APPLICATION_ATTEMPT_LIST"></a>Application Attempt List