Search in sources :

Example 66 with MemorySize

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

the class ProcessMemoryUtilsTestBase method testConfigLegacyHeapSize.

@Test
public void testConfigLegacyHeapSize() {
    MemorySize legacyHeapSize = MemorySize.parse("1g");
    Configuration conf = new Configuration();
    conf.set(legacyMemoryOptions.getHeap(), legacyHeapSize);
    testConfigLegacyHeapMemory(conf, legacyHeapSize);
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 67 with MemorySize

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

the class ProcessMemoryUtilsTestBase method testDerivedTotalProcessMemoryGreaterThanConfiguredFailureWithTotalFlinkMemory.

@Test
public void testDerivedTotalProcessMemoryGreaterThanConfiguredFailureWithTotalFlinkMemory() {
    Configuration conf = getConfigurationWithJvmMetaspaceAndTotalFlinkMemory(100, 200);
    // Total Flink memory + JVM Metaspace > Total Process Memory (no space for JVM overhead)
    MemorySize totalFlinkMemorySize = MemorySize.ofMebiBytes(150);
    conf.set(options.getTotalFlinkMemoryOption(), totalFlinkMemorySize);
    validateFail(conf);
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 68 with MemorySize

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

the class ProcessMemoryUtilsTestBase method testConfigLegacyHeapEnv.

@Test
public void testConfigLegacyHeapEnv() {
    MemorySize jvmHeapSize = MemorySize.parse("1g");
    Map<String, String> env = new HashMap<>();
    env.put(legacyMemoryOptions.getEnvVar(), "1g");
    CommonTestUtils.setEnv(env);
    testConfigLegacyHeapMemory(new Configuration(), jvmHeapSize);
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 69 with MemorySize

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

the class ProcessMemoryUtilsTestBase method testConfigJvmOverheadFraction.

@Test
public void testConfigJvmOverheadFraction() {
    MemorySize minSize = MemorySize.ZERO;
    MemorySize maxSize = MemorySize.parse("1t");
    @SuppressWarnings("MagicNumber") float fraction = 0.2f;
    Configuration conf = new Configuration();
    conf.set(options.getJvmOptions().getJvmOverheadMax(), maxSize);
    conf.set(options.getJvmOptions().getJvmOverheadMin(), minSize);
    conf.setFloat(options.getJvmOptions().getJvmOverheadFraction(), fraction);
    validateInAllConfigurations(conf, jobManagerProcessSpec -> assertThat(jobManagerProcessSpec.getJvmOverheadSize(), is(jobManagerProcessSpec.getTotalProcessMemorySize().multiply(fraction))));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 70 with MemorySize

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

the class ProcessMemoryUtilsTestBase method testConfigJvmOverheadRange.

@Test
public void testConfigJvmOverheadRange() {
    MemorySize minSize = MemorySize.parse("50m");
    MemorySize maxSize = MemorySize.parse("200m");
    Configuration conf = new Configuration();
    conf.set(options.getJvmOptions().getJvmOverheadMax(), maxSize);
    conf.set(options.getJvmOptions().getJvmOverheadMin(), minSize);
    validateInAllConfigurations(conf, JobManagerProcessSpec -> {
        assertThat(JobManagerProcessSpec.getJvmOverheadSize().getBytes(), greaterThanOrEqualTo(minSize.getBytes()));
        assertThat(JobManagerProcessSpec.getJvmOverheadSize().getBytes(), lessThanOrEqualTo(maxSize.getBytes()));
    });
}
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