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));
}
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));
}
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;
}
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;
}
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());
}
Aggregations