Search in sources :

Example 61 with CLIException

use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.

the class PreemptTaskCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        boolean success = scheduler.preemptTask(currentContext.getSessionId(), jobId, taskId);
        resultStack(currentContext).push(success);
        if (success) {
            writeLine(currentContext, "%s has been stopped and will be rescheduled after 5 seconds.", task());
        } else {
            writeLine(currentContext, "%s cannot be stopped and most likely it is not running.", task());
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while attempting to preemt %s:", task()), e, currentContext);
    }
}
Also used : SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 62 with CLIException

use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.

the class RemoveJobCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        boolean success = scheduler.removeJob(currentContext.getSessionId(), jobId);
        resultStack(currentContext).push(success);
        if (success) {
            writeLine(currentContext, "%s sucessfully removed.", job());
        } else {
            writeLine(currentContext, "Cannot remove %s.", job());
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while attempting to remove %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 63 with CLIException

use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.

the class RestartAllInErrorTasksCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        boolean result = scheduler.restartAllInErrorTasks(currentContext.getSessionId(), jobId);
        handleResult(currentContext, result);
    } catch (Exception e) {
        handleError(String.format("An error occurred while attempting to restart all In-Error 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 64 with CLIException

use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.

the class ResumeAllPausedTasksAndRestartAllInErrorTasksCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        String sessionId = currentContext.getSessionId();
        boolean result = scheduler.resumeJob(sessionId, jobId);
        result &= scheduler.restartAllInErrorTasks(sessionId, jobId);
        handleResult(currentContext, result);
    } catch (Exception e) {
        handleError(String.format("An error occurred while attempting to resume/restart all paused/in-error 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 65 with CLIException

use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.

the class ResumeCommand method execute.

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

Aggregations

CLIException (org.ow2.proactive_grid_cloud_portal.cli.CLIException)49 SchedulerRestInterface (org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface)30 HttpResponseWrapper (org.ow2.proactive_grid_cloud_portal.cli.utils.HttpResponseWrapper)22 QueryStringBuilder (org.ow2.proactive_grid_cloud_portal.cli.utils.QueryStringBuilder)12 HttpGet (org.apache.http.client.methods.HttpGet)10 HttpPost (org.apache.http.client.methods.HttpPost)9 IOException (java.io.IOException)8 File (java.io.File)6 List (java.util.List)5 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)4 NSStateView (org.ow2.proactive_grid_cloud_portal.cli.json.NSStateView)4 PluginView (org.ow2.proactive_grid_cloud_portal.cli.json.PluginView)4 ArrayList (java.util.ArrayList)3 RmStateView (org.ow2.proactive_grid_cloud_portal.cli.json.RmStateView)3 FileInputStream (java.io.FileInputStream)2 Stack (java.util.Stack)2 HttpPut (org.apache.http.client.methods.HttpPut)2 ConfigurableFieldView (org.ow2.proactive_grid_cloud_portal.cli.json.ConfigurableFieldView)2 TaskResultData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData)2 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)2