Search in sources :

Example 41 with Scheduler

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

the class GetJobOutputCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        String output = null;
        if (this.tag == null) {
            output = scheduler.jobLogs(currentContext.getSessionId(), jobId);
        } else {
            output = scheduler.taskLogByTag(currentContext.getSessionId(), jobId, tag);
        }
        resultStack(currentContext).push(output);
        if (!currentContext.isSilent()) {
            writeLine(currentContext, "%s", output);
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while retrieving %s output:", job()), e, currentContext);
    }
}
Also used : SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 42 with Scheduler

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

the class GetTaskOutputCommand method execute.

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

Example 43 with Scheduler

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

the class GetTaskResultCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        TaskResultData taskResult = scheduler.taskResult(currentContext.getSessionId(), jobId, taskId);
        resultStack(currentContext).push(taskResult);
        if (!currentContext.isSilent()) {
            writeLine(currentContext, "%s", StringUtility.taskResultAsString(task(), taskResult));
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while retrieving %s result:", task()), e, currentContext);
    }
}
Also used : 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 44 with Scheduler

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

the class InstallPackageCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    ScriptResult scriptResult;
    Map<String, Object> schedulerProperties;
    String packageDirPath;
    try {
        packageDirPath = retrievePackagePath();
        schedulerProperties = retrieveSchedulerProperties(currentContext, scheduler);
        addSessionIdToSchedulerProperties(currentContext, schedulerProperties);
        scriptResult = executeScript(schedulerProperties, packageDirPath);
        if (scriptResult.errorOccured()) {
            logger.error("Failed to execute script: " + SCRIPT_PATH);
            throw new InvalidScriptException("Failed to execute script: " + scriptResult.getException().getMessage(), scriptResult.getException());
        } else {
            writeLine(currentContext, "Package('%s') successfully installed in the catalog", SOURCE_PACKAGE);
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while attempting to install package('%s') in the catalog", SOURCE_PACKAGE), e, currentContext);
    }
}
Also used : ScriptResult(org.ow2.proactive.scripting.ScriptResult) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) IOException(java.io.IOException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)

Example 45 with Scheduler

use of org.ow2.proactive.scheduler.common.Scheduler 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)

Aggregations

Scheduler (org.ow2.proactive.scheduler.common.Scheduler)97 JobId (org.ow2.proactive.scheduler.common.job.JobId)51 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)49 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)46 Path (javax.ws.rs.Path)45 Produces (javax.ws.rs.Produces)43 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)42 Test (org.junit.Test)39 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)38 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)36 File (java.io.File)34 GET (javax.ws.rs.GET)34 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)31 SchedulerRestInterface (org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface)31 CLIException (org.ow2.proactive_grid_cloud_portal.cli.CLIException)30 JobState (org.ow2.proactive.scheduler.common.job.JobState)29 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)28 GZIP (org.jboss.resteasy.annotations.GZIP)23 KeyException (java.security.KeyException)20 CredData (org.ow2.proactive.authentication.crypto.CredData)19