Search in sources :

Example 6 with HttpConfiguration

use of org.apache.sling.distribution.transport.impl.HttpConfiguration in project sling by apache.

the class RemoteDistributionPackageImporterTest method testDummyImport.

@Test
public void testDummyImport() throws Exception {
    DistributionTransportSecretProvider distributionTransportSecretProvider = mock(DistributionTransportSecretProvider.class);
    Map<String, String> endpoints = new HashMap<String, String>();
    RemoteDistributionPackageImporter remotedistributionPackageImporter = new RemoteDistributionPackageImporter(mock(DefaultDistributionLog.class), distributionTransportSecretProvider, endpoints, new HttpConfiguration(10000));
    endpoints.put("default", "http://endpoint");
    ResourceResolver resourceResolver = mock(ResourceResolver.class);
    DistributionPackage distributionPackage = mock(DistributionPackage.class);
    DistributionPackageInfo info = new DistributionPackageInfo("/foo");
    when(distributionPackage.getInfo()).thenReturn(info);
    remotedistributionPackageImporter.importPackage(resourceResolver, distributionPackage);
}
Also used : DistributionPackage(org.apache.sling.distribution.packaging.DistributionPackage) DistributionPackageInfo(org.apache.sling.distribution.packaging.DistributionPackageInfo) HashMap(java.util.HashMap) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) DistributionTransportSecretProvider(org.apache.sling.distribution.transport.DistributionTransportSecretProvider) DefaultDistributionLog(org.apache.sling.distribution.log.impl.DefaultDistributionLog) HttpConfiguration(org.apache.sling.distribution.transport.impl.HttpConfiguration) Test(org.junit.Test)

Example 7 with HttpConfiguration

use of org.apache.sling.distribution.transport.impl.HttpConfiguration in project sling by apache.

the class ReverseDistributionAgentFactory method createAgent.

@Override
protected SimpleDistributionAgent createAgent(String agentName, BundleContext context, Map<String, Object> config, DefaultDistributionLog distributionLog) {
    String serviceName = SettingsUtils.removeEmptyEntry(PropertiesUtil.toString(config.get(SERVICE_NAME), null));
    boolean queueProcessingEnabled = PropertiesUtil.toBoolean(config.get(QUEUE_PROCESSING_ENABLED), true);
    String[] exporterEndpoints = PropertiesUtil.toStringArray(config.get(EXPORTER_ENDPOINTS), new String[0]);
    exporterEndpoints = SettingsUtils.removeEmptyEntries(exporterEndpoints);
    int pullItems = PropertiesUtil.toInteger(config.get(PULL_ITEMS), Integer.MAX_VALUE);
    Integer timeout = PropertiesUtil.toInteger(HTTP, 10) * 1000;
    HttpConfiguration httpConfiguration = new HttpConfiguration(timeout);
    DistributionPackageExporter packageExporter = new RemoteDistributionPackageExporter(distributionLog, packageBuilder, transportSecretProvider, exporterEndpoints, pullItems, httpConfiguration);
    DistributionPackageImporter packageImporter = new LocalDistributionPackageImporter(agentName, distributionEventFactory, packageBuilder);
    DistributionQueueProvider queueProvider = new MonitoringDistributionQueueProvider(new JobHandlingDistributionQueueProvider(agentName, jobManager, context), context);
    DistributionQueueDispatchingStrategy exportQueueStrategy = new SingleQueueDispatchingStrategy();
    DistributionQueueDispatchingStrategy importQueueStrategy = null;
    DistributionRequestType[] allowedRequests = new DistributionRequestType[] { DistributionRequestType.PULL };
    Set<String> processingQueues = new HashSet<String>();
    processingQueues.addAll(exportQueueStrategy.getQueueNames());
    return new SimpleDistributionAgent(agentName, queueProcessingEnabled, processingQueues, serviceName, packageImporter, packageExporter, requestAuthorizationStrategy, queueProvider, exportQueueStrategy, importQueueStrategy, distributionEventFactory, resourceResolverFactory, slingRepository, distributionLog, allowedRequests, null, 0);
}
Also used : DistributionQueueDispatchingStrategy(org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy) LocalDistributionPackageImporter(org.apache.sling.distribution.packaging.impl.importer.LocalDistributionPackageImporter) RemoteDistributionPackageExporter(org.apache.sling.distribution.packaging.impl.exporter.RemoteDistributionPackageExporter) JobHandlingDistributionQueueProvider(org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider) HttpConfiguration(org.apache.sling.distribution.transport.impl.HttpConfiguration) SingleQueueDispatchingStrategy(org.apache.sling.distribution.queue.impl.SingleQueueDispatchingStrategy) RemoteDistributionPackageExporter(org.apache.sling.distribution.packaging.impl.exporter.RemoteDistributionPackageExporter) DistributionPackageExporter(org.apache.sling.distribution.packaging.DistributionPackageExporter) DistributionRequestType(org.apache.sling.distribution.DistributionRequestType) MonitoringDistributionQueueProvider(org.apache.sling.distribution.monitor.impl.MonitoringDistributionQueueProvider) JobHandlingDistributionQueueProvider(org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider) DistributionQueueProvider(org.apache.sling.distribution.queue.DistributionQueueProvider) LocalDistributionPackageImporter(org.apache.sling.distribution.packaging.impl.importer.LocalDistributionPackageImporter) DistributionPackageImporter(org.apache.sling.distribution.packaging.DistributionPackageImporter) MonitoringDistributionQueueProvider(org.apache.sling.distribution.monitor.impl.MonitoringDistributionQueueProvider) HashSet(java.util.HashSet)

Example 8 with HttpConfiguration

use of org.apache.sling.distribution.transport.impl.HttpConfiguration in project sling by apache.

the class RemoteDistributionPackageImporterFactory method activate.

@Activate
protected void activate(Map<String, Object> config) {
    Map<String, String> endpoints = SettingsUtils.toUriMap(config.get(ENDPOINTS));
    String importerName = PropertiesUtil.toString(config.get(NAME), null);
    DefaultDistributionLog distributionLog = new DefaultDistributionLog(DistributionComponentKind.IMPORTER, importerName, RemoteDistributionPackageImporter.class, DefaultDistributionLog.LogLevel.ERROR);
    // default to 10s, we can expose it if needed
    HttpConfiguration httpConfiguration = new HttpConfiguration(10000);
    importer = new RemoteDistributionPackageImporter(distributionLog, transportSecretProvider, endpoints, 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)

Aggregations

HttpConfiguration (org.apache.sling.distribution.transport.impl.HttpConfiguration)8 DefaultDistributionLog (org.apache.sling.distribution.log.impl.DefaultDistributionLog)5 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)3 DistributionRequestType (org.apache.sling.distribution.DistributionRequestType)3 MonitoringDistributionQueueProvider (org.apache.sling.distribution.monitor.impl.MonitoringDistributionQueueProvider)3 DistributionPackage (org.apache.sling.distribution.packaging.DistributionPackage)3 DistributionPackageExporter (org.apache.sling.distribution.packaging.DistributionPackageExporter)3 DistributionPackageImporter (org.apache.sling.distribution.packaging.DistributionPackageImporter)3 DistributionQueueProvider (org.apache.sling.distribution.queue.DistributionQueueProvider)3 DistributionQueueDispatchingStrategy (org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy)3 JobHandlingDistributionQueueProvider (org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider)3 DistributionTransportSecretProvider (org.apache.sling.distribution.transport.DistributionTransportSecretProvider)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Activate (org.apache.felix.scr.annotations.Activate)2 DistributionPackageBuilder (org.apache.sling.distribution.packaging.DistributionPackageBuilder)2 RemoteDistributionPackageExporter (org.apache.sling.distribution.packaging.impl.exporter.RemoteDistributionPackageExporter)2 RemoteDistributionPackageImporter (org.apache.sling.distribution.packaging.impl.importer.RemoteDistributionPackageImporter)2 ErrorQueueDispatchingStrategy (org.apache.sling.distribution.queue.impl.ErrorQueueDispatchingStrategy)2