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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations