|
@@ -72,7 +72,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
boolean rhsGreater = false;
|
|
|
int ret = 0;
|
|
|
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation lhsResourceInformation = lhs
|
|
|
.getResourceInformation(i);
|
|
@@ -110,7 +110,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
// resources and then look for which resource has the biggest
|
|
|
// share overall.
|
|
|
ResourceInformation[] clusterRes = clusterResource.getResources();
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
|
|
|
// If array creation shows up as a time sink, these arrays could be cached
|
|
|
// because they're always the same length.
|
|
@@ -183,7 +183,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
ResourceInformation[] firstRes = first.getResources();
|
|
|
ResourceInformation[] secondRes = second.getResources();
|
|
|
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
firstShares[i] = calculateShare(clusterRes[i], firstRes[i]);
|
|
|
secondShares[i] = calculateShare(clusterRes[i], secondRes[i]);
|
|
@@ -274,7 +274,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
max[0] = 0.0;
|
|
|
max[1] = 0.0;
|
|
|
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
firstShares[i] = calculateShare(clusterRes[i], firstRes[i]);
|
|
|
secondShares[i] = calculateShare(clusterRes[i], secondRes[i]);
|
|
@@ -330,7 +330,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
public long computeAvailableContainers(Resource available,
|
|
|
Resource required) {
|
|
|
long min = Long.MAX_VALUE;
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation availableResource = available
|
|
|
.getResourceInformation(i);
|
|
@@ -346,7 +346,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
@Override
|
|
|
public float divide(Resource clusterResource,
|
|
|
Resource numerator, Resource denominator) {
|
|
|
- int nKnownResourceTypes = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int nKnownResourceTypes = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
ResourceInformation[] clusterRes = clusterResource.getResources();
|
|
|
// We have to provide the calculateShares() method with somewhere to store
|
|
|
// the shares. We don't actually need these shares afterwards.
|
|
@@ -375,7 +375,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
@Override
|
|
|
public float ratio(Resource a, Resource b) {
|
|
|
float ratio = 0.0f;
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation aResourceInformation = a.getResourceInformation(i);
|
|
|
ResourceInformation bResourceInformation = b.getResourceInformation(i);
|
|
@@ -393,7 +393,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
|
|
|
public Resource divideAndCeil(Resource numerator, long denominator) {
|
|
|
Resource ret = Resource.newInstance(numerator);
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation resourceInformation = ret.getResourceInformation(i);
|
|
|
resourceInformation
|
|
@@ -414,7 +414,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
public Resource normalize(Resource r, Resource minimumResource,
|
|
|
Resource maximumResource, Resource stepFactor) {
|
|
|
Resource ret = Resource.newInstance(r);
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation rResourceInformation = r.getResourceInformation(i);
|
|
|
ResourceInformation minimumResourceInformation = minimumResource
|
|
@@ -448,7 +448,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
|
|
|
private Resource rounding(Resource r, Resource stepFactor, boolean roundUp) {
|
|
|
Resource ret = Resource.newInstance(r);
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation rResourceInformation = r.getResourceInformation(i);
|
|
|
ResourceInformation stepFactorResourceInformation = stepFactor
|
|
@@ -473,7 +473,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
public Resource multiplyAndNormalizeUp(Resource r, double[] by,
|
|
|
Resource stepFactor) {
|
|
|
Resource ret = Resource.newInstance(r);
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation rResourceInformation = r.getResourceInformation(i);
|
|
|
ResourceInformation stepFactorResourceInformation = stepFactor
|
|
@@ -502,7 +502,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
private Resource multiplyAndNormalize(Resource r, double by,
|
|
|
Resource stepFactor, boolean roundUp) {
|
|
|
Resource ret = Resource.newInstance(r);
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation rResourceInformation = r.getResourceInformation(i);
|
|
|
ResourceInformation stepFactorResourceInformation = stepFactor
|
|
@@ -528,7 +528,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
|
|
|
@Override
|
|
|
public boolean fitsIn(Resource smaller, Resource bigger) {
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation sResourceInformation = smaller
|
|
|
.getResourceInformation(i);
|
|
@@ -544,7 +544,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
@Override
|
|
|
public Resource normalizeDown(Resource r, Resource stepFactor) {
|
|
|
Resource ret = Resource.newInstance(r);
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation rResourceInformation = r.getResourceInformation(i);
|
|
|
ResourceInformation stepFactorResourceInformation = stepFactor
|
|
@@ -564,7 +564,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
|
|
|
@Override
|
|
|
public boolean isAnyMajorResourceZeroOrNegative(Resource resource) {
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation resourceInformation = resource.getResourceInformation(
|
|
|
i);
|
|
@@ -577,7 +577,7 @@ public class DominantResourceCalculator extends ResourceCalculator {
|
|
|
|
|
|
@Override
|
|
|
public boolean isAnyMajorResourceAboveZero(Resource resource) {
|
|
|
- int maxLength = ResourceUtils.getNumberOfKnownResourceTypes();
|
|
|
+ int maxLength = ResourceUtils.getNumberOfCountableResourceTypes();
|
|
|
for (int i = 0; i < maxLength; i++) {
|
|
|
ResourceInformation resourceInformation = resource.getResourceInformation(
|
|
|
i);
|