Package org.qzerver.model.domain.entities.job

Examples of org.qzerver.model.domain.entities.job.ScheduleExecution


        startExecutionParameters.setManual(false);
        startExecutionParameters.setFired(ChronometerUtils.parseMoment("2012-01-02 12:32:12.000 UTC"));
        startExecutionParameters.setScheduled(ChronometerUtils.parseMoment("2012-01-02 12:32:12.000 UTC"));
        startExecutionParameters.setComment("Test comment");

        ScheduleExecution scheduleExecution1 =
            scheduleExecutionManagementService.startExecution(scheduleJob.getId(), startExecutionParameters);

        scheduleExecutionManagementService.finishExecution(
            scheduleExecution1.getId(), ScheduleExecutionStatus.SUCCEED);

        // Execution 2 - non-finished

        startExecutionParameters.setManual(false);
        startExecutionParameters.setFired(ChronometerUtils.parseMoment("2012-01-02 12:32:13.000 UTC"));
        startExecutionParameters.setScheduled(ChronometerUtils.parseMoment("2012-01-02 12:33:12.000 UTC"));
        startExecutionParameters.setComment("Test comment");

        ScheduleExecution scheduleExecution2 =
            scheduleExecutionManagementService.startExecution(scheduleJob.getId(), startExecutionParameters);

        // Check

        List<ScheduleExecution> scheduleExecutions = scheduleExecutionManagementService.findEngaged(Extraction.ALL);
View Full Code Here


        jobParameters.setActionDefinition("action.data".getBytes());

        ScheduleJob scheduleJob = scheduleJobManagementService.createJob(jobParameters);
        Assert.assertNotNull(scheduleJob);

        ScheduleExecution scheduleExecution = new ScheduleExecution();
        scheduleExecution.setJob(scheduleJob);
        scheduleExecution.setAction(scheduleJob.getAction());
        scheduleExecution.setCron(scheduleJob.getCron());
        scheduleExecution.setName(scheduleJob.getName());
        scheduleExecution.setStrategy(scheduleJob.getStrategy());
        scheduleExecution.setTimeout(scheduleJob.getTimeout());
        scheduleExecution.setAllNodes(scheduleJob.isAllNodes());
        scheduleExecution.setScheduled(chronometer.getCurrentMoment());
        scheduleExecution.setFired(chronometer.getCurrentMoment());
        scheduleExecution.setForced(false);
        scheduleExecution.setDescription("Test execution");
        scheduleExecution.setStatus(ScheduleExecutionStatus.INPROGRESS);
        scheduleExecution.setStarted(chronometer.getCurrentMoment());
        scheduleExecution.setFinished(null);
        scheduleExecution.setHostname("localhost");
        businessEntityDao.save(scheduleExecution);

        scheduleJobManagementService.deleteJob(scheduleJob.getId());

        control.verify();

        Assert.assertEquals(scheduleJob.getId(), idCapture1.getValue());
        Assert.assertEquals(scheduleJob.getId(), idCapture2.getValue());

        ScheduleAction action = scheduleJob.getAction();
        Assert.assertNotNull(action);

        entityManager.flush();
        entityManager.clear();

        scheduleExecution = businessEntityDao.findById(ScheduleExecution.class, scheduleExecution.getId());
        Assert.assertNotNull(scheduleExecution);
        Assert.assertNotNull(scheduleExecution.getAction());
        Assert.assertNull(scheduleExecution.getJob());
    }
View Full Code Here

        StartExecutionParameters startExecutionParameters = new StartExecutionParameters();
        startExecutionParameters.setManual(false);
        startExecutionParameters.setFired(ChronometerUtils.parseMoment("2012-01-02 12:32:12.000 UTC"));
        startExecutionParameters.setScheduled(ChronometerUtils.parseMoment("2012-01-02 12:32:12.000 UTC"));

        ScheduleExecution scheduleExecution =
            scheduleExecutionManagementService.startExecution(scheduleJob.getId(), startExecutionParameters);
        Assert.assertNotNull(scheduleExecution);
        Assert.assertNull(scheduleExecution.getFinished());

        entityManager.flush();
        entityManager.clear();

        ScheduleExecution scheduleExecutionModified =
            scheduleExecutionManagementService.findExecution(scheduleExecution.getId());
        Assert.assertNotNull(scheduleExecutionModified);
        Assert.assertEquals(scheduleExecution, scheduleExecutionModified);
        Assert.assertEquals(ScheduleExecutionStatus.INPROGRESS, scheduleExecutionModified.getStatus());
        Assert.assertEquals(3, scheduleExecutionModified.getNodes().size());

        ScheduleExecutionNode scheduleExecutionNode1 = scheduleExecutionModified.getNodes().get(0);
        Assert.assertNotNull(scheduleExecutionNode1);
        Assert.assertEquals(0, scheduleExecutionNode1.getOrderIndex());
        Assert.assertEquals(clusterNode2.getAddress(), scheduleExecutionNode1.getAddress());

        ScheduleExecutionNode scheduleExecutionNode2 = scheduleExecutionModified.getNodes().get(1);
        Assert.assertNotNull(scheduleExecutionNode2);
        Assert.assertEquals(1, scheduleExecutionNode2.getOrderIndex());
        Assert.assertEquals(clusterNode3.getAddress(), scheduleExecutionNode2.getAddress());

        ScheduleExecutionNode scheduleExecutionNode3 = scheduleExecutionModified.getNodes().get(2);
        Assert.assertNotNull(scheduleExecutionNode3);
        Assert.assertEquals(2, scheduleExecutionNode3.getOrderIndex());
        Assert.assertEquals(clusterNode1.getAddress(), scheduleExecutionNode3.getAddress());

        // Search all executions

        List<ScheduleExecution> scheduleExecutions = scheduleExecutionManagementService.findAll(Extraction.ALL);
        Assert.assertNotNull(scheduleExecutions);
        Assert.assertTrue(scheduleExecutions.size() > 0);
        Assert.assertTrue(Iterators.contains(scheduleExecutions.iterator(), scheduleExecution));

        // Make some progress

        ScheduleExecutionResult scheduleExecutionResult;

        scheduleExecutionResult = scheduleExecutionManagementService.startExecutionResult(scheduleExecutionNode1.getId());
        Assert.assertNotNull(scheduleExecutionResult);

        scheduleExecutionResult = scheduleExecutionManagementService.finishExecutionResult(scheduleExecutionResult.getId(),
            true, null);
        Assert.assertNotNull(scheduleExecutionResult);

        scheduleExecutionResult = scheduleExecutionManagementService.startExecutionResult(scheduleExecutionNode2.getId());
        Assert.assertNotNull(scheduleExecutionResult);

        scheduleExecutionResult = scheduleExecutionManagementService.finishExecutionResult(scheduleExecutionResult.getId(),
            true, null);
        Assert.assertNotNull(scheduleExecutionResult);

        scheduleExecutionResult = scheduleExecutionManagementService.startExecutionResult(scheduleExecutionNode3.getId());
        Assert.assertNotNull(scheduleExecutionResult);

        scheduleExecutionResult = scheduleExecutionManagementService.finishExecutionResult(scheduleExecutionResult.getId(),
            false, null);
        Assert.assertNotNull(scheduleExecutionResult);

        entityManager.flush();
        entityManager.clear();

        scheduleExecutionModified =
            scheduleExecutionManagementService.findExecution(scheduleExecution.getId());
        Assert.assertNotNull(scheduleExecutionModified);
        Assert.assertEquals(scheduleExecution, scheduleExecutionModified);
        Assert.assertEquals(3, scheduleExecutionModified.getResults().size());

        scheduleExecutionResult = scheduleExecutionModified.getResults().get(0);
        Assert.assertNotNull(scheduleExecutionResult);
        Assert.assertEquals(0, scheduleExecutionResult.getOrderIndex());
        Assert.assertTrue(scheduleExecutionResult.isSucceed());

        scheduleExecutionResult = scheduleExecutionModified.getResults().get(1);
        Assert.assertNotNull(scheduleExecutionResult);
        Assert.assertEquals(1, scheduleExecutionResult.getOrderIndex());
        Assert.assertTrue(scheduleExecutionResult.isSucceed());

        scheduleExecutionResult = scheduleExecutionModified.getResults().get(2);
        Assert.assertEquals(2, scheduleExecutionResult.getOrderIndex());
        Assert.assertNotNull(scheduleExecutionResult);
        Assert.assertFalse(scheduleExecutionResult.isSucceed());

        // Finish execution

        scheduleExecutionModified = scheduleExecutionManagementService.finishExecution(
            scheduleExecution.getId(), ScheduleExecutionStatus.SUCCEED);
        Assert.assertNotNull(scheduleExecutionModified);
        Assert.assertNotNull(scheduleExecutionModified.getFinished());

        entityManager.flush();
        entityManager.clear();

        scheduleExecutionModified =
View Full Code Here

        scheduleJob.setAction(scheduleAction);
        scheduleJob.setGroup(scheduleGroup);
        scheduleGroup.getJobs().add(scheduleJob);
        businessEntityDao.save(scheduleJob);

        ScheduleExecution scheduleExecution = new ScheduleExecution();
        scheduleExecution.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        scheduleExecution.setName("rgwrgr");
        scheduleExecution.setCron("0 * * * * ?");
        scheduleExecution.setForced(true);
        scheduleExecution.setHostname("rgwrgwr");
        scheduleExecution.setFired(ChronometerUtils.parseMoment("2011-01-01 12:00:01.000 UTC"));
        scheduleExecution.setScheduled(ChronometerUtils.parseMoment("2011-01-01 12:00:00.000 UTC"));
        scheduleExecution.setStarted(ChronometerUtils.parseMoment("2011-01-01 12:00:02.000 UTC"));
        scheduleExecution.setFinished(ChronometerUtils.parseMoment("2011-01-01 12:00:03.000 UTC"));
        scheduleExecution.setStatus(ScheduleExecutionStatus.SUCCEED);
        scheduleExecution.setAllNodes(true);
        scheduleExecution.setCancelled(false);
        scheduleExecution.setAction(scheduleAction);
        scheduleExecution.setJob(scheduleJob);

        BusinessEntityJpaDaoChecker.checkBusinessEntityDao(entityManager, businessEntityDao,
                ScheduleExecution.class, scheduleExecution);
    }
View Full Code Here

        ScheduleAction scheduleAction = scheduleJob.getAction();
        scheduleAction.setUsedDate(now);
        scheduleAction.incrementUsedCount();

        // Create new execution
        ScheduleExecution scheduleExecution = new ScheduleExecution();
        scheduleExecution.setJob(scheduleJob);
        scheduleExecution.setAction(scheduleAction);
        scheduleExecution.setCron(scheduleJob.getCron());
        scheduleExecution.setName(scheduleJob.getName());
        scheduleExecution.setStrategy(scheduleJob.getStrategy());
        scheduleExecution.setTimeout(scheduleJob.getTimeout());
        scheduleExecution.setAllNodes(scheduleJob.isAllNodes());
        scheduleExecution.setAllNodesPool(scheduleJob.getAllNodesPool());
        scheduleExecution.setScheduled(parameters.getScheduled());
        scheduleExecution.setFired(parameters.getFired());
        scheduleExecution.setForced(parameters.isManual());
        scheduleExecution.setDescription(parameters.getComment());
        scheduleExecution.setStatus(ScheduleExecutionStatus.INPROGRESS);
        scheduleExecution.setStarted(now);
        scheduleExecution.setFinished(null);

        String hostName = StringUtils.left(node, ScheduleExecution.MAX_NODE_LENGTH);
        scheduleExecution.setHostname(hostName);

        List<ScheduleExecutionNode> nodes = selectExecutionNodes(scheduleJob, parameters);
        for (ScheduleExecutionNode node : nodes) {
            node.setExecution(scheduleExecution);
            scheduleExecution.getNodes().add(node);
        }

        businessEntityDao.save(scheduleExecution);

        return scheduleExecution;
View Full Code Here

        ScheduleExecutionNode node = businessEntityDao.findById(ScheduleExecutionNode.class, scheduleExecutionNodeId);
        if (node == null) {
            throw new MissingEntityException(ScheduleExecutionNode.class, scheduleExecutionNodeId);
        }

        ScheduleExecution scheduleExecution = node.getExecution();

        if (scheduleExecution.getFinished() != null) {
            throw new ExecutionAlreadyFinishedException(scheduleExecution.getId());
        }

        businessEntityDao.lock(scheduleExecution);

        ScheduleExecutionResult result = new ScheduleExecutionResult();
        result.setOrderIndex(node.getOrderIndex());
        result.setStarted(chronometer.getCurrentMoment());
        result.setFinished(null);
        result.setSucceed(false);

        result.setNode(node);
        node.setResult(result);

        result.setExecution(scheduleExecution);
        scheduleExecution.getResults().add(result);

        businessEntityDao.save(result);

        return result;
    }
View Full Code Here

    public ScheduleExecution finishExecution(long scheduleExecutionId, ScheduleExecutionStatus status)
        throws AbstractServiceException
    {
        Preconditions.checkNotNull(status);

        ScheduleExecution scheduleExecution = businessEntityDao.lockById(ScheduleExecution.class, scheduleExecutionId);
        if (scheduleExecution == null) {
            throw new MissingEntityException(ScheduleExecution.class, scheduleExecutionId);
        }

        if (scheduleExecution.getFinished() != null) {
            throw new ExecutionAlreadyFinishedException(scheduleExecution.getId());
        }

        scheduleExecution.setFinished(chronometer.getCurrentMoment());
        scheduleExecution.setStatus(status);
        scheduleExecution.setCancelled(false);

        Hibernate.initialize(scheduleExecution.getResults());
        Hibernate.initialize(scheduleExecution.getNodes());
        Hibernate.initialize(scheduleExecution.getJob());
        Hibernate.initialize(scheduleExecution.getAction());

        return scheduleExecution;
    }
View Full Code Here

    }

    @Override
    @Transactional(readOnly = true)
    public ScheduleExecution findExecution(long scheduleExecutionId) {
        ScheduleExecution scheduleExecution = businessEntityDao.findById(ScheduleExecution.class, scheduleExecutionId);

        Hibernate.initialize(scheduleExecution.getResults());
        Hibernate.initialize(scheduleExecution.getNodes());
        Hibernate.initialize(scheduleExecution.getAction());

        return scheduleExecution;
    }
View Full Code Here

        return scheduleExecution;
    }

    @Override
    public ScheduleExecution cancelExecution(long scheduleExecutionId) throws AbstractServiceException {
        ScheduleExecution scheduleExecution = businessEntityDao.lockById(ScheduleExecution.class, scheduleExecutionId);
        if (scheduleExecution == null) {
            throw new MissingEntityException(ScheduleExecution.class, scheduleExecutionId);
        }

        if (scheduleExecution.getFinished() != null) {
            throw new ExecutionAlreadyFinishedException(scheduleExecutionId);
        }

        scheduleExecution.setCancelled(true);

        return scheduleExecution;
    }
View Full Code Here

        executionParameters.setFired(parameters.getFiredTime());
        executionParameters.setManual(false);
        executionParameters.setComment(null);
        executionParameters.setAddresses(null);

        ScheduleExecution scheduleExecution = executeJob(scheduleJobId, executionParameters);

        if (scheduleExecution.getStatus() != ScheduleExecutionStatus.SUCCEED) {
            ScheduleJob scheduleJob = scheduleExecution.getJob();
            if (scheduleJob.isNotifyOnFailure()) {
                mailService.notifyJobExecutionFailed(scheduleExecution);
            }
        }
View Full Code Here

TOP

Related Classes of org.qzerver.model.domain.entities.job.ScheduleExecution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.