Search in sources :

Example 6 with RunningJobsResponse

use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.RunningJobsResponse in project cloudbreak by hortonworks.

the class SaltStatesTest method testJobIsRunningReturnsExceptionOnNullResult.

@Test(expected = CloudbreakOrchestratorFailedException.class)
public void testJobIsRunningReturnsExceptionOnNullResult() throws CloudbreakOrchestratorFailedException {
    RunningJobsResponse runningJobsResponse = new RunningJobsResponse();
    when(saltConnector.run(eq("jobs.active"), any(), eq(RunningJobsResponse.class))).thenReturn(runningJobsResponse);
    SaltStates.jobIsRunning(saltConnector, "1");
}
Also used : RunningJobsResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.RunningJobsResponse) Test(org.junit.Test)

Example 7 with RunningJobsResponse

use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.RunningJobsResponse in project cloudbreak by hortonworks.

the class SaltStates method getRunningJobs.

public static RunningJobsResponse getRunningJobs(SaltConnector sc) throws CloudbreakOrchestratorFailedException {
    RunningJobsResponse runningInfo = sc.run("jobs.active", RUNNER, RunningJobsResponse.class);
    LOGGER.debug("Active salt jobs: {}", runningInfo);
    validateRunningInfoResultNotNull(runningInfo);
    return runningInfo;
}
Also used : RunningJobsResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.RunningJobsResponse)

Example 8 with RunningJobsResponse

use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.RunningJobsResponse in project cloudbreak by hortonworks.

the class SaltJobIdTracker method checkIsOtherJobRunning.

private void checkIsOtherJobRunning() throws CloudbreakOrchestratorFailedException, CloudbreakOrchestratorInProgressException {
    RunningJobsResponse runningJobs = SaltStates.getRunningJobs(saltConnector);
    List<String> runningJobIds = mapToRunningJobIds(runningJobs);
    if (!runningJobIds.isEmpty()) {
        LOGGER.warn("There are running job(s) with id: {}. Postpone starting the new job until these are finished.", runningJobIds);
        throw new CloudbreakOrchestratorInProgressException("There are running job(s) with id: " + runningJobIds, saltJobRunner.getNodesWithError());
    }
}
Also used : CloudbreakOrchestratorInProgressException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorInProgressException) RunningJobsResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.RunningJobsResponse)

Aggregations

RunningJobsResponse (com.sequenceiq.cloudbreak.orchestrator.salt.domain.RunningJobsResponse)8 Test (org.junit.Test)5 CloudbreakOrchestratorInProgressException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorInProgressException)3 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)3 StringContains.containsString (org.hamcrest.core.StringContains.containsString)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1