use of com.hubspot.singularity.SingularityLoadBalancerUpdate in project Singularity by HubSpot.
the class TaskManager method getTaskHistory.
public Optional<SingularityTaskHistory> getTaskHistory(SingularityTaskId taskId) {
final Optional<SingularityTask> task = getTaskCheckCache(taskId, true);
if (!task.isPresent()) {
return Optional.absent();
}
List<SingularityTaskHistoryUpdate> taskUpdates = getTaskHistoryUpdates(taskId);
Optional<String> directory = getDirectory(taskId);
Optional<String> containerId = getContainerId(taskId);
List<SingularityTaskHealthcheckResult> healthchecks = getHealthcheckResults(taskId);
List<SingularityLoadBalancerUpdate> loadBalancerUpdates = Lists.newArrayListWithCapacity(2);
checkLoadBalancerHistory(loadBalancerUpdates, taskId, LoadBalancerRequestType.ADD);
checkLoadBalancerHistory(loadBalancerUpdates, taskId, LoadBalancerRequestType.REMOVE);
List<SingularityTaskShellCommandHistory> shellCommandHistory = getTaskShellCommandHistory(taskId);
List<SingularityTaskMetadata> taskMetadata = getTaskMetadata(taskId);
return Optional.of(new SingularityTaskHistory(taskUpdates, directory, containerId, healthchecks, task.get(), loadBalancerUpdates, shellCommandHistory, taskMetadata));
}
use of com.hubspot.singularity.SingularityLoadBalancerUpdate in project Singularity by HubSpot.
the class SingularitySchedulerTest method testLBCleanup.
@Test
public void testLBCleanup() {
initLoadBalancedRequest();
initFirstDeploy();
configuration.setLoadBalancerRemovalGracePeriodMillis(10000);
SingularityTask task = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
saveLoadBalancerState(BaragonRequestState.SUCCESS, task.getTaskId(), LoadBalancerRequestType.ADD);
statusUpdate(task, TaskState.TASK_FAILED);
Assert.assertTrue(!taskManager.getLBCleanupTasks().isEmpty());
testingLbClient.setNextBaragonRequestState(BaragonRequestState.WAITING);
cleaner.drainCleanupQueue();
Assert.assertTrue(!taskManager.getLBCleanupTasks().isEmpty());
Optional<SingularityLoadBalancerUpdate> lbUpdate = taskManager.getLoadBalancerState(task.getTaskId(), LoadBalancerRequestType.REMOVE);
Assert.assertTrue(lbUpdate.isPresent());
Assert.assertTrue(lbUpdate.get().getLoadBalancerState() == BaragonRequestState.WAITING);
testingLbClient.setNextBaragonRequestState(BaragonRequestState.FAILED);
cleaner.drainCleanupQueue();
Assert.assertTrue(!taskManager.getLBCleanupTasks().isEmpty());
lbUpdate = taskManager.getLoadBalancerState(task.getTaskId(), LoadBalancerRequestType.REMOVE);
Assert.assertTrue(lbUpdate.isPresent());
Assert.assertTrue(lbUpdate.get().getLoadBalancerState() == BaragonRequestState.FAILED);
testingLbClient.setNextBaragonRequestState(BaragonRequestState.SUCCESS);
cleaner.drainCleanupQueue();
Assert.assertTrue(!taskManager.getLBCleanupTasks().isEmpty());
configuration.setLoadBalancerRemovalGracePeriodMillis(0);
cleaner.drainCleanupQueue();
Assert.assertTrue(taskManager.getLBCleanupTasks().isEmpty());
lbUpdate = taskManager.getLoadBalancerState(task.getTaskId(), LoadBalancerRequestType.REMOVE);
Assert.assertTrue(lbUpdate.isPresent());
Assert.assertTrue(lbUpdate.get().getLoadBalancerState() == BaragonRequestState.SUCCESS);
Assert.assertTrue(lbUpdate.get().getLoadBalancerRequestId().getAttemptNumber() == 2);
}
use of com.hubspot.singularity.SingularityLoadBalancerUpdate in project Singularity by HubSpot.
the class SingularitySchedulerTestBase method startDeploy.
protected void startDeploy(SingularityDeployMarker deployMarker, long timestamp) {
SingularityDeployProgress startingDeployProgress = new SingularityDeployProgress(1, 0, 1, 10, false, true, Collections.<SingularityTaskId>emptySet(), timestamp);
deployManager.savePendingDeploy(new SingularityPendingDeploy(deployMarker, Optional.<SingularityLoadBalancerUpdate>absent(), DeployState.WAITING, Optional.of(startingDeployProgress), Optional.<SingularityRequest>absent()));
}
use of com.hubspot.singularity.SingularityLoadBalancerUpdate in project Singularity by HubSpot.
the class SingularitySchedulerTestBase method saveLoadBalancerState.
protected void saveLoadBalancerState(BaragonRequestState brs, SingularityTaskId taskId, LoadBalancerRequestType lbrt) {
final LoadBalancerRequestId lbri = new LoadBalancerRequestId(taskId.getId(), lbrt, Optional.<Integer>absent());
SingularityLoadBalancerUpdate update = new SingularityLoadBalancerUpdate(brs, lbri, Optional.<String>absent(), System.currentTimeMillis(), LoadBalancerMethod.CHECK_STATE, null);
taskManager.saveLoadBalancerState(taskId, lbrt, update);
}
use of com.hubspot.singularity.SingularityLoadBalancerUpdate in project Singularity by HubSpot.
the class SingularityDeployChecker method cancelLoadBalancer.
private SingularityDeployResult cancelLoadBalancer(SingularityPendingDeploy pendingDeploy, List<SingularityDeployFailure> deployFailures) {
final SingularityLoadBalancerUpdate lbUpdate = sendCancelToLoadBalancer(pendingDeploy);
final DeployState deployState = interpretLoadBalancerState(lbUpdate, DeployState.CANCELING);
updatePendingDeploy(pendingDeploy, Optional.of(lbUpdate), deployState);
return new SingularityDeployResult(deployState, lbUpdate, deployFailures);
}
Aggregations