Resources { public static Resource multiplyAndRoundDown(Resource lhs, double by) { Resource out = clone(lhs); int maxLength = ResourceUtils.getNumberOfKnownResourceTypes(); for (int i = 0; i < maxLength; i++) { try { ResourceInformation lhsValue = lhs.getResourceInformation(i); out.setResourceValue(i, (long) (lhsValue.getValue() * by)); } catch (ResourceNotFoundException ye) { LOG.warn("Resource is missing:" + ye.getMessage()); continue; } } return out; }  @Private @Unstable static Resource createResourceWithSameValue(long value); static Resource createResource(int memory); static Resource createResource(int memory, int cores); static Resource createResource(long memory); static Resource createResource(long memory, int cores); static Resource none(); static boolean isNone(Resource other); static Resource unbounded(); static Resource clone(Resource res); static Resource addTo(Resource lhs, Resource rhs); static Resource add(Resource lhs, Resource rhs); static Resource subtractFrom(Resource lhs, Resource rhs); static Resource subtract(Resource lhs, Resource rhs); static Resource subtractFromNonNegative(Resource lhs, Resource rhs); static Resource subtractNonNegative(Resource lhs, Resource rhs); static Resource negate(Resource resource); static Resource multiplyTo(Resource lhs, double by); static Resource multiply(Resource lhs, double by); static Resource multiplyAndAddTo(
      Resource lhs, Resource rhs, double by); static Resource multiplyAndNormalizeUp(ResourceCalculator calculator,
      Resource lhs, double[] by, Resource factor); static Resource multiplyAndNormalizeUp(
      ResourceCalculator calculator,Resource lhs, double by, Resource factor); static Resource multiplyAndNormalizeDown(
      ResourceCalculator calculator,Resource lhs, double by, Resource factor); static Resource multiplyAndRoundDown(Resource lhs, double by); static Resource multiplyAndRoundUp(Resource lhs, double by); static Resource normalize(
      ResourceCalculator calculator, Resource lhs, Resource min,
      Resource max, Resource increment); static Resource roundUp(
      ResourceCalculator calculator, Resource lhs, Resource factor); static Resource roundDown(
      ResourceCalculator calculator, Resource lhs, Resource factor); static boolean isInvalidDivisor(
      ResourceCalculator resourceCalculator, Resource divisor); static float ratio(
      ResourceCalculator resourceCalculator, Resource lhs, Resource rhs); static float divide(
      ResourceCalculator resourceCalculator,
      Resource clusterResource, Resource lhs, Resource rhs); static Resource divideAndCeil(
      ResourceCalculator resourceCalculator, Resource lhs, int rhs); static Resource divideAndCeil(
      ResourceCalculator resourceCalculator, Resource lhs, float rhs); static boolean equals(Resource lhs, Resource rhs); static boolean lessThan(
      ResourceCalculator resourceCalculator, 
      Resource clusterResource,
      Resource lhs, Resource rhs); static boolean lessThanOrEqual(
      ResourceCalculator resourceCalculator, 
      Resource clusterResource,
      Resource lhs, Resource rhs); static boolean greaterThan(
      ResourceCalculator resourceCalculator,
      Resource clusterResource,
      Resource lhs, Resource rhs); static boolean greaterThanOrEqual(
      ResourceCalculator resourceCalculator, 
      Resource clusterResource,
      Resource lhs, Resource rhs); static Resource min(
      ResourceCalculator resourceCalculator, 
      Resource clusterResource,
      Resource lhs, Resource rhs); static Resource max(
      ResourceCalculator resourceCalculator, 
      Resource clusterResource,
      Resource lhs, Resource rhs); static boolean fitsIn(Resource smaller, Resource bigger); static boolean fitsIn(ResourceCalculator rc,
      Resource smaller, Resource bigger); static Resource componentwiseMin(Resource lhs, Resource rhs); static Resource componentwiseMax(Resource lhs, Resource rhs); static Resource normalizeDown(ResourceCalculator calculator,
      Resource resource, Resource factor);  }
@Test public void testMultiplyAndRoundDown() { assertEquals(createResource(4, 1), multiplyAndRoundDown(createResource(3, 1), 1.5)); assertEquals(createResource(4, 1, 0), multiplyAndRoundDown(createResource(3, 1), 1.5)); assertEquals(createResource(1, 4), multiplyAndRoundDown(createResource(1, 3), 1.5)); assertEquals(createResource(1, 4, 0), multiplyAndRoundDown(createResource(1, 3), 1.5)); assertEquals(createResource(7, 7, 0), multiplyAndRoundDown(createResource(3, 3, 0), 2.5)); assertEquals(createResource(2, 2, 7), multiplyAndRoundDown(createResource(1, 1, 3), 2.5)); }