YARN-749. Rename ResourceRequest.(get,set)HostName to ResourceRequest.(get,set)ResourceName. Contributed by Arun C. Murthy.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1488806 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
97f9f49746
commit
f27e484636
@ -241,7 +241,7 @@ protected void containerFailedOnHost(String hostName) {
|
||||
// specified for the blacklisted host to be 0.
|
||||
ResourceRequest zeroedRequest =
|
||||
ResourceRequest.newInstance(req.getPriority(),
|
||||
req.getHostName(), req.getCapability(),
|
||||
req.getResourceName(), req.getCapability(),
|
||||
req.getNumContainers());
|
||||
|
||||
zeroedRequest.setNumContainers(0);
|
||||
@ -323,7 +323,7 @@ private void addResourceRequest(Priority priority, String resourceName,
|
||||
if (remoteRequest == null) {
|
||||
remoteRequest = recordFactory.newRecordInstance(ResourceRequest.class);
|
||||
remoteRequest.setPriority(priority);
|
||||
remoteRequest.setHostName(resourceName);
|
||||
remoteRequest.setResourceName(resourceName);
|
||||
remoteRequest.setCapability(capability);
|
||||
remoteRequest.setNumContainers(0);
|
||||
reqMap.put(capability, remoteRequest);
|
||||
|
@ -227,7 +227,7 @@ public AllocateResponse allocate(AllocateRequest request)
|
||||
List<ResourceRequest> askList = request.getAskList();
|
||||
List<Container> containers = new ArrayList<Container>();
|
||||
for (ResourceRequest req : askList) {
|
||||
if (!ResourceRequest.isAnyLocation(req.getHostName())) {
|
||||
if (!ResourceRequest.isAnyLocation(req.getResourceName())) {
|
||||
continue;
|
||||
}
|
||||
int numContainers = req.getNumContainers();
|
||||
|
@ -1219,7 +1219,7 @@ public synchronized Allocation allocate(
|
||||
List<ResourceRequest> askCopy = new ArrayList<ResourceRequest>();
|
||||
for (ResourceRequest req : ask) {
|
||||
ResourceRequest reqCopy = ResourceRequest.newInstance(req
|
||||
.getPriority(), req.getHostName(), req.getCapability(), req
|
||||
.getPriority(), req.getResourceName(), req.getCapability(), req
|
||||
.getNumContainers());
|
||||
askCopy.add(reqCopy);
|
||||
}
|
||||
|
@ -81,6 +81,9 @@ Release 2.1.0-beta - UNRELEASED
|
||||
YARN-735. Make ApplicationAttemptId, ContaienrId and NodeId immutable.
|
||||
(Jian He via sseth)
|
||||
|
||||
YARN-749. Rename ResourceRequest.(get,set)HostName to
|
||||
ResourceRequest.(get,set)ResourceName. (acmurthy)
|
||||
|
||||
NEW FEATURES
|
||||
|
||||
YARN-482. FS: Extend SchedulingMode to intermediate queues.
|
||||
|
@ -57,7 +57,7 @@ public static ResourceRequest newInstance(Priority priority,
|
||||
String hostName, Resource capability, int numContainers) {
|
||||
ResourceRequest request = Records.newRecord(ResourceRequest.class);
|
||||
request.setPriority(priority);
|
||||
request.setHostName(hostName);
|
||||
request.setResourceName(hostName);
|
||||
request.setCapability(capability);
|
||||
request.setNumContainers(numContainers);
|
||||
return request;
|
||||
@ -99,28 +99,32 @@ public static boolean isAnyLocation(String hostName) {
|
||||
public abstract void setPriority(Priority priority);
|
||||
|
||||
/**
|
||||
* Get the <em>host/rack</em> on which the allocation is desired.
|
||||
* Get the resource (e.g. <em>host/rack</em>) on which the allocation
|
||||
* is desired.
|
||||
*
|
||||
* A special value of <em>*</em> signifies that <em>any</em> host/rack is
|
||||
* acceptable.
|
||||
* A special value of <em>*</em> signifies that <em>any</em> resource
|
||||
* (host/rack) is acceptable.
|
||||
*
|
||||
* @return <em>host/rack</em> on which the allocation is desired
|
||||
* @return resource (e.g. <em>host/rack</em>) on which the allocation
|
||||
* is desired
|
||||
*/
|
||||
@Public
|
||||
@Stable
|
||||
public abstract String getHostName();
|
||||
public abstract String getResourceName();
|
||||
|
||||
/**
|
||||
* Set <em>host/rack</em> on which the allocation is desired.
|
||||
* Set the resource (e.g. <em>host/rack</em>) on which the allocation
|
||||
* is desired.
|
||||
*
|
||||
* A special value of <em>*</em> signifies that <em>any</em> host/rack is
|
||||
* acceptable.
|
||||
* A special value of <em>*</em> signifies that <em>any</em> resource
|
||||
* (e.g. host/rack) is acceptable.
|
||||
*
|
||||
* @param hostName <em>host/rack</em> on which the allocation is desired
|
||||
* @param resourceName (e.g. <em>host/rack</em>) on which the
|
||||
* allocation is desired
|
||||
*/
|
||||
@Public
|
||||
@Stable
|
||||
public abstract void setHostName(String hostName);
|
||||
public abstract void setResourceName(String resourceName);
|
||||
|
||||
/**
|
||||
* Get the <code>Resource</code> capability of the request.
|
||||
@ -198,7 +202,7 @@ public int hashCode() {
|
||||
final int prime = 2153;
|
||||
int result = 2459;
|
||||
Resource capability = getCapability();
|
||||
String hostName = getHostName();
|
||||
String hostName = getResourceName();
|
||||
Priority priority = getPriority();
|
||||
result =
|
||||
prime * result + ((capability == null) ? 0 : capability.hashCode());
|
||||
@ -223,11 +227,11 @@ public boolean equals(Object obj) {
|
||||
return false;
|
||||
} else if (!capability.equals(other.getCapability()))
|
||||
return false;
|
||||
String hostName = getHostName();
|
||||
String hostName = getResourceName();
|
||||
if (hostName == null) {
|
||||
if (other.getHostName() != null)
|
||||
if (other.getResourceName() != null)
|
||||
return false;
|
||||
} else if (!hostName.equals(other.getHostName()))
|
||||
} else if (!hostName.equals(other.getResourceName()))
|
||||
return false;
|
||||
if (getNumContainers() != other.getNumContainers())
|
||||
return false;
|
||||
@ -245,7 +249,7 @@ public int compareTo(ResourceRequest other) {
|
||||
int priorityComparison = this.getPriority().compareTo(other.getPriority());
|
||||
if (priorityComparison == 0) {
|
||||
int hostNameComparison =
|
||||
this.getHostName().compareTo(other.getHostName());
|
||||
this.getResourceName().compareTo(other.getResourceName());
|
||||
if (hostNameComparison == 0) {
|
||||
int capabilityComparison =
|
||||
this.getCapability().compareTo(other.getCapability());
|
||||
|
@ -98,22 +98,22 @@ public void setPriority(Priority priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
@Override
|
||||
public String getHostName() {
|
||||
public String getResourceName() {
|
||||
ResourceRequestProtoOrBuilder p = viaProto ? proto : builder;
|
||||
if (!p.hasHostName()) {
|
||||
if (!p.hasResourceName()) {
|
||||
return null;
|
||||
}
|
||||
return (p.getHostName());
|
||||
return (p.getResourceName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHostName(String hostName) {
|
||||
public void setResourceName(String resourceName) {
|
||||
maybeInitBuilder();
|
||||
if (hostName == null) {
|
||||
builder.clearHostName();
|
||||
if (resourceName == null) {
|
||||
builder.clearResourceName();
|
||||
return;
|
||||
}
|
||||
builder.setHostName((hostName));
|
||||
builder.setResourceName((resourceName));
|
||||
}
|
||||
@Override
|
||||
public Resource getCapability() {
|
||||
@ -179,7 +179,7 @@ private ResourceProto convertToProtoFormat(Resource t) {
|
||||
public String toString() {
|
||||
return "{Priority: " + getPriority() + ", Capability: " + getCapability()
|
||||
+ ", # Containers: " + getNumContainers()
|
||||
+ ", Location: " + getHostName()
|
||||
+ ", Location: " + getResourceName()
|
||||
+ ", Relax Locality: " + getRelaxLocality() + "}";
|
||||
}
|
||||
}
|
@ -201,7 +201,7 @@ message NodeReportProto {
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
message ResourceRequestProto {
|
||||
optional PriorityProto priority = 1;
|
||||
optional string host_name = 2;
|
||||
optional string resource_name = 2;
|
||||
optional ResourceProto capability = 3;
|
||||
optional int32 num_containers = 4;
|
||||
optional bool relax_locality = 5 [default = true];
|
||||
|
@ -97,8 +97,8 @@ public int compare(org.apache.hadoop.yarn.api.records.ResourceRequest r1,
|
||||
// Compare priority, host and capability
|
||||
int ret = r1.getPriority().compareTo(r2.getPriority());
|
||||
if (ret == 0) {
|
||||
String h1 = r1.getHostName();
|
||||
String h2 = r2.getHostName();
|
||||
String h1 = r1.getResourceName();
|
||||
String h2 = r2.getResourceName();
|
||||
ret = h1.compareTo(h2);
|
||||
}
|
||||
if (ret == 0) {
|
||||
@ -296,7 +296,7 @@ public static ResourceRequest newResourceRequest(Priority priority,
|
||||
ResourceRequest request = recordFactory
|
||||
.newRecordInstance(ResourceRequest.class);
|
||||
request.setPriority(priority);
|
||||
request.setHostName(hostName);
|
||||
request.setResourceName(hostName);
|
||||
request.setCapability(capability);
|
||||
request.setNumContainers(numContainers);
|
||||
return request;
|
||||
@ -306,7 +306,7 @@ public static ResourceRequest newResourceRequest(ResourceRequest r) {
|
||||
ResourceRequest request = recordFactory
|
||||
.newRecordInstance(ResourceRequest.class);
|
||||
request.setPriority(r.getPriority());
|
||||
request.setHostName(r.getHostName());
|
||||
request.setResourceName(r.getResourceName());
|
||||
request.setCapability(r.getCapability());
|
||||
request.setNumContainers(r.getNumContainers());
|
||||
return request;
|
||||
|
@ -123,11 +123,11 @@ synchronized public void updateResourceRequests(
|
||||
// Update resource requests
|
||||
for (ResourceRequest request : requests) {
|
||||
Priority priority = request.getPriority();
|
||||
String hostName = request.getHostName();
|
||||
String resourceName = request.getResourceName();
|
||||
boolean updatePendingResources = false;
|
||||
ResourceRequest lastRequest = null;
|
||||
|
||||
if (hostName.equals(ResourceRequest.ANY)) {
|
||||
if (resourceName.equals(ResourceRequest.ANY)) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("update:" + " application=" + applicationId + " request="
|
||||
+ request);
|
||||
@ -152,10 +152,10 @@ synchronized public void updateResourceRequests(
|
||||
this.requests.put(priority, asks);
|
||||
this.priorities.add(priority);
|
||||
} else if (updatePendingResources) {
|
||||
lastRequest = asks.get(hostName);
|
||||
lastRequest = asks.get(resourceName);
|
||||
}
|
||||
|
||||
asks.put(hostName, request);
|
||||
asks.put(resourceName, request);
|
||||
if (updatePendingResources) {
|
||||
|
||||
// Similarly, deactivate application?
|
||||
@ -187,9 +187,9 @@ synchronized public Map<String, ResourceRequest> getResourceRequests(
|
||||
}
|
||||
|
||||
synchronized public ResourceRequest getResourceRequest(Priority priority,
|
||||
String nodeAddress) {
|
||||
String resourceName) {
|
||||
Map<String, ResourceRequest> nodeRequests = requests.get(priority);
|
||||
return (nodeRequests == null) ? null : nodeRequests.get(nodeAddress);
|
||||
return (nodeRequests == null) ? null : nodeRequests.get(resourceName);
|
||||
}
|
||||
|
||||
public synchronized Resource getResource(Priority priority) {
|
||||
|
@ -152,8 +152,8 @@ public Collection<Priority> getPriorities() {
|
||||
return this.appSchedulingInfo.getPriorities();
|
||||
}
|
||||
|
||||
public ResourceRequest getResourceRequest(Priority priority, String nodeAddress) {
|
||||
return this.appSchedulingInfo.getResourceRequest(priority, nodeAddress);
|
||||
public ResourceRequest getResourceRequest(Priority priority, String resourceName) {
|
||||
return this.appSchedulingInfo.getResourceRequest(priority, resourceName);
|
||||
}
|
||||
|
||||
public synchronized int getTotalRequiredResources(Priority priority) {
|
||||
|
@ -130,7 +130,7 @@ public List<ResourceRequest> createReq(String[] hosts, int memory, int priority,
|
||||
public ResourceRequest createResourceReq(String resource, int memory, int priority,
|
||||
int containers) throws Exception {
|
||||
ResourceRequest req = Records.newRecord(ResourceRequest.class);
|
||||
req.setHostName(resource);
|
||||
req.setResourceName(resource);
|
||||
req.setNumContainers(containers);
|
||||
Priority pri = Records.newRecord(Priority.class);
|
||||
pri.setPriority(priority);
|
||||
|
@ -122,7 +122,7 @@ public static ResourceRequest createResourceRequest(
|
||||
Resource capability = Resources.createResource(memory, 1);
|
||||
|
||||
request.setNumContainers(numContainers);
|
||||
request.setHostName(hostName);
|
||||
request.setResourceName(hostName);
|
||||
request.setCapability(capability);
|
||||
request.setPriority(priority);
|
||||
return request;
|
||||
|
@ -153,7 +153,7 @@ private ResourceRequest createResourceRequest(int memory, String host,
|
||||
int priority, int numContainers, boolean relaxLocality) {
|
||||
ResourceRequest request = recordFactory.newRecordInstance(ResourceRequest.class);
|
||||
request.setCapability(Resources.createResource(memory));
|
||||
request.setHostName(host);
|
||||
request.setResourceName(host);
|
||||
request.setNumContainers(numContainers);
|
||||
Priority prio = recordFactory.newRecordInstance(Priority.class);
|
||||
prio.setPriority(priority);
|
||||
|
@ -106,7 +106,7 @@ private ResourceRequest createResourceRequest(int memory, String host,
|
||||
ResourceRequest request = recordFactory
|
||||
.newRecordInstance(ResourceRequest.class);
|
||||
request.setCapability(Resources.createResource(memory));
|
||||
request.setHostName(host);
|
||||
request.setResourceName(host);
|
||||
request.setNumContainers(numContainers);
|
||||
Priority prio = recordFactory.newRecordInstance(Priority.class);
|
||||
prio.setPriority(priority);
|
||||
|
Loading…
Reference in New Issue
Block a user