Search in sources :

Example 26 with NotConnectedException

use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.

the class SchedulerStateRest method getLiveLogJob.

@Override
public String getLiveLogJob(String sessionId, String jobId, boolean allLogs) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException, LogForwardingRestException, IOException {
    try {
        Scheduler scheduler = checkAccess(sessionId, "/scheduler/jobs/" + jobId + "/livelog");
        Session session = sessionStore.get(sessionId);
        JobState jobState = scheduler.getJobState(jobId);
        boolean isFinished = jobState != null && jobState.isFinished();
        int availableLinesCount = session.getJobsOutputController().availableLinesCount(jobId);
        if (allLogs) {
            if (!isFinished || availableLinesCount > 0) {
                return session.getJobsOutputController().getAllLogs(jobId);
            } else {
                session.getJobsOutputController().removeAppender(jobId);
                return "";
            }
        } else {
            if (!isFinished || availableLinesCount > 0) {
                return session.getJobsOutputController().getNewLogs(jobId);
            } else {
                session.getJobsOutputController().removeAppender(jobId);
                return "";
            }
        }
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    } catch (LogForwardingException e) {
        throw new LogForwardingRestException(e);
    }
}
Also used : LogForwardingException(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException) HttpSession(javax.servlet.http.HttpSession) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Example 27 with NotConnectedException

use of org.ow2.proactive.scheduler.common.exception.NotConnectedException 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 28 with NotConnectedException

use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.

the class SchedulerStateListener method getSchedulerStatus.

public SchedulerStatus getSchedulerStatus(Scheduler scheduler) throws PermissionException, NotConnectedException {
    SchedulerStatus status = state.getStatus();
    if (status == null) {
        status = scheduler.getStatus();
        state.setStatus(status);
    }
    return status;
}
Also used : SchedulerStatus(org.ow2.proactive.scheduler.common.SchedulerStatus)

Example 29 with NotConnectedException

use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.

the class NoVncSecuredTargetResolverTest method mockSchedulerState.

@Before
public void mockSchedulerState() throws NotConnectedException, UnknownJobException, PermissionException, UnknownTaskException {
    JobState jobState = mock(JobState.class);
    when(schedulerMock.getJobState("42")).thenReturn(jobState);
    TaskId taskId = mock(TaskId.class);
    when(taskId.value()).thenReturn("1");
    TaskState taskState = mock(TaskState.class);
    when(taskState.getName()).thenReturn("remoteVisuTask");
    when(taskState.getId()).thenReturn(taskId);
    when(schedulerMock.getTaskState(JobIdImpl.makeJobId("42"), "remoteVisuTask")).thenReturn(taskState);
    when(jobState.getHMTasks()).thenReturn(Collections.singletonMap(taskId, taskState));
    JobState jobState2 = mock(JobState.class);
    when(schedulerMock.getJobState("43")).thenReturn(jobState2);
    TaskId taskId2 = mock(TaskId.class);
    when(taskId2.value()).thenReturn("1");
    TaskState taskState2 = mock(TaskState.class);
    TaskInfo taskInfo2 = mock(TaskInfo.class);
    when(taskState2.getTaskInfo()).thenReturn(taskInfo2);
    when(taskState2.getName()).thenReturn("remoteVisuTask");
    when(taskState2.getId()).thenReturn(taskId2);
    when(schedulerMock.getTaskState(JobIdImpl.makeJobId("43"), "remoteVisuTask")).thenReturn(taskState2);
    when(taskInfo2.isVisualizationActivated()).thenReturn(true);
    when(taskInfo2.getVisualizationConnectionString()).thenReturn("PA_REMOTE_CONNECTION;43;1;vnc;node.grid.com:5900");
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) Before(org.junit.Before)

Example 30 with NotConnectedException

use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.

the class SessionSharingTest method sessions_are_shared_rm_login.

@Test
public void sessions_are_shared_rm_login() throws Exception {
    String sessionId = rmRest.rmConnect("login", "pw");
    assertTrue(studioRest.getWorkflows(sessionId).isEmpty());
    when(schedulerMock.freeze()).thenReturn(true);
    boolean frozen = schedulerRest.freezeScheduler(sessionId);
    assertTrue(frozen);
    when(rmMock.getState()).thenReturn(new RMState(new RMStateNodeUrls(new HashSet<String>(), new HashSet<String>(), new HashSet<String>()), Long.valueOf(-1)));
    RMState rmState = rmRest.getState(sessionId);
    assertNotNull(rmState);
    rmRest.rmDisconnect(sessionId);
    try {
        rmRest.getState(sessionId);
        fail();
    } catch (NotConnectedException expected) {
    // expected
    }
    try {
        schedulerRest.freezeScheduler(sessionId);
        fail();
    } catch (NotConnectedRestException expected) {
    // expected
    }
}
Also used : NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) RMState(org.ow2.proactive.resourcemanager.common.RMState) RMStateNodeUrls(org.ow2.proactive.resourcemanager.common.RMStateNodeUrls) Test(org.junit.Test)

Aggregations

NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)85 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)76 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)54 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)53 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)47 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)44 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)36 Path (javax.ws.rs.Path)33 GET (javax.ws.rs.GET)29 Produces (javax.ws.rs.Produces)28 ImmediateService (org.objectweb.proactive.annotation.ImmediateService)28 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)26 IOException (java.io.IOException)25 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)25 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)24 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)24 JobId (org.ow2.proactive.scheduler.common.job.JobId)23 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)20 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)20 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)20