Search in sources :

Example 56 with MemorySize

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

the class JobManagerProcessUtilsTest method configWithFineGrainedOptions.

@Override
protected void configWithFineGrainedOptions(Configuration configuration, MemorySize totalFlinkMemorySize) {
    MemorySize heapSize = new MemorySize(totalFlinkMemorySize.getBytes() / 2);
    MemorySize offHeapSize = totalFlinkMemorySize.subtract(heapSize);
    configuration.set(JobManagerOptions.JVM_HEAP_MEMORY, heapSize);
    configuration.set(JobManagerOptions.OFF_HEAP_MEMORY, offHeapSize);
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize)

Example 57 with MemorySize

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

the class SsgNetworkMemoryCalculationUtilsTest method testGenerateEnrichedResourceProfile.

@Test
public void testGenerateEnrichedResourceProfile() throws Exception {
    SlotSharingGroup slotSharingGroup0 = new SlotSharingGroup();
    slotSharingGroup0.setResourceProfile(DEFAULT_RESOURCE);
    SlotSharingGroup slotSharingGroup1 = new SlotSharingGroup();
    slotSharingGroup1.setResourceProfile(DEFAULT_RESOURCE);
    createExecutionGraphAndEnrichNetworkMemory(Arrays.asList(slotSharingGroup0, slotSharingGroup0, slotSharingGroup1));
    assertEquals(new MemorySize(TestShuffleMaster.computeRequiredShuffleMemoryBytes(0, 2) + TestShuffleMaster.computeRequiredShuffleMemoryBytes(1, 6)), slotSharingGroup0.getResourceProfile().getNetworkMemory());
    assertEquals(new MemorySize(TestShuffleMaster.computeRequiredShuffleMemoryBytes(5, 0)), slotSharingGroup1.getResourceProfile().getNetworkMemory());
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) SlotSharingGroup(org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup) IntermediateResultPartitionTest(org.apache.flink.runtime.executiongraph.IntermediateResultPartitionTest) Test(org.junit.Test)

Example 58 with MemorySize

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

the class TaskExecutorProcessUtilsTest method testConfigFrameworkOffHeapMemory.

@Test
public void testConfigFrameworkOffHeapMemory() {
    final MemorySize frameworkOffHeapSize = MemorySize.parse("10m");
    Configuration conf = new Configuration();
    conf.set(TaskManagerOptions.FRAMEWORK_OFF_HEAP_MEMORY, frameworkOffHeapSize);
    validateInAllConfigurations(conf, taskExecutorProcessSpec -> assertThat(taskExecutorProcessSpec.getFrameworkOffHeapMemorySize(), is(frameworkOffHeapSize)));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 59 with MemorySize

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

the class TaskExecutorProcessUtilsTest method testConfigNetworkMemoryLegacyRangeFraction.

@Test
public void testConfigNetworkMemoryLegacyRangeFraction() {
    final MemorySize networkMin = MemorySize.parse("200m");
    final MemorySize networkMax = MemorySize.parse("500m");
    final float fraction = 0.2f;
    @SuppressWarnings("deprecation") final ConfigOption<String> legacyOptionMin = NettyShuffleEnvironmentOptions.NETWORK_BUFFERS_MEMORY_MIN;
    @SuppressWarnings("deprecation") final ConfigOption<String> legacyOptionMax = NettyShuffleEnvironmentOptions.NETWORK_BUFFERS_MEMORY_MAX;
    @SuppressWarnings("deprecation") final ConfigOption<Float> legacyOptionFraction = NettyShuffleEnvironmentOptions.NETWORK_BUFFERS_MEMORY_FRACTION;
    Configuration conf = new Configuration();
    conf.setString(legacyOptionMin, networkMin.getMebiBytes() + "m");
    conf.setString(legacyOptionMax, networkMax.getMebiBytes() + "m");
    validateInAllConfigurations(conf, taskExecutorProcessSpec -> {
        assertThat(taskExecutorProcessSpec.getNetworkMemSize().getBytes(), greaterThanOrEqualTo(networkMin.getBytes()));
        assertThat(taskExecutorProcessSpec.getNetworkMemSize().getBytes(), lessThanOrEqualTo(networkMax.getBytes()));
    });
    conf.setString(legacyOptionMin, "0m");
    conf.setString(legacyOptionMax, "1t");
    conf.setFloat(legacyOptionFraction, fraction);
    validateInConfigWithExplicitTaskHeapAndManagedMem(conf, taskExecutorProcessSpec -> assertThat(taskExecutorProcessSpec.getNetworkMemSize(), is(taskExecutorProcessSpec.getTotalFlinkMemorySize().multiply(fraction))));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 60 with MemorySize

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

the class TaskExecutorProcessUtilsTest method testConfigTotalProcessMemoryLegacySize.

@Test
public void testConfigTotalProcessMemoryLegacySize() {
    final MemorySize totalProcessMemorySize = MemorySize.parse("2g");
    @SuppressWarnings("deprecation") final ConfigOption<MemorySize> legacyOption = TaskManagerOptions.TOTAL_PROCESS_MEMORY;
    Configuration conf = new Configuration();
    conf.set(legacyOption, totalProcessMemorySize);
    TaskExecutorProcessSpec taskExecutorProcessSpec = TaskExecutorProcessUtils.processSpecFromConfig(conf);
    assertThat(taskExecutorProcessSpec.getTotalProcessMemorySize(), is(totalProcessMemorySize));
}
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