use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface in project scheduling by ow2-proactive.
the class SchedulerClientExample method main.
public static void main(String[] args) throws Exception {
// LOGIN IN
SchedulerRestClient client = new SchedulerRestClient("http://localhost:8080/rest/");
SchedulerRestInterface scheduler = client.getScheduler();
String sessionId = scheduler.login("admin", "admin");
// JOB SUBMISSION
File xmlJobFile = new File("/path/to/some/existing/job/job_1.xml");
JobIdData xmlJob;
try (FileInputStream inputStream = new FileInputStream(xmlJobFile)) {
xmlJob = client.submitXml(sessionId, inputStream);
}
System.out.println(xmlJob.getReadableName() + " " + xmlJob.getId());
// FLAT JOB SUBMISSION
JobIdData flatJob = scheduler.submitFlat(sessionId, "echo hello", "test-hello", null, null);
System.out.println("Jobid=" + flatJob);
String serverlog = scheduler.jobServerLog(sessionId, Long.toString(flatJob.getId()));
System.out.println(serverlog);
while (true) {
JobStateData jobState2 = scheduler.listJobs(sessionId, Long.toString(flatJob.getId()));
System.out.println(jobState2);
if (jobState2.getJobInfo().getStatus().name().equals("FINISHED")) {
break;
}
Thread.sleep(100);
}
JobResultData jobResultData = scheduler.jobResult(sessionId, Long.toString(flatJob.getId()));
System.out.println(jobResultData);
TaskResultData taskresult = scheduler.taskResult(sessionId, Long.toString(flatJob.getId()), "task_1");
System.out.println(taskresult);
List<TaskStateData> jobTaskStates = scheduler.getJobTaskStates(sessionId, Long.toString(flatJob.getId())).getList();
System.out.println(jobTaskStates);
TaskStateData task_1 = scheduler.jobTask(sessionId, Long.toString(flatJob.getId()), "task_1");
System.out.println(task_1);
// OTHER CALLS
List<SchedulerUserData> users = scheduler.getUsers(sessionId);
System.out.println(users);
System.out.println(users.size());
RestMapPage<Long, ArrayList<UserJobData>> page = scheduler.revisionAndJobsInfo(sessionId, 0, 50, true, true, true, true, true, null, null, null, null, null);
Map<Long, ArrayList<UserJobData>> map = page.getMap();
System.out.println(map);
System.out.println(scheduler.getSchedulerStatus(sessionId));
System.out.println(scheduler.getUsageOnMyAccount(sessionId, new Date(), new Date()));
// FAILING CALL
try {
JobStateData jobState = scheduler.listJobs(sessionId, "601");
System.out.println(jobState);
} catch (UnknownJobRestException e) {
System.err.println("exception! " + e.getMessage());
e.printStackTrace();
}
}
use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface in project scheduling by ow2-proactive.
the class PauseCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
try {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
boolean success = scheduler.pauseScheduler(currentContext.getSessionId());
resultStack(currentContext).push(success);
if (success) {
writeLine(currentContext, "Scheduler successfully paused.");
} else {
writeLine(currentContext, "Cannot pause scheduler.");
}
} catch (Exception e) {
handleError("An error occurred while attempting to pause scheduler:", e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface in project scheduling by ow2-proactive.
the class RestartInErrorTaskCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
try {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
boolean result = scheduler.restartInErrorTask(currentContext.getSessionId(), jobId, taskId);
handleResult(currentContext, result);
} catch (Exception e) {
handleError(String.format("An error occurred while attempting to restart %s:", task()), e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface in project scheduling by ow2-proactive.
the class StartCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
try {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
boolean success = scheduler.startScheduler(currentContext.getSessionId());
resultStack(currentContext).push(success);
if (success) {
writeLine(currentContext, "Scheduler successfully started.");
} else {
writeLine(currentContext, "Cannot start scheduler.");
}
} catch (Exception e) {
handleError("An error occurred while attempting to start scheduler:", e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface in project scheduling by ow2-proactive.
the class ShutdownCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
try {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
boolean success = scheduler.shutdownScheduler(currentContext.getSessionId());
resultStack(currentContext).push(success);
if (success) {
writeLine(currentContext, "Scheduler successfully shutdown.");
} else {
writeLine(currentContext, "Cannot shutdown scheduler.");
}
} catch (Exception e) {
handleError("An error occurred while attempting to shutdown scheduler:", e, currentContext);
}
}
Aggregations