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 2022/03/02 12:34:00 UTC

[GitHub] [sling-org-apache-sling-distribution-journal] jose-correia commented on a change in pull request #101: SLING-10585 - Add support for invalidation requests

jose-correia commented on a change in pull request #101:
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/101#discussion_r817628741



##########
File path: src/main/java/org/apache/sling/distribution/journal/bookkeeper/BookKeeper.java
##########
@@ -172,7 +172,26 @@ public void importPackage(PackageMessage pkgMsg, long offset, long createdTime)
             failure(pkgMsg, offset, e);
         }
     }
-    
+
+    public void invalidateCache(PackageMessage pkgMsg, long offset) throws LoginException, PersistenceException, ImportPostProcessException {
+        log.debug("Invalidating the cache for the package {}", pkgMsg);
+        try (ResourceResolver resolver = getServiceResolver(SUBSERVICE_BOOKKEEPER)) {
+            if (config.isEditable()) {
+                storeStatus(resolver, new PackageStatus(Status.INVALIDATED, offset, pkgMsg.getPubAgentName()));
+            }
+            storeOffset(resolver, offset);
+            resolver.commit();
+
+            postProcess(pkgMsg);
+
+            packageRetries.clear(pkgMsg.getPubAgentName());
+
+            Event event = new ImportedEvent(pkgMsg, config.getSubAgentName()).toEvent();
+            eventAdmin.postEvent(event);
+            log.info("Invalidated the cache for the package {}", pkgMsg);

Review comment:
       same log change here

##########
File path: src/main/java/org/apache/sling/distribution/journal/bookkeeper/BookKeeper.java
##########
@@ -172,7 +172,26 @@ public void importPackage(PackageMessage pkgMsg, long offset, long createdTime)
             failure(pkgMsg, offset, e);
         }
     }
-    
+
+    public void invalidateCache(PackageMessage pkgMsg, long offset) throws LoginException, PersistenceException, ImportPostProcessException {
+        log.debug("Invalidating the cache for the package {}", pkgMsg);
+        try (ResourceResolver resolver = getServiceResolver(SUBSERVICE_BOOKKEEPER)) {
+            if (config.isEditable()) {
+                storeStatus(resolver, new PackageStatus(Status.INVALIDATED, offset, pkgMsg.getPubAgentName()));
+            }
+            storeOffset(resolver, offset);
+            resolver.commit();
+
+            postProcess(pkgMsg);
+
+            packageRetries.clear(pkgMsg.getPubAgentName());
+
+            Event event = new ImportedEvent(pkgMsg, config.getSubAgentName()).toEvent();

Review comment:
       I'm wondering if this `ImportedEvent` class should have a more abstract naming, something like `PackageEvent`. This way it doesn't cause confusion.

##########
File path: src/main/java/org/apache/sling/distribution/journal/bookkeeper/BookKeeper.java
##########
@@ -172,7 +172,26 @@ public void importPackage(PackageMessage pkgMsg, long offset, long createdTime)
             failure(pkgMsg, offset, e);
         }
     }
-    
+
+    public void invalidateCache(PackageMessage pkgMsg, long offset) throws LoginException, PersistenceException, ImportPostProcessException {
+        log.debug("Invalidating the cache for the package {}", pkgMsg);

Review comment:
       Maybe we should log the offset here, like in the `importPackage` and `removePackage` methods

##########
File path: src/main/java/org/apache/sling/distribution/journal/impl/publisher/DistributionPublisher.java
##########
@@ -147,6 +145,7 @@ public DistributionPublisher() {
         log = new DefaultDistributionLog(pubAgentName, this.getClass(), DefaultDistributionLog.LogLevel.INFO);
         reqTypes.put(ADD,    this::sendAndWait);
         reqTypes.put(DELETE, this::sendAndWait);
+        reqTypes.put(INVALIDATE, this::sendAndWait);
         reqTypes.put(TEST,   this::send);

Review comment:
       💅 maybe fix the indentation of the other lines to be like it was before, with the `this::sendAndWait` aligned.




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org