use of io.fabric8.kubernetes.api.model.Quantity in project flink by apache.
the class InitTaskManagerDecoratorTest method testMainContainerResourceRequirements.
@Test
public void testMainContainerResourceRequirements() {
final ResourceRequirements resourceRequirements = this.resultMainContainer.getResources();
final Map<String, Quantity> requests = resourceRequirements.getRequests();
assertEquals(Double.toString(TASK_MANAGER_CPU), requests.get("cpu").getAmount());
assertEquals(String.valueOf(TOTAL_PROCESS_MEMORY), requests.get("memory").getAmount());
final Map<String, Quantity> limits = resourceRequirements.getLimits();
assertEquals(Double.toString(TASK_MANAGER_CPU * TASK_MANAGER_CPU_LIMIT_FACTOR), limits.get("cpu").getAmount());
assertEquals(Integer.toString((int) (TOTAL_PROCESS_MEMORY * TASK_MANAGER_MEMORY_LIMIT_FACTOR)), limits.get("memory").getAmount());
}
use of io.fabric8.kubernetes.api.model.Quantity in project flink by apache.
the class InitTaskManagerDecoratorTest method testExternalResourceInResourceRequirements.
@Test
public void testExternalResourceInResourceRequirements() {
final ResourceRequirements resourceRequirements = this.resultMainContainer.getResources();
final Map<String, Quantity> requests = resourceRequirements.getRequests();
assertEquals(Long.toString(RESOURCE_AMOUNT), requests.get(RESOURCE_CONFIG_KEY).getAmount());
final Map<String, Quantity> limits = resourceRequirements.getLimits();
assertEquals(Long.toString(RESOURCE_AMOUNT), limits.get(RESOURCE_CONFIG_KEY).getAmount());
}
use of io.fabric8.kubernetes.api.model.Quantity in project flink by apache.
the class InitJobManagerDecoratorTest method testMainContainerResourceRequirements.
@Test
public void testMainContainerResourceRequirements() {
final ResourceRequirements resourceRequirements = this.resultMainContainer.getResources();
final Map<String, Quantity> requests = resourceRequirements.getRequests();
assertEquals(Double.toString(JOB_MANAGER_CPU), requests.get("cpu").getAmount());
assertEquals(String.valueOf(JOB_MANAGER_MEMORY), requests.get("memory").getAmount());
final Map<String, Quantity> limits = resourceRequirements.getLimits();
assertEquals(Double.toString(JOB_MANAGER_CPU * JOB_MANAGER_CPU_LIMIT_FACTOR), limits.get("cpu").getAmount());
assertEquals(Integer.toString((int) (JOB_MANAGER_MEMORY * JOB_MANAGER_MEMORY_LIMIT_FACTOR)), limits.get("memory").getAmount());
}
use of io.fabric8.kubernetes.api.model.Quantity in project flink by apache.
the class DecoratorWithPodTemplateTestBase method testMainContainerResourceRequirementsMerging.
@Test
public void testMainContainerResourceRequirementsMerging() {
final ResourceRequirements resourceRequirements = this.resultPod.getMainContainer().getResources();
final Map<String, Quantity> requests = resourceRequirements.getRequests();
assertThat(requests.get("cpu").getAmount(), is(String.valueOf(RESOURCE_CPU)));
assertThat(requests.get("memory").getAmount(), is(String.valueOf(RESOURCE_MEMORY)));
assertThat(requests.get("ephemeral-storage").getAmount(), is("256"));
final Map<String, Quantity> limits = resourceRequirements.getLimits();
assertThat(limits.get("cpu").getAmount(), is(String.valueOf(RESOURCE_CPU)));
assertThat(limits.get("memory").getAmount(), is(String.valueOf(RESOURCE_MEMORY)));
assertThat(limits.get("ephemeral-storage").getAmount(), is("256"));
}
use of io.fabric8.kubernetes.api.model.Quantity in project zalenium by zalando.
the class KubernetesContainerClient method buildResourceMaps.
private void buildResourceMaps() {
for (Resources resource : Resources.values()) {
String envValue = environment.getStringEnvVariable(resource.getEnvVar(), null);
if (StringUtils.isNotBlank(envValue)) {
Map<String, Quantity> resourceMap = null;
switch(resource.getResourceType()) {
case REQUEST:
resourceMap = seleniumPodRequests;
break;
case LIMIT:
resourceMap = seleniumPodLimits;
break;
default:
break;
}
if (resourceMap != null) {
Quantity quantity = new Quantity(envValue);
resourceMap.put(resource.getRequestType(), quantity);
}
}
}
}
Aggregations