Search in sources :

Example 6 with RMProxy

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.

the class RMTestUser method connect.

public void connect(TestUsers user, String rmUrl) throws RMException, KeyException, LoginException, ActiveObjectCreationException, NodeException {
    this.connectedUserName = user.username;
    this.connectedUserPassword = user.password;
    this.rmUrl = rmUrl;
    disconnectFromRM();
    if (rmProxy == null) {
        monitorsHandler = new RMMonitorsHandler();
        RMMonitorEventReceiver passiveEventReceiver = new RMMonitorEventReceiver(monitorsHandler);
        rmProxy = PAActiveObject.turnActive(passiveEventReceiver);
        RMTHelper.log("RM Proxy initialized : " + PAActiveObject.getUrl(rmProxy));
    }
    RMTHelper.log("Connecting user " + connectedUserName + " to the Resource Manager at " + rmUrl);
    CredData credData = new CredData(CredData.parseLogin(connectedUserName), CredData.parseDomain(connectedUserName), connectedUserPassword);
    // this is to prevent starting working with the rmProxy on the calling
    // thread whereas it has not finished to be initialized
    PAFuture.waitFor(rmProxy.init(rmUrl, credData));
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) RMMonitorEventReceiver(functionaltests.monitor.RMMonitorEventReceiver) RMMonitorsHandler(functionaltests.monitor.RMMonitorsHandler)

Example 7 with RMProxy

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.

the class TerminationDataTest method testHandleTerminationForTaskNormalTermination.

@Test
public void testHandleTerminationForTaskNormalTermination() throws RMProxyCreationException, IOException, ClassNotFoundException {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    JobId jobId = new JobIdImpl(666, "readableName");
    InternalTask internalTask = new InternalScriptTask(job);
    TaskId taskId = TaskIdImpl.createTaskId(jobId, "task-name", 777L);
    internalTask.setId(taskId);
    internalTask.setName("task-name");
    internalTask.setStatus(TaskStatus.RUNNING);
    internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
    RunningTaskData taskData = new RunningTaskData(internalTask, "user", null, launcher);
    terminationData.addTaskData(null, taskData, TerminationData.TerminationStatus.NORMAL, null);
    terminationData.handleTermination(service);
    Mockito.verify(proxiesManager, Mockito.times(1)).getUserRMProxy("user", null);
    Mockito.verify(rmProxy, Mockito.times(1)).releaseNodes(org.mockito.Matchers.any(NodeSet.class), org.mockito.Matchers.any(org.ow2.proactive.scripting.Script.class), Mockito.any(VariablesMap.class), Mockito.any(HashMap.class), Mockito.any(TaskId.class), Mockito.any(Credentials.class));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) NodeSet(org.ow2.proactive.utils.NodeSet) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) HashMap(java.util.HashMap) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Credentials(org.ow2.proactive.authentication.crypto.Credentials) Test(org.junit.Test)

Example 8 with RMProxy

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.

the class SchedulerStateRecoverHelper method recoverJobTasks.

private void recoverJobTasks(InternalJob job, List<InternalTask> tasks, RMProxy rmProxy, ExecutorService recoverRunningTasksThreadPool) {
    TaskStatusCounter counter = new TaskStatusCounter();
    for (InternalTask task : tasks) {
        // pending task
        if ((task.getStatus() == TaskStatus.RUNNING || task.getStatus() == TaskStatus.PAUSED) && task.getExecuterInformation() != null) {
            recoverRunningTaskAsynchronously(rmProxy, recoverRunningTasksThreadPool, counter, task);
        } else {
            recoverTaskOtherThanRunning(counter, task);
        }
        logger.debug("Task " + task.getId() + " status is " + task.getStatus().name());
    }
    this.jobsToUpdate.put(job.getId(), counter);
}
Also used : InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask)

Example 9 with RMProxy

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.

the class SchedulerStateRecoverHelper method recover.

public RecoveredSchedulerState recover(long loadJobPeriod, RMProxy rmProxy) {
    List<InternalJob> notFinishedJobs = dbManager.loadNotFinishedJobs(true);
    Vector<InternalJob> pendingJobs = new Vector<>();
    Vector<InternalJob> runningJobs = new Vector<>();
    ExecutorService recoverRunningTasksThreadPool = Executors.newFixedThreadPool(PASchedulerProperties.SCHEDULER_PARALLEL_SCHEDULER_STATE_RECOVER_NBTHREAD.getValueAsInt());
    for (InternalJob job : notFinishedJobs) {
        recoverJob(rmProxy, pendingJobs, runningJobs, job, recoverRunningTasksThreadPool);
    }
    recoverRunningTasksThreadPool.shutdown();
    boolean terminatedWithoutTimeout;
    try {
        terminatedWithoutTimeout = recoverRunningTasksThreadPool.awaitTermination(PASchedulerProperties.SCHEDULER_PARALLEL_SCHEDULER_STATE_RECOVER_TIMEOUT.getValueAsInt(), TimeUnit.MINUTES);
    } catch (InterruptedException e) {
        logger.error("Interrupted while waiting for the Scheduler state to be recovered", e);
        Thread.currentThread().interrupt();
        throw new SchedulerStateNotRecoveredException(e);
    }
    failIfSchedulerStateRecoveryTimeout(terminatedWithoutTimeout);
    applyJobUpdates(notFinishedJobs);
    Vector<InternalJob> finishedJobs = new Vector<>();
    for (Iterator<InternalJob> iterator = runningJobs.iterator(); iterator.hasNext(); ) {
        InternalJob job = iterator.next();
        try {
            List<InternalTask> tasksList = copyAndSort(job.getITasks());
            // simulate the running execution to recreate the tree.
            for (InternalTask task : tasksList) {
                job.recoverTask(task.getId());
            }
            if (job.getStatus() == JobStatus.PAUSED) {
                job.setStatus(JobStatus.STALLED);
                job.setPaused();
                // update the count of pending and running task.
                job.setNumberOfPendingTasks(job.getNumberOfPendingTasks() + job.getNumberOfRunningTasks());
                job.setNumberOfRunningTasks(0);
            }
        } catch (Exception e) {
            logger.error("Failed to recover job " + job.getId() + " " + job.getName() + " job might be in a inconsistent state", e);
            jobLogger.error(job.getId(), "Failed to recover job, job might be in an inconsistent state", e);
            // partially cancel job (not tasks) and move it to finished jobs to avoid running it
            iterator.remove();
            job.setStatus(JobStatus.CANCELED);
            finishedJobs.add(job);
            dbManager.updateJobAndTasksState(job);
        }
    }
    finishedJobs.addAll(dbManager.loadFinishedJobs(false, loadJobPeriod));
    logger.info("[Recovering counters] " + " Pending: " + pendingJobs.size() + " Running: " + runningJobs.size() + " Finished: " + finishedJobs.size());
    return new RecoveredSchedulerState(pendingJobs, runningJobs, finishedJobs);
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ExecutorService(java.util.concurrent.ExecutorService) Vector(java.util.Vector)

Example 10 with RMProxy

use of org.ow2.proactive.scheduler.core.rmproxies.RMProxy in project scheduling by ow2-proactive.

the class TestRMProxy method requestTooManyNodes.

private void requestTooManyNodes(RMProxy proxy, ResourceManager rm) throws Exception {
    log("Request more nodes than RM has");
    Criteria criteria = new Criteria(NODES_NUMBER + 1);
    criteria.setBestEffort(false);
    NodeSet nodeSet = proxy.getNodes(criteria);
    PAFuture.waitFor(nodeSet);
    assertEquals(0, nodeSet.size());
    assertEquals(NODES_NUMBER, rm.getState().getFreeNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria)

Aggregations

NodeSet (org.ow2.proactive.utils.NodeSet)9 Criteria (org.ow2.proactive.utils.Criteria)7 RMProxy (org.ow2.proactive.scheduler.core.rmproxies.RMProxy)4 Credentials (org.ow2.proactive.authentication.crypto.Credentials)3 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)3 ExecutorService (java.util.concurrent.ExecutorService)2 CredData (org.ow2.proactive.authentication.crypto.CredData)2 PerUserConnectionRMProxiesManager (org.ow2.proactive.scheduler.core.rmproxies.PerUserConnectionRMProxiesManager)2 RMProxiesManager (org.ow2.proactive.scheduler.core.rmproxies.RMProxiesManager)2 SingleConnectionRMProxiesManager (org.ow2.proactive.scheduler.core.rmproxies.SingleConnectionRMProxiesManager)2 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)2 RMMonitorEventReceiver (functionaltests.monitor.RMMonitorEventReceiver)1 RMMonitorsHandler (functionaltests.monitor.RMMonitorsHandler)1 URI (java.net.URI)1 KeyException (java.security.KeyException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Vector (java.util.Vector)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1