use of com.hubspot.singularity.SingularityRequestHistory.RequestHistoryType in project Singularity by HubSpot.
the class SingularitySchedulerTest method itCorrectlyUpdatesRequestDeletingStateHistory.
@Test
public void itCorrectlyUpdatesRequestDeletingStateHistory() {
initRequest();
Assert.assertEquals(RequestState.ACTIVE, requestManager.getRequest(requestId).get().getState());
Assert.assertEquals(1, requestManager.getRequestHistory(requestId).size());
requestManager.startDeletingRequest(request, Optional.absent(), Optional.<String>absent(), Optional.<String>absent(), Optional.of("the cake is a lie"));
Assert.assertEquals(RequestState.DELETING, requestManager.getRequest(requestId).get().getState());
Assert.assertEquals(2, requestManager.getRequestHistory(requestId).size());
cleaner.drainCleanupQueue();
Assert.assertEquals(3, requestManager.getRequestHistory(requestId).size());
List<RequestHistoryType> historyTypes = new ArrayList<>();
for (SingularityRequestHistory request : requestManager.getRequestHistory(requestId)) {
historyTypes.add(request.getEventType());
}
Assert.assertTrue(historyTypes.contains(RequestHistoryType.CREATED));
Assert.assertTrue(historyTypes.contains(RequestHistoryType.DELETING));
Assert.assertTrue(historyTypes.contains(RequestHistoryType.DELETED));
}
use of com.hubspot.singularity.SingularityRequestHistory.RequestHistoryType in project Singularity by HubSpot.
the class RequestHelper method updateRequest.
public void updateRequest(SingularityRequest request, Optional<SingularityRequest> maybeOldRequest, RequestState requestState, Optional<RequestHistoryType> historyType, Optional<String> user, Optional<Boolean> skipHealthchecks, Optional<String> message, Optional<SingularityBounceRequest> maybeBounceRequest) {
SingularityRequestDeployHolder deployHolder = getDeployHolder(request.getId());
SingularityRequest newRequest = validator.checkSingularityRequest(request, maybeOldRequest, deployHolder.getActiveDeploy(), deployHolder.getPendingDeploy());
final long now = System.currentTimeMillis();
if (requestState == RequestState.FINISHED && maybeOldRequest.isPresent() && shouldReschedule(newRequest, maybeOldRequest.get())) {
requestState = RequestState.ACTIVE;
}
RequestHistoryType historyTypeToSet = null;
if (historyType.isPresent()) {
historyTypeToSet = historyType.get();
} else if (maybeOldRequest.isPresent()) {
historyTypeToSet = RequestHistoryType.UPDATED;
} else {
historyTypeToSet = RequestHistoryType.CREATED;
}
requestManager.save(newRequest, requestState, historyTypeToSet, now, user, message);
checkReschedule(newRequest, maybeOldRequest, user, now, skipHealthchecks, message, maybeBounceRequest);
}
Aggregations