YARN-7564. Cleanup to fix checkstyle issues of YARN-5881 branch. Contributed by Sunil G.
This commit is contained in:
parent
1012b901c8
commit
daa1cdd062
|
@ -1171,16 +1171,16 @@ public class StringUtils {
|
|||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -236,12 +236,12 @@ public class QueueConfigurationsPBImpl extends QueueConfigurations {
|
|||
}
|
||||
|
||||
@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 class QueueConfigurationsPBImpl extends QueueConfigurations {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setConfiguredMaxCapacity(Resource configuredMaxResource) {
|
||||
public void setConfiguredMaxCapacity(Resource maxResource) {
|
||||
maybeInitBuilder();
|
||||
if (configuredMaxResource == null) {
|
||||
builder.clearConfiguredMaxCapacity();
|
||||
}
|
||||
this.configuredMaxResource = configuredMaxResource;
|
||||
this.configuredMaxResource = maxResource;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -515,7 +515,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Resource multiplyAndNormalizeUp(Resource r, double by,
|
||||
Resource stepFactor) {
|
||||
|
|
|
@ -127,12 +127,12 @@ public abstract class ResourceCalculator {
|
|||
Resource r, double by, Resource stepFactor);
|
||||
|
||||
/**
|
||||
* Multiply resource <code>r</code> by factor <code>by</code>
|
||||
* Multiply resource <code>r</code> by factor <code>by</code>
|
||||
* and normalize up using step-factor <code>stepFactor</code>.
|
||||
*
|
||||
*
|
||||
* @param r resource to be multiplied
|
||||
* @param by multiplier array for all resource types
|
||||
* @param stepFactor factor by which to normalize up
|
||||
* @param stepFactor factor by which to normalize up
|
||||
* @return resulting normalized resource
|
||||
*/
|
||||
public abstract Resource multiplyAndNormalizeUp(
|
||||
|
@ -149,7 +149,7 @@ public abstract class ResourceCalculator {
|
|||
*/
|
||||
public abstract Resource multiplyAndNormalizeDown(
|
||||
Resource r, double by, Resource stepFactor);
|
||||
|
||||
|
||||
/**
|
||||
* Normalize resource <code>r</code> given the base
|
||||
* <code>minimumResource</code> and verify against max allowed
|
||||
|
@ -162,9 +162,7 @@ public abstract class ResourceCalculator {
|
|||
* @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>.
|
||||
|
|
|
@ -55,7 +55,10 @@ public class 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 class AbstractResourceUsage {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UsageByLabel stores resource array for all resource usage types.
|
||||
*/
|
||||
public static class UsageByLabel {
|
||||
// usage by label, contains all UsageType
|
||||
private final AtomicReferenceArray<Resource> resArr;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -366,11 +366,21 @@ public interface CSQueue extends SchedulerQueue<CSQueue> {
|
|||
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 interface CSQueue extends SchedulerQueue<CSQueue> {
|
|||
*
|
||||
* @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 interface CSQueue extends SchedulerQueue<CSQueue> {
|
|||
*
|
||||
* @param label
|
||||
* partition
|
||||
* @param factor
|
||||
* factor to normalize down
|
||||
* @return effective max queue capacity
|
||||
*/
|
||||
Resource getEffectiveMaxCapacity(String label);
|
||||
Resource getEffectiveMaxCapacityDown(String label, Resource factor);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.hadoop.yarn.api.records.QueueACL;
|
|||
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 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
|
|||
}
|
||||
|
||||
// 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 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
|
|||
}
|
||||
|
||||
// Memory has to be configured always.
|
||||
if (resource.getMemorySize() == 0l) {
|
||||
if (resource.getMemorySize() == 0L) {
|
||||
return Resources.none();
|
||||
}
|
||||
|
||||
|
@ -1884,14 +1888,16 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -904,12 +904,11 @@ public class TestReservations {
|
|||
String host_1 = "host_1";
|
||||
FiCaSchedulerNode node_1 = TestUtils.getMockNode(host_1, DEFAULT_RACK, 0,
|
||||
8 * GB);
|
||||
|
||||
|
||||
Resource clusterResource = Resources.createResource(2 * 8 * GB);
|
||||
root.updateClusterResource(clusterResource,
|
||||
new ResourceLimits(clusterResource));
|
||||
|
||||
|
||||
// Setup resource-requests
|
||||
Priority p = TestUtils.createMockPriority(5);
|
||||
SchedulerRequestKey priorityMap = toSchedulerKey(p);
|
||||
|
|
Loading…
Reference in New Issue