use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class UndeployNodeSourceCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
HttpPut request = new HttpPut(currentContext.getResourceUrl(RM_REST_ENDPOINT));
QueryStringBuilder queryStringBuilder = new QueryStringBuilder();
queryStringBuilder.add("nodeSourceName", this.nodeSourceName).add("preempt", Boolean.toString(this.preempt));
request.setEntity(queryStringBuilder.buildEntity(APPLICATION_FORM_URLENCODED));
HttpResponseWrapper response = this.execute(request, currentContext);
if (this.statusCode(OK) == this.statusCode(response)) {
NSStateView nsState = this.readValue(response, NSStateView.class, currentContext);
boolean success = nsState.isResult();
this.resultStack(currentContext).push(success);
if (success) {
writeLine(currentContext, "Node source successfully undeployed.");
} else {
writeLine(currentContext, "%s %s", "Cannot undeploy node source:", this.nodeSourceName);
}
} else {
this.handleError("An error occurred while undeploying node source:", response, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class ChangeJobPriorityCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
try {
scheduler.schedulerChangeJobPriorityByValue(currentContext.getSessionId(), jobId, priorityValue);
resultStack(currentContext).push(Boolean.TRUE);
writeLine(currentContext, "%s priority changed successfully.", job());
} catch (Exception e) {
handleError(String.format("An error occurred while changing %s priority:", job()), e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException in project scheduling by ow2-proactive.
the class DownloadFileCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
InputStream in = null;
OutputStream out = null;
try {
in = currentContext.getRestClient().getScheduler().pullFile(currentContext.getSessionId(), spaceName, pathName);
out = buildOutputStream(new File(localFile));
copy(in, out);
resultStack(currentContext).push(true);
writeLine(currentContext, "%s successfully downloaded to %s.", pathName, localFile);
} catch (Exception error) {
handleError("An error occurred while pulling the file from the server. " + localFile, error, currentContext);
} finally {
if (in != null) {
closeQuietly(in);
}
if (out != null) {
closeQuietly(out);
}
}
}
use of org.ow2.proactive_grid_cloud_portal.cli.CLIException 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.cli.CLIException 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);
}
}
Aggregations