Search in sources :

Example 56 with NotConnectedRestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.

the class SchedulerStateRest method getUserDataFromSessionId.

/**
 * {@inheritDoc}
 */
@Override
@GET
@Path("logins/sessionid/{sessionId}/userdata")
@Produces("application/json")
public UserData getUserDataFromSessionId(@PathParam("sessionId") String sessionId) {
    if (sessionId != null && sessionStore.exists(sessionId)) {
        try {
            renewSession(sessionId);
            Scheduler scheduler = sessionStore.get(sessionId).getScheduler();
            UserData userData = scheduler.getCurrentUserData();
            return userData;
        } catch (NotConnectedRestException | NotConnectedException e) {
            logger.trace(e);
        } catch (Exception e) {
            logger.warn(e);
        }
    }
    return null;
}
Also used : NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UserData(org.ow2.proactive.authentication.UserData) SchedulerUserData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.SchedulerUserData) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) LogForwardingRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.LogForwardingRestException) NodeException(org.objectweb.proactive.core.node.NodeException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) JobCreationRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobCreationRestException) ConnectionException(org.ow2.proactive.scheduler.common.exception.ConnectionException) IOException(java.io.IOException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) LoginException(javax.security.auth.login.LoginException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) URISyntaxException(java.net.URISyntaxException) UnknownTaskRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException) LogForwardingException(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) JobAlreadyFinishedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobAlreadyFinishedRestException) SubmissionClosedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SubmissionClosedRestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 57 with NotConnectedRestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.

the class SchedulerStateRest method taskLogByTag.

/**
 * Returns all the logs generated by a set of the tasks (either stdout and
 * stderr) filtered by a tag.
 *
 * @param sessionId
 *            a valid session id
 * @param jobId
 *            the id of the job
 * @param taskTag
 *            the tag used to filter the tasks.
 * @return the list of logs generated by each filtered task (either stdout
 *         and stderr) or an empty string if the result is not yet available
 */
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/tag/{tasktag}/result/log/all")
@Produces("application/json")
public String taskLogByTag(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("tasktag") String taskTag) throws NotConnectedRestException, UnknownJobRestException, PermissionRestException {
    try {
        Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/tag/" + taskTag + "/result/log/err");
        List<TaskResult> trs = s.getTaskResultsByTag(jobId, taskTag);
        StringBuffer buf = new StringBuffer();
        for (TaskResult tr : trs) {
            if (tr.getOutput() != null) {
                buf.append(tr.getOutput().getAllLogs(true));
            }
        }
        return buf.toString();
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (UnknownJobException e) {
        throw new UnknownJobRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) GZIP(org.jboss.resteasy.annotations.GZIP)

Example 58 with NotConnectedRestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.

the class SchedulerStateRest method disconnect.

/**
 * terminates the session id <code>sessionId</code>
 *
 * @param sessionId
 *            a valid session id
 * @throws NotConnectedRestException
 *             if the scheduler cannot be contacted
 * @throws PermissionRestException
 *             if you are not authorized to perform the action
 */
@Override
@PUT
@Path("disconnect")
@Produces("application/json")
public void disconnect(@HeaderParam("sessionid") final String sessionId) throws NotConnectedRestException, PermissionRestException {
    try {
        final Scheduler s = checkAccess(sessionId, "disconnect");
        logger.info("disconnection user " + sessionStore.get(sessionId) + " to session " + sessionId);
        s.disconnect();
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } finally {
        sessionStore.terminate(sessionId);
        logger.debug("sessionid " + sessionId + " terminated");
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 59 with NotConnectedRestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.

the class SessionSharingTest method sessions_are_shared_scheduler_login.

@Test
public void sessions_are_shared_scheduler_login() throws Exception {
    String sessionId = schedulerRest.login("login", "pw");
    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);
    when(schedulerMock.freeze()).thenReturn(true);
    boolean frozen = schedulerRest.freezeScheduler(sessionId);
    assertTrue(frozen);
    schedulerRest.disconnect(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)

Example 60 with NotConnectedRestException

use of org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException in project scheduling by ow2-proactive.

the class RestDataspaceImpl method create.

@POST
@Path("/{dataspace}/{path-name:.*}")
public Response create(@HeaderParam("sessionid") String sessionId, @PathParam("dataspace") String dataspacePath, @PathParam("path-name") String pathname, @FormParam("mimetype") String mimeType) throws NotConnectedRestException, PermissionRestException {
    Session session = checkSessionValidity(sessionId);
    try {
        checkPathParams(dataspacePath, pathname);
        FileObject fileObject = resolveFile(session, dataspacePath, pathname);
        if (mimeType.equals(org.ow2.proactive_grid_cloud_portal.common.FileType.FOLDER.getMimeType())) {
            logger.debug(String.format("Creating folder %s in %s", pathname, dataspacePath));
            fileObject.createFolder();
        } else if (mimeType.equals(org.ow2.proactive_grid_cloud_portal.common.FileType.FILE.getMimeType())) {
            logger.debug(String.format("Creating file %s in %s", pathname, dataspacePath));
            fileObject.createFile();
        } else {
            return serverErrorRes("Cannot create specified file since mimetype is not specified");
        }
        return Response.ok().build();
    } catch (FileSystemException e) {
        logger.error(String.format("Cannot create %s in %s", pathname, dataspacePath), e);
        throw rethrow(e);
    } catch (Throwable e) {
        logger.error(String.format("Cannot create %s in %s", pathname, dataspacePath), e);
        throw rethrow(e);
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) FileObject(org.apache.commons.vfs2.FileObject) Session(org.ow2.proactive_grid_cloud_portal.common.Session)

Aggregations

NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)53 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)42 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)40 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)40 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)38 Path (javax.ws.rs.Path)37 Produces (javax.ws.rs.Produces)35 GET (javax.ws.rs.GET)28 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)28 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)28 GZIP (org.jboss.resteasy.annotations.GZIP)17 ArrayList (java.util.ArrayList)13 JobState (org.ow2.proactive.scheduler.common.job.JobState)13 Session (org.ow2.proactive_grid_cloud_portal.common.Session)12 RestPage (org.ow2.proactive_grid_cloud_portal.scheduler.dto.RestPage)12 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)11 Response (javax.ws.rs.core.Response)10 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)10 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)10 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)10