YARN-6778. In ResourceWeights, weights and setWeights() should be final. (Daniel Templeton via Yufei Gu)

This commit is contained in:
Yufei Gu 2017-07-18 16:38:07 -07:00
parent 5aa2bf231f
commit daaf530fce

View File

@ -27,7 +27,7 @@
public class ResourceWeights { public class ResourceWeights {
public static final ResourceWeights NEUTRAL = new ResourceWeights(1.0f); public static final ResourceWeights NEUTRAL = new ResourceWeights(1.0f);
private float[] weights = new float[ResourceType.values().length]; private final float[] weights = new float[ResourceType.values().length];
public ResourceWeights(float memoryWeight, float cpuWeight) { public ResourceWeights(float memoryWeight, float cpuWeight) {
weights[ResourceType.MEMORY.ordinal()] = memoryWeight; weights[ResourceType.MEMORY.ordinal()] = memoryWeight;
@ -40,7 +40,7 @@ public ResourceWeights(float weight) {
public ResourceWeights() { } public ResourceWeights() { }
public void setWeight(float weight) { public final void setWeight(float weight) {
for (int i = 0; i < weights.length; i++) { for (int i = 0; i < weights.length; i++) {
weights[i] = weight; weights[i] = weight;
} }