Package org.rhq.enterprise.server.scheduler

Examples of org.rhq.enterprise.server.scheduler.SchedulerLocal


        RepoSyncJob.createJobDataMap(jobDetail, repo);

        SimpleTrigger trigger = new SimpleTrigger(jobDetail.getName(), jobDetail.getGroup());
        trigger.setVolatility(false);

        SchedulerLocal scheduler = LookupUtil.getSchedulerBean();

        boolean cancelled = scheduler.interrupt(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME);

        getLog().info("Cancelled repo sync job [" + jobDetail.getName() + ':' + jobDetail.getGroup() + "].");
    }
View Full Code Here


        if ((syncSchedule == null) || (syncSchedule.trim().length() == 0)) {
            getLog().debug(contentSource.toString() + " does not define a sync schedule - not scheduling.");
            return;
        }

        SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
        scheduler.scheduleCronJob(ContentProviderSyncJob.createJobName(contentSource), CONTENT_SRC_SYNC_JOB_GROUP_NAME,
            ContentProviderSyncJob.createJobDataMap(contentSource, null), ContentProviderSyncJob.class, true, false,
            syncSchedule);
    }
View Full Code Here

        if ((syncSchedule == null) || (syncSchedule.trim().length() == 0)) {
            getLog().warn(repo.toString() + " does not define a sync schedule - not scheduling.");
            return;
        }

        SchedulerLocal scheduler = LookupUtil.getSchedulerBean();

        scheduler.scheduleCronJob(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME, RepoSyncJob
            .createJobDataMap(null, repo), RepoSyncJob.class, true, false, syncSchedule);
    }
View Full Code Here

     * @param  contentSource cannot be <code>null</code>
     *
     * @throws SchedulerException if failed to unschedule the job
     */
    public void unscheduleProviderSyncJob(ContentSource contentSource) throws SchedulerException {
        SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
        scheduler.deleteJob(ContentProviderSyncJob.createJobName(contentSource), CONTENT_SRC_SYNC_JOB_GROUP_NAME);
    }
View Full Code Here

     * @param  repo cannot be <code>null</code>
     *
     * @throws SchedulerException if failed to unschedule the job
     */
    public void unscheduleRepoSyncJob(Repo repo) throws SchedulerException {
        SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
        scheduler.deleteJob(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME);
    }
View Full Code Here

    }

    private void unscheduleJob(JobDataMap jobDataMap) {
        final String triggerName = (String) jobDataMap.get(KEY_TRIGGER_NAME);
        final String triggerGroupName = (String) jobDataMap.get(KEY_TRIGGER_GROUP_NAME);
        SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
        try {
            scheduler.unscheduleJob(triggerName, triggerGroupName);
        } catch (SchedulerException e) {
            log.error("Failed to unschedule Quartz trigger [" + triggerName + "].", e);
        }
    }
View Full Code Here

    }

    private void triggerDataPurgeJobNow() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);

        SchedulerLocal schedulerBean = LookupUtil.getSchedulerBean();
        schedulerBean.scheduleSimpleCronJob(DataPurgeJob.class, true, false, "0 0 0 1 1 ? 2099", null);

        schedulerBean.addGlobalJobListener(new JobListener() {
            @Override
            public String getName() {
                return "DataPurgeJobTestListener";
            }

            @Override
            public void jobExecutionVetoed(JobExecutionContext arg0) {
            }

            @Override
            public void jobToBeExecuted(JobExecutionContext arg0) {
            }

            @Override
            public void jobWasExecuted(JobExecutionContext c, JobExecutionException e) {
                if (c.getJobDetail().getJobClass().getName().equals(DataPurgeJob.class.getName())) {
                    latch.countDown(); // the data purge job is finished! let our test continue
                }
            }
        });

        try {
            // trigger the data purge job so it executes immediately - this does not block
            DataPurgeJob.purgeNow();

            // wait for the job to finish - abort the test if it takes too long
            assertTrue("Data purge job didn't complete in a timely fashion", latch.await(60, TimeUnit.SECONDS));
        } finally {
            schedulerBean.deleteJob(DataPurgeJob.class.getName(), DataPurgeJob.class.getName());
        }
    }
View Full Code Here

    }

    private void triggerDataCalcJobNow() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);

        SchedulerLocal schedulerBean = LookupUtil.getSchedulerBean();
        schedulerBean.scheduleSimpleCronJob(DataCalcJob.class, true, false, "0 0 0 1 1 ? 2099", null);

        schedulerBean.addGlobalJobListener(new JobListener() {
            @Override
            public String getName() {
                return "DataCalcJobTestListener";
            }

            @Override
            public void jobExecutionVetoed(JobExecutionContext arg0) {
            }

            @Override
            public void jobToBeExecuted(JobExecutionContext arg0) {
            }

            @Override
            public void jobWasExecuted(JobExecutionContext c, JobExecutionException e) {
                if (c.getJobDetail().getJobClass().getName().equals(DataCalcJob.class.getName())) {
                    latch.countDown(); // the data calc job is finished! let our test continue
                }
            }
        });

        try {
            // trigger the data calc job so it executes immediately - this does not block
            DataCalcJob.calcNow();

            // wait for the job to finish - abort the test if it takes too long
            assertTrue("Data calc job didn't complete in a timely fashion", latch.await(60, TimeUnit.SECONDS));
        } finally {
            schedulerBean.deleteJob(DataCalcJob.class.getName(), DataCalcJob.class.getName());
        }

    }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.scheduler.SchedulerLocal

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.