use of org.ow2.proactive_grid_cloud_portal.cli.CLIException 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.cli.CLIException 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.cli.CLIException in project scheduling by ow2-proactive.
the class LiveLogCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
writeLine(currentContext, "Displaying live log for job %s. Press 'q' to stop.", jobId);
try {
LogReader reader = new LogReader(currentContext);
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(reader);
String line = readLine(currentContext, "> ");
while (Strings.isNullOrEmpty(line) || !line.trim().equals("q")) {
line = readLine(currentContext, "> ");
}
reader.terminate();
executor.shutdownNow();
} catch (Exception e) {
handleError("An error occurred while displaying live log", e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException 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);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class PauseJobCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
try {
boolean success = scheduler.pauseJob(currentContext.getSessionId(), jobId);
resultStack(currentContext).push(success);
if (success) {
writeLine(currentContext, "%s successfully paused.", job());
} else {
writeLine(currentContext, "Cannot pause %s.", job());
}
} catch (Exception e) {
handleError(String.format("An error occurred while attempting to pause %s:", job()), e, currentContext);
}
}
Aggregations