Search in sources :

Example 6 with TaskGroup

use of com.hashicorp.nomad.apimodel.TaskGroup in project heron by twitter.

the class NomadSchedulerTest method testGetTaskGroup.

@Test
public void testGetTaskGroup() {
    Set<PackingPlan.ContainerPlan> containers = new HashSet<>();
    containers.add(Mockito.mock(PackingPlan.ContainerPlan.class));
    Resource resource = new Resource(CPU_RESOURCE, MEMORY_RESOURCE, DISK_RESOURCE);
    PackingPlan.ContainerPlan containerPlan = new PackingPlan.ContainerPlan(CONTAINER_INDEX, new HashSet<>(), Mockito.mock(Resource.class));
    scheduler.initialize(this.mockConfig, this.mockRuntime);
    Mockito.doReturn(new Task()).when(scheduler).getTask(Mockito.anyString(), Mockito.anyInt(), Mockito.any());
    TaskGroup taskGroup = scheduler.getTaskGroup(GROUP_NAME, CONTAINER_INDEX, resource);
    LOG.info("taskGroup: " + taskGroup);
    Assert.assertEquals(GROUP_NAME, taskGroup.getName());
    Assert.assertNotNull(taskGroup.getCount());
    Assert.assertNotNull(taskGroup.getTasks());
}
Also used : Task(com.hashicorp.nomad.apimodel.Task) PackingPlan(org.apache.heron.spi.packing.PackingPlan) Resource(org.apache.heron.spi.packing.Resource) TaskGroup(com.hashicorp.nomad.apimodel.TaskGroup) HashSet(java.util.HashSet) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with TaskGroup

use of com.hashicorp.nomad.apimodel.TaskGroup in project twister2 by DSC-SPIDAL.

the class NomadController method getTaskGroup.

private TaskGroup getTaskGroup(JobAPI.Job job) {
    TaskGroup taskGroup = new TaskGroup();
    if (JobMasterContext.jobMasterRunsInClient(config)) {
        taskGroup.setCount(job.getNumberOfWorkers());
    } else {
        taskGroup.setCount(job.getNumberOfWorkers() + 1);
    }
    taskGroup.setName(job.getJobId());
    taskGroup.addTasks(getShellDriver(job));
    return taskGroup;
}
Also used : TaskGroup(com.hashicorp.nomad.apimodel.TaskGroup)

Aggregations

TaskGroup (com.hashicorp.nomad.apimodel.TaskGroup)7 HashSet (java.util.HashSet)4 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 Job (com.hashicorp.nomad.apimodel.Job)2 Task (com.hashicorp.nomad.apimodel.Task)2 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)2 Resource (com.twitter.heron.spi.packing.Resource)2 PackingPlan (org.apache.heron.spi.packing.PackingPlan)2 Resource (org.apache.heron.spi.packing.Resource)2