Search in sources :

Example 51 with MemorySize

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

the class TaskExecutorFlinkMemoryUtils method deriveFromRequiredFineGrainedOptions.

@Override
public TaskExecutorFlinkMemory deriveFromRequiredFineGrainedOptions(Configuration config) {
    final MemorySize taskHeapMemorySize = getTaskHeapMemorySize(config);
    final MemorySize managedMemorySize = getManagedMemorySize(config);
    final MemorySize frameworkHeapMemorySize = getFrameworkHeapMemorySize(config);
    final MemorySize frameworkOffHeapMemorySize = getFrameworkOffHeapMemorySize(config);
    final MemorySize taskOffHeapMemorySize = getTaskOffHeapMemorySize(config);
    final MemorySize networkMemorySize;
    final MemorySize totalFlinkExcludeNetworkMemorySize = frameworkHeapMemorySize.add(frameworkOffHeapMemorySize).add(taskHeapMemorySize).add(taskOffHeapMemorySize).add(managedMemorySize);
    if (isTotalFlinkMemorySizeExplicitlyConfigured(config)) {
        // derive network memory from total flink memory, and check against network min/max
        final MemorySize totalFlinkMemorySize = getTotalFlinkMemorySize(config);
        if (totalFlinkExcludeNetworkMemorySize.getBytes() > totalFlinkMemorySize.getBytes()) {
            throw new IllegalConfigurationException("Sum of configured Framework Heap Memory (" + frameworkHeapMemorySize.toHumanReadableString() + "), Framework Off-Heap Memory (" + frameworkOffHeapMemorySize.toHumanReadableString() + "), Task Heap Memory (" + taskHeapMemorySize.toHumanReadableString() + "), Task Off-Heap Memory (" + taskOffHeapMemorySize.toHumanReadableString() + ") and Managed Memory (" + managedMemorySize.toHumanReadableString() + ") exceed configured Total Flink Memory (" + totalFlinkMemorySize.toHumanReadableString() + ").");
        }
        networkMemorySize = totalFlinkMemorySize.subtract(totalFlinkExcludeNetworkMemorySize);
        sanityCheckNetworkMemoryWithExplicitlySetTotalFlinkAndHeapMemory(config, networkMemorySize, totalFlinkMemorySize);
    } else {
        // derive network memory from network configs
        networkMemorySize = isUsingLegacyNetworkConfigs(config) ? getNetworkMemorySizeWithLegacyConfig(config) : deriveNetworkMemoryWithInverseFraction(config, totalFlinkExcludeNetworkMemorySize);
    }
    final TaskExecutorFlinkMemory flinkInternalMemory = new TaskExecutorFlinkMemory(frameworkHeapMemorySize, frameworkOffHeapMemorySize, taskHeapMemorySize, taskOffHeapMemorySize, networkMemorySize, managedMemorySize);
    sanityCheckTotalFlinkMemory(config, flinkInternalMemory);
    return flinkInternalMemory;
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException)

Example 52 with MemorySize

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

the class BashJavaUtils method logTaskExecutorConfiguration.

private static void logTaskExecutorConfiguration(TaskExecutorProcessSpec spec) {
    TaskExecutorFlinkMemory flinkMemory = spec.getFlinkMemory();
    MemorySize totalOffHeapMemory = flinkMemory.getManaged().add(flinkMemory.getJvmDirectMemorySize());
    LOG.info("Final TaskExecutor Memory configuration:");
    LOG.info("  Total Process Memory:          {}", spec.getTotalProcessMemorySize().toHumanReadableString());
    LOG.info("    Total Flink Memory:          {}", flinkMemory.getTotalFlinkMemorySize().toHumanReadableString());
    LOG.info("      Total JVM Heap Memory:     {}", flinkMemory.getJvmHeapMemorySize().toHumanReadableString());
    LOG.info("        Framework:               {}", flinkMemory.getFrameworkHeap().toHumanReadableString());
    LOG.info("        Task:                    {}", flinkMemory.getTaskHeap().toHumanReadableString());
    LOG.info("      Total Off-heap Memory:     {}", totalOffHeapMemory.toHumanReadableString());
    LOG.info("        Managed:                 {}", flinkMemory.getManaged().toHumanReadableString());
    LOG.info("        Total JVM Direct Memory: {}", flinkMemory.getJvmDirectMemorySize().toHumanReadableString());
    LOG.info("          Framework:             {}", flinkMemory.getFrameworkOffHeap().toHumanReadableString());
    LOG.info("          Task:                  {}", flinkMemory.getTaskOffHeap().toHumanReadableString());
    LOG.info("          Network:               {}", flinkMemory.getNetwork().toHumanReadableString());
    LOG.info("    JVM Metaspace:               {}", spec.getJvmMetaspaceSize().toHumanReadableString());
    LOG.info("    JVM Overhead:                {}", spec.getJvmOverheadSize().toHumanReadableString());
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) TaskExecutorFlinkMemory(org.apache.flink.runtime.util.config.memory.taskmanager.TaskExecutorFlinkMemory)

Example 53 with MemorySize

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

the class JobManagerProcessUtilsTest method testDeriveFromRequiredFineGrainedOptions.

@Test
public void testDeriveFromRequiredFineGrainedOptions() {
    MemorySize jvmHeap = MemorySize.ofMebiBytes(150);
    MemorySize offHeap = MemorySize.ofMebiBytes(50);
    MemorySize totalFlinkMemory = MemorySize.ofMebiBytes(200);
    MemorySize expectedOffHeap = MemorySize.ofMebiBytes(50);
    Configuration conf = new Configuration();
    conf.set(JobManagerOptions.TOTAL_FLINK_MEMORY, totalFlinkMemory);
    conf.set(JobManagerOptions.OFF_HEAP_MEMORY, offHeap);
    conf.set(JobManagerOptions.JVM_HEAP_MEMORY, jvmHeap);
    JobManagerProcessSpec jobManagerProcessSpec = JobManagerProcessUtils.processSpecFromConfig(conf);
    assertThat(jobManagerProcessSpec.getJvmDirectMemorySize(), is(expectedOffHeap));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 54 with MemorySize

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

the class JobManagerProcessUtilsTest method testConfigJvmHeapMemory.

@Test
public void testConfigJvmHeapMemory() {
    MemorySize jvmHeapSize = MemorySize.parse("50m");
    Configuration conf = new Configuration();
    conf.set(JobManagerOptions.JVM_HEAP_MEMORY, jvmHeapSize);
    JobManagerProcessSpec jobManagerProcessSpec = JobManagerProcessUtils.processSpecFromConfig(conf);
    assertThat(jobManagerProcessSpec.getJvmHeapMemorySize(), is(jvmHeapSize));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 55 with MemorySize

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

the class JobManagerProcessUtilsTest method testLogFailureOfJvmHeapSizeMinSizeVerification.

@Test
public void testLogFailureOfJvmHeapSizeMinSizeVerification() {
    MemorySize jvmHeapMemory = MemorySize.parse("50m");
    Configuration conf = new Configuration();
    conf.set(JobManagerOptions.JVM_HEAP_MEMORY, jvmHeapMemory);
    JobManagerProcessUtils.processSpecFromConfig(conf);
    MatcherAssert.assertThat(testLoggerResource.getMessages(), hasItem(containsString(String.format("The configured or derived JVM heap memory size (%s) is less than its recommended minimum value (%s)", jvmHeapMemory.toHumanReadableString(), JobManagerOptions.MIN_JVM_HEAP_SIZE.toHumanReadableString()))));
}
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