Search in sources :

Example 6 with DistributionQueue

use of org.apache.sling.distribution.queue.DistributionQueue in project sling by apache.

the class SimpleDistributionQueueProcessorTest method testRunWithNoQueue.

@Test
public void testRunWithNoQueue() throws Exception {
    DistributionQueue queue = mock(DistributionQueue.class);
    DistributionQueueProcessor queueProcessor = mock(DistributionQueueProcessor.class);
    SimpleDistributionQueueProcessor simpleDistributionQueueProcessor = new SimpleDistributionQueueProcessor(queue, queueProcessor);
    simpleDistributionQueueProcessor.run();
}
Also used : DistributionQueueProcessor(org.apache.sling.distribution.queue.DistributionQueueProcessor) DistributionQueue(org.apache.sling.distribution.queue.DistributionQueue) Test(org.junit.Test)

Example 7 with DistributionQueue

use of org.apache.sling.distribution.queue.DistributionQueue in project sling by apache.

the class SimpleDistributionQueueProviderTest method testGetOrCreateQueueWithCheckpointing.

@Test
public void testGetOrCreateQueueWithCheckpointing() throws Exception {
    String name = "agentName";
    try {
        SimpleDistributionQueueProvider simpledistributionQueueProvider = new SimpleDistributionQueueProvider(mock(Scheduler.class), name, true);
        DistributionQueue queue = simpledistributionQueueProvider.getQueue("default");
        assertNotNull(queue);
    } finally {
        new File(name + "-simple-queues-checkpoints").deleteOnExit();
    }
}
Also used : DistributionQueue(org.apache.sling.distribution.queue.DistributionQueue) Scheduler(org.apache.sling.commons.scheduler.Scheduler) File(java.io.File) Test(org.junit.Test)

Example 8 with DistributionQueue

use of org.apache.sling.distribution.queue.DistributionQueue in project sling by apache.

the class SimpleDistributionQueueProviderTest method testGetOrCreateQueue.

@Test
public void testGetOrCreateQueue() throws Exception {
    SimpleDistributionQueueProvider simpledistributionQueueProvider = new SimpleDistributionQueueProvider(mock(Scheduler.class), "agentName", false);
    DistributionQueue queue = simpledistributionQueueProvider.getQueue("default");
    assertNotNull(queue);
}
Also used : DistributionQueue(org.apache.sling.distribution.queue.DistributionQueue) Scheduler(org.apache.sling.commons.scheduler.Scheduler) Test(org.junit.Test)

Example 9 with DistributionQueue

use of org.apache.sling.distribution.queue.DistributionQueue in project sling by apache.

the class MonitoringDistributionQueueProvider method getQueue.

@Override
public DistributionQueue getQueue(String queueName) throws DistributionException {
    DistributionQueue distributionQueue = wrapped.getQueue(queueName);
    monitorQueue(distributionQueue);
    return distributionQueue;
}
Also used : DistributionQueue(org.apache.sling.distribution.queue.DistributionQueue)

Example 10 with DistributionQueue

use of org.apache.sling.distribution.queue.DistributionQueue in project sling by apache.

the class SimpleDistributionAgent method getState.

@Nonnull
public DistributionAgentState getState() {
    DistributionAgentState agentState = DistributionAgentState.IDLE;
    // if it is passive and it is not a queueing agent
    if (isPassive() && distributionPackageImporter != null) {
        return DistributionAgentState.PAUSED;
    }
    for (String queueName : getQueueNames()) {
        DistributionQueue queue = getQueue(queueName);
        DistributionQueueState state = queue.getStatus().getState();
        if (DistributionQueueState.BLOCKED == state) {
            return DistributionAgentState.BLOCKED;
        }
        if (DistributionQueueState.RUNNING == state) {
            agentState = DistributionAgentState.RUNNING;
        }
    }
    return agentState;
}
Also used : DistributionAgentState(org.apache.sling.distribution.agent.DistributionAgentState) SimpleAgentDistributionQueue(org.apache.sling.distribution.queue.impl.SimpleAgentDistributionQueue) DistributionQueue(org.apache.sling.distribution.queue.DistributionQueue) DistributionQueueState(org.apache.sling.distribution.queue.DistributionQueueState) Nonnull(javax.annotation.Nonnull)

Aggregations

DistributionQueue (org.apache.sling.distribution.queue.DistributionQueue)40 Test (org.junit.Test)25 DistributionQueueItem (org.apache.sling.distribution.queue.DistributionQueueItem)20 DistributionQueueEntry (org.apache.sling.distribution.queue.DistributionQueueEntry)18 DistributionQueueItemStatus (org.apache.sling.distribution.queue.DistributionQueueItemStatus)14 HashMap (java.util.HashMap)8 DistributionQueueProvider (org.apache.sling.distribution.queue.DistributionQueueProvider)8 DistributionPackage (org.apache.sling.distribution.packaging.DistributionPackage)7 DistributionPackageInfo (org.apache.sling.distribution.packaging.DistributionPackageInfo)7 ArrayList (java.util.ArrayList)6 File (java.io.File)5 Map (java.util.Map)5 DistributionAgent (org.apache.sling.distribution.agent.DistributionAgent)5 Matchers.anyString (org.mockito.Matchers.anyString)5 DistributionException (org.apache.sling.distribution.common.DistributionException)4 SharedDistributionPackage (org.apache.sling.distribution.packaging.impl.SharedDistributionPackage)4 DistributionQueueStatus (org.apache.sling.distribution.queue.DistributionQueueStatus)4 Result (org.apache.sling.hc.api.Result)4 LinkedList (java.util.LinkedList)3 Scheduler (org.apache.sling.commons.scheduler.Scheduler)3