Search in sources :

Example 36 with NotConnectedException

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

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

the class AuthenticationTest method loginAsAdmin.

private void loginAsAdmin(SchedulerAuthenticationInterface auth, PublicKey pubKey) throws KeyException, LoginException, AlreadyConnectedException, NotConnectedException, PermissionException {
    log("Test 1");
    log("Trying to authorized as an admin with correct user name and password");
    Credentials cred = Credentials.createCredentials(new CredData(TestUsers.DEMO.username, TestUsers.DEMO.password), pubKey);
    Scheduler admin = auth.login(cred);
    String userName = admin.getCurrentUser();
    Assert.assertEquals(TestUsers.DEMO.username, userName);
    UserData userData = admin.getCurrentUserData();
    Assert.assertNotNull(userData);
    Assert.assertNotNull(userData.getUserName());
    Assert.assertNotNull(userData.getGroups());
    Assert.assertTrue(userData.getGroups().contains("scheduleradmins"));
    admin.disconnect();
    log("Passed: successful authentication");
}
Also used : UserData(org.ow2.proactive.authentication.UserData) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) CredData(org.ow2.proactive.authentication.crypto.CredData) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Example 38 with NotConnectedException

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

the class SchedulerUsageTest method fallbackToMyAccountUsage.

private void fallbackToMyAccountUsage(Scheduler scheduler) throws NotConnectedException, PermissionException {
    List<JobUsage> asAUser = scheduler.getMyAccountUsage(new Date(0), new Date(0));
    assertNotNull(asAUser);
    // fallback to my account usage
    List<JobUsage> forMyUser = scheduler.getAccountUsage(TestUsers.USER.username, new Date(0), new Date(0));
    assertNotNull(forMyUser);
    try {
        scheduler.getAccountUsage(TestUsers.DEMO.username, new Date(0), new Date(0));
        fail("Should throw permission exception");
    } catch (PermissionException e) {
    }
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) JobUsage(org.ow2.proactive.scheduler.common.usage.JobUsage) Date(java.util.Date)

Example 39 with NotConnectedException

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

the class AbstractSmartProxy method syncAwaitedJob.

/**
 * This method will synchronize this proxy with a remote Scheduler for the
 * given job
 *
 * @param id job ID
 */
private void syncAwaitedJob(String id) {
    AwaitedJob awaitedJob = jobTracker.getAwaitedJob(id);
    try {
        JobState js = getJobState(id);
        for (TaskState ts : js.getTasks()) {
            String tname = ts.getName();
            AwaitedTask at = awaitedJob.getAwaitedTask(tname);
            if ((at != null) && (!at.isTransferring())) {
                TaskResult tres = null;
                try {
                    tres = getTaskResult(id, tname);
                    if (tres != null) {
                        log.debug("Synchonizing task " + tname + " of job " + id);
                        taskStateUpdatedEvent(new NotificationData<>(SchedulerEvent.TASK_RUNNING_TO_FINISHED, ts.getTaskInfo()));
                    }
                } catch (NotConnectedException e) {
                    log.error("Scheduler connection error", e);
                } catch (UnknownJobException e) {
                    log.error("Could not retrieve output data for job " + id + " because this job is not known by the Scheduler. \n ", e);
                } catch (UnknownTaskException e) {
                    log.error("Could not retrieve output data for task " + tname + " of job " + id + " because this task is not known by the Scheduler. \n ", e);
                } catch (Exception e) {
                    log.error("Unexpected error while getting the output data for task " + tname + " of job " + id, e);
                }
            }
        }
        if (js.isFinished()) {
            jobStateUpdatedEvent(new NotificationData<>(SchedulerEvent.JOB_RUNNING_TO_FINISHED, js.getJobInfo()));
        }
    } catch (NotConnectedException e) {
        log.error("A connection error occured while trying to download output data of Job " + id + ". This job will remain in the list of awaited jobs. Another attempt to dowload the output data will be made next time the application is initialized. ", e);
    } catch (UnknownJobException e) {
        log.error("Could not retrieve output data for job " + id + " because this job is not known by the Scheduler. \n ", e);
        log.warn("Job  " + id + " will be removed from the known job list. The system will not attempt again to retrieve data for this job. You could try to manually copy the data from the location  " + awaitedJob.getPullURL());
        jobTracker.removeAwaitedJob(id);
    } catch (PermissionException e) {
        log.error("Could not retrieve output data for job " + id + " because you don't have permmission to access this job. You need to use the same connection credentials you used for submitting the job.  \n Another attempt to dowload the output data for this job will be made next time the application is initialized. ", e);
    }
}
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) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) LoginException(javax.security.auth.login.LoginException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) 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) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException)

Example 40 with NotConnectedException

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

the class RMRest method getSupportedNodeSourceInfrastructures.

@Override
public Collection<PluginDescriptorData> getSupportedNodeSourceInfrastructures(String sessionId) throws NotConnectedException, PermissionRestException {
    ResourceManager rm = checkAccess(sessionId);
    Collection<PluginDescriptor> pluginDescriptors = orThrowRpe(rm.getSupportedNodeSourceInfrastructures());
    return pluginDescriptors.stream().map(PluginDescriptorData::new).collect(Collectors.toList());
}
Also used : PluginDescriptor(org.ow2.proactive.resourcemanager.nodesource.common.PluginDescriptor) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager)

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