Search in sources :

Example 1 with SchedulerProxyUserInterface

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;
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Example 2 with SchedulerProxyUserInterface

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();
}
Also used : SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) Test(org.junit.Test)

Example 3 with SchedulerProxyUserInterface

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;
}
Also used : SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface)

Example 4 with SchedulerProxyUserInterface

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;
}
Also used : SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface)

Example 5 with SchedulerProxyUserInterface

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;
}
Also used : SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) FileObject(org.apache.commons.vfs2.FileObject)

Aggregations

SchedulerProxyUserInterface (org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface)7 HttpSession (javax.servlet.http.HttpSession)2 Session (org.ow2.proactive_grid_cloud_portal.common.Session)2 URISyntaxException (java.net.URISyntaxException)1 KeyException (java.security.KeyException)1 LoginException (javax.security.auth.login.LoginException)1 FileObject (org.apache.commons.vfs2.FileObject)1 AtmosphereResource (org.atmosphere.cpr.AtmosphereResource)1 WebSocketEventListenerAdapter (org.atmosphere.websocket.WebSocketEventListenerAdapter)1 Test (org.junit.Test)1 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)1 PAActiveObject (org.objectweb.proactive.api.PAActiveObject)1 NodeException (org.objectweb.proactive.core.node.NodeException)1 CredData (org.ow2.proactive.authentication.crypto.CredData)1 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)1 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)1 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)1 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)1 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)1 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)1