Search in sources :

Example 1 with DefaultDistributionLog

use of org.apache.sling.distribution.log.impl.DefaultDistributionLog in project sling by apache.

the class RemoteDistributionPackageExporterFactory method activate.

@Activate
protected void activate(Map<String, Object> config) throws Exception {
    log.info("activating remote exporter with pb {} and dtsp {}", packageBuilder, transportSecretProvider);
    String[] endpoints = PropertiesUtil.toStringArray(config.get(ENDPOINTS), new String[0]);
    endpoints = SettingsUtils.removeEmptyEntries(endpoints);
    int pollItems = PropertiesUtil.toInteger(config.get(PULL_ITEMS), Integer.MAX_VALUE);
    String exporterName = PropertiesUtil.toString(config.get(NAME), null);
    DefaultDistributionLog distributionLog = new DefaultDistributionLog(DistributionComponentKind.EXPORTER, exporterName, RemoteDistributionPackageExporter.class, DefaultDistributionLog.LogLevel.ERROR);
    // default to 10s, we can expose it if needed
    HttpConfiguration httpConfiguration = new HttpConfiguration(10000);
    exporter = new RemoteDistributionPackageExporter(distributionLog, packageBuilder, transportSecretProvider, endpoints, pollItems, httpConfiguration);
}
Also used : DefaultDistributionLog(org.apache.sling.distribution.log.impl.DefaultDistributionLog) HttpConfiguration(org.apache.sling.distribution.transport.impl.HttpConfiguration) Activate(org.apache.felix.scr.annotations.Activate)

Example 2 with DefaultDistributionLog

use of org.apache.sling.distribution.log.impl.DefaultDistributionLog in project sling by apache.

the class QueueingDistributionPackageProcessorTest method testGetPackagesCount.

@Test
public void testGetPackagesCount() throws Exception {
    String callingUser = "mr-who-cares";
    String requestId = "id231";
    long startTime = System.currentTimeMillis();
    DistributionEventFactory eventFactory = mock(DistributionEventFactory.class);
    DistributionQueueDispatchingStrategy scheduleQueueStrategy = mock(DistributionQueueDispatchingStrategy.class);
    DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
    DefaultDistributionLog log = mock(DefaultDistributionLog.class);
    String agentName = "dummy";
    QueueingDistributionPackageProcessor exporterProcessor = new QueueingDistributionPackageProcessor(callingUser, requestId, startTime, eventFactory, scheduleQueueStrategy, queueProvider, log, agentName);
    int packagesCount = exporterProcessor.getPackagesCount();
    assertEquals(0, packagesCount);
}
Also used : DistributionQueueDispatchingStrategy(org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy) DistributionQueueProvider(org.apache.sling.distribution.queue.DistributionQueueProvider) DefaultDistributionLog(org.apache.sling.distribution.log.impl.DefaultDistributionLog) DistributionEventFactory(org.apache.sling.distribution.event.impl.DistributionEventFactory) Test(org.junit.Test)

Example 3 with DefaultDistributionLog

use of org.apache.sling.distribution.log.impl.DefaultDistributionLog in project sling by apache.

the class QueueingDistributionPackageProcessorTest method testGetPackagesSize.

@Test
public void testGetPackagesSize() throws Exception {
    String callingUser = "mr-who-cares";
    String requestId = "id231";
    long startTime = System.currentTimeMillis();
    DistributionEventFactory eventFactory = mock(DistributionEventFactory.class);
    DistributionQueueDispatchingStrategy scheduleQueueStrategy = mock(DistributionQueueDispatchingStrategy.class);
    DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
    DefaultDistributionLog log = mock(DefaultDistributionLog.class);
    String agentName = "dummy";
    QueueingDistributionPackageProcessor exporterProcessor = new QueueingDistributionPackageProcessor(callingUser, requestId, startTime, eventFactory, scheduleQueueStrategy, queueProvider, log, agentName);
    long packagesSize = exporterProcessor.getPackagesSize();
    assertEquals(0L, packagesSize);
}
Also used : DistributionQueueDispatchingStrategy(org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy) DistributionQueueProvider(org.apache.sling.distribution.queue.DistributionQueueProvider) DefaultDistributionLog(org.apache.sling.distribution.log.impl.DefaultDistributionLog) DistributionEventFactory(org.apache.sling.distribution.event.impl.DistributionEventFactory) Test(org.junit.Test)

Example 4 with DefaultDistributionLog

use of org.apache.sling.distribution.log.impl.DefaultDistributionLog in project sling by apache.

the class QueueingDistributionPackageProcessorTest method testProcess.

@Test
public void testProcess() throws Exception {
    String callingUser = "mr-who-cares";
    String requestId = "id231";
    long startTime = System.currentTimeMillis();
    DistributionEventFactory eventFactory = mock(DistributionEventFactory.class);
    DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
    DistributionPackage distributionPackage = mock(DistributionPackage.class);
    DistributionQueueDispatchingStrategy scheduleQueueStrategy = mock(DistributionQueueDispatchingStrategy.class);
    // assume scheduling works
    List<DistributionQueueItemStatus> statuses = new LinkedList<DistributionQueueItemStatus>();
    DistributionQueueItemStatus qis = new DistributionQueueItemStatus(DistributionQueueItemState.QUEUED, "queue-1");
    statuses.add(qis);
    when(scheduleQueueStrategy.add(distributionPackage, queueProvider)).thenReturn(statuses);
    DefaultDistributionLog log = mock(DefaultDistributionLog.class);
    String agentName = "dummy";
    QueueingDistributionPackageProcessor exporterProcessor = new QueueingDistributionPackageProcessor(callingUser, requestId, startTime, eventFactory, scheduleQueueStrategy, queueProvider, log, agentName);
    DistributionPackageInfo info = new DistributionPackageInfo("type-a", new HashMap<String, Object>());
    when(distributionPackage.getInfo()).thenReturn(info);
    exporterProcessor.process(distributionPackage);
}
Also used : DistributionQueueDispatchingStrategy(org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy) DistributionQueueItemStatus(org.apache.sling.distribution.queue.DistributionQueueItemStatus) DistributionPackageInfo(org.apache.sling.distribution.packaging.DistributionPackageInfo) DefaultDistributionLog(org.apache.sling.distribution.log.impl.DefaultDistributionLog) DistributionEventFactory(org.apache.sling.distribution.event.impl.DistributionEventFactory) LinkedList(java.util.LinkedList) DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) DistributionQueueProvider(org.apache.sling.distribution.queue.DistributionQueueProvider) Test(org.junit.Test)

Example 5 with DefaultDistributionLog

use of org.apache.sling.distribution.log.impl.DefaultDistributionLog in project sling by apache.

the class SimpleDistributionAgentQueueProcessorTest method testProcess.

@Test
public void testProcess() throws Exception {
    DistributionPackageExporter packageExporter = mock(DistributionPackageExporter.class);
    DistributionPackageImporter packageImporter = mock(DistributionPackageImporter.class);
    int retryAttempts = 3;
    DefaultDistributionLog log = mock(DefaultDistributionLog.class);
    DistributionQueueProvider queueProvider = mock(DistributionQueueProvider.class);
    DistributionEventFactory eventFactory = mock(DistributionEventFactory.class);
    SimpleDistributionAgentAuthenticationInfo authenticationInfo = mock(SimpleDistributionAgentAuthenticationInfo.class);
    String agentName = "dummy-a";
    SimpleDistributionAgentQueueProcessor queueProcessor = new SimpleDistributionAgentQueueProcessor(packageExporter, packageImporter, retryAttempts, null, log, queueProvider, eventFactory, authenticationInfo, agentName);
    String id = "123-456";
    DistributionQueueItem item = new DistributionQueueItem("pckg-123", new HashMap<String, Object>());
    String queueName = "queue-1";
    DistributionQueueItemStatus status = new DistributionQueueItemStatus(DistributionQueueItemState.QUEUED, queueName);
    DistributionQueueEntry entry = new DistributionQueueEntry(id, item, status);
    queueProcessor.process(queueName, entry);
}
Also used : DistributionQueueItemStatus(org.apache.sling.distribution.queue.DistributionQueueItemStatus) DistributionQueueEntry(org.apache.sling.distribution.queue.DistributionQueueEntry) DefaultDistributionLog(org.apache.sling.distribution.log.impl.DefaultDistributionLog) DistributionPackageExporter(org.apache.sling.distribution.packaging.DistributionPackageExporter) DistributionEventFactory(org.apache.sling.distribution.event.impl.DistributionEventFactory) DistributionQueueItem(org.apache.sling.distribution.queue.DistributionQueueItem) DistributionQueueProvider(org.apache.sling.distribution.queue.DistributionQueueProvider) DistributionPackageImporter(org.apache.sling.distribution.packaging.DistributionPackageImporter) Test(org.junit.Test)

Aggregations

DefaultDistributionLog (org.apache.sling.distribution.log.impl.DefaultDistributionLog)14 Test (org.junit.Test)11 DistributionEventFactory (org.apache.sling.distribution.event.impl.DistributionEventFactory)5 DistributionPackageImporter (org.apache.sling.distribution.packaging.DistributionPackageImporter)5 DistributionQueueProvider (org.apache.sling.distribution.queue.DistributionQueueProvider)5 ResourceResolverFactory (org.apache.sling.api.resource.ResourceResolverFactory)4 DistributionQueueDispatchingStrategy (org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy)4 SlingRepository (org.apache.sling.jcr.api.SlingRepository)4 Activate (org.apache.felix.scr.annotations.Activate)2 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)2 DistributionRequest (org.apache.sling.distribution.DistributionRequest)2 DistributionAgent (org.apache.sling.distribution.agent.DistributionAgent)2 DistributionPackage (org.apache.sling.distribution.packaging.DistributionPackage)2 DistributionPackageInfo (org.apache.sling.distribution.packaging.DistributionPackageInfo)2 DistributionQueueItemStatus (org.apache.sling.distribution.queue.DistributionQueueItemStatus)2 HttpConfiguration (org.apache.sling.distribution.transport.impl.HttpConfiguration)2 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1