use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class UnlockNodeCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
HttpPost request = new HttpPost(currentContext.getResourceUrl("node/unlock"));
QueryStringBuilder queryStringBuilder = new QueryStringBuilder();
for (String nodeUrl : nodeUrls) {
queryStringBuilder.add("nodeurls", nodeUrl);
}
request.setEntity(queryStringBuilder.buildEntity(APPLICATION_FORM_URLENCODED));
HttpResponseWrapper response = execute(request, currentContext);
if (statusCode(OK) == statusCode(response)) {
boolean success = readValue(response, Boolean.TYPE, currentContext);
resultStack(currentContext).push(success);
if (success) {
writeLine(currentContext, "Node(s) unlocked successfully.");
} else {
writeLine(currentContext, "Cannot unlock node(s).");
}
} else {
handleError("An error occurred while unlocking nodes:", response, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class FreezeCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
try {
boolean success = scheduler.freezeScheduler(currentContext.getSessionId());
resultStack(currentContext).push(success);
if (success) {
writeLine(currentContext, "Scheduler successfully frozen.");
} else {
writeLine(currentContext, "Cannot freeze scheduler.");
}
} catch (Exception e) {
handleError("Error occurred while trying to freeze the scheduler:", e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException 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_grid_cloud_portal.cli.CLIException 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_grid_cloud_portal.cli.CLIException 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);
}
}
Aggregations