YARN-8522. Application fails with InvalidResourceRequestException. (Zian Chen via wangda)

Change-Id: I34dd7fa49bd4d10580c4a78051033b1068d28f1e
(cherry picked from commit 5cc8e99147)
This commit is contained in:
Wangda Tan 2018-07-31 17:48:44 -07:00
parent cbfd7358d2
commit f4a3b26f9a
1 changed files with 46 additions and 41 deletions

View File

@ -84,7 +84,7 @@ extends ApplicationSubmissionContext {
viaProto = true; viaProto = true;
} }
public ApplicationSubmissionContextProto getProto() { public synchronized ApplicationSubmissionContextProto getProto() {
mergeLocalToProto(); mergeLocalToProto();
proto = viaProto ? proto : builder.build(); proto = viaProto ? proto : builder.build();
viaProto = true; viaProto = true;
@ -164,7 +164,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public Priority getPriority() { public synchronized Priority getPriority() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (this.priority != null) { if (this.priority != null) {
return this.priority; return this.priority;
@ -177,7 +177,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setPriority(Priority priority) { public synchronized void setPriority(Priority priority) {
maybeInitBuilder(); maybeInitBuilder();
if (priority == null) if (priority == null)
builder.clearPriority(); builder.clearPriority();
@ -185,7 +185,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public ApplicationId getApplicationId() { public synchronized ApplicationId getApplicationId() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (this.applicationId != null) { if (this.applicationId != null) {
return applicationId; return applicationId;
@ -198,7 +198,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setApplicationId(ApplicationId applicationId) { public synchronized void setApplicationId(ApplicationId applicationId) {
maybeInitBuilder(); maybeInitBuilder();
if (applicationId == null) if (applicationId == null)
builder.clearApplicationId(); builder.clearApplicationId();
@ -206,7 +206,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public String getApplicationName() { public synchronized String getApplicationName() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (!p.hasApplicationName()) { if (!p.hasApplicationName()) {
return null; return null;
@ -215,7 +215,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setApplicationName(String applicationName) { public synchronized void setApplicationName(String applicationName) {
maybeInitBuilder(); maybeInitBuilder();
if (applicationName == null) { if (applicationName == null) {
builder.clearApplicationName(); builder.clearApplicationName();
@ -225,7 +225,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public String getQueue() { public synchronized String getQueue() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (!p.hasQueue()) { if (!p.hasQueue()) {
return null; return null;
@ -234,7 +234,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public String getApplicationType() { public synchronized String getApplicationType() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (!p.hasApplicationType()) { if (!p.hasApplicationType()) {
return null; return null;
@ -252,13 +252,13 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public Set<String> getApplicationTags() { public synchronized Set<String> getApplicationTags() {
initApplicationTags(); initApplicationTags();
return this.applicationTags; return this.applicationTags;
} }
@Override @Override
public void setQueue(String queue) { public synchronized void setQueue(String queue) {
maybeInitBuilder(); maybeInitBuilder();
if (queue == null) { if (queue == null) {
builder.clearQueue(); builder.clearQueue();
@ -268,7 +268,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setApplicationType(String applicationType) { public synchronized void setApplicationType(String applicationType) {
maybeInitBuilder(); maybeInitBuilder();
if (applicationType == null) { if (applicationType == null) {
builder.clearApplicationType(); builder.clearApplicationType();
@ -296,7 +296,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setApplicationTags(Set<String> tags) { public synchronized void setApplicationTags(Set<String> tags) {
maybeInitBuilder(); maybeInitBuilder();
if (tags == null || tags.isEmpty()) { if (tags == null || tags.isEmpty()) {
builder.clearApplicationTags(); builder.clearApplicationTags();
@ -312,7 +312,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public ContainerLaunchContext getAMContainerSpec() { public synchronized ContainerLaunchContext getAMContainerSpec() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (this.amContainer != null) { if (this.amContainer != null) {
return amContainer; return amContainer;
@ -325,7 +325,8 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setAMContainerSpec(ContainerLaunchContext amContainer) { public synchronized void
setAMContainerSpec(ContainerLaunchContext amContainer) {
maybeInitBuilder(); maybeInitBuilder();
if (amContainer == null) { if (amContainer == null) {
builder.clearAmContainerSpec(); builder.clearAmContainerSpec();
@ -334,44 +335,44 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public boolean getUnmanagedAM() { public synchronized boolean getUnmanagedAM() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
return p.getUnmanagedAm(); return p.getUnmanagedAm();
} }
@Override @Override
public void setUnmanagedAM(boolean value) { public synchronized void setUnmanagedAM(boolean value) {
maybeInitBuilder(); maybeInitBuilder();
builder.setUnmanagedAm(value); builder.setUnmanagedAm(value);
} }
@Override @Override
public boolean getCancelTokensWhenComplete() { public synchronized boolean getCancelTokensWhenComplete() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
//There is a default so cancelTokens should never be null //There is a default so cancelTokens should never be null
return p.getCancelTokensWhenComplete(); return p.getCancelTokensWhenComplete();
} }
@Override @Override
public void setCancelTokensWhenComplete(boolean cancel) { public synchronized void setCancelTokensWhenComplete(boolean cancel) {
maybeInitBuilder(); maybeInitBuilder();
builder.setCancelTokensWhenComplete(cancel); builder.setCancelTokensWhenComplete(cancel);
} }
@Override @Override
public int getMaxAppAttempts() { public synchronized int getMaxAppAttempts() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
return p.getMaxAppAttempts(); return p.getMaxAppAttempts();
} }
@Override @Override
public void setMaxAppAttempts(int maxAppAttempts) { public synchronized void setMaxAppAttempts(int maxAppAttempts) {
maybeInitBuilder(); maybeInitBuilder();
builder.setMaxAppAttempts(maxAppAttempts); builder.setMaxAppAttempts(maxAppAttempts);
} }
@Override @Override
public Resource getResource() { public synchronized Resource getResource() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (this.resource != null) { if (this.resource != null) {
return this.resource; return this.resource;
@ -384,7 +385,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setResource(Resource resource) { public synchronized void setResource(Resource resource) {
maybeInitBuilder(); maybeInitBuilder();
if (resource == null) { if (resource == null) {
builder.clearResource(); builder.clearResource();
@ -393,7 +394,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public ReservationId getReservationID() { public synchronized ReservationId getReservationID() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (reservationId != null) { if (reservationId != null) {
return reservationId; return reservationId;
@ -406,7 +407,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setReservationID(ReservationId reservationID) { public synchronized void setReservationID(ReservationId reservationID) {
maybeInitBuilder(); maybeInitBuilder();
if (reservationID == null) { if (reservationID == null) {
builder.clearReservationId(); builder.clearReservationId();
@ -416,14 +417,14 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void public synchronized void
setKeepContainersAcrossApplicationAttempts(boolean keepContainers) { setKeepContainersAcrossApplicationAttempts(boolean keepContainers) {
maybeInitBuilder(); maybeInitBuilder();
builder.setKeepContainersAcrossApplicationAttempts(keepContainers); builder.setKeepContainersAcrossApplicationAttempts(keepContainers);
} }
@Override @Override
public boolean getKeepContainersAcrossApplicationAttempts() { public synchronized boolean getKeepContainersAcrossApplicationAttempts() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
return p.getKeepContainersAcrossApplicationAttempts(); return p.getKeepContainersAcrossApplicationAttempts();
} }
@ -481,7 +482,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public String getNodeLabelExpression() { public synchronized String getNodeLabelExpression() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (!p.hasNodeLabelExpression()) { if (!p.hasNodeLabelExpression()) {
return null; return null;
@ -490,7 +491,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setNodeLabelExpression(String labelExpression) { public synchronized void setNodeLabelExpression(String labelExpression) {
maybeInitBuilder(); maybeInitBuilder();
if (labelExpression == null) { if (labelExpression == null) {
builder.clearNodeLabelExpression(); builder.clearNodeLabelExpression();
@ -501,7 +502,7 @@ extends ApplicationSubmissionContext {
@Override @Override
@Deprecated @Deprecated
public ResourceRequest getAMContainerResourceRequest() { public synchronized ResourceRequest getAMContainerResourceRequest() {
List<ResourceRequest> reqs = getAMContainerResourceRequests(); List<ResourceRequest> reqs = getAMContainerResourceRequests();
if (reqs == null || reqs.isEmpty()) { if (reqs == null || reqs.isEmpty()) {
return null; return null;
@ -510,7 +511,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public List<ResourceRequest> getAMContainerResourceRequests() { public synchronized List<ResourceRequest> getAMContainerResourceRequests() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (this.amResourceRequests != null) { if (this.amResourceRequests != null) {
return amResourceRequests; return amResourceRequests;
@ -525,7 +526,8 @@ extends ApplicationSubmissionContext {
@Override @Override
@Deprecated @Deprecated
public void setAMContainerResourceRequest(ResourceRequest request) { public synchronized void setAMContainerResourceRequest(
ResourceRequest request) {
maybeInitBuilder(); maybeInitBuilder();
if (request == null) { if (request == null) {
builder.clearAmContainerResourceRequest(); builder.clearAmContainerResourceRequest();
@ -534,7 +536,8 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setAMContainerResourceRequests(List<ResourceRequest> requests) { public synchronized void setAMContainerResourceRequests(
List<ResourceRequest> requests) {
maybeInitBuilder(); maybeInitBuilder();
if (requests == null) { if (requests == null) {
builder.clearAmContainerResourceRequest(); builder.clearAmContainerResourceRequest();
@ -543,13 +546,13 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public long getAttemptFailuresValidityInterval() { public synchronized long getAttemptFailuresValidityInterval() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
return p.getAttemptFailuresValidityInterval(); return p.getAttemptFailuresValidityInterval();
} }
@Override @Override
public void setAttemptFailuresValidityInterval( public synchronized void setAttemptFailuresValidityInterval(
long attemptFailuresValidityInterval) { long attemptFailuresValidityInterval) {
maybeInitBuilder(); maybeInitBuilder();
builder.setAttemptFailuresValidityInterval(attemptFailuresValidityInterval); builder.setAttemptFailuresValidityInterval(attemptFailuresValidityInterval);
@ -566,7 +569,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public LogAggregationContext getLogAggregationContext() { public synchronized LogAggregationContext getLogAggregationContext() {
ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder; ApplicationSubmissionContextProtoOrBuilder p = viaProto ? proto : builder;
if (this.logAggregationContext != null) { if (this.logAggregationContext != null) {
return this.logAggregationContext; return this.logAggregationContext;
@ -579,7 +582,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setLogAggregationContext( public synchronized void setLogAggregationContext(
LogAggregationContext logAggregationContext) { LogAggregationContext logAggregationContext) {
maybeInitBuilder(); maybeInitBuilder();
if (logAggregationContext == null) if (logAggregationContext == null)
@ -596,7 +599,8 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public Map<ApplicationTimeoutType, Long> getApplicationTimeouts() { public synchronized
Map<ApplicationTimeoutType, Long> getApplicationTimeouts() {
initApplicationTimeout(); initApplicationTimeout();
return this.applicationTimeouts; return this.applicationTimeouts;
} }
@ -618,7 +622,7 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public void setApplicationTimeouts( public synchronized void setApplicationTimeouts(
Map<ApplicationTimeoutType, Long> appTimeouts) { Map<ApplicationTimeoutType, Long> appTimeouts) {
if (appTimeouts == null) { if (appTimeouts == null) {
return; return;
@ -719,13 +723,14 @@ extends ApplicationSubmissionContext {
} }
@Override @Override
public Map<String, String> getApplicationSchedulingPropertiesMap() { public synchronized
Map<String, String> getApplicationSchedulingPropertiesMap() {
initApplicationSchedulingProperties(); initApplicationSchedulingProperties();
return this.schedulingProperties; return this.schedulingProperties;
} }
@Override @Override
public void setApplicationSchedulingPropertiesMap( public synchronized void setApplicationSchedulingPropertiesMap(
Map<String, String> schedulingPropertyMap) { Map<String, String> schedulingPropertyMap) {
if (schedulingPropertyMap == null) { if (schedulingPropertyMap == null) {
return; return;