YARN-6022. Revert changes of AbstractResourceRequest. (Contributed by Wangda Tan / Daniel Templeton)
This commit is contained in:
parent
a7cdd39234
commit
c00a468b0b
|
@ -1,55 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hadoop.yarn.api.records;
|
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience.Public;
|
|
||||||
import org.apache.hadoop.classification.InterfaceStability.Stable;
|
|
||||||
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@code AbstractResourceRequest} represents a generic resource request made
|
|
||||||
* by an application to the {@code ResourceManager}.
|
|
||||||
* <p>
|
|
||||||
* It includes:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@link Resource} capability required for each request.</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @see Resource
|
|
||||||
*/
|
|
||||||
@Public
|
|
||||||
@Unstable
|
|
||||||
public abstract class AbstractResourceRequest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the <code>Resource</code> capability of the request
|
|
||||||
* @param capability <code>Resource</code> capability of the request
|
|
||||||
*/
|
|
||||||
@Public
|
|
||||||
@Stable
|
|
||||||
public abstract void setCapability(Resource capability);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the <code>Resource</code> capability of the request.
|
|
||||||
* @return <code>Resource</code> capability of the request
|
|
||||||
*/
|
|
||||||
@Public
|
|
||||||
@Stable
|
|
||||||
public abstract Resource getCapability();
|
|
||||||
}
|
|
|
@ -58,8 +58,7 @@ import org.apache.hadoop.yarn.util.Records;
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
@Stable
|
@Stable
|
||||||
public abstract class ResourceRequest extends AbstractResourceRequest
|
public abstract class ResourceRequest implements Comparable<ResourceRequest> {
|
||||||
implements Comparable<ResourceRequest>{
|
|
||||||
|
|
||||||
@Public
|
@Public
|
||||||
@Stable
|
@Stable
|
||||||
|
@ -507,6 +506,22 @@ public abstract class ResourceRequest extends AbstractResourceRequest
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the <code>Resource</code> capability of the request.
|
||||||
|
* @param capability <code>Resource</code> capability of the request
|
||||||
|
*/
|
||||||
|
@Public
|
||||||
|
@Stable
|
||||||
|
public abstract void setCapability(Resource capability);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the <code>Resource</code> capability of the request.
|
||||||
|
* @return <code>Resource</code> capability of the request
|
||||||
|
*/
|
||||||
|
@Public
|
||||||
|
@Stable
|
||||||
|
public abstract Resource getCapability();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 2153;
|
final int prime = 2153;
|
||||||
|
|
|
@ -62,7 +62,7 @@ import org.apache.hadoop.yarn.util.Records;
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Unstable
|
@InterfaceStability.Unstable
|
||||||
public abstract class UpdateContainerRequest extends AbstractResourceRequest {
|
public abstract class UpdateContainerRequest {
|
||||||
|
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Unstable
|
@InterfaceStability.Unstable
|
||||||
|
@ -143,6 +143,22 @@ public abstract class UpdateContainerRequest extends AbstractResourceRequest {
|
||||||
@InterfaceStability.Unstable
|
@InterfaceStability.Unstable
|
||||||
public abstract void setExecutionType(ExecutionType executionType);
|
public abstract void setExecutionType(ExecutionType executionType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the <code>Resource</code> capability of the request.
|
||||||
|
* @param capability <code>Resource</code> capability of the request
|
||||||
|
*/
|
||||||
|
@InterfaceAudience.Public
|
||||||
|
@InterfaceStability.Unstable
|
||||||
|
public abstract void setCapability(Resource capability);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the <code>Resource</code> capability of the request.
|
||||||
|
* @return <code>Resource</code> capability of the request
|
||||||
|
*/
|
||||||
|
@InterfaceAudience.Public
|
||||||
|
@InterfaceStability.Unstable
|
||||||
|
public abstract Resource getCapability();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 2153;
|
final int prime = 2153;
|
||||||
|
|
|
@ -451,7 +451,7 @@ public class RMAppManager implements EventHandler<RMAppManagerEvent>,
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduler.normalizeRequest(amReq);
|
amReq.setCapability(scheduler.getNormalizedResource(amReq.getCapability()));
|
||||||
return amReq;
|
return amReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,7 @@ public class RMServerUtils {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ResourceScheduler scheduler = rmContext.getScheduler();
|
ResourceScheduler scheduler = rmContext.getScheduler();
|
||||||
scheduler.normalizeRequest(request);
|
request.setCapability(scheduler.getNormalizedResource(request.getCapability()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.hadoop.service.AbstractService;
|
import org.apache.hadoop.service.AbstractService;
|
||||||
import org.apache.hadoop.yarn.api.records.AbstractResourceRequest;
|
|
||||||
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.ApplicationResourceUsageReport;
|
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
|
||||||
|
@ -1043,8 +1042,8 @@ public abstract class AbstractYarnScheduler
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void normalizeRequest(AbstractResourceRequest ask) {
|
public Resource getNormalizedResource(Resource requestedResource) {
|
||||||
SchedulerUtils.normalizeRequest(ask,
|
return SchedulerUtils.getNormalizedResource(requestedResource,
|
||||||
getResourceCalculator(),
|
getResourceCalculator(),
|
||||||
getMinimumResourceCapability(),
|
getMinimumResourceCapability(),
|
||||||
getMaximumResourceCapability(),
|
getMaximumResourceCapability(),
|
||||||
|
@ -1058,7 +1057,7 @@ public abstract class AbstractYarnScheduler
|
||||||
*/
|
*/
|
||||||
protected void normalizeRequests(List<ResourceRequest> asks) {
|
protected void normalizeRequests(List<ResourceRequest> asks) {
|
||||||
for (ResourceRequest ask: asks) {
|
for (ResourceRequest ask: asks) {
|
||||||
normalizeRequest(ask);
|
ask.setCapability(getNormalizedResource(ask.getCapability()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
||||||
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
||||||
|
@ -32,7 +33,6 @@ import org.apache.hadoop.yarn.api.records.QueueACL;
|
||||||
import org.apache.hadoop.yarn.api.records.QueueInfo;
|
import org.apache.hadoop.yarn.api.records.QueueInfo;
|
||||||
import org.apache.hadoop.yarn.api.records.Resource;
|
import org.apache.hadoop.yarn.api.records.Resource;
|
||||||
import org.apache.hadoop.yarn.api.records.ResourceRequest;
|
import org.apache.hadoop.yarn.api.records.ResourceRequest;
|
||||||
import org.apache.hadoop.yarn.api.records.AbstractResourceRequest;
|
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.exceptions.InvalidLabelResourceRequestException;
|
import org.apache.hadoop.yarn.exceptions.InvalidLabelResourceRequestException;
|
||||||
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException;
|
import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException;
|
||||||
|
@ -127,29 +127,33 @@ public class SchedulerUtils {
|
||||||
* Utility method to normalize a resource request, by insuring that the
|
* Utility method to normalize a resource request, by insuring that the
|
||||||
* requested memory is a multiple of minMemory and is not zero.
|
* requested memory is a multiple of minMemory and is not zero.
|
||||||
*/
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
public static void normalizeRequest(
|
public static void normalizeRequest(
|
||||||
ResourceRequest ask,
|
ResourceRequest ask,
|
||||||
ResourceCalculator resourceCalculator,
|
ResourceCalculator resourceCalculator,
|
||||||
Resource minimumResource,
|
Resource minimumResource,
|
||||||
Resource maximumResource) {
|
Resource maximumResource) {
|
||||||
normalizeRequest(ask, resourceCalculator,
|
ask.setCapability(
|
||||||
minimumResource, maximumResource, minimumResource);
|
getNormalizedResource(ask.getCapability(), resourceCalculator,
|
||||||
|
minimumResource, maximumResource, minimumResource));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to normalize a resource request, by insuring that the
|
* Utility method to normalize a resource request, by insuring that the
|
||||||
* requested memory is a multiple of increment resource and is not zero.
|
* requested memory is a multiple of increment resource and is not zero.
|
||||||
|
*
|
||||||
|
* @return normalized resource
|
||||||
*/
|
*/
|
||||||
public static void normalizeRequest(
|
public static Resource getNormalizedResource(
|
||||||
AbstractResourceRequest ask,
|
Resource ask,
|
||||||
ResourceCalculator resourceCalculator,
|
ResourceCalculator resourceCalculator,
|
||||||
Resource minimumResource,
|
Resource minimumResource,
|
||||||
Resource maximumResource,
|
Resource maximumResource,
|
||||||
Resource incrementResource) {
|
Resource incrementResource) {
|
||||||
Resource normalized = Resources.normalize(
|
Resource normalized = Resources.normalize(
|
||||||
resourceCalculator, ask.getCapability(), minimumResource,
|
resourceCalculator, ask, minimumResource,
|
||||||
maximumResource, incrementResource);
|
maximumResource, incrementResource);
|
||||||
ask.setCapability(normalized);
|
return normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void normalizeNodeLabelExpressionInRequest(
|
private static void normalizeNodeLabelExpressionInRequest(
|
||||||
|
|
|
@ -43,7 +43,6 @@ import org.apache.hadoop.yarn.api.records.QueueUserACLInfo;
|
||||||
import org.apache.hadoop.yarn.api.records.Resource;
|
import org.apache.hadoop.yarn.api.records.Resource;
|
||||||
import org.apache.hadoop.yarn.api.records.ResourceRequest;
|
import org.apache.hadoop.yarn.api.records.ResourceRequest;
|
||||||
import org.apache.hadoop.yarn.api.records.UpdateContainerRequest;
|
import org.apache.hadoop.yarn.api.records.UpdateContainerRequest;
|
||||||
import org.apache.hadoop.yarn.api.records.AbstractResourceRequest;
|
|
||||||
import org.apache.hadoop.yarn.event.EventHandler;
|
import org.apache.hadoop.yarn.event.EventHandler;
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
|
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
|
||||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||||
|
@ -385,7 +384,8 @@ public interface YarnScheduler extends EventHandler<SchedulerEvent> {
|
||||||
/**
|
/**
|
||||||
* Normalize a resource request.
|
* Normalize a resource request.
|
||||||
*
|
*
|
||||||
* @param request the resource request to be normalized
|
* @param requestedResource the resource to be normalized
|
||||||
|
* @return the normalized resource
|
||||||
*/
|
*/
|
||||||
void normalizeRequest(AbstractResourceRequest request);
|
Resource getNormalizedResource(Resource requestedResource);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.apache.hadoop.classification.InterfaceAudience.LimitedPrivate;
|
||||||
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.hadoop.yarn.api.records.AbstractResourceRequest;
|
|
||||||
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.Container;
|
import org.apache.hadoop.yarn.api.records.Container;
|
||||||
|
@ -986,8 +985,8 @@ public class FairScheduler extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void normalizeRequest(AbstractResourceRequest ask) {
|
public Resource getNormalizedResource(Resource requestedResource) {
|
||||||
SchedulerUtils.normalizeRequest(ask,
|
return SchedulerUtils.getNormalizedResource(requestedResource,
|
||||||
DOMINANT_RESOURCE_CALCULATOR,
|
DOMINANT_RESOURCE_CALCULATOR,
|
||||||
minimumAllocation,
|
minimumAllocation,
|
||||||
getMaximumResourceCapability(),
|
getMaximumResourceCapability(),
|
||||||
|
|
Loading…
Reference in New Issue