Search in sources :

Example 6 with SchedulerRestInterface

use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface 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 7 with SchedulerRestInterface

use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface in project scheduling by ow2-proactive.

the class LinkRmCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        boolean success = scheduler.linkRm(currentContext.getSessionId(), rmUrl);
        resultStack(currentContext).push(success);
        if (success) {
            writeLine(currentContext, "New resource manager relinked successfully.");
        } else {
            writeLine(currentContext, "Cannot relink '%s'.", rmUrl);
        }
    } catch (Exception e) {
        handleError("An error occurred while relinking:", e, currentContext);
    }
}
Also used : SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 8 with SchedulerRestInterface

use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface 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 9 with SchedulerRestInterface

use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface in project scheduling by ow2-proactive.

the class PauseCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        boolean success = scheduler.pauseScheduler(currentContext.getSessionId());
        resultStack(currentContext).push(success);
        if (success) {
            writeLine(currentContext, "Scheduler successfully paused.");
        } else {
            writeLine(currentContext, "Cannot pause scheduler.");
        }
    } catch (Exception e) {
        handleError("An error occurred while attempting to pause scheduler:", e, currentContext);
    }
}
Also used : SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 10 with SchedulerRestInterface

use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface in project scheduling by ow2-proactive.

the class RestartInErrorTaskCommand method execute.

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

Aggregations

SchedulerRestInterface (org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface)32 CLIException (org.ow2.proactive_grid_cloud_portal.cli.CLIException)30 TaskResultData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData)3 JobResultData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData)2 JobStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobStateData)2 TaskStateData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)1 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)1 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)1 InvalidScriptException (org.ow2.proactive.scripting.InvalidScriptException)1 ScriptResult (org.ow2.proactive.scripting.ScriptResult)1 JobIdData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData)1 SchedulerUserData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.SchedulerUserData)1 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)1 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)1