Search in sources :

Example 16 with ExternalResource

use of org.apache.flink.api.common.resources.ExternalResource in project flink by apache.

the class WorkerResourceSpecTest method testCreateFromResourceProfile.

@Test
public void testCreateFromResourceProfile() {
    final int numSlots = 3;
    final ResourceProfile resourceProfile = ResourceProfile.newBuilder().setCpuCores(1).setManagedMemoryMB(100).setNetworkMemoryMB(100).setTaskOffHeapMemoryMB(10).setTaskHeapMemoryMB(10).setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, 1)).build();
    final WorkerResourceSpec workerResourceSpec = WorkerResourceSpec.fromTotalResourceProfile(resourceProfile, numSlots);
    assertEquals(workerResourceSpec.getCpuCores(), resourceProfile.getCpuCores());
    assertEquals(workerResourceSpec.getTaskHeapSize(), resourceProfile.getTaskHeapMemory());
    assertEquals(workerResourceSpec.getTaskOffHeapSize(), resourceProfile.getTaskOffHeapMemory());
    assertEquals(workerResourceSpec.getNetworkMemSize(), resourceProfile.getNetworkMemory());
    assertEquals(workerResourceSpec.getManagedMemSize(), resourceProfile.getManagedMemory());
    assertEquals(workerResourceSpec.getNumSlots(), numSlots);
    assertEquals(workerResourceSpec.getExtendedResources(), resourceProfile.getExtendedResources());
}
Also used : ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) ExternalResource(org.apache.flink.api.common.resources.ExternalResource) Test(org.junit.Test)

Example 17 with ExternalResource

use of org.apache.flink.api.common.resources.ExternalResource in project flink by apache.

the class SlotManagerUtilsTest method testGenerateDefaultSlotProfileFromWorkerResourceSpec.

@Test
public void testGenerateDefaultSlotProfileFromWorkerResourceSpec() {
    final int numSlots = 5;
    final ResourceProfile resourceProfile = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemoryMB(1).setTaskOffHeapMemoryMB(2).setNetworkMemoryMB(3).setManagedMemoryMB(4).setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, 1)).build();
    final WorkerResourceSpec workerResourceSpec = new WorkerResourceSpec.Builder().setCpuCores(1.0 * numSlots).setTaskHeapMemoryMB(1 * numSlots).setTaskOffHeapMemoryMB(2 * numSlots).setNetworkMemoryMB(3 * numSlots).setManagedMemoryMB(4 * numSlots).setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, numSlots)).build();
    assertThat(SlotManagerUtils.generateDefaultSlotResourceProfile(workerResourceSpec, numSlots), is(resourceProfile));
}
Also used : ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) WorkerResourceSpec(org.apache.flink.runtime.resourcemanager.WorkerResourceSpec) ExternalResource(org.apache.flink.api.common.resources.ExternalResource) Test(org.junit.Test)

Example 18 with ExternalResource

use of org.apache.flink.api.common.resources.ExternalResource in project flink by apache.

the class SlotManagerUtilsTest method testGenerateTaskManagerTotalResourceProfile.

@Test
public void testGenerateTaskManagerTotalResourceProfile() {
    final ResourceProfile resourceProfile = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemoryMB(1).setTaskOffHeapMemoryMB(2).setNetworkMemoryMB(3).setManagedMemoryMB(4).setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, 1)).build();
    final WorkerResourceSpec workerResourceSpec = new WorkerResourceSpec.Builder().setCpuCores(1.0).setTaskHeapMemoryMB(1).setTaskOffHeapMemoryMB(2).setNetworkMemoryMB(3).setManagedMemoryMB(4).setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, 1)).build();
    assertThat(SlotManagerUtils.generateTaskManagerTotalResourceProfile(workerResourceSpec), equalTo(resourceProfile));
}
Also used : ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) WorkerResourceSpec(org.apache.flink.runtime.resourcemanager.WorkerResourceSpec) ExternalResource(org.apache.flink.api.common.resources.ExternalResource) Test(org.junit.Test)

Example 19 with ExternalResource

use of org.apache.flink.api.common.resources.ExternalResource in project flink by apache.

the class SlotManagerUtilsTest method testGenerateDefaultSlotProfileFromTotalResourceProfile.

@Test
public void testGenerateDefaultSlotProfileFromTotalResourceProfile() {
    final int numSlots = 5;
    final ResourceProfile resourceProfile = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemoryMB(1).setTaskOffHeapMemoryMB(2).setNetworkMemoryMB(3).setManagedMemoryMB(4).setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, 1)).build();
    final ResourceProfile totalResourceProfile = ResourceProfile.newBuilder().setCpuCores(1.0 * numSlots).setTaskHeapMemoryMB(1 * numSlots).setTaskOffHeapMemoryMB(2 * numSlots).setNetworkMemoryMB(3 * numSlots).setManagedMemoryMB(4 * numSlots).setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, numSlots)).build();
    assertThat(SlotManagerUtils.generateDefaultSlotResourceProfile(totalResourceProfile, numSlots), is(resourceProfile));
}
Also used : ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) ExternalResource(org.apache.flink.api.common.resources.ExternalResource) Test(org.junit.Test)

Aggregations

ExternalResource (org.apache.flink.api.common.resources.ExternalResource)19 Test (org.junit.Test)16 CPUResource (org.apache.flink.api.common.resources.CPUResource)6 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)5 ResourceSpec (org.apache.flink.api.common.operators.ResourceSpec)4 WorkerResourceSpec (org.apache.flink.runtime.resourcemanager.WorkerResourceSpec)4 Configuration (org.apache.flink.configuration.Configuration)3 HashMap (java.util.HashMap)2 TaskExecutorProcessSpec (org.apache.flink.runtime.clusterframework.TaskExecutorProcessSpec)2 Quantity (io.fabric8.kubernetes.api.model.Quantity)1 ResourceRequirementsBuilder (io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder)1 Map (java.util.Map)1 SlotSharingGroup (org.apache.flink.api.common.operators.SlotSharingGroup)1 MemorySize (org.apache.flink.configuration.MemorySize)1 KubernetesConfigMap (org.apache.flink.kubernetes.kubeclient.resources.KubernetesConfigMap)1 TaskExecutorResourceSpec (org.apache.flink.runtime.taskexecutor.TaskExecutorResourceSpec)1