Search in sources :

Example 16 with NodeTask

use of org.apache.myriad.state.NodeTask in project incubator-myriad by apache.

the class SchedulerUtilsTest method testIsUniqueFilenameTrue.

@Test
public void testIsUniqueFilenameTrue() throws Exception {
    List<NodeTask> tasks = Lists.newArrayList(taskOne, taskTwo, taskThree);
    NodeTask newTask = TestObjectFactory.getNodeTask("medium", "server1", 0.4, 2048.0, Long.valueOf(1), Long.valueOf(2));
    Offer offer = TestObjectFactory.getOffer("server2", "slave1", "mock-framework", "offer1", 0.0, 0.0);
    assertTrue(SchedulerUtils.isUniqueHostname(offer, newTask, tasks));
}
Also used : Offer(org.apache.mesos.Protos.Offer) NodeTask(org.apache.myriad.state.NodeTask) Test(org.junit.Test) BaseConfigurableTest(org.apache.myriad.BaseConfigurableTest)

Example 17 with NodeTask

use of org.apache.myriad.state.NodeTask in project incubator-myriad by apache.

the class SchedulerUtilsTest method testIsUniqueFilenameFalse.

@Test
public void testIsUniqueFilenameFalse() throws Exception {
    List<NodeTask> tasks = Lists.newArrayList(taskOne, taskTwo, taskThree);
    NodeTask newTask = TestObjectFactory.getNodeTask("medium", "localhost", 0.4, 2048.0, Long.valueOf(1), Long.valueOf(2));
    Offer offer = TestObjectFactory.getOffer("localhost", "slave1", "mock-framework", "offer1", 0.2, 512.0);
    assertFalse(SchedulerUtils.isUniqueHostname(offer, newTask, tasks));
}
Also used : Offer(org.apache.mesos.Protos.Offer) NodeTask(org.apache.myriad.state.NodeTask) Test(org.junit.Test) BaseConfigurableTest(org.apache.myriad.BaseConfigurableTest)

Example 18 with NodeTask

use of org.apache.myriad.state.NodeTask in project incubator-myriad by apache.

the class SchedulerUtils method isUniqueHostname.

public static boolean isUniqueHostname(Protos.OfferOrBuilder offer, NodeTask taskToLaunch, Collection<NodeTask> tasks) {
    Preconditions.checkArgument(offer != null);
    String offerHostname = offer.getHostname();
    if (!CollectionUtils.isEmpty(tasks)) {
        for (NodeTask task : tasks) {
            if (offerHostname.equalsIgnoreCase(task.getHostname())) {
                LOGGER.debug("Offer's hostname {} is not unique", offerHostname);
                return false;
            }
        }
    }
    LOGGER.debug("Offer's hostname {} is unique", offerHostname);
    return true;
}
Also used : NodeTask(org.apache.myriad.state.NodeTask)

Example 19 with NodeTask

use of org.apache.myriad.state.NodeTask in project incubator-myriad by apache.

the class MyriadOperations method flexDownTasks.

private int flexDownTasks(Collection<Protos.TaskID> taskIDs, ServiceResourceProfile profile, Constraint constraint, int numInstancesToScaleDown) {
    int numInstancesScaledDown = 0;
    for (Protos.TaskID taskID : taskIDs) {
        NodeTask nodeTask = schedulerState.getTask(taskID);
        if (nodeTask.getProfile().getName().equals(profile.getName()) && meetsConstraint(nodeTask, constraint)) {
            this.schedulerState.makeTaskKillable(taskID);
            numInstancesScaledDown++;
            if (numInstancesScaledDown == numInstancesToScaleDown) {
                break;
            }
        }
    }
    return numInstancesScaledDown;
}
Also used : Protos(org.apache.mesos.Protos) NodeTask(org.apache.myriad.state.NodeTask) LikeConstraint(org.apache.myriad.scheduler.constraints.LikeConstraint) Constraint(org.apache.myriad.scheduler.constraints.Constraint)

Example 20 with NodeTask

use of org.apache.myriad.state.NodeTask in project incubator-myriad by apache.

the class ByteBufferSupportTest method setUp.

@Before
public void setUp() throws Exception {
    task = new NodeTask(new ServiceResourceProfile("profile", 0.1, 1024.0, new TreeMap<String, Long>()), new LikeConstraint("hostname", "host-[0-9]*.example.com"));
    task.setHostname("localhost");
    task.setTaskPrefix("prefix");
    task.setExecutorInfo(getExecutorInfo());
}
Also used : ServiceResourceProfile(org.apache.myriad.scheduler.ServiceResourceProfile) NodeTask(org.apache.myriad.state.NodeTask) LikeConstraint(org.apache.myriad.scheduler.constraints.LikeConstraint) Before(org.junit.Before)

Aggregations

NodeTask (org.apache.myriad.state.NodeTask)20 LikeConstraint (org.apache.myriad.scheduler.constraints.LikeConstraint)8 Protos (org.apache.mesos.Protos)6 Test (org.junit.Test)6 BaseConfigurableTest (org.apache.myriad.BaseConfigurableTest)5 Constraint (org.apache.myriad.scheduler.constraints.Constraint)5 Offer (org.apache.mesos.Protos.Offer)4 ServiceResourceProfile (org.apache.myriad.scheduler.ServiceResourceProfile)3 ResourceOfferContainer (org.apache.myriad.scheduler.resource.ResourceOfferContainer)3 ByteBuffer (java.nio.ByteBuffer)2 HashSet (java.util.HashSet)2 TaskID (org.apache.mesos.Protos.TaskID)2 ServiceConfiguration (org.apache.myriad.configuration.ServiceConfiguration)2 OfferBuilder (org.apache.myriad.scheduler.offer.OfferBuilder)2 TreeMap (java.util.TreeMap)1 MyriadFileSystemRMStateStore (org.apache.hadoop.yarn.server.resourcemanager.recovery.MyriadFileSystemRMStateStore)1 Status (org.apache.mesos.Protos.Status)1 TaskInfo (org.apache.mesos.Protos.TaskInfo)1 TaskState (org.apache.mesos.Protos.TaskState)1 TaskStatus (org.apache.mesos.Protos.TaskStatus)1