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

The following examples show how to use org.apache.flink.configuration.Configuration#setDouble() . These examples are extracted from open source projects. 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
@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
@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
@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
@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
@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
@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
@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
@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
@Test
public void testConfigNegativeCpuCores() {
	Configuration conf = new Configuration();
	conf.setDouble(TaskManagerOptions.CPU_CORES, -0.1f);
	validateFailInAllConfigurations(conf);
}