Search in sources :

Example 11 with MemorySize

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

the class TaskExecutorProcessUtilsTest method testConfigNetworkMemoryRangeFailure.

@Test
public void testConfigNetworkMemoryRangeFailure() {
    final MemorySize networkMin = MemorySize.parse("200m");
    final MemorySize networkMax = MemorySize.parse("50m");
    Configuration conf = new Configuration();
    conf.set(TaskManagerOptions.NETWORK_MEMORY_MAX, networkMax);
    conf.set(TaskManagerOptions.NETWORK_MEMORY_MIN, networkMin);
    validateFailInAllConfigurations(conf);
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 12 with MemorySize

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

the class TaskExecutorProcessUtilsTest method configWithFineGrainedOptions.

@Override
protected void configWithFineGrainedOptions(Configuration configuration, MemorySize totalFlinkMemorySize) {
    MemorySize componentSize = new MemorySize(totalFlinkMemorySize.getBytes() / 6);
    configuration.set(TaskManagerOptions.TASK_HEAP_MEMORY, componentSize);
    configuration.set(TaskManagerOptions.TASK_OFF_HEAP_MEMORY, componentSize);
    configuration.set(TaskManagerOptions.FRAMEWORK_HEAP_MEMORY, componentSize);
    configuration.set(TaskManagerOptions.FRAMEWORK_OFF_HEAP_MEMORY, componentSize);
    configuration.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, componentSize);
// network is the 6th component, fixed implicitly
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize)

Example 13 with MemorySize

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

the class TaskExecutorProcessUtilsTest method testConfigManagedMemorySize.

@Test
public void testConfigManagedMemorySize() {
    final MemorySize managedMemSize = MemorySize.parse("100m");
    Configuration conf = new Configuration();
    conf.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, 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 14 with MemorySize

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

the class TaskExecutorProcessUtils method processSpecFromWorkerResourceSpec.

public static TaskExecutorProcessSpec processSpecFromWorkerResourceSpec(final Configuration config, final WorkerResourceSpec workerResourceSpec) {
    final MemorySize frameworkHeapMemorySize = TaskExecutorFlinkMemoryUtils.getFrameworkHeapMemorySize(config);
    final MemorySize frameworkOffHeapMemorySize = TaskExecutorFlinkMemoryUtils.getFrameworkOffHeapMemorySize(config);
    final TaskExecutorFlinkMemory flinkMemory = new TaskExecutorFlinkMemory(frameworkHeapMemorySize, frameworkOffHeapMemorySize, workerResourceSpec.getTaskHeapSize(), workerResourceSpec.getTaskOffHeapSize(), workerResourceSpec.getNetworkMemSize(), workerResourceSpec.getManagedMemSize());
    final JvmMetaspaceAndOverhead jvmMetaspaceAndOverhead = PROCESS_MEMORY_UTILS.deriveJvmMetaspaceAndOverheadFromTotalFlinkMemory(config, flinkMemory.getTotalFlinkMemorySize());
    return new TaskExecutorProcessSpec(workerResourceSpec.getCpuCores(), flinkMemory, jvmMetaspaceAndOverhead, workerResourceSpec.getNumSlots(), workerResourceSpec.getExtendedResources().values());
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) JvmMetaspaceAndOverhead(org.apache.flink.runtime.util.config.memory.JvmMetaspaceAndOverhead) TaskExecutorFlinkMemory(org.apache.flink.runtime.util.config.memory.taskmanager.TaskExecutorFlinkMemory)

Example 15 with MemorySize

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

the class ProcessMemoryUtils method deriveJvmMetaspaceAndOverheadWithTotalProcessMemory.

private JvmMetaspaceAndOverhead deriveJvmMetaspaceAndOverheadWithTotalProcessMemory(Configuration config, MemorySize totalProcessMemorySize) {
    MemorySize jvmMetaspaceSize = getMemorySizeFromConfig(config, options.getJvmOptions().getJvmMetaspaceOption());
    MemorySize jvmOverheadSize = deriveWithFraction("jvm overhead memory", totalProcessMemorySize, getJvmOverheadRangeFraction(config));
    JvmMetaspaceAndOverhead jvmMetaspaceAndOverhead = new JvmMetaspaceAndOverhead(jvmMetaspaceSize, jvmOverheadSize);
    if (jvmMetaspaceAndOverhead.getTotalJvmMetaspaceAndOverheadSize().getBytes() > totalProcessMemorySize.getBytes()) {
        throw new IllegalConfigurationException("Sum of configured JVM Metaspace (" + jvmMetaspaceAndOverhead.getMetaspace().toHumanReadableString() + ") and JVM Overhead (" + jvmMetaspaceAndOverhead.getOverhead().toHumanReadableString() + ") exceed configured Total Process Memory (" + totalProcessMemorySize.toHumanReadableString() + ").");
    }
    return jvmMetaspaceAndOverhead;
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException)

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