throw new IllegalStateException("The job is no longer in-progress - cannot cancel it: " + doomedHistory);
}
String jobIdString = doomedHistory.getJobId().toString();
int resourceId = doomedHistory.getResource().getId();
CancelResults results = null;
AgentClient agent = null;
boolean canceled = false;
try {
agent = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
// since this method is usually called by the UI, we want to quickly determine if we can even talk to the agent
if (agent.pingService(5000L)) {
results = agent.getOperationAgentService().cancelOperation(jobIdString);
InterruptedState interruptedState = results.getInterruptedState();
switch (interruptedState) {
case FINISHED: {
// If the agent says the interrupted state was FINISHED, we should not set the history state
// to canceled because it can't be canceled after its completed. Besides, the agent will very