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 2019/07/12 10:29:15 UTC

[sling-org-apache-sling-distribution-journal] branch master updated: SLING-8531 - Make some fields final, fix parent pom

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


The following commit(s) were added to refs/heads/master by this push:
     new 7819bc6  SLING-8531 - Make some fields final, fix parent pom
7819bc6 is described below

commit 7819bc61cbbccdf361b2d04239ec4171e67b214b
Author: Christian Schneider <cs...@adobe.com>
AuthorDate: Fri Jul 12 12:29:07 2019 +0200

    SLING-8531 - Make some fields final, fix parent pom
---
 pom.xml                                             |  2 +-
 .../impl/shared/JournalAvailableChecker.java        | 21 ++++++++++++---------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/pom.xml b/pom.xml
index e204997..5a458b1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
     <!-- ======================================================================= -->
     <parent>
         <groupId>org.apache.sling</groupId>
-        <artifactId>sling</artifactId>
+        <artifactId>sling-bundle-parent</artifactId>
         <version>35</version>
         <relativePath />
     </parent>
diff --git a/src/main/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableChecker.java b/src/main/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableChecker.java
index 0514706..c7397c0 100644
--- a/src/main/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableChecker.java
+++ b/src/main/java/org/apache/sling/distribution/journal/impl/shared/JournalAvailableChecker.java
@@ -54,6 +54,10 @@ public class JournalAvailableChecker implements JournalAvailable, EventHandler {
     public static final int MIN_ERRORS = 2;
 
     private static final Logger LOG = LoggerFactory.getLogger(JournalAvailableChecker.class);
+    
+    private final ExponentialBackOff backoffRetry;
+    
+    private final AtomicInteger numErrors;
 
     @Reference
     Topics topics;
@@ -70,20 +74,19 @@ public class JournalAvailableChecker implements JournalAvailable, EventHandler {
 
     private GaugeService<Boolean> gauge;
 
-    private ExponentialBackOff backoffRetry;
-    
-    private AtomicInteger numErrors;
+    public JournalAvailableChecker() {
+        this.numErrors = new AtomicInteger();
+        this.backoffRetry = new ExponentialBackOff(INITIAL_RETRY_DELAY, MAX_RETRY_DELAY, true, this::run);
+    }
     
     @Activate
     public void activate(BundleContext context) {
         requireNonNull(provider);
         requireNonNull(topics);
         this.context = context;
-        this.numErrors = new AtomicInteger();
-        gauge = metrics.createGauge(DistributionMetricsService.BASE_COMPONENT + ".journal_available", "", this::isAvailable);
-        LOG.info("Started Journal availability checker service");
-        this.backoffRetry = new ExponentialBackOff(INITIAL_RETRY_DELAY, MAX_RETRY_DELAY, true, this::run);
         this.backoffRetry.startChecks();
+        this.gauge = metrics.createGauge(DistributionMetricsService.BASE_COMPONENT + ".journal_available", "", this::isAvailable);
+        LOG.info("Started Journal availability checker service");
     }
 
     @Deactivate
@@ -108,7 +111,7 @@ public class JournalAvailableChecker implements JournalAvailable, EventHandler {
         }
     }
     
-    private void unAvailable(Exception e) {
+    private void stillUnAvailable(Exception e) {
         String msg = "Journal is still unavailable: " + e.getMessage();
         if (LOG.isDebugEnabled()) {
             LOG.warn(msg, e);
@@ -128,7 +131,7 @@ public class JournalAvailableChecker implements JournalAvailable, EventHandler {
             doChecks();
             available();
         } catch (Exception e) {
-            unAvailable(e);
+            stillUnAvailable(e);
             throw e;
         }
     }