Search in sources :

Example 16 with CPUResource

use of org.apache.flink.api.common.resources.CPUResource in project flink by apache.

the class TaskExecutorProcessUtilsTest method testConfigCpuCores.

@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))));
}
Also used : Configuration(org.apache.flink.configuration.Configuration) CPUResource(org.apache.flink.api.common.resources.CPUResource) Test(org.junit.Test)

Example 17 with CPUResource

use of org.apache.flink.api.common.resources.CPUResource in project flink by apache.

the class TaskExecutorProcessSpecTest method testEquals.

@Test
public void testEquals() {
    TaskExecutorProcessSpec spec1 = new TaskExecutorProcessSpec(new CPUResource(1.0), MemorySize.parse("1m"), MemorySize.parse("2m"), MemorySize.parse("3m"), MemorySize.parse("4m"), MemorySize.parse("5m"), MemorySize.parse("6m"), MemorySize.parse("7m"), MemorySize.parse("8m"), Collections.singleton(new ExternalResource(EXTERNAL_RESOURCE_NAME, 1)));
    TaskExecutorProcessSpec spec2 = new TaskExecutorProcessSpec(new CPUResource(1.0), MemorySize.parse("1m"), MemorySize.parse("2m"), MemorySize.parse("3m"), MemorySize.parse("4m"), MemorySize.parse("5m"), MemorySize.parse("6m"), MemorySize.parse("7m"), MemorySize.parse("8m"), Collections.singleton(new ExternalResource(EXTERNAL_RESOURCE_NAME, 1)));
    assertThat(spec1, is(spec2));
}
Also used : TaskExecutorProcessSpec(org.apache.flink.runtime.clusterframework.TaskExecutorProcessSpec) CPUResource(org.apache.flink.api.common.resources.CPUResource) ExternalResource(org.apache.flink.api.common.resources.ExternalResource) Test(org.junit.Test)

Example 18 with CPUResource

use of org.apache.flink.api.common.resources.CPUResource in project flink by apache.

the class YarnWorkerResourceSpecFactoryTest method testGetCpuCoresNumSlots.

@Test
public void testGetCpuCoresNumSlots() {
    final Configuration configuration = new Configuration();
    configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, 3);
    assertThat(YarnWorkerResourceSpecFactory.getDefaultCpus(configuration), is(new CPUResource(3.0)));
}
Also used : Configuration(org.apache.flink.configuration.Configuration) CPUResource(org.apache.flink.api.common.resources.CPUResource) Test(org.junit.Test)

Example 19 with CPUResource

use of org.apache.flink.api.common.resources.CPUResource in project flink by apache.

the class YarnWorkerResourceSpecFactoryTest method testGetCpuRoundUp.

@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)));
}
Also used : Configuration(org.apache.flink.configuration.Configuration) CPUResource(org.apache.flink.api.common.resources.CPUResource) Test(org.junit.Test)

Aggregations

CPUResource (org.apache.flink.api.common.resources.CPUResource)19 Test (org.junit.Test)19 Configuration (org.apache.flink.configuration.Configuration)10 ExternalResource (org.apache.flink.api.common.resources.ExternalResource)6 TaskExecutorProcessSpec (org.apache.flink.runtime.clusterframework.TaskExecutorProcessSpec)3 ArrayList (java.util.ArrayList)2 MemorySize (org.apache.flink.configuration.MemorySize)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 CompletableFuture (java.util.concurrent.CompletableFuture)1 ResourceSpec (org.apache.flink.api.common.operators.ResourceSpec)1 GlobalConfiguration (org.apache.flink.configuration.GlobalConfiguration)1 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)1 WorkerResourceSpec (org.apache.flink.runtime.resourcemanager.WorkerResourceSpec)1 TaskExecutorResourceSpec (org.apache.flink.runtime.taskexecutor.TaskExecutorResourceSpec)1 Container (org.apache.hadoop.yarn.api.records.Container)1 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)1 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)1 Priority (org.apache.hadoop.yarn.api.records.Priority)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1 AMRMClient (org.apache.hadoop.yarn.client.api.AMRMClient)1