sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpet...@apache.org
Subject svn commit: r1650232 - in /sling/trunk/contrib/extensions/distribution: core/src/main/java/org/apache/sling/distribution/agent/impl/ sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install.author/publish-multiple/
Date Thu, 08 Jan 2015 08:45:15 GMT
Author: mpetria
Date: Thu Jan  8 08:45:15 2015
New Revision: 1650232

URL: http://svn.apache.org/r1650232
Log:
SLING-4009: making multiple queue delivery option explicit via osgi config

Modified:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install.author/publish-multiple/org.apache.sling.distribution.agent.impl.ForwardDistributionAgentFactory-publish-multiple.json

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java?rev=1650232&r1=1650231&r2=1650232&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
Thu Jan  8 08:45:15 2015
@@ -39,6 +39,7 @@ import org.apache.sling.distribution.pac
 import org.apache.sling.distribution.queue.DistributionQueueProvider;
 import org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.MultipleQueueDispatchingStrategy;
+import org.apache.sling.distribution.queue.impl.SingleQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider;
 import org.apache.sling.distribution.serialization.DistributionPackageBuilder;
 import org.apache.sling.distribution.transport.DistributionTransportSecretProvider;
@@ -84,6 +85,9 @@ public class ForwardDistributionAgentFac
     @Property(cardinality = -1)
     public static final String IMPORTER_ENDPOINTS = "packageImporter.endpoints";
 
+    @Property(label = "Use multiple queues", boolValue = false)
+    public static final String USE_MULTIPLE_QUEUES = "useMultipleQueues";
+
     @Reference
     private Packaging packaging;
 
@@ -140,15 +144,24 @@ public class ForwardDistributionAgentFac
     protected SimpleDistributionAgent createAgent(String agentName, BundleContext context,
Map<String, Object> config) {
         String serviceName = PropertiesUtil.toString(config.get(SERVICE_NAME), null);
 
-        Map<String, String> importerEndpointsMap = SettingsUtils.toUriMap(config.get(IMPORTER_ENDPOINTS));
-
 
         DistributionPackageExporter packageExporter = new LocalDistributionPackageExporter(packageBuilder);
-        DistributionPackageImporter packageImporter = new RemoteDistributionPackageImporter(transportSecretProvider,
importerEndpointsMap, TransportEndpointStrategyType.One);
         DistributionQueueProvider queueProvider =  new JobHandlingDistributionQueueProvider(agentName,
jobManager, context);
 
-        String[] queueNames = importerEndpointsMap.keySet().toArray(new String[0]);
-        DistributionQueueDispatchingStrategy dispatchingStrategy = new MultipleQueueDispatchingStrategy(queueNames);
+        DistributionQueueDispatchingStrategy dispatchingStrategy = null;
+        DistributionPackageImporter packageImporter = null;
+        Map<String, String> importerEndpointsMap = SettingsUtils.toUriMap(config.get(IMPORTER_ENDPOINTS));
+        boolean useMultipleQueues = PropertiesUtil.toBoolean(config.get(USE_MULTIPLE_QUEUES),
false);
+
+        if (useMultipleQueues) {
+            String[] queueNames = importerEndpointsMap.keySet().toArray(new String[0]);
+            dispatchingStrategy = new MultipleQueueDispatchingStrategy(queueNames);
+            packageImporter = new RemoteDistributionPackageImporter(transportSecretProvider,
importerEndpointsMap, TransportEndpointStrategyType.One);
+        } else {
+            dispatchingStrategy = new SingleQueueDispatchingStrategy();
+            packageImporter = new RemoteDistributionPackageImporter(transportSecretProvider,
importerEndpointsMap, TransportEndpointStrategyType.All);
+        }
+
 
         return new SimpleDistributionAgent(agentName, false, serviceName,
                 packageImporter, packageExporter, requestAuthorizationStrategy,

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java?rev=1650232&r1=1650231&r2=1650232&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
Thu Jan  8 08:45:15 2015
@@ -38,6 +38,7 @@ import org.apache.sling.distribution.pac
 import org.apache.sling.distribution.packaging.impl.importer.RemoteDistributionPackageImporter;
 import org.apache.sling.distribution.queue.impl.DistributionQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.DistributionQueueProvider;
+import org.apache.sling.distribution.queue.impl.MultipleQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.SingleQueueDispatchingStrategy;
 import org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider;
 import org.apache.sling.distribution.serialization.DistributionPackageBuilder;
@@ -90,6 +91,11 @@ public class SyncDistributionAgentFactor
     @Property(cardinality = -1)
     public static final String IMPORTER_ENDPOINTS = "packageImporter.endpoints";
 
+
+
+    @Property(label = "Use multiple queues", boolValue = false)
+    public static final String USE_MULTIPLE_QUEUES = "useMultipleQueues";
+
     @Reference
     private Packaging packaging;
 
@@ -149,13 +155,25 @@ public class SyncDistributionAgentFactor
 
 
         String[] exporterEndpoints = PropertiesUtil.toStringArray(config.get(EXPORTER_ENDPOINTS),
new String[0]);
+
+
+        DistributionQueueDispatchingStrategy dispatchingStrategy = null;
+        DistributionPackageImporter packageImporter = null;
         Map<String, String> importerEndpointsMap = SettingsUtils.toUriMap(config.get(IMPORTER_ENDPOINTS));
+        boolean useMultipleQueues = PropertiesUtil.toBoolean(config.get(USE_MULTIPLE_QUEUES),
false);
+
+        if (useMultipleQueues) {
+            String[] queueNames = importerEndpointsMap.keySet().toArray(new String[0]);
+            dispatchingStrategy = new MultipleQueueDispatchingStrategy(queueNames);
+            packageImporter = new RemoteDistributionPackageImporter(transportSecretProvider,
importerEndpointsMap, TransportEndpointStrategyType.One);
+        } else {
+            dispatchingStrategy = new SingleQueueDispatchingStrategy();
+            packageImporter = new RemoteDistributionPackageImporter(transportSecretProvider,
importerEndpointsMap, TransportEndpointStrategyType.All);
+        }
 
 
         DistributionPackageExporter packageExporter = new RemoteDistributionPackageExporter(packageBuilder,
transportSecretProvider, exporterEndpoints, TransportEndpointStrategyType.All, 1);
-        DistributionPackageImporter packageImporter = new RemoteDistributionPackageImporter(transportSecretProvider,
importerEndpointsMap, TransportEndpointStrategyType.All);
         DistributionQueueProvider queueProvider =  new JobHandlingDistributionQueueProvider(agentName,
jobManager, context);
-        DistributionQueueDispatchingStrategy dispatchingStrategy = new SingleQueueDispatchingStrategy();
 
         return new SimpleDistributionAgent(agentName, false, serviceName,
                 packageImporter, packageExporter, requestAuthorizationStrategy,

Modified: sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install.author/publish-multiple/org.apache.sling.distribution.agent.impl.ForwardDistributionAgentFactory-publish-multiple.json
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install.author/publish-multiple/org.apache.sling.distribution.agent.impl.ForwardDistributionAgentFactory-publish-multiple.json?rev=1650232&r1=1650231&r2=1650232&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install.author/publish-multiple/org.apache.sling.distribution.agent.impl.ForwardDistributionAgentFactory-publish-multiple.json
(original)
+++ sling/trunk/contrib/extensions/distribution/sample/src/main/resources/SLING-CONTENT/libs/sling/distribution/install.author/publish-multiple/org.apache.sling.distribution.agent.impl.ForwardDistributionAgentFactory-publish-multiple.json
Thu Jan  8 08:45:15 2015
@@ -11,6 +11,8 @@
 
     "transportSecretProvider.target" : "(name=publishAdmin)",
 
+    "useMultipleQueues" : true,
+
     "packageImporter.endpoints" : [
         "endpoint1=http://localhost:4503/libs/sling/distribution/services/importers/default",
         "endpoint2=http://localhost:4503/libs/sling/distribution/services/importers/defaultbadaddress"



Mime
View raw message