Search in sources :

Example 6 with MemorySize

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);
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) ResourceSpec(org.apache.flink.api.common.operators.ResourceSpec) ExternalResource(org.apache.flink.api.common.resources.ExternalResource) Test(org.junit.Test)

Example 7 with MemorySize

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()));
    });
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 8 with MemorySize

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)));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 9 with MemorySize

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)));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 10 with MemorySize

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);
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Aggregations

MemorySize (org.apache.flink.configuration.MemorySize)81 Test (org.junit.Test)56 Configuration (org.apache.flink.configuration.Configuration)51 IllegalConfigurationException (org.apache.flink.configuration.IllegalConfigurationException)6 Path (org.apache.flink.core.fs.Path)5 File (java.io.File)4 ArrayList (java.util.ArrayList)3 CPUResource (org.apache.flink.api.common.resources.CPUResource)3 FileSourceSplit (org.apache.flink.connector.file.src.FileSourceSplit)2 BulkFormat (org.apache.flink.connector.file.src.reader.BulkFormat)2 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)2 IntermediateResultPartitionTest (org.apache.flink.runtime.executiongraph.IntermediateResultPartitionTest)2 SlotSharingGroup (org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup)2 TaskExecutorFlinkMemory (org.apache.flink.runtime.util.config.memory.taskmanager.TaskExecutorFlinkMemory)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 UUID (java.util.UUID)1 ResourceSpec (org.apache.flink.api.common.operators.ResourceSpec)1