Search in sources :

Example 61 with MemorySize

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

the class TaskExecutorProcessUtilsTest method testConfigFrameworkHeapMemory.

@Test
public void testConfigFrameworkHeapMemory() {
    final MemorySize frameworkHeapSize = MemorySize.parse("100m");
    Configuration conf = new Configuration();
    conf.set(TaskManagerOptions.FRAMEWORK_HEAP_MEMORY, frameworkHeapSize);
    validateInAllConfigurations(conf, taskExecutorProcessSpec -> assertThat(taskExecutorProcessSpec.getFrameworkHeapSize(), is(frameworkHeapSize)));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 62 with MemorySize

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

the class TaskExecutorProcessUtilsTest method testConfigNetworkMemoryLegacyNumOfBuffers.

@Test
public void testConfigNetworkMemoryLegacyNumOfBuffers() {
    final MemorySize pageSize = MemorySize.parse("32k");
    final int numOfBuffers = 1024;
    final MemorySize networkSize = pageSize.multiply(numOfBuffers);
    @SuppressWarnings("deprecation") final ConfigOption<Integer> legacyOption = NettyShuffleEnvironmentOptions.NETWORK_NUM_BUFFERS;
    Configuration conf = new Configuration();
    conf.set(TaskManagerOptions.MEMORY_SEGMENT_SIZE, pageSize);
    conf.setInteger(legacyOption, numOfBuffers);
    // validate in configurations without explicit total flink/process memory, otherwise
    // explicit configured
    // network memory size might conflict with total flink/process memory minus other memory
    // sizes
    validateInConfigWithExplicitTaskHeapAndManagedMem(conf, taskExecutorProcessSpec -> assertThat(taskExecutorProcessSpec.getNetworkMemSize(), is(networkSize)));
    validateInConfigurationsWithoutExplicitTaskHeapMem(conf, taskExecutorProcessSpec -> assertThat(taskExecutorProcessSpec.getNetworkMemSize(), is(networkSize)));
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) Configuration(org.apache.flink.configuration.Configuration) Test(org.junit.Test)

Example 63 with MemorySize

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

the class BucketsRollingPolicyTest method testDefaultRollingPolicy.

@Test
public void testDefaultRollingPolicy() throws Exception {
    final File outDir = TEMP_FOLDER.newFolder();
    final Path path = new Path(outDir.toURI());
    final RollingPolicy<String, String> originalRollingPolicy = DefaultRollingPolicy.builder().withMaxPartSize(new MemorySize(10L)).withInactivityInterval(Duration.ofMillis(4L)).withRolloverInterval(Duration.ofMillis(11L)).build();
    final MethodCallCountingPolicyWrapper<String, String> rollingPolicy = new MethodCallCountingPolicyWrapper<>(originalRollingPolicy);
    final Buckets<String, String> buckets = createBuckets(path, rollingPolicy);
    rollingPolicy.verifyCallCounters(0L, 0L, 0L, 0L, 0L, 0L);
    // these two will fill up the first in-progress file and at the third it will roll ...
    buckets.onElement("test1", new TestUtils.MockSinkContext(1L, 1L, 1L));
    buckets.onElement("test1", new TestUtils.MockSinkContext(2L, 1L, 2L));
    rollingPolicy.verifyCallCounters(0L, 0L, 1L, 0L, 0L, 0L);
    buckets.onElement("test1", new TestUtils.MockSinkContext(3L, 1L, 3L));
    rollingPolicy.verifyCallCounters(0L, 0L, 2L, 1L, 0L, 0L);
    // still no time to roll
    buckets.onProcessingTime(5L);
    rollingPolicy.verifyCallCounters(0L, 0L, 2L, 1L, 1L, 0L);
    // roll due to inactivity
    buckets.onProcessingTime(7L);
    rollingPolicy.verifyCallCounters(0L, 0L, 2L, 1L, 2L, 1L);
    buckets.onElement("test1", new TestUtils.MockSinkContext(3L, 1L, 3L));
    // roll due to rollover interval
    buckets.onProcessingTime(20L);
    rollingPolicy.verifyCallCounters(0L, 0L, 2L, 1L, 3L, 2L);
    // we take a checkpoint but we should not roll.
    buckets.snapshotState(1L, new TestUtils.MockListState<>(), new TestUtils.MockListState<>());
    rollingPolicy.verifyCallCounters(0L, 0L, 2L, 1L, 3L, 2L);
}
Also used : Path(org.apache.flink.core.fs.Path) MemorySize(org.apache.flink.configuration.MemorySize) File(java.io.File) Test(org.junit.Test)

Example 64 with MemorySize

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

the class BucketsRollingPolicyTest method testDefaultRollingPolicyDeprecatedCreate.

@Test
public void testDefaultRollingPolicyDeprecatedCreate() throws Exception {
    DefaultRollingPolicy policy = DefaultRollingPolicy.builder().withInactivityInterval(Duration.ofMillis(10)).withMaxPartSize(new MemorySize(20)).withRolloverInterval(Duration.ofMillis(30)).build();
    Assert.assertEquals(10, policy.getInactivityInterval());
    Assert.assertEquals(20, policy.getMaxPartSize());
    Assert.assertEquals(30, policy.getRolloverInterval());
}
Also used : MemorySize(org.apache.flink.configuration.MemorySize) DefaultRollingPolicy(org.apache.flink.streaming.api.functions.sink.filesystem.rollingpolicies.DefaultRollingPolicy) Test(org.junit.Test)

Example 65 with MemorySize

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

the class ProcessMemoryUtilsTestBase method testDerivedTotalProcessMemoryGreaterThanConfiguredFailureWithFineGrainedOptions.

@Test
public void testDerivedTotalProcessMemoryGreaterThanConfiguredFailureWithFineGrainedOptions() {
    Configuration conf = getConfigurationWithJvmMetaspaceAndTotalFlinkMemory(100, 200);
    // Total Flink memory + JVM Metaspace > Total Process Memory (no space for JVM overhead)
    MemorySize totalFlinkMemorySize = MemorySize.ofMebiBytes(150);
    configWithFineGrainedOptions(conf, totalFlinkMemorySize);
    validateFail(conf);
}
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