public Resource getResource(Resource clusterResource) {
    if (percentages != null && clusterResource != null) {
      long memory = (long) (clusterResource.getMemorySize() * percentages[0]);
      int vcore = (int) (clusterResource.getVirtualCores() * percentages[1]);
      Resource res = Resource.newInstance(memory, vcore);
      ResourceInformation[] clusterInfo = clusterResource.getResources();

      for (int i = 2; i < clusterInfo.length; i++) {
        res.setResourceValue(i,
            (long)(clusterInfo[i].getValue() * percentages[i]));
      }

      return res;
    } else {
      return resource;
    }
  }
@Test
  public void testGetResourceWithAbsolute() {
    ConfigurableResource configurableResource =
        new ConfigurableResource(Resources.createResource(3072, 3));
    assertThat(configurableResource.getResource().getMemorySize()).
        isEqualTo(3072);
    assertThat(configurableResource.getResource().getVirtualCores()).
        isEqualTo(3);

    assertEquals(
        configurableResource.getResource(clusterResource).getMemorySize(),
        3072);
    assertEquals(
        configurableResource.getResource(clusterResource).getVirtualCores(),
        3);

    assertThat(configurableResource.getResource(null).getMemorySize()).
        isEqualTo(3072);
    assertThat(configurableResource.getResource(null).getVirtualCores()).
        isEqualTo(3);
  }