You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by GitBox <gi...@apache.org> on 2020/02/16 10:24:58 UTC

[GitHub] [sling-org-apache-sling-distribution-journal] cschneider opened a new pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition

cschneider opened a new pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] sonarcloud[bot] commented on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#issuecomment-587464092
 
 
   SonarCloud Quality Gate failed.
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) to review)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL)
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] sonarcloud[bot] removed a comment on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#issuecomment-586690049
 
 
   SonarCloud Quality Gate failed.
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E.png' alt='E' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) to review)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL)
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] tmaret commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
tmaret commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#discussion_r380647468
 
 

 ##########
 File path: src/main/java/org/apache/sling/distribution/journal/impl/subscriber/PackageStatusWatcher.java
 ##########
 @@ -54,61 +50,28 @@ public PackageStatusWatcher(MessagingProvider messagingProvider, Topics topics,
         );
     }
 
-
     /**
      * Gets the status that confirms the package at offset pkgOffset
      * @param pkgOffset the offset of the package
      * @return the status confirming the package; or null if it has not been confirmed yet
      */
-    public PackageStatusMessage.Status getStatus(long pkgOffset) {
-        FullMessage<PackageStatusMessage> msg = cache.get(pkgOffset);
-
-        return msg != null ? msg.getMessage().getStatus() : null;
-    }
-
-    /**
-     * Gets the status offset that confirms the packages at offset pkgOffset
-     * @param pkgOffset the offset of the package
-     * @return the offset of the confirming package; or null if has not been confirmed yet
-     */
-    public Long getStatusOffset(long pkgOffset) {
-        FullMessage<PackageStatusMessage> msg = cache.get(pkgOffset);
-
-        return msg != null ? msg.getInfo().getOffset() : null;
+    public PackageStatusMessage.Status getStatus(String subAgentName, long pkgOffset) {
+        Map<Long, Status> statusPerAgent = getAgentStatus(subAgentName);
+        return statusPerAgent.get(pkgOffset);
     }
 
-    /**
-     * Clear all offsets in the cache smaller to the given pkgOffset.
-     * @param pkgOffset package offset
-     */
-    public void clear(long pkgOffset) {
-        NavigableMap<Long, FullMessage<PackageStatusMessage>> removed = cache.headMap(pkgOffset, false);
-        if (! removed.isEmpty()) {
-            LOG.info("Remove package offsets {} from status cache", removed.keySet());
-        }
-        removed.clear();
+    private Map<Long, Status> getAgentStatus(String subAgentName) {
+        return pkgStatusPerSubAgent.computeIfAbsent(subAgentName, offset -> new HashMap<Long, Messages.PackageStatusMessage.Status>());
 
 Review comment:
   Same here, we should `s/HashMap/ConcurrentMap` as the map is read and written by different threads.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] sonarcloud[bot] commented on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#issuecomment-587047207
 
 
   SonarCloud Quality Gate failed.
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) to review)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [3 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL)
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] cschneider commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
cschneider commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#discussion_r380665112
 
 

 ##########
 File path: src/main/java/org/apache/sling/distribution/journal/impl/subscriber/PackageStatusWatcher.java
 ##########
 @@ -54,61 +50,28 @@ public PackageStatusWatcher(MessagingProvider messagingProvider, Topics topics,
         );
     }
 
-
     /**
      * Gets the status that confirms the package at offset pkgOffset
      * @param pkgOffset the offset of the package
      * @return the status confirming the package; or null if it has not been confirmed yet
      */
-    public PackageStatusMessage.Status getStatus(long pkgOffset) {
-        FullMessage<PackageStatusMessage> msg = cache.get(pkgOffset);
-
-        return msg != null ? msg.getMessage().getStatus() : null;
-    }
-
-    /**
-     * Gets the status offset that confirms the packages at offset pkgOffset
-     * @param pkgOffset the offset of the package
-     * @return the offset of the confirming package; or null if has not been confirmed yet
-     */
-    public Long getStatusOffset(long pkgOffset) {
-        FullMessage<PackageStatusMessage> msg = cache.get(pkgOffset);
-
-        return msg != null ? msg.getInfo().getOffset() : null;
+    public PackageStatusMessage.Status getStatus(String subAgentName, long pkgOffset) {
+        Map<Long, Status> statusPerAgent = getAgentStatus(subAgentName);
+        return statusPerAgent.get(pkgOffset);
     }
 
-    /**
-     * Clear all offsets in the cache smaller to the given pkgOffset.
-     * @param pkgOffset package offset
-     */
-    public void clear(long pkgOffset) {
-        NavigableMap<Long, FullMessage<PackageStatusMessage>> removed = cache.headMap(pkgOffset, false);
-        if (! removed.isEmpty()) {
-            LOG.info("Remove package offsets {} from status cache", removed.keySet());
-        }
-        removed.clear();
+    private Map<Long, Status> getAgentStatus(String subAgentName) {
+        return pkgStatusPerSubAgent.computeIfAbsent(subAgentName, offset -> new HashMap<Long, Messages.PackageStatusMessage.Status>());
 
 Review comment:
   Make sense

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] cschneider commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
cschneider commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#discussion_r380665097
 
 

 ##########
 File path: src/main/java/org/apache/sling/distribution/journal/impl/subscriber/PackageStatusWatcher.java
 ##########
 @@ -19,33 +19,29 @@
 package org.apache.sling.distribution.journal.impl.subscriber;
 
 
-import org.apache.sling.distribution.journal.impl.shared.Topics;
-import org.apache.sling.distribution.journal.messages.Messages;
-import org.apache.sling.distribution.journal.messages.Messages.PackageStatusMessage;
-import org.apache.sling.distribution.journal.FullMessage;
-import org.apache.sling.distribution.journal.MessageInfo;
-import org.apache.sling.distribution.journal.MessagingProvider;
-import org.apache.sling.distribution.journal.Reset;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.apache.sling.distribution.journal.HandlerAdapter.create;
 
 import java.io.Closeable;
 import java.io.IOException;
-import java.util.NavigableMap;
-import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.HashMap;
+import java.util.Map;
 
-import static org.apache.sling.distribution.journal.HandlerAdapter.create;
+import org.apache.sling.distribution.journal.MessageInfo;
+import org.apache.sling.distribution.journal.MessagingProvider;
+import org.apache.sling.distribution.journal.Reset;
+import org.apache.sling.distribution.journal.impl.shared.Topics;
+import org.apache.sling.distribution.journal.messages.Messages;
+import org.apache.sling.distribution.journal.messages.Messages.PackageStatusMessage;
+import org.apache.sling.distribution.journal.messages.Messages.PackageStatusMessage.Status;
 
 public class PackageStatusWatcher implements Closeable {
-    private static final Logger LOG = LoggerFactory.getLogger(PackageStatusWatcher.class);
-
     private final Closeable poller;
-    private final String subAgentName;
-    private final NavigableMap<Long, FullMessage<PackageStatusMessage>> cache = new ConcurrentSkipListMap<>();
+    
+    // subAgentName -> pkgOffset -> Status
+    private final Map<String, Map<Long, Status>> pkgStatusPerSubAgent = new HashMap<>();
 
 Review comment:
   Make sense

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] sonarcloud[bot] commented on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#issuecomment-586690049
 
 
   SonarCloud Quality Gate failed.
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E.png' alt='E' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) to review)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL)
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] tmaret commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
tmaret commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#discussion_r380646199
 
 

 ##########
 File path: src/main/java/org/apache/sling/distribution/journal/impl/subscriber/PackageStatusWatcher.java
 ##########
 @@ -19,33 +19,29 @@
 package org.apache.sling.distribution.journal.impl.subscriber;
 
 
-import org.apache.sling.distribution.journal.impl.shared.Topics;
-import org.apache.sling.distribution.journal.messages.Messages;
-import org.apache.sling.distribution.journal.messages.Messages.PackageStatusMessage;
-import org.apache.sling.distribution.journal.FullMessage;
-import org.apache.sling.distribution.journal.MessageInfo;
-import org.apache.sling.distribution.journal.MessagingProvider;
-import org.apache.sling.distribution.journal.Reset;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.apache.sling.distribution.journal.HandlerAdapter.create;
 
 import java.io.Closeable;
 import java.io.IOException;
-import java.util.NavigableMap;
-import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.HashMap;
+import java.util.Map;
 
-import static org.apache.sling.distribution.journal.HandlerAdapter.create;
+import org.apache.sling.distribution.journal.MessageInfo;
+import org.apache.sling.distribution.journal.MessagingProvider;
+import org.apache.sling.distribution.journal.Reset;
+import org.apache.sling.distribution.journal.impl.shared.Topics;
+import org.apache.sling.distribution.journal.messages.Messages;
+import org.apache.sling.distribution.journal.messages.Messages.PackageStatusMessage;
+import org.apache.sling.distribution.journal.messages.Messages.PackageStatusMessage.Status;
 
 public class PackageStatusWatcher implements Closeable {
-    private static final Logger LOG = LoggerFactory.getLogger(PackageStatusWatcher.class);
-
     private final Closeable poller;
-    private final String subAgentName;
-    private final NavigableMap<Long, FullMessage<PackageStatusMessage>> cache = new ConcurrentSkipListMap<>();
+    
+    // subAgentName -> pkgOffset -> Status
+    private final Map<String, Map<Long, Status>> pkgStatusPerSubAgent = new HashMap<>();
 
 Review comment:
   It seems that `pkgStatusPerSubAgent` should be a `ConcurrentMap` as `getAgentStatus` (get or set) is invoked from multiple threads.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] sonarcloud[bot] removed a comment on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#issuecomment-587393771
 
 
   SonarCloud Quality Gate failed.
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) to review)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL)
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] tmaret commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
tmaret commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#discussion_r380651535
 
 

 ##########
 File path: src/main/java/org/apache/sling/distribution/journal/impl/subscriber/StagingPrecondition.java
 ##########
 @@ -54,65 +55,51 @@
     private volatile PackageStatusWatcher watcher;
 
     private volatile boolean running = true;
-
-
+    
     @Activate
-    public void activate(Configuration config) {
-        String subAgentName = config.subAgentName();
-        watcher = new PackageStatusWatcher(messagingProvider, topics, subAgentName);
-        LOG.info("Activated Staging Precondition for subAgentName {}", subAgentName);
+    public void activate() {
+        watcher = new PackageStatusWatcher(messagingProvider, topics);
+        LOG.info("Activated Staging Precondition");
     }
 
     @Deactivate
-    public void deactivate() {
+    public synchronized void deactivate() {
         IOUtils.closeQuietly(watcher);
         running = false;
     }
 
-
     @Override
-    public boolean canProcess(long pkgOffset, int timeoutSeconds) {
-
+    public boolean canProcess(String subAgentName, long pkgOffset, int timeoutSeconds) throws InterruptedException {
         if (timeoutSeconds < 1) {
             throw new IllegalArgumentException();
         }
 
-        // clear all offsets less than the required one as they are not needed anymore.
-        // this works OK only if pkgOffset are always queried in increasing order.
-        watcher.clear(pkgOffset);
-
         // try to get the status for timeoutSeconds and then throw
-        for(int i=0; running && i < timeoutSeconds; i++) {
-            Status status = watcher.getStatus(pkgOffset);
+        for(int i=0; i < timeoutSeconds * 10; i++) {
+            Status status = getStatus(subAgentName, pkgOffset);
 
             if (status != null) {
                 return status == Status.IMPORTED;
             } else {
-                try {
-                    Thread.sleep(1000);
-                } catch (InterruptedException e) {
-                    Thread.currentThread().interrupt();
-                    throw new IllegalStateException("Precondition evaluation has been interrupted");
-                }
+                Thread.sleep(100);
+            }
+            
+            if (!running) {
+                throw new InterruptedException("Staging precondition is shutting down");
             }
         }
 
         throw new IllegalStateException("Timeout waiting for package offset " + pkgOffset + " on status topic.");
 
 Review comment:
   As we are throwing checked exceptions, we could go a step further. How about throwing `TimeoutException` instead of `IllegalStateException` when the timeout elapse?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] cschneider merged pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
cschneider merged pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] sonarcloud[bot] commented on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#issuecomment-587393771
 
 
   SonarCloud Quality Gate failed.
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) to review)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL)
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] sonarcloud[bot] removed a comment on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] removed a comment on issue #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#issuecomment-587047207
 
 
   SonarCloud Quality Gate failed.
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=BUG)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=VULNERABILITY) (and [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=SECURITY_HOTSPOT) to review)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL) [3 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&resolved=false&types=CODE_SMELL)
   
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_coverage&view=list)  
   [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal&pullRequest=24&metric=new_duplicated_lines_density&view=list)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [sling-org-apache-sling-distribution-journal] cschneider commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition

Posted by GitBox <gi...@apache.org>.
cschneider commented on a change in pull request #24: SLING-9075 - Support multiple agents with one StagingPrecondition
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/24#discussion_r380664887
 
 

 ##########
 File path: src/main/java/org/apache/sling/distribution/journal/impl/subscriber/StagingPrecondition.java
 ##########
 @@ -54,65 +55,51 @@
     private volatile PackageStatusWatcher watcher;
 
     private volatile boolean running = true;
-
-
+    
     @Activate
-    public void activate(Configuration config) {
-        String subAgentName = config.subAgentName();
-        watcher = new PackageStatusWatcher(messagingProvider, topics, subAgentName);
-        LOG.info("Activated Staging Precondition for subAgentName {}", subAgentName);
+    public void activate() {
+        watcher = new PackageStatusWatcher(messagingProvider, topics);
+        LOG.info("Activated Staging Precondition");
     }
 
     @Deactivate
-    public void deactivate() {
+    public synchronized void deactivate() {
         IOUtils.closeQuietly(watcher);
         running = false;
     }
 
-
     @Override
-    public boolean canProcess(long pkgOffset, int timeoutSeconds) {
-
+    public boolean canProcess(String subAgentName, long pkgOffset, int timeoutSeconds) throws InterruptedException {
         if (timeoutSeconds < 1) {
             throw new IllegalArgumentException();
         }
 
-        // clear all offsets less than the required one as they are not needed anymore.
-        // this works OK only if pkgOffset are always queried in increasing order.
-        watcher.clear(pkgOffset);
-
         // try to get the status for timeoutSeconds and then throw
-        for(int i=0; running && i < timeoutSeconds; i++) {
-            Status status = watcher.getStatus(pkgOffset);
+        for(int i=0; i < timeoutSeconds * 10; i++) {
+            Status status = getStatus(subAgentName, pkgOffset);
 
             if (status != null) {
                 return status == Status.IMPORTED;
             } else {
-                try {
-                    Thread.sleep(1000);
-                } catch (InterruptedException e) {
-                    Thread.currentThread().interrupt();
-                    throw new IllegalStateException("Precondition evaluation has been interrupted");
-                }
+                Thread.sleep(100);
+            }
+            
+            if (!running) {
+                throw new InterruptedException("Staging precondition is shutting down");
             }
         }
 
         throw new IllegalStateException("Timeout waiting for package offset " + pkgOffset + " on status topic.");
 
 Review comment:
   Makes sense

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services