Search in sources :

Example 1 with UserIdentification

use of org.ow2.proactive.scheduler.common.job.UserIdentification in project scheduling by ow2-proactive.

the class SchedulerFrontendState method jobSubmitted.

synchronized void jobSubmitted(InternalJob job, UserIdentificationImpl ident) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
    // put the job inside the frontend management list
    jobs.put(job.getId(), new IdentifiedJob(job.getId(), ident, job.getGenericInformation()));
    // increase number of submit for this user
    ident.addSubmit();
    // send update user event
    usersUpdated(new NotificationData<UserIdentification>(SchedulerEvent.USERS_UPDATE, ident));
    jlogger.info(job.getId(), "submitted: name '" + job.getName() + "', tasks '" + job.getTotalNumberOfTasks() + "', owner '" + job.getOwner() + "'");
    try {
        jlogger.info(job.getId(), job.display());
    } catch (Exception e) {
        jlogger.error(job.getId(), "Error while displaying the job :", e);
    }
}
Also used : IdentifiedJob(org.ow2.proactive.scheduler.job.IdentifiedJob) UserIdentification(org.ow2.proactive.scheduler.common.job.UserIdentification) 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) AlreadyConnectedException(org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException)

Example 2 with UserIdentification

use of org.ow2.proactive.scheduler.common.job.UserIdentification in project scheduling by ow2-proactive.

the class SchedulerClientTest method testJobSubmissionEventListener.

@Test(timeout = MAX_WAIT_TIME * 2)
public void testJobSubmissionEventListener() throws Exception {
    ISchedulerClient client = clientInstance();
    SchedulerEventListenerImpl listener = new SchedulerEventListenerImpl();
    client.addEventListener(listener, true, SchedulerEvent.JOB_SUBMITTED, SchedulerEvent.USERS_UPDATE);
    Job job = defaultJob();
    Map<String, JobVariable> jobVariables = new LinkedHashMap<>();
    jobVariables.put("MY_VAR", new JobVariable("MY_VAR", "MY_VALUE", "PA:NOT_EMPTY_STRING", "a test variable", "MY_GROUP", true, true));
    job.setVariables(jobVariables);
    JobId jobId = client.submit(job);
    JobState submittedJob = listener.getSubmittedJob();
    while (!submittedJob.getId().value().equals(jobId.value())) {
        submittedJob = listener.getSubmittedJob();
    }
    UserIdentification userIdentification = listener.getLastUserUpdate();
    assertTrue(userIdentification.getLastSubmitTime() != -1);
    JobInfo jobInfo = client.getJobInfo(jobId.toString());
    System.out.println("Variables = " + jobInfo.getVariables());
    Map<String, JobVariable> stateJobVariables = jobInfo.getDetailedVariables();
    assertEquals(jobVariables, stateJobVariables);
    client.removeEventListener();
    client.waitForJob(jobId, TimeUnit.SECONDS.toMillis(120));
}
Also used : JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) UserIdentification(org.ow2.proactive.scheduler.common.job.UserIdentification) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 3 with UserIdentification

use of org.ow2.proactive.scheduler.common.job.UserIdentification in project scheduling by ow2-proactive.

the class SchedulerFrontendState method recover.

/**
 * Called to recover the front end state. This method may have to rebuild
 * the different list of userIdentification and job/user association.
 */
private void recover(SchedulerStateImpl sState) {
    Vector<ClientJobState> pendingJobs = sState.getPendingJobs();
    Vector<ClientJobState> runningJobs = sState.getRunningJobs();
    Vector<ClientJobState> finishedJobs = sState.getFinishedJobs();
    // default state = started
    Set<JobState> jobStates = new HashSet<>(pendingJobs.size() + runningJobs.size() + finishedJobs.size());
    if (logger.isInfoEnabled()) {
        logger.info("#Pending jobs: " + pendingJobs.size() + " #Running jobs: " + runningJobs.size() + " #Finished jobs: " + finishedJobs.size());
    }
    for (ClientJobState js : pendingJobs) {
        prepare(jobStates, js, false);
    }
    for (ClientJobState js : runningJobs) {
        prepare(jobStates, js, false);
    }
    for (ClientJobState js : finishedJobs) {
        prepare(jobStates, js, true);
    }
}
Also used : ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState)

Example 4 with UserIdentification

use of org.ow2.proactive.scheduler.common.job.UserIdentification in project scheduling by ow2-proactive.

the class SchedulerEventBroadcaster method usersUpdatedEvent.

@Override
public void usersUpdatedEvent(NotificationData<UserIdentification> notification) {
    logEvent(notification);
    broadcast(new EventNotification(EventNotification.Action.USERS_UPDATED, eventTypeName(notification), notification.getData()));
}
Also used : EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification)

Example 5 with UserIdentification

use of org.ow2.proactive.scheduler.common.job.UserIdentification in project scheduling by ow2-proactive.

the class RestSmartProxyTest method testInErrorEventsReception.

@Test(timeout = TEN_MINUTES)
public void testInErrorEventsReception() throws Exception {
    System.out.println("Begin testInErrorEventsReception ");
    TaskFlowJob job = createInErrorJob();
    final Semaphore semaphore = new Semaphore(0);
    printJobXmlRepresentation(job);
    final MutableBoolean taskHasBeenInError = new MutableBoolean(false);
    final MutableBoolean taskMarkedAsFinished = new MutableBoolean(false);
    SchedulerEventListenerExtended listener = new SchedulerEventListenerExtended() {

        @Override
        public void schedulerStateUpdatedEvent(SchedulerEvent eventType) {
            System.out.println("RestSmartProxyTest.schedulerStateUpdatedEvent " + eventType);
        }

        @Override
        public void jobSubmittedEvent(JobState job) {
            System.out.println("RestSmartProxyTest.jobSubmittedEvent");
        }

        @Override
        public void jobStateUpdatedEvent(NotificationData<JobInfo> notification) {
            JobStatus status = notification.getData().getStatus();
            System.out.println("RestSmartProxyTest.jobStateUpdatedEvent, eventType=" + notification.getEventType() + ", jobStatus=" + status);
            if (status == JobStatus.IN_ERROR) {
                semaphore.release();
            }
        }

        @Override
        public void taskStateUpdatedEvent(NotificationData<TaskInfo> notification) {
            TaskStatus status = notification.getData().getStatus();
            System.out.println("RestSmartProxyTest.taskStateUpdatedEvent, taskStatus=" + status);
            if (status == TaskStatus.WAITING_ON_ERROR || status == TaskStatus.IN_ERROR) {
                // IN_ERROR previously
                taskHasBeenInError.setTrue();
            }
            if (status == TaskStatus.FINISHED && taskHasBeenInError.isTrue()) {
                taskMarkedAsFinished.setTrue();
            }
        }

        @Override
        public void usersUpdatedEvent(NotificationData<UserIdentification> notification) {
            System.out.println("RestSmartProxyTest.usersUpdatedEvent " + notification.getData());
        }

        @Override
        public void pullDataFinished(String jobId, String taskName, String localFolderPath) {
            System.out.println("RestSmartProxyTest.pullDataFinished");
        }

        @Override
        public void pullDataFailed(String jobId, String taskName, String remoteFolder_URL, Throwable t) {
            System.out.println("RestSmartProxyTest.pullDataFailed");
        }

        @Override
        public void jobUpdatedFullDataEvent(JobState job) {
            System.out.println("RestSmartProxyTest.jobUpdatedFullDataEvent");
        }
    };
    restSmartProxy.addEventListener(listener);
    JobId jobId = restSmartProxy.submit(job, inputLocalFolder.getAbsolutePath(), outputLocalFolder.getAbsolutePath(), false, false);
    // the next line blocks until jobStateUpdatedEvent is called on the
    // listener
    // with job status set to IN_ERROR
    semaphore.acquire();
    String jobIdAsString = jobId.value();
    System.out.println("Finish in-error task");
    restSmartProxy.finishInErrorTask(jobIdAsString, inerrorTaskName);
    waitForJobFinishState(jobIdAsString);
    assertThat(taskHasBeenInError.booleanValue()).isTrue();
    assertThat(taskMarkedAsFinished.booleanValue()).isTrue();
    System.out.println("End testInErrorEventsReception");
}
Also used : JobStatus(org.ow2.proactive.scheduler.common.job.JobStatus) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) JobState(org.ow2.proactive.scheduler.common.job.JobState) SchedulerEventListenerExtended(org.ow2.proactive.scheduler.smartproxy.common.SchedulerEventListenerExtended) Semaphore(java.util.concurrent.Semaphore) TaskStatus(org.ow2.proactive.scheduler.common.task.TaskStatus) JobId(org.ow2.proactive.scheduler.common.job.JobId) SchedulerEvent(org.ow2.proactive.scheduler.common.SchedulerEvent) NotificationData(org.ow2.proactive.scheduler.common.NotificationData) Test(org.junit.Test)

Aggregations

JobState (org.ow2.proactive.scheduler.common.job.JobState)3 Test (org.junit.Test)2 JobId (org.ow2.proactive.scheduler.common.job.JobId)2 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)2 UserIdentification (org.ow2.proactive.scheduler.common.job.UserIdentification)2 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)1 SimpleJob (functionaltests.jobs.SimpleJob)1 IOException (java.io.IOException)1 Semaphore (java.util.concurrent.Semaphore)1 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)1 NotificationData (org.ow2.proactive.scheduler.common.NotificationData)1 SchedulerEvent (org.ow2.proactive.scheduler.common.SchedulerEvent)1 AlreadyConnectedException (org.ow2.proactive.scheduler.common.exception.AlreadyConnectedException)1 JobAlreadyFinishedException (org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException)1 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)1 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)1 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)1 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)1 SubmissionClosedException (org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)1 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)1