use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class NoVncSecuredTargetResolver method doResolve.
// package-protected for testing
InetSocketAddress doResolve(String sessionId, String jobId, String taskName) {
if (sessionId == null || jobId == null || taskName == null) {
LOGGER.warn("One of the web socket path parameter is missing (sessionId, jobId, taskName).");
return null;
}
Session session = SharedSessionStore.getInstance().get(sessionId);
if (session == null) {
LOGGER.warn("Unknown sessionId.");
return null;
}
SchedulerProxyUserInterface scheduler = session.getScheduler();
try {
TaskResult taskResult = scheduler.getTaskResult(jobId, taskName);
List<String> paRemoteConnectionLines = retrievePaRemoteConnectionLines(session, jobId, taskResult);
String taskId = retrieveTaskId(taskName, scheduler.getJobState(jobId));
return resolveVncTargetFromLogs(paRemoteConnectionLines, jobId, taskId);
} catch (NotConnectedException e) {
LOGGER.warn("Failed to connect to scheduler", e);
} catch (UnknownJobException e) {
LOGGER.warn("Job does not exist", e);
} catch (UnknownTaskException e) {
LOGGER.warn("Task does not exist", e);
} catch (PermissionException e) {
LOGGER.warn("Not allowed to access task", e);
}
return null;
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class RestFuncTHelper method startRestfulSchedulerWebapp.
public static void startRestfulSchedulerWebapp(int nbNodes) throws Exception {
// Kill all children processes on exit
org.apache.log4j.BasicConfigurator.configure(new org.apache.log4j.varia.NullAppender());
CookieBasedProcessTreeKiller.registerKillChildProcessesOnShutdown("rest_tests");
List<String> cmd = new ArrayList<>();
String javaPath = RestFuncTUtils.getJavaPathFromSystemProperties();
cmd.add(javaPath);
cmd.add("-Djava.security.manager");
cmd.add(CentralPAPropertyRepository.JAVA_SECURITY_POLICY.getCmdLine() + toPath(serverJavaPolicy));
cmd.add(CentralPAPropertyRepository.PA_HOME.getCmdLine() + getSchedHome());
cmd.add(PASchedulerProperties.SCHEDULER_HOME.getCmdLine() + getSchedHome());
cmd.add(PAResourceManagerProperties.RM_HOME.getCmdLine() + getRmHome());
cmd.add(PAResourceManagerProperties.RM_DB_HIBERNATE_DROPDB.getCmdLine() + System.getProperty("rm.deploy.dropDB", "true"));
cmd.add(PAResourceManagerProperties.RM_DB_HIBERNATE_CONFIG.getCmdLine() + toPath(rmHibernateConfig));
cmd.add(PASchedulerProperties.SCHEDULER_DB_HIBERNATE_DROPDB.getCmdLine() + System.getProperty("scheduler.deploy.dropDB", "true"));
cmd.add(PASchedulerProperties.SCHEDULER_DB_HIBERNATE_CONFIG.getCmdLine() + toPath(schedHibernateConfig));
cmd.add(WebProperties.WEB_HTTPS.getCmdLine() + "true");
cmd.add(CentralPAPropertyRepository.PA_COMMUNICATION_PROTOCOL.getCmdLine() + "pnp");
cmd.add(PNPConfig.PA_PNP_PORT.getCmdLine() + "1200");
cmd.add("-cp");
cmd.add(getClassPath());
cmd.add(SchedulerStarter.class.getName());
cmd.add("-ln");
cmd.add("" + nbNodes);
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
processBuilder.redirectErrorStream(true);
schedProcess = processBuilder.start();
ProcessStreamReader out = new ProcessStreamReader("scheduler-output: ", schedProcess.getInputStream());
out.start();
// RM and scheduler are on the same url
String port = "1200";
String url = "pnp://localhost:" + port + "/";
// Connect a scheduler client
SchedulerAuthenticationInterface schedAuth = SchedulerConnection.waitAndJoin(url, TimeUnit.SECONDS.toMillis(120));
schedulerPublicKey = schedAuth.getPublicKey();
Credentials schedCred = RestFuncTUtils.createCredentials("admin", "admin", schedulerPublicKey);
scheduler = schedAuth.login(schedCred);
// Connect a rm client
RMAuthentication rmAuth = RMConnection.waitAndJoin(url, TimeUnit.SECONDS.toMillis(120));
Credentials rmCredentials = getRmCredentials();
rm = rmAuth.login(rmCredentials);
restServerUrl = "https://localhost:8443/rest/";
restfulSchedulerUrl = restServerUrl + "scheduler";
await().atMost(Duration.FIVE_MINUTES).until(restIsStarted());
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class RestSchedulerJobPaginationTest method setUp.
@Before
public void setUp() throws Exception {
Scheduler scheduler = RestFuncTHelper.getScheduler();
SchedulerState state = scheduler.getState();
List<JobState> jobStates = new ArrayList<>();
jobStates.addAll(state.getPendingJobs());
jobStates.addAll(state.getRunningJobs());
jobStates.addAll(state.getFinishedJobs());
for (JobState jobState : jobStates) {
JobId jobId = jobState.getId();
scheduler.killJob(jobId);
scheduler.removeJob(jobId);
}
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class RestSchedulerJobTaskTest method cleanScheduler.
private static void cleanScheduler() throws NotConnectedException, PermissionException, UnknownJobException {
Scheduler scheduler = RestFuncTHelper.getScheduler();
SchedulerState state = scheduler.getState();
Iterable<JobState> jobs = Iterables.concat(state.getPendingJobs(), state.getRunningJobs(), state.getFinishedJobs());
for (JobState jobState : jobs) {
JobId jobId = jobState.getId();
scheduler.killJob(jobId);
scheduler.removeJob(jobId);
}
}
use of org.ow2.proactive.scheduler.common.Scheduler in project scheduling by ow2-proactive.
the class RestSchedulerTest method testStartScheduler.
@Test
public void testStartScheduler() throws Exception {
Scheduler scheduler = getScheduler();
scheduler.stop();
String resourceUrl = getResourceUrl("start");
HttpPut httpPut = new HttpPut(resourceUrl);
setSessionHeader(httpPut);
HttpResponse response = executeUriRequest(httpPut);
assertHttpStatusOK(response);
assertTrue(Boolean.valueOf(getContent(response)));
assertTrue(SchedulerStatus.STARTED.equals(scheduler.getStatus()));
}
Aggregations