Search in sources :

Example 51 with Job

use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.

the class KillJobCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        boolean success = scheduler.killJob(currentContext.getSessionId(), jobId);
        resultStack(currentContext).push(success);
        if (success) {
            writeLine(currentContext, "%s successfully killed.", job());
        } else {
            writeLine(currentContext, "Cannot kill %s:", job());
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while attempting to kill %s:", job()), e, currentContext);
    }
}
Also used : SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 52 with Job

use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.

the class ListJobTasksCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        List<String> tasks = null;
        if (this.tag != null) {
            if (this.limit == 0) {
                tasks = scheduler.getJobTasksIdsByTag(currentContext.getSessionId(), jobId, tag).getList();
            } else {
                tasks = scheduler.getJobTasksIdsByTagPaginated(currentContext.getSessionId(), jobId, tag, offset, limit).getList();
            }
        } else {
            if (this.limit == 0) {
                tasks = scheduler.getTasksNames(currentContext.getSessionId(), jobId).getList();
            } else {
                tasks = scheduler.getTasksNamesPaginated(currentContext.getSessionId(), jobId, offset, limit).getList();
            }
        }
        resultStack(currentContext).push(tasks);
        if (!currentContext.isSilent()) {
            writeLine(currentContext, "%s", tasks);
        }
    } catch (Exception e) {
        String message = null;
        if (this.tag == null) {
            message = String.format("An error occurred while retrieving %s tasks:", job());
        } else {
            message = String.format("An error occurred while retrieving %s tasks filtered by tag %s:", job(), tag);
        }
        handleError(message, e, currentContext);
    }
}
Also used : SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 53 with Job

use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.

the class ResumeAllPausedTasksCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        boolean result = scheduler.resumeJob(currentContext.getSessionId(), jobId);
        handleResult(currentContext, result);
    } catch (Exception e) {
        handleError(String.format("An error occurred while attempting to resume all paused tasks for %s:", job()), e, currentContext);
    }
}
Also used : SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 54 with Job

use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.

the class ResumeJobCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    writeDeprecation(currentContext, CommandSet.JOB_RESUME_ALL_PAUSED_TASKS);
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        boolean success = scheduler.resumeJob(currentContext.getSessionId(), jobId);
        resultStack(currentContext).push(success);
        if (success) {
            writeLine(currentContext, "%s resumed successfully.", job());
        } else {
            writeLine(currentContext, "Cannot resume %s.", job());
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while attempting to resume: %s", job()), e, currentContext);
    }
}
Also used : SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 55 with Job

use of org.ow2.proactive.scheduler.common.job.Job in project scheduling by ow2-proactive.

the class AbstractFunctCmdTest method cleanScheduler.

protected void cleanScheduler() throws NotConnectedException, PermissionException, UnknownJobException {
    scheduler = RestFuncTHelper.getScheduler();
    SchedulerState state = scheduler.getState();
    System.out.println("Cleaning scheduler.");
    List<JobState> aliveJobsStates = new ArrayList<>(state.getPendingJobs().size() + state.getRunningJobs().size());
    aliveJobsStates.addAll(state.getPendingJobs());
    aliveJobsStates.addAll(state.getRunningJobs());
    List<JobState> finishedJobsStates = new ArrayList<>(state.getFinishedJobs().size());
    finishedJobsStates.addAll(state.getFinishedJobs());
    for (JobState jobState : aliveJobsStates) {
        JobId jobId = jobState.getId();
        try {
            System.out.println("Killing job " + jobId);
            scheduler.killJob(jobId);
        } catch (Exception ignored) {
        }
        System.out.println("Removing killed job " + jobId);
        scheduler.removeJob(jobId);
    }
    for (JobState jobState : finishedJobsStates) {
        JobId jobId = jobState.getId();
        System.out.println("Removing finished job " + jobId);
        scheduler.removeJob(jobId);
    }
}
Also used : SchedulerState(org.ow2.proactive.scheduler.common.SchedulerState) ArrayList(java.util.ArrayList) JobState(org.ow2.proactive.scheduler.common.job.JobState) JobId(org.ow2.proactive.scheduler.common.job.JobId) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException)

Aggregations

Test (org.junit.Test)260 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)198 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)145 JobId (org.ow2.proactive.scheduler.common.job.JobId)122 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)91 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)87 File (java.io.File)76 SimpleScript (org.ow2.proactive.scripting.SimpleScript)70 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)68 TaskScript (org.ow2.proactive.scripting.TaskScript)65 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)64 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)58 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)52 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)48 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)48 ArrayList (java.util.ArrayList)46 JobState (org.ow2.proactive.scheduler.common.job.JobState)45 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)45 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)41 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)39