You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by np...@apache.org on 2017/10/24 16:52:54 UTC
[sling-org-apache-sling-pipes] branch master updated: SLING-7171
add osgi sleep capability after each persistence
This is an automated email from the ASF dual-hosted git repository.
npeltier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git
The following commit(s) were added to refs/heads/master by this push:
new 1586c3e SLING-7171 add osgi sleep capability after each persistence
1586c3e is described below
commit 1586c3e23a20f084cffda33978b461984962af26
Author: npeltier <pe...@gmail.com>
AuthorDate: Tue Oct 24 18:50:26 2017 +0200
SLING-7171 add osgi sleep capability after each persistence
---
.../java/org/apache/sling/pipes/internal/PlumberImpl.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java b/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
index 7135a42..2d6f0c8 100644
--- a/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
+++ b/src/main/java/org/apache/sling/pipes/internal/PlumberImpl.java
@@ -86,6 +86,9 @@ public class PlumberImpl implements Plumber, JobConsumer {
@AttributeDefinition(description="Number of iterations after which plumber should saves a pipe execution")
int bufferSize() default PlumberImpl.DEFAULT_BUFFER_SIZE;
+ @AttributeDefinition(description="Number of milliseconds of sleep after each persistence")
+ long sleep() default 0L;
+
@AttributeDefinition(description="Name of service user, with appropriate rights, that will be used for async execution")
String serviceUser();
@@ -97,7 +100,7 @@ public class PlumberImpl implements Plumber, JobConsumer {
public static final String SLING_EVENT_TOPIC = "org/apache/sling/pipes/topic";
- private int bufferSize;
+ private Configuration configuration;
private Map serviceUser;
@@ -105,7 +108,7 @@ public class PlumberImpl implements Plumber, JobConsumer {
@Activate
public void activate(Configuration configuration){
- bufferSize = configuration.bufferSize();
+ this.configuration = configuration;
serviceUser = Collections.singletonMap(SUBSERVICE, configuration.serviceUser());
allowedUsers = Arrays.asList(configuration.authorizedUsers());
registry = new HashMap<>();
@@ -229,10 +232,14 @@ public class PlumberImpl implements Plumber, JobConsumer {
*/
protected void persist(ResourceResolver resolver, Pipe pipe, Set<String> paths, Resource currentResource) throws Exception {
if (pipe.modifiesContent() && resolver.hasChanges() && !pipe.isDryRun()){
- if (currentResource == null || paths.size() % bufferSize == 0){
+ if (currentResource == null || paths.size() % configuration.bufferSize() == 0){
log.info("[{}] saving changes...", pipe.getName());
writeStatus(pipe, currentResource == null ? STATUS_FINISHED : currentResource.getPath());
resolver.commit();
+ if (configuration.sleep() > 0){
+ log.debug("sleeping for {}ms", configuration.sleep());
+ Thread.sleep(configuration.sleep());
+ }
}
if (currentResource == null && distributor != null && StringUtils.isNotBlank(pipe.getDistributionAgent())) {
log.info("a distribution agent is configured, will try to distribute the changes");
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].