use of org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface 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 = null;
try {
session = SharedSessionStore.getInstance().get(sessionId);
} catch (NotConnectedRestException e) {
LOGGER.warn("Session not valid.");
return null;
}
SchedulerProxyUserInterface scheduler = session.getScheduler();
try {
TaskState taskState = scheduler.getTaskState(JobIdImpl.makeJobId(jobId), taskName);
if (taskState != null && taskState.getTaskInfo() != null && taskState.getTaskInfo().isVisualizationActivated() && taskState.getTaskInfo().getVisualizationConnectionString() != null) {
List<String> connectionInfoRetrievedFromTaskState = Collections.singletonList(taskState.getTaskInfo().getVisualizationConnectionString());
return resolveVncTarget(connectionInfoRetrievedFromTaskState, jobId, taskState.getId().value());
}
TaskResult taskResult = scheduler.getTaskResult(jobId, taskName);
List<String> paRemoteConnectionLinesRetrievedFromLogs = retrievePaRemoteConnectionLines(session, jobId, taskResult);
return resolveVncTarget(paRemoteConnectionLinesRetrievedFromLogs, jobId, taskState.getId().value());
} 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.util.SchedulerProxyUserInterface in project scheduling by ow2-proactive.
the class SessionTest method testRenewSession.
/**
* Check that session id does not change if {@link Session#renewSession} is called on an existing session instance.
* The test also checks that {@link SchedulerProxyUserInterface#renewSession} is invoked on embedded scheduler
* instance if available.
*
* @throws NotConnectedException
*/
@Test
public void testRenewSession() throws NotConnectedException {
SchedulerRMProxyFactory schedulerProxyFactory = mock(SchedulerRMProxyFactory.class);
SchedulerProxyUserInterface scheduler = mock(SchedulerProxyUserInterface.class);
Session session = new Session("sessionId", schedulerProxyFactory, new Clock());
session.setScheduler(scheduler);
session.renewSession();
Assert.assertEquals("sessionId", session.getSessionId());
verify(scheduler).renewSession();
}
use of org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface in project scheduling by ow2-proactive.
the class SchedulerRMProxyFactory method connectToScheduler.
public SchedulerProxyUserInterface connectToScheduler(CredData credData) throws ActiveObjectCreationException, NodeException, LoginException, SchedulerException {
SchedulerProxyUserInterface scheduler = PAActiveObject.newActive(SchedulerProxyUserInterface.class, new Object[] {});
scheduler.init(PortalConfiguration.SCHEDULER_URL.getValueAsString(), credData);
return scheduler;
}
use of org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface in project scheduling by ow2-proactive.
the class SchedulerRMProxyFactory method connectToScheduler.
public SchedulerProxyUserInterface connectToScheduler(Credentials credentials) throws LoginException, SchedulerException, ActiveObjectCreationException, NodeException {
SchedulerProxyUserInterface scheduler = PAActiveObject.newActive(SchedulerProxyUserInterface.class, new Object[] {});
scheduler.init(PortalConfiguration.SCHEDULER_URL.getValueAsString(), credentials);
return scheduler;
}
use of org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface in project scheduling by ow2-proactive.
the class SchedulerStateRest method getSchedulerPropertiesFromSessionId.
@Override
public Map<String, Object> getSchedulerPropertiesFromSessionId(String sessionId) throws RestException {
SchedulerProxyUserInterface scheduler = checkAccess(sessionId, "properties");
Map<String, Object> schedulerProperties;
try {
schedulerProperties = scheduler.getSchedulerProperties();
schedulerProperties.putAll(WebProperties.getPropertiesAsHashMap());
schedulerProperties.putAll(PortalConfiguration.getPropertiesAsHashMap());
} catch (SchedulerException e) {
logger.warn("Attempt to retrieve scheduler properties but failed because connection exception", e);
throw RestException.wrapExceptionToRest(e);
}
return schedulerProperties;
}
Aggregations