Search in sources :

Example 26 with MemorySize

use of org.apache.flink.configuration.MemorySize in project flink by apache.

the class JobManagerFlinkMemoryUtils method deriveFromTotalFlinkMemory.

@Override
public JobManagerFlinkMemory deriveFromTotalFlinkMemory(Configuration config, MemorySize totalFlinkMemorySize) {
    MemorySize offHeapMemorySize = ProcessMemoryUtils.getMemorySizeFromConfig(config, JobManagerOptions.OFF_HEAP_MEMORY);
    if (totalFlinkMemorySize.compareTo(offHeapMemorySize) < 1) {
        throw new IllegalConfigurationException("The configured Total Flink Memory (%s) is less than the configured Off-heap Memory (%s).", totalFlinkMemorySize.toHumanReadableString(), offHeapMemorySize.toHumanReadableString());
    }
    MemorySize derivedJvmHeapMemorySize = totalFlinkMemorySize.subtract(offHeapMemorySize);
    return createJobManagerFlinkMemory(derivedJvmHeapMemorySize, offHeapMemorySize);
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException)

Example 27 with MemorySize

use of org.apache.flink.configuration.MemorySize in project flink by apache.

the class TaskExecutorFlinkMemoryUtils method getNetworkMemoryRangeFraction.

private static RangeFraction getNetworkMemoryRangeFraction(final Configuration config) {
    final MemorySize minSize = ProcessMemoryUtils.getMemorySizeFromConfig(config, TaskManagerOptions.NETWORK_MEMORY_MIN);
    final MemorySize maxSize = ProcessMemoryUtils.getMemorySizeFromConfig(config, TaskManagerOptions.NETWORK_MEMORY_MAX);
    return ProcessMemoryUtils.getRangeFraction(minSize, maxSize, TaskManagerOptions.NETWORK_MEMORY_FRACTION, config);
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize)

Example 28 with MemorySize

use of org.apache.flink.configuration.MemorySize in project flink by apache.

the class TaskExecutorMemoryConfigurationTest method testInitialization.

@Test
public void testInitialization() {
    Configuration config = new Configuration();
    config.set(FRAMEWORK_HEAP_MEMORY, new MemorySize(1));
    config.set(TASK_HEAP_MEMORY, new MemorySize(2));
    config.set(FRAMEWORK_OFF_HEAP_MEMORY, new MemorySize(3));
    config.set(TASK_OFF_HEAP_MEMORY, new MemorySize(4));
    config.set(NETWORK_MEMORY_MIN, new MemorySize(6));
    config.set(NETWORK_MEMORY_MAX, new MemorySize(6));
    config.set(NETWORK_MEMORY_FRACTION, 0.1f);
    config.set(MANAGED_MEMORY_SIZE, new MemorySize(7));
    config.set(MANAGED_MEMORY_FRACTION, 0.2f);
    config.set(JVM_METASPACE, new MemorySize(8));
    config.set(JVM_OVERHEAD_MIN, new MemorySize(10));
    config.set(JVM_OVERHEAD_MAX, new MemorySize(10));
    config.set(JVM_OVERHEAD_FRACTION, 0.3f);
    TaskExecutorMemoryConfiguration actual = TaskExecutorMemoryConfiguration.create(config);
    TaskExecutorMemoryConfiguration expected = new TaskExecutorMemoryConfiguration(1L, 2L, 3L, 4L, 6L, 7L, 8L, 10L, 23L, 41L);
    assertThat(actual, is(expected));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 29 with MemorySize

use of org.apache.flink.configuration.MemorySize in project flink by apache.

the class TaskExecutorResourceUtilsTest method testCalculateTotalProcessMemoryWithMissingFactors.

@Test(expected = IllegalArgumentException.class)
public void testCalculateTotalProcessMemoryWithMissingFactors() {
    Configuration config = new Configuration();
    config.set(TaskManagerOptions.FRAMEWORK_HEAP_MEMORY, new MemorySize(1));
    config.set(TaskManagerOptions.FRAMEWORK_OFF_HEAP_MEMORY, new MemorySize(3));
    config.set(TaskManagerOptions.TASK_OFF_HEAP_MEMORY, new MemorySize(4));
    config.set(TaskManagerOptions.NETWORK_MEMORY_MAX, new MemorySize(6));
    config.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, new MemorySize(7));
    config.set(TaskManagerOptions.JVM_METASPACE, new MemorySize(8));
    TaskExecutorResourceUtils.calculateTotalProcessMemoryFromComponents(config);
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 30 with MemorySize

use of org.apache.flink.configuration.MemorySize in project flink by apache.

the class TaskExecutorResourceUtilsTest method testCalculateTotalProcessMemoryWithAllFactorsBeingSet.

@Test
public void testCalculateTotalProcessMemoryWithAllFactorsBeingSet() {
    Configuration config = new Configuration();
    config.set(TaskManagerOptions.FRAMEWORK_HEAP_MEMORY, new MemorySize(1));
    config.set(TaskManagerOptions.TASK_HEAP_MEMORY, new MemorySize(2));
    config.set(TaskManagerOptions.FRAMEWORK_OFF_HEAP_MEMORY, new MemorySize(3));
    config.set(TaskManagerOptions.TASK_OFF_HEAP_MEMORY, new MemorySize(4));
    config.set(TaskManagerOptions.NETWORK_MEMORY_MAX, new MemorySize(6));
    config.set(TaskManagerOptions.NETWORK_MEMORY_MIN, new MemorySize(6));
    config.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, new MemorySize(7));
    config.set(TaskManagerOptions.JVM_METASPACE, new MemorySize(8));
    config.set(TaskManagerOptions.JVM_OVERHEAD_MAX, new MemorySize(10));
    config.set(TaskManagerOptions.JVM_OVERHEAD_MIN, new MemorySize(10));
    assertThat(TaskExecutorResourceUtils.calculateTotalProcessMemoryFromComponents(config), is(41L));
}
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