Search in sources :

Example 76 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class LiveJobs method finishInErrorTask.

TerminationData finishInErrorTask(JobId jobId, String taskName) throws UnknownTaskException, UnknownJobException {
    JobData jobData = lockJob(jobId);
    if (jobData == null) {
        throw new UnknownJobException(jobId);
    }
    InternalJob job = jobData.job;
    try {
        InternalTask task = job.getTask(taskName);
        if (task == null) {
            throw new UnknownTaskException(taskName);
        }
        TaskId taskId = task.getId();
        if (task.getStatus() != TaskStatus.IN_ERROR) {
            tlogger.info(task.getId(), "Task must be in state IN_ERROR: " + task.getStatus());
            return emptyResult(task.getId());
        }
        TaskResultImpl taskResult = taskResultCreator.getTaskResult(dbManager, job, task);
        RunningTaskData data = new RunningTaskData(task, job.getOwner(), job.getCredentials(), null);
        TerminationData terminationData = TerminationData.newTerminationData();
        terminationData.addTaskData(job, data, TerminationData.TerminationStatus.ABORTED, taskResult);
        tlogger.debug(taskId, "result added to job " + job.getId());
        // to be done before terminating the task, once terminated it is not
        // running anymore..
        ChangedTasksInfo changesInfo = job.finishInErrorTask(taskId, taskResult, listener);
        ((JobInfoImpl) job.getJobInfo()).setPreciousTasks(job.getPreciousTasksFinished());
        boolean jobFinished = job.isFinished();
        // update job info if it is terminated
        if (jobFinished) {
            // terminating job
            job.terminate();
            jlogger.debug(job.getId(), "terminated");
            jobs.remove(job.getId());
            terminationData.addJobToTerminate(job.getId(), job.getGenericInformation(), job.getCredentials());
        }
        task.setInErrorTime(-1);
        boolean jobUpdated = false;
        if (job.getNumberOfInErrorTasks() == 0) {
            job.setInErrorTime(-1);
            jobUpdated = true;
        }
        // Update database
        if (taskResult.getAction() != null) {
            dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, taskResult);
        } else {
            dbManager.updateAfterTaskFinished(job, task, taskResult);
        }
        // send event
        listener.taskStateUpdated(job.getOwner(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_IN_ERROR_TO_FINISHED, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
        // if this job is finished (every task have finished)
        jlogger.info(job.getId(), "finished tasks " + job.getNumberOfFinishedTasks() + ", total tasks " + job.getTotalNumberOfTasks() + ", finished " + jobFinished);
        if (jobFinished) {
            // send event to client
            listener.jobStateUpdated(job.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_RUNNING_TO_FINISHED, new JobInfoImpl((JobInfoImpl) job.getJobInfo())));
            listener.jobUpdatedFullData(job);
        } else if (jobUpdated) {
            listener.jobStateUpdated(job.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_UPDATED, new JobInfoImpl((JobInfoImpl) job.getJobInfo())));
            listener.jobUpdatedFullData(job);
        }
        return terminationData;
    } finally {
        jobData.unlock();
    }
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ChangedTasksInfo(org.ow2.proactive.scheduler.job.ChangedTasksInfo) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) NotificationData(org.ow2.proactive.scheduler.common.NotificationData)

Example 77 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class LiveJobs method terminateTask.

private void terminateTask(JobData jobData, InternalTask task, boolean errorOccurred, TaskResultImpl result, TerminationData terminationData) {
    InternalJob job = jobData.job;
    TaskId taskId = task.getId();
    tlogger.debug(taskId, "result added to job " + job.getId());
    // to be done before terminating the task, once terminated it is not
    // running anymore..
    job.getRunningTaskDescriptor(taskId);
    // merge task map result to job map result
    job.getResultMap().putAll(result.getResultMap());
    ChangedTasksInfo changesInfo = job.terminateTask(errorOccurred, taskId, listener, result.getAction(), result);
    ((JobInfoImpl) job.getJobInfo()).setPreciousTasks(job.getPreciousTasksFinished());
    boolean jobFinished = job.isFinished();
    // update job info if it is terminated
    if (jobFinished) {
        // terminating job
        job.terminate();
        // Cleaning job signals
        cleanJobSignals(job.getId());
        jlogger.debug(job.getId(), "terminated");
        terminationData.addJobToTerminate(job.getId(), job.getGenericInformation(), job.getCredentials());
        jobs.remove(job.getId());
    }
    task.setTaskResult(result);
    // Update database
    if (result.getAction() != null) {
        dbManager.updateAfterWorkflowTaskFinished(job, changesInfo, result);
    } else {
        dbManager.updateAfterTaskFinished(job, task, result);
    }
    // send event
    listener.taskStateUpdated(job.getOwner(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_RUNNING_TO_FINISHED, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
    // if this job is finished (every task have finished)
    jlogger.info(job.getId(), "finished tasks " + job.getNumberOfFinishedTasks() + ", total tasks " + job.getTotalNumberOfTasks() + ", finished " + jobFinished);
    if (jobFinished) {
        // send event to client
        listener.jobStateUpdated(job.getOwner(), new NotificationData<JobInfo>(SchedulerEvent.JOB_RUNNING_TO_FINISHED, new JobInfoImpl((JobInfoImpl) job.getJobInfo())));
        listener.jobUpdatedFullData(job);
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ChangedTasksInfo(org.ow2.proactive.scheduler.job.ChangedTasksInfo) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl)

Example 78 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class SchedulerFactory method createScheduler.

/**
 * Create a new scheduler on the local host plugged on the given resource manager.<br>
 * This constructor also requires the credentials of the client to connect.<br><br>
 * It will return a client scheduler able to managed the scheduler.<br><br>
 * <font color="red">WARNING :</font> this method provides a way to connect to the scheduler after its creation,
 * BUT if the scheduler is restarting after failure, this method will create the scheduler
 * but will throw a SchedulerException due to the failure of client connection.<br>
 * In fact, while the scheduler is restarting after a crash, no one can connect it during the whole restore process.<br><br>
 * In any other case, the method will block until connection is allowed or error occurred.
 *
 * @param rmURL the resource manager URL on which the scheduler will connect
 * @param policyFullClassName the full policy class name for the scheduler.
 * @return a scheduler interface to manage the scheduler.
 * @throws SchedulerException if the scheduler cannot be created.
 * @throws AdminSchedulerException if a client connection exception occurs.
 * @throws LoginException if a user login/password exception occurs.
 */
public static Scheduler createScheduler(Credentials creds, URI rmURL, String policyFullClassName) throws AdminSchedulerException, SchedulerException, LoginException {
    createScheduler(rmURL, policyFullClassName, SchedulerStatus.STARTED);
    SchedulerAuthenticationInterface auth = SchedulerConnection.waitAndJoin(null);
    return auth.login(creds);
}
Also used : SchedulerAuthenticationInterface(org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)

Example 79 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class SchedulerAuthentication method login.

/**
 * {@inheritDoc}
 */
public Scheduler login(Credentials cred) throws LoginException, AlreadyConnectedException {
    Subject subject = authenticate(cred);
    UserNamePrincipal unPrincipal = subject.getPrincipals(UserNamePrincipal.class).iterator().next();
    String user = unPrincipal.getName();
    logger.info("user : " + user);
    // add this user to the scheduler front-end
    UserIdentificationImpl ident = new UserIdentificationImpl(user, subject);
    ident.setHostName(getSenderHostName());
    this.frontend.connect(PAActiveObject.getContext().getCurrentRequest().getSourceBodyID(), ident, cred);
    try {
        // return the stub on Scheduler interface to keep avoid using server class on client side
        return PAActiveObject.lookupActive(Scheduler.class, PAActiveObject.getUrl(frontend));
    } catch (ActiveObjectCreationException e) {
        rethrowSchedulerStubException(e);
    } catch (IOException e) {
        rethrowSchedulerStubException(e);
    }
    return null;
}
Also used : UserNamePrincipal(org.ow2.proactive.authentication.principals.UserNamePrincipal) IOException(java.io.IOException) Subject(javax.security.auth.Subject) UserIdentificationImpl(org.ow2.proactive.scheduler.job.UserIdentificationImpl) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException)

Example 80 with Client

use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.

the class RMRestClient method createRestProxy.

private static RMRestInterface createRestProxy(ResteasyProviderFactory provider, String restEndpointURL, ClientHttpEngine httpEngine) {
    ResteasyClient client = buildResteasyClient(provider);
    ResteasyWebTarget target = client.target(restEndpointURL);
    RMRestInterface rmRestInterface = target.proxy(RMRestInterface.class);
    return createExceptionProxy(rmRestInterface);
}
Also used : ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) RMRestInterface(org.ow2.proactive_grid_cloud_portal.common.RMRestInterface)

Aggregations

Test (org.junit.Test)69 ISchedulerClient (org.ow2.proactive.scheduler.rest.ISchedulerClient)36 Client (org.ow2.proactive.resourcemanager.authentication.Client)31 JobId (org.ow2.proactive.scheduler.common.job.JobId)30 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)28 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)25 SimpleJob (functionaltests.jobs.SimpleJob)25 Job (org.ow2.proactive.scheduler.common.job.Job)25 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)18 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)18 ListFile (org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile)18 File (java.io.File)17 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)13 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)13 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)11 Node (org.objectweb.proactive.core.node.Node)9 IOException (java.io.IOException)8 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)8 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)8 NodeSet (org.ow2.proactive.utils.NodeSet)7