Search in sources :

Example 21 with SchedulerRestInterface

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

the class GetJobResultCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        if (this.tag == null) {
            JobResultData results = scheduler.jobResult(currentContext.getSessionId(), jobId);
            resultStack(currentContext).push(results);
            if (!currentContext.isForced()) {
                writeLine(currentContext, "%s", StringUtility.jobResultAsString(job(), results));
            }
        } else {
            List<TaskResultData> results = scheduler.taskResultByTag(currentContext.getSessionId(), jobId, tag);
            resultStack(currentContext).push(results);
            if (!currentContext.isForced()) {
                writeLine(currentContext, "%s", StringUtility.taskResultsAsString(results));
            }
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while retrieving %s result:", job()), e, currentContext);
    }
}
Also used : JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 22 with SchedulerRestInterface

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

the class GetJobStateCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        JobStateData jobState = scheduler.listJobs(currentContext.getSessionId(), jobId);
        resultStack(currentContext).push(jobState);
        if (!currentContext.isSilent()) {
            writeLine(currentContext, "%s", StringUtility.jobStateAsString(job(), jobState));
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while retrieving %s state:", job()), e, currentContext);
    }
}
Also used : JobStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobStateData) SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 23 with SchedulerRestInterface

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

the class KillCommand method execute.

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

Example 24 with SchedulerRestInterface

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

the class ListTaskStatesCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        List<TaskStateData> tasks = null;
        if (this.tag == null) {
            if (this.limit == 0) {
                tasks = scheduler.getJobTaskStates(currentContext.getSessionId(), jobId).getList();
            } else {
                tasks = scheduler.getJobTaskStatesPaginated(currentContext.getSessionId(), jobId, offset, limit).getList();
            }
        } else {
            if (this.limit == 0) {
                tasks = scheduler.getJobTaskStatesByTag(currentContext.getSessionId(), jobId, tag).getList();
            } else {
                tasks = scheduler.getJobTaskStatesByTagPaginated(currentContext.getSessionId(), jobId, tag, offset, limit).getList();
            }
        }
        resultStack(currentContext).push(tasks);
        if (!currentContext.isSilent()) {
            writeLine(currentContext, "%s", StringUtility.taskStatesAsString(tasks, false));
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while retrieving %s state:", job()), e, currentContext);
    }
}
Also used : TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 25 with SchedulerRestInterface

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

the class LoginSchedCommand method login.

@Override
protected String login(ApplicationContext currentContext) throws CLIException {
    String password = currentContext.getProperty(PASSWORD, String.class);
    if (password == null) {
        password = new String(readPassword(currentContext, "password:"));
    }
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        return scheduler.login(username, password);
    } catch (Exception e) {
        throw new CLIException(REASON_OTHER, "An error occurred while logging.", e);
    }
}
Also used : CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException) 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