You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cs...@apache.org on 2020/01/17 09:11:55 UTC
[sling-org-apache-sling-distribution-journal] 01/02: SLING-8932 -
Make calls more concise
This is an automated email from the ASF dual-hosted git repository.
cschneider pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-journal.git
commit 25cd04421d57eeb98a8013eb21db21624ecbe846
Author: Christian Schneider <cs...@adobe.com>
AuthorDate: Fri Jan 17 08:46:21 2020 +0100
SLING-8932 - Make calls more concise
---
.../sling/distribution/journal/impl/subscriber/BookKeeper.java | 8 +++++++-
.../journal/impl/subscriber/DistributionSubscriber.java | 6 +++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/BookKeeper.java b/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/BookKeeper.java
index d39e57f..d56713c 100644
--- a/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/BookKeeper.java
+++ b/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/BookKeeper.java
@@ -231,7 +231,11 @@ public class BookKeeper implements Closeable {
}
}
- public void sendStoredStatus() throws InterruptedException, IOException {
+ /**
+ * Send status stored in a previous run if exists
+ * @throws InterruptedException
+ */
+ public void sendStoredStatus() throws InterruptedException {
try (Timer.Context context = distributionMetricsService.getSendStoredStatusDuration().time()) {
PackageStatus status = new PackageStatus(statusStore.load());
boolean sent = status.sent;
@@ -245,6 +249,8 @@ public class BookKeeper implements Closeable {
Thread.sleep(RETRY_SEND_DELAY);
}
}
+ } catch (IOException e) {
+ log.warn("Error in timer close", e);
}
}
diff --git a/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java b/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java
index 3a40fbf..14dd87d 100644
--- a/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java
+++ b/src/main/java/org/apache/sling/distribution/journal/impl/subscriber/DistributionSubscriber.java
@@ -360,17 +360,17 @@ public class DistributionSubscriber implements DistributionAgent {
private void fetchAndProcessQueueItem() throws InterruptedException {
try {
- // send status stored in a previous run if exists
+
bookKeeper.sendStoredStatus();
- // block until an item is available
DistributionQueueItem item = blockingPeekQueueItem();
- // and then process it
+
subscriberIdle.busy();
try (Timer.Context context = distributionMetricsService.getProcessQueueItemDuration().time()) {
processQueueItem(item);
} finally {
subscriberIdle.idle();
}
+
} catch (IllegalStateException e) {
/**
* Precondition timed out. We only log this on info level as it is no error