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());
}
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));
}
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));
}
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));
}
Aggregations