Java Code Examples for org.apache.flink.configuration.Configuration#setDouble()

The following examples show how to use org.apache.flink.configuration.Configuration#setDouble() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KubernetesWorkerResourceSpecFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetCpuCoresCommonOption() {
	final Configuration configuration = new Configuration();
	configuration.setDouble(TaskManagerOptions.CPU_CORES, 1.0);
	configuration.setDouble(KubernetesConfigOptions.TASK_MANAGER_CPU, 2.0);
	configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 3);

	assertThat(KubernetesWorkerResourceSpecFactory.getDefaultCpus(configuration),
		is(new CPUResource(1.0)));
}
 
Example 2
Source File: KubernetesWorkerResourceSpecFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetCpuCoresKubernetesOption() {
	final Configuration configuration = new Configuration();
	configuration.setDouble(KubernetesConfigOptions.TASK_MANAGER_CPU, 2.0);
	configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 3);

	assertThat(KubernetesWorkerResourceSpecFactory.getDefaultCpus(configuration),
		is(new CPUResource(2.0)));
}
 
Example 3
Source File: MesosTaskManagerParametersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigCpuCores() {
	Configuration config = getConfiguration();
	config.setDouble(TaskManagerOptions.CPU_CORES, 1.5);
	config.setDouble(MesosTaskManagerParameters.MESOS_RM_TASKS_CPUS, 2.5);
	config.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 3);
	MesosTaskManagerParameters mesosTaskManagerParameters = MesosTaskManagerParameters.create(config);
	assertThat(mesosTaskManagerParameters.cpus(), is(1.5));
}
 
Example 4
Source File: MesosTaskManagerParametersTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testLegacyConfigCpuCores() {
	Configuration config = getConfiguration();
	config.setDouble(MesosTaskManagerParameters.MESOS_RM_TASKS_CPUS, 1.5);
	config.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 3);
	MesosTaskManagerParameters mesosTaskManagerParameters = MesosTaskManagerParameters.create(config);
	assertThat(mesosTaskManagerParameters.cpus(), is(1.5));
}
 
Example 5
Source File: YarnWorkerResourceSpecFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetCpuCoresCommonOption() {
	final Configuration configuration = new Configuration();
	configuration.setDouble(TaskManagerOptions.CPU_CORES, 1.0);
	configuration.setInteger(YarnConfigOptions.VCORES, 2);
	configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 3);

	assertThat(YarnWorkerResourceSpecFactory.getDefaultCpus(configuration), is(new CPUResource(1.0)));
}
 
Example 6
Source File: YarnWorkerResourceSpecFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetCpuRoundUp() {
	final Configuration configuration = new Configuration();
	configuration.setDouble(TaskManagerOptions.CPU_CORES, 0.5);

	assertThat(YarnWorkerResourceSpecFactory.getDefaultCpus(configuration), is(new CPUResource(1.0)));
}
 
Example 7
Source File: YarnWorkerResourceSpecFactoryTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalConfigurationException.class)
public void testGetCpuExceedMaxInt() {
	final Configuration configuration = new Configuration();
	configuration.setDouble(TaskManagerOptions.CPU_CORES, Double.MAX_VALUE);

	YarnWorkerResourceSpecFactory.getDefaultCpus(configuration);
}
 
Example 8
Source File: TaskExecutorProcessUtilsTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigCpuCores() {
	final double cpuCores = 1.0;

	Configuration conf = new Configuration();
	conf.setDouble(TaskManagerOptions.CPU_CORES, cpuCores);

	validateInAllConfigurations(conf, taskExecutorProcessSpec -> assertThat(taskExecutorProcessSpec.getCpuCores(), is(new CPUResource(cpuCores))));
}
 
Example 9
Source File: TaskExecutorProcessUtilsTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testConfigNegativeCpuCores() {
	Configuration conf = new Configuration();
	conf.setDouble(TaskManagerOptions.CPU_CORES, -0.1f);
	validateFailInAllConfigurations(conf);
}