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