use of org.apache.flink.configuration.MemorySize in project flink by apache.
the class JobManagerFlinkMemoryUtils method deriveFromTotalFlinkMemory.
@Override
public JobManagerFlinkMemory deriveFromTotalFlinkMemory(Configuration config, MemorySize totalFlinkMemorySize) {
MemorySize offHeapMemorySize = ProcessMemoryUtils.getMemorySizeFromConfig(config, JobManagerOptions.OFF_HEAP_MEMORY);
if (totalFlinkMemorySize.compareTo(offHeapMemorySize) < 1) {
throw new IllegalConfigurationException("The configured Total Flink Memory (%s) is less than the configured Off-heap Memory (%s).", totalFlinkMemorySize.toHumanReadableString(), offHeapMemorySize.toHumanReadableString());
}
MemorySize derivedJvmHeapMemorySize = totalFlinkMemorySize.subtract(offHeapMemorySize);
return createJobManagerFlinkMemory(derivedJvmHeapMemorySize, offHeapMemorySize);
}
use of org.apache.flink.configuration.MemorySize in project flink by apache.
the class TaskExecutorFlinkMemoryUtils method getNetworkMemoryRangeFraction.
private static RangeFraction getNetworkMemoryRangeFraction(final Configuration config) {
final MemorySize minSize = ProcessMemoryUtils.getMemorySizeFromConfig(config, TaskManagerOptions.NETWORK_MEMORY_MIN);
final MemorySize maxSize = ProcessMemoryUtils.getMemorySizeFromConfig(config, TaskManagerOptions.NETWORK_MEMORY_MAX);
return ProcessMemoryUtils.getRangeFraction(minSize, maxSize, TaskManagerOptions.NETWORK_MEMORY_FRACTION, config);
}
use of org.apache.flink.configuration.MemorySize in project flink by apache.
the class TaskExecutorMemoryConfigurationTest method testInitialization.
@Test
public void testInitialization() {
Configuration config = new Configuration();
config.set(FRAMEWORK_HEAP_MEMORY, new MemorySize(1));
config.set(TASK_HEAP_MEMORY, new MemorySize(2));
config.set(FRAMEWORK_OFF_HEAP_MEMORY, new MemorySize(3));
config.set(TASK_OFF_HEAP_MEMORY, new MemorySize(4));
config.set(NETWORK_MEMORY_MIN, new MemorySize(6));
config.set(NETWORK_MEMORY_MAX, new MemorySize(6));
config.set(NETWORK_MEMORY_FRACTION, 0.1f);
config.set(MANAGED_MEMORY_SIZE, new MemorySize(7));
config.set(MANAGED_MEMORY_FRACTION, 0.2f);
config.set(JVM_METASPACE, new MemorySize(8));
config.set(JVM_OVERHEAD_MIN, new MemorySize(10));
config.set(JVM_OVERHEAD_MAX, new MemorySize(10));
config.set(JVM_OVERHEAD_FRACTION, 0.3f);
TaskExecutorMemoryConfiguration actual = TaskExecutorMemoryConfiguration.create(config);
TaskExecutorMemoryConfiguration expected = new TaskExecutorMemoryConfiguration(1L, 2L, 3L, 4L, 6L, 7L, 8L, 10L, 23L, 41L);
assertThat(actual, is(expected));
}
use of org.apache.flink.configuration.MemorySize in project flink by apache.
the class TaskExecutorResourceUtilsTest method testCalculateTotalProcessMemoryWithMissingFactors.
@Test(expected = IllegalArgumentException.class)
public void testCalculateTotalProcessMemoryWithMissingFactors() {
Configuration config = new Configuration();
config.set(TaskManagerOptions.FRAMEWORK_HEAP_MEMORY, new MemorySize(1));
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.MANAGED_MEMORY_SIZE, new MemorySize(7));
config.set(TaskManagerOptions.JVM_METASPACE, new MemorySize(8));
TaskExecutorResourceUtils.calculateTotalProcessMemoryFromComponents(config);
}
use of org.apache.flink.configuration.MemorySize in project flink by apache.
the class TaskExecutorResourceUtilsTest method testCalculateTotalProcessMemoryWithAllFactorsBeingSet.
@Test
public void testCalculateTotalProcessMemoryWithAllFactorsBeingSet() {
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));
config.set(TaskManagerOptions.JVM_METASPACE, new MemorySize(8));
config.set(TaskManagerOptions.JVM_OVERHEAD_MAX, new MemorySize(10));
config.set(TaskManagerOptions.JVM_OVERHEAD_MIN, new MemorySize(10));
assertThat(TaskExecutorResourceUtils.calculateTotalProcessMemoryFromComponents(config), is(41L));
}
Aggregations