Search in sources :

Example 71 with MemorySize

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

the class ProcessMemoryUtilsTestBase method testConfigTotalFlinkMemory.

@Test
public void testConfigTotalFlinkMemory() {
    MemorySize totalFlinkMemorySize = MemorySize.parse("1g");
    Configuration conf = new Configuration();
    conf.set(options.getTotalFlinkMemoryOption(), totalFlinkMemorySize);
    T processSpec = processSpecFromConfig(conf);
    assertThat(processSpec.getTotalFlinkMemorySize(), is(totalFlinkMemorySize));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 72 with MemorySize

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

the class TaskExecutorResourceUtilsTest method testNetworkMinAdjustForLocalExecutionIfMaxSet.

@Test
public void testNetworkMinAdjustForLocalExecutionIfMaxSet() {
    MemorySize networkMemorySize = MemorySize.ofMebiBytes(1);
    Configuration configuration = new Configuration();
    configuration.set(TaskManagerOptions.NETWORK_MEMORY_MAX, networkMemorySize);
    TaskExecutorResourceUtils.adjustForLocalExecution(configuration);
    assertThat(configuration.get(TaskManagerOptions.NETWORK_MEMORY_MIN), is(networkMemorySize));
    assertThat(configuration.get(TaskManagerOptions.NETWORK_MEMORY_MAX), is(networkMemorySize));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 73 with MemorySize

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

the class TaskExecutorResourceUtilsTest method testCalculateTotalFlinkMemoryWithAllFactorsBeingSet.

@Test
public void testCalculateTotalFlinkMemoryWithAllFactorsBeingSet() {
    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));
    assertThat(TaskExecutorResourceUtils.calculateTotalFlinkMemoryFromComponents(config), is(23L));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 74 with MemorySize

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

the class TaskExecutorResourceUtilsTest method testNetworkMaxAdjustForLocalExecutionIfMinSet.

@Test
public void testNetworkMaxAdjustForLocalExecutionIfMinSet() {
    MemorySize networkMemorySize = MemorySize.ofMebiBytes(1);
    Configuration configuration = new Configuration();
    configuration.set(TaskManagerOptions.NETWORK_MEMORY_MIN, networkMemorySize);
    TaskExecutorResourceUtils.adjustForLocalExecution(configuration);
    assertThat(configuration.get(TaskManagerOptions.NETWORK_MEMORY_MIN), is(networkMemorySize));
    assertThat(configuration.get(TaskManagerOptions.NETWORK_MEMORY_MAX), is(networkMemorySize));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 75 with MemorySize

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

the class TaskExecutorResourceUtilsTest method setAllRequiredOptionsExceptOne.

private static Configuration setAllRequiredOptionsExceptOne(ConfigOption<?> optionToNotSet) {
    Configuration configuration = new Configuration();
    if (!TaskManagerOptions.CPU_CORES.equals(optionToNotSet)) {
        configuration.set(TaskManagerOptions.CPU_CORES, 1.0);
    }
    // skip network to exclude min/max mismatch config failure
    MemorySize network = MemorySize.ofMebiBytes(3);
    configuration.set(TaskManagerOptions.NETWORK_MEMORY_MIN, network);
    configuration.set(TaskManagerOptions.NETWORK_MEMORY_MAX, network);
    // noinspection unchecked
    TaskExecutorResourceUtils.CONFIG_OPTIONS.stream().filter(option -> !option.equals(TaskManagerOptions.CPU_CORES)).filter(option -> !option.equals(optionToNotSet)).forEach(option -> configuration.set((ConfigOption<MemorySize>) option, MemorySize.ofMebiBytes(1)));
    return configuration;
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Assert.assertThat(org.junit.Assert.assertThat) IllegalConfigurationException(org.apache.flink.configuration.IllegalConfigurationException) TaskManagerOptions(org.apache.flink.configuration.TaskManagerOptions) Configuration(org.apache.flink.configuration.Configuration) TestLogger(org.apache.flink.util.TestLogger) Test(org.junit.Test) Assert.fail(org.junit.Assert.fail) ConfigOption(org.apache.flink.configuration.ConfigOption) ExternalResourceOptions(org.apache.flink.configuration.ExternalResourceOptions) MemorySize(org.apache.flink.configuration.MemorySize) CPUResource(org.apache.flink.api.common.resources.CPUResource) ConfigOption(org.apache.flink.configuration.ConfigOption) MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration)

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