Examples of ScheduleOptions


Examples of org.apache.karaf.scheduler.ScheduleOptions

    @Override
    public Object execute() throws Exception {
        if (cron != null && (at != null || times != -1 || period != 0)) {
            throw new IllegalArgumentException("Both cron expression and explicit execution time can not be specified");
        }
        ScheduleOptions options;
        if (cron != null) {
            options = scheduler.EXPR(cron);
        } else {
            Date date;
            if (at != null) {
                date = DatatypeConverter.parseDateTime(at).getTime();
            } else {
                date = new Date();
            }
            if (period > 0) {
                options = scheduler.AT(date, times, period);
            } else {
                options = scheduler.AT(date);
            }
        }
        if (name != null) {
            options.name(name);
        }
        if (concurrent) {
            options.canRunConcurrently(concurrent);
        }
        scheduler.schedule(new ScriptJob(session, script), options);
        return null;
    }
View Full Code Here

Examples of org.apache.karaf.scheduler.ScheduleOptions

        org.quartz.Scheduler s = this.scheduler;
        if (s != null) {
            for (String group : s.getJobGroupNames()) {
                for (JobKey key : s.getJobKeys(GroupMatcher.jobGroupEquals(group))) {
                    JobDetail detail = s.getJobDetail(key);
                    ScheduleOptions options = (ScheduleOptions) detail.getJobDataMap().get(DATA_MAP_OPTIONS);
                    Object job = detail.getJobDataMap().get(DATA_MAP_OBJECT);
                    jobs.put(job, options);
                }
            }
        }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.ScheduleOptions

    protected void deleteQueue(ReplicationQueue queue) {
        // do nothing as queues just exist in the cache
    }

    public void enableQueueProcessing(@Nonnull String agentName, @Nonnull ReplicationQueueProcessor queueProcessor) {
        ScheduleOptions options = scheduler.NOW(-1, 10)
                .canRunConcurrently(false)
                .name(getJobName(agentName));
        scheduler.schedule(new ScheduledReplicationQueueProcessorTask(this, queueProcessor), options);
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.ScheduleOptions

    }

    @Test
    public void testEnableQueueProcessing() throws Exception {
        Scheduler scheduler = mock(Scheduler.class);
        ScheduleOptions options = mock(ScheduleOptions.class);
        when(scheduler.NOW(-1, 10)).thenReturn(options);
        when(options.canRunConcurrently(false)).thenReturn(options);
        when(options.name(any(String.class))).thenReturn(options);
        SimpleReplicationQueueProvider simpleReplicationQueueProvider = new SimpleReplicationQueueProvider(scheduler);
        ReplicationQueueProcessor processor = mock(ReplicationQueueProcessor.class);
        simpleReplicationQueueProvider.enableQueueProcessing("dummy-agent", processor);
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.ScheduleOptions

    }

    @Test
    public void testDisableQueueProcessing() throws Exception {
        Scheduler scheduler = mock(Scheduler.class);
        ScheduleOptions options = mock(ScheduleOptions.class);
        when(scheduler.NOW(-1, 10)).thenReturn(options);
        when(options.canRunConcurrently(false)).thenReturn(options);
        when(options.name(any(String.class))).thenReturn(options);
        SimpleReplicationQueueProvider simpleReplicationQueueProvider = new SimpleReplicationQueueProvider(scheduler);
        simpleReplicationQueueProvider.disableQueueProcessing("dummy-agent");
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.ScheduleOptions

        this.scheduler = scheduler;
    }

    public void register(@Nonnull ReplicationRequestHandler requestHandler) throws ReplicationTriggerException {
        try {
            ScheduleOptions options = scheduler.NOW(-1, secondsInterval);
            options.name(requestHandler.toString());
            scheduler.schedule(new ScheduledReplication(requestHandler), options);
        } catch (Exception e) {
            throw new ReplicationTriggerException("unable to register handler " + requestHandler, e);
        }
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.ScheduleOptions

    public void register(@Nonnull ReplicationRequestHandler requestHandler) throws ReplicationTriggerException {
        try {
            log.info("applying remote event replication trigger");

            ScheduleOptions options = scheduler.NOW();
            options.name(requestHandler.toString());
            scheduler.schedule(new EventBasedReplication(requestHandler), options);
        } catch (Exception e) {
            throw new ReplicationTriggerException("unable to register handler " + requestHandler, e);
        }
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.ScheduleOptions

        for (ReplicationActionType action : ReplicationActionType.values()) {
            String path = "/path/to/somewhere";
            int interval = 10;
            ReplicationRequestHandler handler = mock(ReplicationRequestHandler.class);
            Scheduler scheduler = mock(Scheduler.class);
            ScheduleOptions options = mock(ScheduleOptions.class);
            when(scheduler.NOW(-1, interval)).thenReturn(options);
            when(options.name(handler.toString())).thenReturn(options);
            ScheduledReplicationTrigger scheduledReplicationTrigger = new ScheduledReplicationTrigger(action.name(), path, interval, scheduler);
            scheduledReplicationTrigger.register(handler);
        }
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.ScheduleOptions

        ReplicationRequestHandler handler = mock(ReplicationRequestHandler.class);
        String endpoint = "";
        TransportAuthenticationProvider<CredentialsProvider, CredentialsProvider> authProvider = mock(TransportAuthenticationProvider.class);
        when(authProvider.canAuthenticate(CredentialsProvider.class)).thenReturn(true);
        Scheduler scheduler = mock(Scheduler.class);
        ScheduleOptions options = mock(ScheduleOptions.class);
        when(options.name(handler.toString())).thenReturn(options);
        when(scheduler.NOW()).thenReturn(options);
        RemoteEventReplicationTrigger remoteEventReplicationTrigger = new RemoteEventReplicationTrigger(
                endpoint, authProvider, scheduler);
        remoteEventReplicationTrigger.register(handler);
    }
View Full Code Here

Examples of org.apache.sling.commons.scheduler.ScheduleOptions

                }
            }
            config.put(JOB_CONFIG, properties);
            config.put(JOB_SCHEDULE_INFO, scheduleInfo);

            final ScheduleOptions options;
            if ( scheduleInfo.expression != null ) {
                if ( this.logger.isDebugEnabled() ) {
                    this.logger.debug("Adding timed event " + config.get(JOB_TOPIC) + "(" + scheduleInfo.jobId + ")" + " with cron expression " + scheduleInfo.expression);
                }
                options = localScheduler.EXPR(scheduleInfo.expression);
            } else if ( scheduleInfo.period != null ) {
                if ( this.logger.isDebugEnabled() ) {
                    this.logger.debug("Adding timed event " + config.get(JOB_TOPIC) + "(" + scheduleInfo.jobId + ")" + " with period " + scheduleInfo.period);
                }
                final Date startDate = new Date(System.currentTimeMillis() + scheduleInfo.period * 1000);
                options = localScheduler.AT(startDate, -1, scheduleInfo.period);
            } else {
                // then it must be date
                if ( this.logger.isDebugEnabled() ) {
                    this.logger.debug("Adding timed event " + config.get(JOB_TOPIC) + "(" + scheduleInfo.jobId + ")" + " with date " + scheduleInfo.date);
                }
                options = localScheduler.AT(scheduleInfo.date);
            }
            localScheduler.schedule(this, options.canRunConcurrently(false).name(scheduleInfo.jobId).config(config));
            this.startedSchedulerJobs.add(scheduleInfo.jobId);
            return true;
        } else {
            this.logger.error("No scheduler available to start timed event " + event);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.