use of com.hubspot.singularity.SingularityPendingTask in project Singularity by HubSpot.
the class SingularityWebCache method cachePendingTasks.
public void cachePendingTasks(List<SingularityPendingTask> pendingTasks) {
pendingMissMeter.mark();
Map<SingularityPendingTaskId, SingularityPendingTask> newPendingTasks = new HashMap<>(pendingTasks.size());
for (SingularityPendingTask pendingTask : pendingTasks) {
newPendingTasks.put(pendingTask.getPendingTaskId(), pendingTask);
}
cachedPendingTasks = newPendingTasks;
lastPendingTaskCache = System.currentTimeMillis();
}
use of com.hubspot.singularity.SingularityPendingTask in project Singularity by HubSpot.
the class SingularitySchedulerTest method testCustomResourcesWithRunNowRequest.
@Test
public void testCustomResourcesWithRunNowRequest() {
SingularityRequestBuilder bldr = new SingularityRequestBuilder(requestId, RequestType.ON_DEMAND);
requestResource.postRequest(bldr.build(), singularityUser);
deploy("d2");
SingularityRunNowRequest runNowRequest = new SingularityRunNowRequestBuilder().setResources(new Resources(2, 2, 0)).build();
requestResource.scheduleImmediately(singularityUser, requestId, runNowRequest);
scheduler.drainPendingQueue();
SingularityPendingTask pendingTaskWithResourcs = taskManager.getPendingTasks().get(0);
Assert.assertTrue(pendingTaskWithResourcs.getResources().isPresent());
Assert.assertEquals(pendingTaskWithResourcs.getResources().get().getCpus(), 2, 0.0);
sms.resourceOffers(Arrays.asList(createOffer(5, 5, 5, "slave1", "host1", Optional.of("rack1"))));
SingularityTask task = taskManager.getActiveTasks().get(0);
Assert.assertEquals(MesosUtils.getNumCpus(mesosProtosUtils.toResourceList(task.getMesosTask().getResources()), Optional.<String>absent()), 2.0, 0.0);
}
use of com.hubspot.singularity.SingularityPendingTask in project Singularity by HubSpot.
the class SingularitySchedulerTestBase method createAndSchedulePendingTask.
protected SingularityPendingTask createAndSchedulePendingTask(String deployId) {
Random random = new Random();
SingularityPendingTaskId pendingTaskId = new SingularityPendingTaskId(requestId, deployId, System.currentTimeMillis() + TimeUnit.DAYS.toMillis(random.nextInt(3)), random.nextInt(10), PendingType.NEW_DEPLOY, System.currentTimeMillis());
SingularityPendingTask pendingTask = new SingularityPendingTaskBuilder().setPendingTaskId(pendingTaskId).build();
taskManager.savePendingTask(pendingTask);
return pendingTask;
}
use of com.hubspot.singularity.SingularityPendingTask in project Singularity by HubSpot.
the class SingularityDeploysTest method testDeployClearsObsoleteScheduledTasks.
@Test
public void testDeployClearsObsoleteScheduledTasks() {
initRequest();
initFirstDeploy();
initSecondDeploy();
SingularityPendingTaskId taskIdOne = new SingularityPendingTaskId(requestId, firstDeployId, System.currentTimeMillis() + TimeUnit.DAYS.toMillis(3), 1, PendingType.IMMEDIATE, System.currentTimeMillis());
SingularityPendingTask taskOne = new SingularityPendingTaskBuilder().setPendingTaskId(taskIdOne).build();
SingularityPendingTaskId taskIdTwo = new SingularityPendingTaskId(requestId, firstDeployId, System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1), 2, PendingType.IMMEDIATE, System.currentTimeMillis());
SingularityPendingTask taskTwo = new SingularityPendingTaskBuilder().setPendingTaskId(taskIdTwo).build();
SingularityPendingTaskId taskIdThree = new SingularityPendingTaskId(requestId, secondDeployId, System.currentTimeMillis() + TimeUnit.DAYS.toMillis(3), 1, PendingType.IMMEDIATE, System.currentTimeMillis());
SingularityPendingTask taskThree = new SingularityPendingTaskBuilder().setPendingTaskId(taskIdThree).build();
SingularityPendingTaskId taskIdFour = new SingularityPendingTaskId(requestId + "hi", firstDeployId, System.currentTimeMillis() + TimeUnit.DAYS.toMillis(3), 5, PendingType.IMMEDIATE, System.currentTimeMillis());
SingularityPendingTask taskFour = new SingularityPendingTaskBuilder().setPendingTaskId(taskIdFour).build();
taskManager.savePendingTask(taskOne);
taskManager.savePendingTask(taskTwo);
taskManager.savePendingTask(taskThree);
taskManager.savePendingTask(taskFour);
launchTask(request, secondDeploy, 1, TaskState.TASK_RUNNING);
deployChecker.checkDeploys();
List<SingularityPendingTaskId> pendingTaskIds = taskManager.getPendingTaskIds();
Assert.assertTrue(!pendingTaskIds.contains(taskIdOne));
Assert.assertTrue(!pendingTaskIds.contains(taskIdTwo));
Assert.assertTrue(pendingTaskIds.contains(taskIdThree));
Assert.assertTrue(pendingTaskIds.contains(taskIdFour));
}
use of com.hubspot.singularity.SingularityPendingTask in project Singularity by HubSpot.
the class SingularitySchedulerTestBase method buildPendingTask.
protected SingularityPendingTask buildPendingTask(SingularityRequest request, SingularityDeploy deploy, long launchTime, int instanceNo, Optional<String> runId) {
SingularityPendingTaskId pendingTaskId = new SingularityPendingTaskId(request.getId(), deploy.getId(), launchTime, instanceNo, PendingType.IMMEDIATE, launchTime);
SingularityPendingTask pendingTask = new SingularityPendingTaskBuilder().setPendingTaskId(pendingTaskId).setRunId(runId).build();
return pendingTask;
}
Aggregations