use of org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider in project sling by apache.
the class SimpleDistributionAgentFactory 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);
DistributionQueueProvider queueProvider = new JobHandlingDistributionQueueProvider(agentName, jobManager, context);
DistributionQueueDispatchingStrategy exportQueueStrategy = new SingleQueueDispatchingStrategy();
DistributionQueueDispatchingStrategy importQueueStrategy = null;
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, null, null, 0);
}
use of org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider in project sling by apache.
the class ForwardDistributionAgentFactory 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));
String[] allowedRoots = PropertiesUtil.toStringArray(config.get(ALLOWED_ROOTS), null);
allowedRoots = SettingsUtils.removeEmptyEntries(allowedRoots);
boolean queueProcessingEnabled = PropertiesUtil.toBoolean(config.get(QUEUE_PROCESSING_ENABLED), true);
String[] passiveQueues = PropertiesUtil.toStringArray(config.get(PASSIVE_QUEUES), new String[0]);
passiveQueues = SettingsUtils.removeEmptyEntries(passiveQueues, new String[0]);
Map<String, String> priorityQueues = PropertiesUtil.toMap(config.get(PRIORITY_QUEUES), new String[0]);
priorityQueues = SettingsUtils.removeEmptyEntries(priorityQueues);
Integer timeout = PropertiesUtil.toInteger(HTTP, 10) * 1000;
HttpConfiguration httpConfiguration = new HttpConfiguration(timeout);
DistributionPackageExporter packageExporter = new LocalDistributionPackageExporter(packageBuilder);
DistributionQueueProvider queueProvider;
String queueProviderName = PropertiesUtil.toString(config.get(QUEUE_PROVIDER), JobHandlingDistributionQueueProvider.TYPE);
if (JobHandlingDistributionQueueProvider.TYPE.equals(queueProviderName)) {
queueProvider = new JobHandlingDistributionQueueProvider(agentName, jobManager, context, configAdmin);
} else if (SimpleDistributionQueueProvider.TYPE.equals(queueProviderName)) {
queueProvider = new SimpleDistributionQueueProvider(scheduler, agentName, false);
} else {
queueProvider = new SimpleDistributionQueueProvider(scheduler, agentName, true);
}
queueProvider = new MonitoringDistributionQueueProvider(queueProvider, context);
DistributionQueueDispatchingStrategy exportQueueStrategy;
DistributionQueueDispatchingStrategy errorQueueStrategy = null;
DistributionPackageImporter packageImporter;
Map<String, String> importerEndpointsMap = SettingsUtils.toUriMap(config.get(IMPORTER_ENDPOINTS));
Set<String> processingQueues = new HashSet<String>();
Set<String> endpointNames = importerEndpointsMap.keySet();
Set<String> endpointsAndPassiveQueues = new TreeSet<String>();
endpointsAndPassiveQueues.addAll(endpointNames);
endpointsAndPassiveQueues.addAll(Arrays.asList(passiveQueues));
// names of all the queues
String[] queueNames = endpointsAndPassiveQueues.toArray(new String[endpointsAndPassiveQueues.size()]);
if (priorityQueues != null) {
PriorityQueueDispatchingStrategy dispatchingStrategy = new PriorityQueueDispatchingStrategy(priorityQueues, queueNames);
Map<String, String> queueAliases = dispatchingStrategy.getMatchingQueues(null);
importerEndpointsMap = SettingsUtils.expandUriMap(importerEndpointsMap, queueAliases);
exportQueueStrategy = dispatchingStrategy;
endpointNames = importerEndpointsMap.keySet();
} else {
boolean asyncDelivery = PropertiesUtil.toBoolean(config.get(ASYNC_DELIVERY), false);
if (asyncDelivery) {
// delivery queues' names
Map<String, String> deliveryQueues = new HashMap<String, String>();
for (String e : endpointNames) {
deliveryQueues.put(e, "delivery-" + e);
}
processingQueues.addAll(deliveryQueues.values());
exportQueueStrategy = new AsyncDeliveryDispatchingStrategy(deliveryQueues);
} else {
exportQueueStrategy = new MultipleQueueDispatchingStrategy(endpointNames.toArray(new String[endpointNames.size()]));
}
}
processingQueues.addAll(endpointNames);
processingQueues.removeAll(Arrays.asList(passiveQueues));
packageImporter = new RemoteDistributionPackageImporter(distributionLog, transportSecretProvider, importerEndpointsMap, httpConfiguration);
DistributionRequestType[] allowedRequests = new DistributionRequestType[] { DistributionRequestType.ADD, DistributionRequestType.DELETE };
String retryStrategy = SettingsUtils.removeEmptyEntry(PropertiesUtil.toString(config.get(RETRY_STRATEGY), null));
int retryAttepts = PropertiesUtil.toInteger(config.get(RETRY_ATTEMPTS), 100);
if ("errorQueue".equals(retryStrategy)) {
errorQueueStrategy = new ErrorQueueDispatchingStrategy(processingQueues.toArray(new String[processingQueues.size()]));
}
return new SimpleDistributionAgent(agentName, queueProcessingEnabled, processingQueues, serviceName, packageImporter, packageExporter, requestAuthorizationStrategy, queueProvider, exportQueueStrategy, errorQueueStrategy, distributionEventFactory, resourceResolverFactory, slingRepository, distributionLog, allowedRequests, allowedRoots, retryAttepts);
}
use of org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider in project sling by apache.
the class QueueDistributionAgentFactory 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));
String[] allowedRoots = PropertiesUtil.toStringArray(config.get(ALLOWED_ROOTS), null);
allowedRoots = SettingsUtils.removeEmptyEntries(allowedRoots);
Map<String, String> priorityQueues = PropertiesUtil.toMap(config.get(PRIORITY_QUEUES), new String[0]);
priorityQueues = SettingsUtils.removeEmptyEntries(priorityQueues);
DistributionQueueProvider queueProvider = new MonitoringDistributionQueueProvider(new JobHandlingDistributionQueueProvider(agentName, jobManager, context), context);
DistributionQueueDispatchingStrategy exportQueueStrategy = null;
if (priorityQueues != null) {
exportQueueStrategy = new PriorityQueueDispatchingStrategy(priorityQueues, new String[] { DistributionQueueDispatchingStrategy.DEFAULT_QUEUE_NAME });
} else {
exportQueueStrategy = new SingleQueueDispatchingStrategy();
}
DistributionPackageExporter packageExporter = new LocalDistributionPackageExporter(packageBuilder);
DistributionRequestType[] allowedRequests = new DistributionRequestType[] { DistributionRequestType.ADD, DistributionRequestType.DELETE };
return new SimpleDistributionAgent(agentName, false, null, serviceName, null, packageExporter, requestAuthorizationStrategy, queueProvider, exportQueueStrategy, null, distributionEventFactory, resourceResolverFactory, slingRepository, distributionLog, allowedRequests, allowedRoots, 0);
}
use of org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider in project sling by apache.
the class SyncDistributionAgentFactory 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[] passiveQueues = PropertiesUtil.toStringArray(config.get(PASSIVE_QUEUES), new String[0]);
passiveQueues = SettingsUtils.removeEmptyEntries(passiveQueues, new String[0]);
Object exporterEndpointsValue = config.get(EXPORTER_ENDPOINTS);
Object importerEndpointsValue = config.get(IMPORTER_ENDPOINTS);
String[] exporterEndpoints = PropertiesUtil.toStringArray(exporterEndpointsValue, new String[0]);
exporterEndpoints = SettingsUtils.removeEmptyEntries(exporterEndpoints);
Map<String, String> importerEndpointsMap = SettingsUtils.toUriMap(importerEndpointsValue);
int pullItems = PropertiesUtil.toInteger(config.get(PULL_ITEMS), Integer.MAX_VALUE);
DistributionQueueDispatchingStrategy exportQueueStrategy;
DistributionQueueDispatchingStrategy importQueueStrategy = null;
DistributionPackageImporter packageImporter;
Set<String> processingQueues = new HashSet<String>();
Set<String> queuesMap = new TreeSet<String>();
queuesMap.addAll(importerEndpointsMap.keySet());
queuesMap.addAll(Arrays.asList(passiveQueues));
processingQueues.addAll(importerEndpointsMap.keySet());
processingQueues.removeAll(Arrays.asList(passiveQueues));
String[] queueNames = queuesMap.toArray(new String[queuesMap.size()]);
exportQueueStrategy = new MultipleQueueDispatchingStrategy(queueNames);
Integer timeout = PropertiesUtil.toInteger(HTTP, 10) * 1000;
HttpConfiguration httpConfiguration = new HttpConfiguration(timeout);
packageImporter = new RemoteDistributionPackageImporter(distributionLog, transportSecretProvider, importerEndpointsMap, httpConfiguration);
DistributionPackageExporter packageExporter = new RemoteDistributionPackageExporter(distributionLog, packageBuilder, transportSecretProvider, exporterEndpoints, pullItems, httpConfiguration);
DistributionQueueProvider queueProvider = new MonitoringDistributionQueueProvider(new JobHandlingDistributionQueueProvider(agentName, jobManager, context), context);
DistributionRequestType[] allowedRequests = new DistributionRequestType[] { DistributionRequestType.PULL };
String retryStrategy = SettingsUtils.removeEmptyEntry(PropertiesUtil.toString(config.get(RETRY_STRATEGY), null));
int retryAttepts = PropertiesUtil.toInteger(config.get(RETRY_ATTEMPTS), 100);
if ("errorQueue".equals(retryStrategy)) {
importQueueStrategy = new ErrorQueueDispatchingStrategy(processingQueues.toArray(new String[processingQueues.size()]));
}
return new SimpleDistributionAgent(agentName, queueProcessingEnabled, processingQueues, serviceName, packageImporter, packageExporter, requestAuthorizationStrategy, queueProvider, exportQueueStrategy, importQueueStrategy, distributionEventFactory, resourceResolverFactory, slingRepository, distributionLog, allowedRequests, null, retryAttepts);
}
use of org.apache.sling.distribution.queue.impl.jobhandling.JobHandlingDistributionQueueProvider 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);
}
Aggregations