YARN-2780. Log aggregated resource allocation in rm-appsummary.log. Contributed by Eric Payne

(cherry picked from commit f8aefa5e9c)
This commit is contained in:
Jason Lowe 2014-11-12 17:01:15 +00:00
parent d863f54f57
commit 6984d899e3
3 changed files with 22 additions and 2 deletions

View File

@ -41,6 +41,9 @@ Release 2.7.0 - UNRELEASED
YARN-570. Time strings are formated in different timezone. YARN-570. Time strings are formated in different timezone.
(Akira Ajisaka and Peng Zhang via kasha) (Akira Ajisaka and Peng Zhang via kasha)
YARN-2780. Log aggregated resource allocation in rm-appsummary.log (Eric
Payne via jlowe)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -47,6 +47,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEventType; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEventType;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppImpl; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppImpl;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppRecoverEvent; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppRecoverEvent;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppRejectedEvent; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppRejectedEvent;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
@ -155,6 +156,7 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
trackingUrl = attempt.getTrackingUrl(); trackingUrl = attempt.getTrackingUrl();
host = attempt.getHost(); host = attempt.getHost();
} }
RMAppMetrics metrics = app.getRMAppMetrics();
SummaryBuilder summary = new SummaryBuilder() SummaryBuilder summary = new SummaryBuilder()
.add("appId", app.getApplicationId()) .add("appId", app.getApplicationId())
.add("name", app.getName()) .add("name", app.getName())
@ -165,7 +167,12 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
.add("appMasterHost", host) .add("appMasterHost", host)
.add("startTime", app.getStartTime()) .add("startTime", app.getStartTime())
.add("finishTime", app.getFinishTime()) .add("finishTime", app.getFinishTime())
.add("finalStatus", app.getFinalApplicationStatus()); .add("finalStatus", app.getFinalApplicationStatus())
.add("memorySeconds", metrics.getMemorySeconds())
.add("vcoreSeconds", metrics.getVcoreSeconds())
.add("preemptedAMContainers", metrics.getNumAMContainersPreempted())
.add("preemptedNonAMContainers", metrics.getNumNonAMContainersPreempted())
.add("preemptedResources", metrics.getResourcePreempted());
return summary; return summary;
} }

View File

@ -59,6 +59,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.MockRMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEventType; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEventType;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AMLivelinessMonitor; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AMLivelinessMonitor;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.ContainerAllocationExpirer; import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.ContainerAllocationExpirer;
@ -572,6 +573,10 @@ public class TestAppManager{
when(app.getQueue()).thenReturn("Multiline\n\n\r\rQueueName"); when(app.getQueue()).thenReturn("Multiline\n\n\r\rQueueName");
when(app.getState()).thenReturn(RMAppState.RUNNING); when(app.getState()).thenReturn(RMAppState.RUNNING);
RMAppMetrics metrics =
new RMAppMetrics(Resource.newInstance(1234, 56), 10, 1, 16384, 64);
when(app.getRMAppMetrics()).thenReturn(metrics);
RMAppManager.ApplicationSummary.SummaryBuilder summary = RMAppManager.ApplicationSummary.SummaryBuilder summary =
new RMAppManager.ApplicationSummary().createAppSummary(app); new RMAppManager.ApplicationSummary().createAppSummary(app);
String msg = summary.toString(); String msg = summary.toString();
@ -583,7 +588,12 @@ public class TestAppManager{
Assert.assertTrue(msg.contains("Multiline" + escaped +"AppName")); Assert.assertTrue(msg.contains("Multiline" + escaped +"AppName"));
Assert.assertTrue(msg.contains("Multiline" + escaped +"UserName")); Assert.assertTrue(msg.contains("Multiline" + escaped +"UserName"));
Assert.assertTrue(msg.contains("Multiline" + escaped +"QueueName")); Assert.assertTrue(msg.contains("Multiline" + escaped +"QueueName"));
} Assert.assertTrue(msg.contains("memorySeconds=16384"));
Assert.assertTrue(msg.contains("vcoreSeconds=64"));
Assert.assertTrue(msg.contains("preemptedAMContainers=1"));
Assert.assertTrue(msg.contains("preemptedNonAMContainers=10"));
Assert.assertTrue(msg.contains("preemptedResources=<memory:1234\\, vCores:56>"));
}
private static ResourceScheduler mockResourceScheduler() { private static ResourceScheduler mockResourceScheduler() {
ResourceScheduler scheduler = mock(ResourceScheduler.class); ResourceScheduler scheduler = mock(ResourceScheduler.class);