use of org.apache.flink.configuration.MemorySize in project flink by apache.
the class ResourceProfileTest method testEquals.
@Test
public void testEquals() {
ResourceSpec rs1 = ResourceSpec.newBuilder(1.0, 100).build();
ResourceSpec rs2 = ResourceSpec.newBuilder(1.0, 100).build();
assertEquals(ResourceProfile.fromResourceSpec(rs1), ResourceProfile.fromResourceSpec(rs2));
ResourceSpec rs3 = ResourceSpec.newBuilder(1.0, 100).setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, 2.2)).build();
ResourceSpec rs4 = ResourceSpec.newBuilder(1.0, 100).setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, 1.1)).build();
assertNotEquals(ResourceProfile.fromResourceSpec(rs3), ResourceProfile.fromResourceSpec(rs4));
ResourceSpec rs5 = ResourceSpec.newBuilder(1.0, 100).setExtendedResource(new ExternalResource(EXTERNAL_RESOURCE_NAME, 2.2)).build();
MemorySize networkMemory = MemorySize.ofMebiBytes(100);
assertEquals(ResourceProfile.fromResourceSpec(rs3, networkMemory), ResourceProfile.fromResourceSpec(rs5, networkMemory));
final ResourceProfile rp1 = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemoryMB(100).setTaskOffHeapMemoryMB(100).setManagedMemoryMB(100).setNetworkMemoryMB(100).build();
final ResourceProfile rp2 = ResourceProfile.newBuilder().setCpuCores(1.1).setTaskHeapMemoryMB(100).setTaskOffHeapMemoryMB(100).setManagedMemoryMB(100).setNetworkMemoryMB(100).build();
final ResourceProfile rp3 = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemoryMB(110).setTaskOffHeapMemoryMB(100).setManagedMemoryMB(100).setNetworkMemoryMB(100).build();
final ResourceProfile rp4 = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemoryMB(100).setTaskOffHeapMemoryMB(110).setManagedMemoryMB(100).setNetworkMemoryMB(100).build();
final ResourceProfile rp5 = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemoryMB(100).setTaskOffHeapMemoryMB(100).setManagedMemoryMB(110).setNetworkMemoryMB(100).build();
final ResourceProfile rp6 = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemoryMB(100).setTaskOffHeapMemoryMB(100).setManagedMemoryMB(110).setNetworkMemoryMB(100).build();
final ResourceProfile rp7 = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemoryMB(100).setTaskOffHeapMemoryMB(100).setManagedMemoryMB(100).setNetworkMemoryMB(110).build();
final ResourceProfile rp8 = ResourceProfile.newBuilder().setCpuCores(1.0).setTaskHeapMemoryMB(100).setTaskOffHeapMemoryMB(100).setManagedMemoryMB(100).setNetworkMemoryMB(100).build();
assertNotEquals(rp1, rp2);
assertNotEquals(rp1, rp3);
assertNotEquals(rp1, rp4);
assertNotEquals(rp1, rp5);
assertNotEquals(rp1, rp6);
assertNotEquals(rp1, rp7);
assertEquals(rp1, rp8);
}
use of org.apache.flink.configuration.MemorySize in project flink by apache.
the class TaskExecutorProcessUtilsTest method testConfigNetworkMemoryRange.
@Test
public void testConfigNetworkMemoryRange() {
final MemorySize networkMin = MemorySize.parse("200m");
final MemorySize networkMax = MemorySize.parse("500m");
Configuration conf = new Configuration();
conf.set(TaskManagerOptions.NETWORK_MEMORY_MAX, networkMax);
conf.set(TaskManagerOptions.NETWORK_MEMORY_MIN, networkMin);
validateInAllConfigurations(conf, taskExecutorProcessSpec -> {
assertThat(taskExecutorProcessSpec.getNetworkMemSize().getBytes(), greaterThanOrEqualTo(networkMin.getBytes()));
assertThat(taskExecutorProcessSpec.getNetworkMemSize().getBytes(), lessThanOrEqualTo(networkMax.getBytes()));
});
}
use of org.apache.flink.configuration.MemorySize in project flink by apache.
the class TaskExecutorProcessUtilsTest method testConfigTaskOffheapMemory.
@Test
public void testConfigTaskOffheapMemory() {
final MemorySize taskOffHeapSize = MemorySize.parse("50m");
Configuration conf = new Configuration();
conf.set(TaskManagerOptions.TASK_OFF_HEAP_MEMORY, taskOffHeapSize);
validateInAllConfigurations(conf, taskExecutorProcessSpec -> assertThat(taskExecutorProcessSpec.getTaskOffHeapSize(), is(taskOffHeapSize)));
}
use of org.apache.flink.configuration.MemorySize in project flink by apache.
the class TaskExecutorProcessUtilsTest method testConfigManagedMemoryLegacySize.
@Test
public void testConfigManagedMemoryLegacySize() {
final MemorySize managedMemSize = MemorySize.parse("100m");
@SuppressWarnings("deprecation") final ConfigOption<MemorySize> legacyOption = TaskManagerOptions.MANAGED_MEMORY_SIZE;
Configuration conf = new Configuration();
conf.set(legacyOption, managedMemSize);
// validate in configurations without explicit managed memory size,
// to avoid checking against overwritten managed memory size
validateInConfigurationsWithoutExplicitManagedMem(conf, taskExecutorProcessSpec -> assertThat(taskExecutorProcessSpec.getManagedMemorySize(), is(managedMemSize)));
}
use of org.apache.flink.configuration.MemorySize in project flink by apache.
the class TaskExecutorProcessUtilsTest method testFlinkInternalMemorySizeAddUpFailure.
@Test
public void testFlinkInternalMemorySizeAddUpFailure() {
final MemorySize totalFlinkMemory = MemorySize.parse("499m");
final MemorySize frameworkHeap = MemorySize.parse("100m");
final MemorySize taskHeap = MemorySize.parse("100m");
final MemorySize taskOffHeap = MemorySize.parse("100m");
final MemorySize network = MemorySize.parse("100m");
final MemorySize managed = MemorySize.parse("100m");
Configuration conf = new Configuration();
conf.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, totalFlinkMemory);
conf.set(TaskManagerOptions.FRAMEWORK_HEAP_MEMORY, frameworkHeap);
conf.set(TaskManagerOptions.TASK_HEAP_MEMORY, taskHeap);
conf.set(TaskManagerOptions.TASK_OFF_HEAP_MEMORY, taskOffHeap);
conf.set(TaskManagerOptions.NETWORK_MEMORY_MIN, network);
conf.set(TaskManagerOptions.NETWORK_MEMORY_MAX, network);
conf.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, managed);
validateFail(conf);
}
Aggregations