YARN-7564. Cleanup to fix checkstyle issues of YARN-5881 branch. Contributed by Sunil G.

This commit is contained in:
Sunil G 2017-11-28 14:07:09 +05:30 committed by Wangda Tan
parent 1012b901c8
commit daa1cdd062
9 changed files with 70 additions and 45 deletions

View File

@ -1171,16 +1171,16 @@ public static boolean equalsIgnoreCase(String s1, String s2) {
* @return <code>true</code> if only contains letters, and is non-null
*/
public static boolean isAlpha(String str) {
if (str == null) {
return false;
if (str == null) {
return false;
}
int sz = str.length();
for (int i = 0; i < sz; i++) {
if (!Character.isLetter(str.charAt(i))) {
return false;
}
int sz = str.length();
for (int i = 0; i < sz; i++) {
if (Character.isLetter(str.charAt(i)) == false) {
return false;
}
}
return true;
}
return true;
}
}

View File

@ -236,12 +236,12 @@ public Resource getConfiguredMinCapacity() {
}
@Override
public void setConfiguredMinCapacity(Resource configuredMinResource) {
public void setConfiguredMinCapacity(Resource minResource) {
maybeInitBuilder();
if (configuredMinResource == null) {
if (minResource == null) {
builder.clearConfiguredMinCapacity();
}
this.configuredMinResource = configuredMinResource;
this.configuredMinResource = minResource;
}
@Override
@ -259,11 +259,11 @@ public Resource getConfiguredMaxCapacity() {
}
@Override
public void setConfiguredMaxCapacity(Resource configuredMaxResource) {
public void setConfiguredMaxCapacity(Resource maxResource) {
maybeInitBuilder();
if (configuredMaxResource == null) {
builder.clearConfiguredMaxCapacity();
}
this.configuredMaxResource = configuredMaxResource;
this.configuredMaxResource = maxResource;
}
}

View File

@ -162,9 +162,7 @@ public abstract Resource multiplyAndNormalizeDown(
* @return normalized resource
*/
public abstract Resource normalize(Resource r, Resource minimumResource,
Resource maximumResource,
Resource stepFactor);
Resource maximumResource, Resource stepFactor);
/**
* Round-up resource <code>r</code> given factor <code>stepFactor</code>.

View File

@ -55,7 +55,10 @@ public AbstractResourceUsage() {
usages.put(CommonNodeLabelsManager.NO_LABEL, noLabelUsages);
}
// Usage enum here to make implement cleaner
/**
* Use enum here to make implementation more cleaner and readable.
* Indicates array index for each resource usage type.
*/
public enum ResourceType {
// CACHED_USED and CACHED_PENDING may be read by anyone, but must only
// be written by ordering policies
@ -70,6 +73,9 @@ public enum ResourceType {
}
}
/**
* UsageByLabel stores resource array for all resource usage types.
*/
public static class UsageByLabel {
// usage by label, contains all UsageType
private final AtomicReferenceArray<Resource> resArr;

View File

@ -18,13 +18,7 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;

View File

@ -366,11 +366,21 @@ public void validateSubmitApplication(ApplicationId applicationId,
public QueueResourceQuotas getQueueResourceQuotas();
/**
* Get CapacityConfigType as PERCENTAGE or ABSOLUTE_RESOURCE
* Get CapacityConfigType as PERCENTAGE or ABSOLUTE_RESOURCE.
* @return CapacityConfigType
*/
public CapacityConfigType getCapacityConfigType();
/**
* Get effective capacity of queue. If min/max resource is configured,
* preference will be given to absolute configuration over normal capacity.
*
* @param label
* partition
* @return effective queue capacity
*/
Resource getEffectiveCapacity(String label);
/**
* Get effective capacity of queue. If min/max resource is configured,
* preference will be given to absolute configuration over normal capacity.
@ -378,11 +388,22 @@ public void validateSubmitApplication(ApplicationId applicationId,
*
* @param label
* partition
* @param factor
* factor to normalize down
* @return effective queue capacity
*/
Resource getEffectiveCapacity(String label);
Resource getEffectiveCapacityDown(String label, Resource factor);
/**
* Get effective max capacity of queue. If min/max resource is configured,
* preference will be given to absolute configuration over normal capacity.
*
* @param label
* partition
* @return effective max queue capacity
*/
Resource getEffectiveMaxCapacity(String label);
/**
* Get effective max capacity of queue. If min/max resource is configured,
* preference will be given to absolute configuration over normal capacity.
@ -390,8 +411,9 @@ public void validateSubmitApplication(ApplicationId applicationId,
*
* @param label
* partition
* @param factor
* factor to normalize down
* @return effective max queue capacity
*/
Resource getEffectiveMaxCapacity(String label);
Resource getEffectiveMaxCapacityDown(String label, Resource factor);
}

View File

@ -32,6 +32,7 @@
import org.apache.hadoop.yarn.api.records.QueueState;
import org.apache.hadoop.yarn.api.records.ReservationACL;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.ResourceInformation;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
@ -320,7 +321,7 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
@Private
public static final int DEFAULT_MAX_ASSIGN_PER_HEARTBEAT = -1;
/** Configuring absolute min/max resources in a queue **/
/** Configuring absolute min/max resources in a queue. **/
@Private
public static final String MINIMUM_RESOURCE = "min-resource";
@ -333,6 +334,9 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
private static final Pattern RESOURCE_PATTERN = Pattern.compile(PATTERN_FOR_ABSOLUTE_RESOURCE);
/**
* Different resource types supported.
*/
public enum AbsoluteResourceType {
MEMORY, VCORES;
}
@ -1825,7 +1829,7 @@ private Resource internalGetLabeledResourceRequirementForQueue(String queue,
}
// Define resource here.
Resource resource = Resource.newInstance(0l, 0);
Resource resource = Resource.newInstance(0L, 0);
Matcher matcher = RESOURCE_PATTERN.matcher(resourceString);
/*
@ -1852,7 +1856,7 @@ private Resource internalGetLabeledResourceRequirementForQueue(String queue,
}
// Memory has to be configured always.
if (resource.getMemorySize() == 0l) {
if (resource.getMemorySize() == 0L) {
return Resources.none();
}
@ -1884,14 +1888,16 @@ private void updateResourceValuesFromConfig(Set<String> resourceTypes,
AbsoluteResourceType resType = AbsoluteResourceType
.valueOf(StringUtils.toUpperCase(splits[0].trim()));
switch (resType) {
case MEMORY :
resource.setMemorySize(resourceValue);
break;
case VCORES :
resource.setVirtualCores(resourceValue.intValue());
break;
default :
break;
case MEMORY :
resource.setMemorySize(resourceValue);
break;
case VCORES :
resource.setVirtualCores(resourceValue.intValue());
break;
default :
resource.setResourceInformation(splits[0].trim(), ResourceInformation
.newInstance(splits[0].trim(), units, resourceValue));
break;
}
}
}

View File

@ -909,7 +909,6 @@ public void testGetAppToUnreserve() throws Exception {
root.updateClusterResource(clusterResource,
new ResourceLimits(clusterResource));
// Setup resource-requests
Priority p = TestUtils.createMockPriority(5);
SchedulerRequestKey priorityMap = toSchedulerKey(p);