Search in sources :

Example 6 with ScheduleOptions

use of org.apache.sling.commons.scheduler.ScheduleOptions in project sling by apache.

the class SimpleDistributionQueueProviderTest method testEnableQueueProcessingWithCheckpointing.

@Test
public void testEnableQueueProcessingWithCheckpointing() throws Exception {
    String name = "dummy-agent";
    try {
        Scheduler scheduler = mock(Scheduler.class);
        ScheduleOptions options = mock(ScheduleOptions.class);
        when(scheduler.NOW(-1, 1)).thenReturn(options);
        when(options.canRunConcurrently(false)).thenReturn(options);
        when(options.name(any(String.class))).thenReturn(options);
        SimpleDistributionQueueProvider simpledistributionQueueProvider = new SimpleDistributionQueueProvider(scheduler, name, true);
        DistributionQueueProcessor processor = mock(DistributionQueueProcessor.class);
        simpledistributionQueueProvider.enableQueueProcessing(processor);
    } finally {
        new File(name + "-simple-queues-checkpoints").deleteOnExit();
    }
}
Also used : DistributionQueueProcessor(org.apache.sling.distribution.queue.DistributionQueueProcessor) ScheduleOptions(org.apache.sling.commons.scheduler.ScheduleOptions) Scheduler(org.apache.sling.commons.scheduler.Scheduler) File(java.io.File) Test(org.junit.Test)

Example 7 with ScheduleOptions

use of org.apache.sling.commons.scheduler.ScheduleOptions in project sling by apache.

the class RemoteEventDistributionTriggerTest method testRegister.

@Test
public void testRegister() throws Exception {
    DistributionRequestHandler handler = mock(DistributionRequestHandler.class);
    String endpoint = "";
    DistributionTransportSecretProvider distributionTransportSecretProvider = mock(DistributionTransportSecretProvider.class);
    Scheduler scheduler = mock(Scheduler.class);
    ScheduleOptions options = mock(ScheduleOptions.class);
    when(options.name(handler.toString())).thenReturn(options);
    when(scheduler.NOW()).thenReturn(options);
    RemoteEventDistributionTrigger remoteEventdistributionTrigger = new RemoteEventDistributionTrigger(endpoint, distributionTransportSecretProvider, scheduler);
    remoteEventdistributionTrigger.register(handler);
}
Also used : DistributionRequestHandler(org.apache.sling.distribution.trigger.DistributionRequestHandler) ScheduleOptions(org.apache.sling.commons.scheduler.ScheduleOptions) Scheduler(org.apache.sling.commons.scheduler.Scheduler) DistributionTransportSecretProvider(org.apache.sling.distribution.transport.DistributionTransportSecretProvider) Test(org.junit.Test)

Example 8 with ScheduleOptions

use of org.apache.sling.commons.scheduler.ScheduleOptions in project acs-aem-commons by Adobe-Consulting-Services.

the class EnsureOakIndex method apply.

/**
 * {@inheritDoc}
 */
@Override
public final void apply(boolean force) {
    if (!force && this.applied) {
        return;
    }
    log.info("Ensuring Oak Indexes [ {} ~> {} ]", ensureDefinitionsPath, oakIndexesPath);
    // Start the indexing process asynchronously, so the activate won't get blocked
    // by rebuilding a synchronous index
    EnsureOakIndexJobHandler jobHandler = new EnsureOakIndexJobHandler(this, oakIndexesPath, ensureDefinitionsPath);
    ScheduleOptions options = scheduler.NOW();
    options.name(toString());
    options.canRunConcurrently(false);
    scheduler.schedule(jobHandler, options);
    applied = true;
    log.info("Job scheduled for ensuring Oak Indexes [ {} ~> {} ]", ensureDefinitionsPath, oakIndexesPath);
}
Also used : ScheduleOptions(org.apache.sling.commons.scheduler.ScheduleOptions)

Example 9 with ScheduleOptions

use of org.apache.sling.commons.scheduler.ScheduleOptions in project acs-aem-commons by Adobe-Consulting-Services.

the class AEMWorkflowRunnerImpl method getOptions.

@Override
public ScheduleOptions getOptions(Config config) {
    ScheduleOptions options = scheduler.NOW(-1, config.getInterval());
    options.canRunConcurrently(false);
    options.onLeaderOnly(true);
    options.name(config.getWorkspace().getJobName());
    return options;
}
Also used : ScheduleOptions(org.apache.sling.commons.scheduler.ScheduleOptions)

Example 10 with ScheduleOptions

use of org.apache.sling.commons.scheduler.ScheduleOptions in project acs-aem-commons by Adobe-Consulting-Services.

the class AEMTransientWorkflowRunnerImpl method getOptions.

@Override
public ScheduleOptions getOptions(Config config) {
    ScheduleOptions options = scheduler.NOW(-1, config.getInterval());
    options.canRunConcurrently(false);
    options.onLeaderOnly(true);
    options.name(config.getWorkspace().getJobName());
    return options;
}
Also used : ScheduleOptions(org.apache.sling.commons.scheduler.ScheduleOptions)

Aggregations

ScheduleOptions (org.apache.sling.commons.scheduler.ScheduleOptions)21 Scheduler (org.apache.sling.commons.scheduler.Scheduler)8 Test (org.junit.Test)7 File (java.io.File)4 Date (java.util.Date)3 DistributionQueueProcessor (org.apache.sling.distribution.queue.DistributionQueueProcessor)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 LoginException (org.apache.sling.api.resource.LoginException)2 DistributionException (org.apache.sling.distribution.common.DistributionException)2 DistributionQueue (org.apache.sling.distribution.queue.DistributionQueue)2 DistributionQueueItem (org.apache.sling.distribution.queue.DistributionQueueItem)2 DistributionRequestHandler (org.apache.sling.distribution.trigger.DistributionRequestHandler)2 Workspace (com.adobe.acs.commons.workflow.bulk.execution.model.Workspace)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 StringReader (java.io.StringReader)1