YARN-1424. RMAppAttemptImpl should return the DummyApplicationResourceUsageReport for all invalid accesses. (Ray Chiang via kasha)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1601745 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
74a6db7b27
commit
d4d1ccc992
|
@ -136,6 +136,10 @@ Release 2.5.0 - UNRELEASED
|
||||||
|
|
||||||
YARN-2030. Augmented RMStateStore with state machine.(Binglin Chang via jianhe)
|
YARN-2030. Augmented RMStateStore with state machine.(Binglin Chang via jianhe)
|
||||||
|
|
||||||
|
YARN-1424. RMAppAttemptImpl should return the
|
||||||
|
DummyApplicationResourceUsageReport for all invalid accesses.
|
||||||
|
(Ray Chiang via kasha)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -47,7 +47,7 @@ public abstract class ApplicationResourceUsageReport {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of used containers
|
* Get the number of used containers. -1 for invalid/inaccessible reports.
|
||||||
* @return the number of used containers
|
* @return the number of used containers
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
|
@ -63,7 +63,7 @@ public abstract class ApplicationResourceUsageReport {
|
||||||
public abstract void setNumUsedContainers(int num_containers);
|
public abstract void setNumUsedContainers(int num_containers);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of reserved containers
|
* Get the number of reserved containers. -1 for invalid/inaccessible reports.
|
||||||
* @return the number of reserved containers
|
* @return the number of reserved containers
|
||||||
*/
|
*/
|
||||||
@Private
|
@Private
|
||||||
|
@ -79,7 +79,7 @@ public abstract class ApplicationResourceUsageReport {
|
||||||
public abstract void setNumReservedContainers(int num_reserved_containers);
|
public abstract void setNumReservedContainers(int num_reserved_containers);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the used <code>Resource</code>
|
* Get the used <code>Resource</code>. -1 for invalid/inaccessible reports.
|
||||||
* @return the used <code>Resource</code>
|
* @return the used <code>Resource</code>
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
|
@ -91,7 +91,7 @@ public abstract class ApplicationResourceUsageReport {
|
||||||
public abstract void setUsedResources(Resource resources);
|
public abstract void setUsedResources(Resource resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the reserved <code>Resource</code>
|
* Get the reserved <code>Resource</code>. -1 for invalid/inaccessible reports.
|
||||||
* @return the reserved <code>Resource</code>
|
* @return the reserved <code>Resource</code>
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
|
@ -103,7 +103,7 @@ public abstract class ApplicationResourceUsageReport {
|
||||||
public abstract void setReservedResources(Resource reserved_resources);
|
public abstract void setReservedResources(Resource reserved_resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the needed <code>Resource</code>
|
* Get the needed <code>Resource</code>. -1 for invalid/inaccessible reports.
|
||||||
* @return the needed <code>Resource</code>
|
* @return the needed <code>Resource</code>
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.hadoop.security.AccessControlException;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.hadoop.security.authorize.AccessControlList;
|
import org.apache.hadoop.security.authorize.AccessControlList;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
||||||
|
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
|
||||||
import org.apache.hadoop.yarn.api.records.ContainerId;
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
||||||
import org.apache.hadoop.yarn.api.records.NodeState;
|
import org.apache.hadoop.yarn.api.records.NodeState;
|
||||||
import org.apache.hadoop.yarn.api.records.Resource;
|
import org.apache.hadoop.yarn.api.records.Resource;
|
||||||
|
@ -43,6 +44,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
|
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
|
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
|
||||||
|
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
|
||||||
|
import org.apache.hadoop.yarn.util.resource.Resources;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods to aid serving RM data through the REST and RPC APIs
|
* Utility methods to aid serving RM data through the REST and RPC APIs
|
||||||
|
@ -225,4 +228,13 @@ public class RMServerUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Statically defined dummy ApplicationResourceUsageREport. Used as
|
||||||
|
* a return value when a valid report cannot be found.
|
||||||
|
*/
|
||||||
|
public static final ApplicationResourceUsageReport
|
||||||
|
DUMMY_APPLICATION_RESOURCE_USAGE_REPORT =
|
||||||
|
BuilderUtils.newApplicationResourceUsageReport(-1, -1,
|
||||||
|
Resources.createResource(-1, -1), Resources.createResource(-1, -1),
|
||||||
|
Resources.createResource(-1, -1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeCleanAppEvent;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppRemovedSchedulerEvent;
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppRemovedSchedulerEvent;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.RMServerUtils;
|
||||||
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
|
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
|
||||||
import org.apache.hadoop.yarn.state.InvalidStateTransitonException;
|
import org.apache.hadoop.yarn.state.InvalidStateTransitonException;
|
||||||
import org.apache.hadoop.yarn.state.MultipleArcTransition;
|
import org.apache.hadoop.yarn.state.MultipleArcTransition;
|
||||||
|
@ -293,11 +294,6 @@ public class RMAppImpl implements RMApp, Recoverable {
|
||||||
private final StateMachine<RMAppState, RMAppEventType, RMAppEvent>
|
private final StateMachine<RMAppState, RMAppEventType, RMAppEvent>
|
||||||
stateMachine;
|
stateMachine;
|
||||||
|
|
||||||
private static final ApplicationResourceUsageReport
|
|
||||||
DUMMY_APPLICATION_RESOURCE_USAGE_REPORT =
|
|
||||||
BuilderUtils.newApplicationResourceUsageReport(-1, -1,
|
|
||||||
Resources.createResource(-1, -1), Resources.createResource(-1, -1),
|
|
||||||
Resources.createResource(-1, -1));
|
|
||||||
private static final int DUMMY_APPLICATION_ATTEMPT_NUMBER = -1;
|
private static final int DUMMY_APPLICATION_ATTEMPT_NUMBER = -1;
|
||||||
|
|
||||||
public RMAppImpl(ApplicationId applicationId, RMContext rmContext,
|
public RMAppImpl(ApplicationId applicationId, RMContext rmContext,
|
||||||
|
@ -498,7 +494,7 @@ public class RMAppImpl implements RMApp, Recoverable {
|
||||||
String origTrackingUrl = UNAVAILABLE;
|
String origTrackingUrl = UNAVAILABLE;
|
||||||
int rpcPort = -1;
|
int rpcPort = -1;
|
||||||
ApplicationResourceUsageReport appUsageReport =
|
ApplicationResourceUsageReport appUsageReport =
|
||||||
DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
|
RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
|
||||||
FinalApplicationStatus finishState = getFinalApplicationStatus();
|
FinalApplicationStatus finishState = getFinalApplicationStatus();
|
||||||
String diags = UNAVAILABLE;
|
String diags = UNAVAILABLE;
|
||||||
float progress = 0.0f;
|
float progress = 0.0f;
|
||||||
|
|
|
@ -675,9 +675,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
||||||
ApplicationResourceUsageReport report =
|
ApplicationResourceUsageReport report =
|
||||||
scheduler.getAppResourceUsageReport(this.getAppAttemptId());
|
scheduler.getAppResourceUsageReport(this.getAppAttemptId());
|
||||||
if (report == null) {
|
if (report == null) {
|
||||||
Resource none = Resource.newInstance(0, 0);
|
report = RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT;
|
||||||
report = ApplicationResourceUsageReport.newInstance(0, 0, none, none,
|
|
||||||
none);
|
|
||||||
}
|
}
|
||||||
return report;
|
return report;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -77,6 +77,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
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.ApplicationResourceUsageReport;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
|
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
|
||||||
import org.apache.hadoop.yarn.api.records.Container;
|
import org.apache.hadoop.yarn.api.records.Container;
|
||||||
import org.apache.hadoop.yarn.api.records.ContainerId;
|
import org.apache.hadoop.yarn.api.records.ContainerId;
|
||||||
|
@ -258,6 +259,28 @@ public class TestClientRMService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetApplicationResourceUsageReportDummy() throws YarnException,
|
||||||
|
IOException {
|
||||||
|
ApplicationAttemptId attemptId = getApplicationAttemptId(1);
|
||||||
|
YarnScheduler yarnScheduler = mockYarnScheduler();
|
||||||
|
RMContext rmContext = mock(RMContext.class);
|
||||||
|
mockRMContext(yarnScheduler, rmContext);
|
||||||
|
when(rmContext.getDispatcher().getEventHandler()).thenReturn(
|
||||||
|
new EventHandler<Event>() {
|
||||||
|
public void handle(Event event) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ApplicationSubmissionContext asContext =
|
||||||
|
mock(ApplicationSubmissionContext.class);
|
||||||
|
YarnConfiguration config = new YarnConfiguration();
|
||||||
|
RMAppAttemptImpl rmAppAttemptImpl = new RMAppAttemptImpl(attemptId,
|
||||||
|
rmContext, yarnScheduler, null, asContext, config, false);
|
||||||
|
ApplicationResourceUsageReport report = rmAppAttemptImpl
|
||||||
|
.getApplicationResourceUsageReport();
|
||||||
|
assertEquals(report, RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetApplicationAttempts() throws YarnException, IOException {
|
public void testGetApplicationAttempts() throws YarnException, IOException {
|
||||||
ClientRMService rmService = createRMService();
|
ClientRMService rmService = createRMService();
|
||||||
|
@ -964,6 +987,8 @@ public class TestClientRMService {
|
||||||
Arrays.asList(getApplicationAttemptId(101), getApplicationAttemptId(102)));
|
Arrays.asList(getApplicationAttemptId(101), getApplicationAttemptId(102)));
|
||||||
when(yarnScheduler.getAppsInQueue(QUEUE_2)).thenReturn(
|
when(yarnScheduler.getAppsInQueue(QUEUE_2)).thenReturn(
|
||||||
Arrays.asList(getApplicationAttemptId(103)));
|
Arrays.asList(getApplicationAttemptId(103)));
|
||||||
|
ApplicationAttemptId attemptId = getApplicationAttemptId(1);
|
||||||
|
when(yarnScheduler.getAppResourceUsageReport(attemptId)).thenReturn(null);
|
||||||
return yarnScheduler;
|
return yarnScheduler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMAppManagerEvent;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.RMAppManagerEventType;
|
import org.apache.hadoop.yarn.server.resourcemanager.RMAppManagerEventType;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl;
|
import org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl;
|
||||||
|
import org.apache.hadoop.yarn.server.resourcemanager.RMServerUtils;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWriter;
|
import org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWriter;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore;
|
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationState;
|
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.ApplicationState;
|
||||||
|
@ -921,6 +922,7 @@ public class TestRMAppTransitions {
|
||||||
assertAppState(RMAppState.NEW, app);
|
assertAppState(RMAppState.NEW, app);
|
||||||
ApplicationReport report = app.createAndGetApplicationReport(null, true);
|
ApplicationReport report = app.createAndGetApplicationReport(null, true);
|
||||||
Assert.assertNotNull(report.getApplicationResourceUsageReport());
|
Assert.assertNotNull(report.getApplicationResourceUsageReport());
|
||||||
|
Assert.assertEquals(report.getApplicationResourceUsageReport(),RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT);
|
||||||
report = app.createAndGetApplicationReport("clientuser", true);
|
report = app.createAndGetApplicationReport("clientuser", true);
|
||||||
Assert.assertNotNull(report.getApplicationResourceUsageReport());
|
Assert.assertNotNull(report.getApplicationResourceUsageReport());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue