You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by jo...@apache.org on 2025/02/21 11:29:11 UTC

(sling-org-apache-sling-jcr-repoinit) branch master updated: SLING-12663 log duration of successful repoinit execution (#60)

This is an automated email from the ASF dual-hosted git repository.

joerghoh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-repoinit.git


The following commit(s) were added to refs/heads/master by this push:
     new f9727a1  SLING-12663 log duration of successful repoinit execution (#60)
f9727a1 is described below

commit f9727a1064fd13b39dbf11a51c9d87edbfb5e9d4
Author: Jörg Hoh <jo...@users.noreply.github.com>
AuthorDate: Fri Feb 21 12:29:06 2025 +0100

    SLING-12663 log duration of successful repoinit execution (#60)
---
 .../org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java    | 5 +++++
 .../apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
index aefc0d2..67bbcf0 100644
--- a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
+++ b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializer.java
@@ -23,6 +23,8 @@ import javax.jcr.Session;
 
 import java.io.IOException;
 import java.io.StringReader;
+import java.time.Duration;
+import java.time.Instant;
 import java.util.Arrays;
 import java.util.List;
 
@@ -98,6 +100,7 @@ public class RepositoryInitializer implements SlingRepositoryInitializer {
             @SuppressWarnings("deprecation")
             final Session s = repo.loginAdministrative(null);
             try {
+                Instant start = Instant.now();
                 final RepoinitTextProvider p = new RepoinitTextProvider();
                 for (String reference : config.references()) {
                     try {
@@ -115,6 +118,8 @@ public class RepositoryInitializer implements SlingRepositoryInitializer {
                         throw new RepoInitException("Error executing repoinit from " + reference, e);
                     }
                 }
+                Duration duration = Duration.between(start, Instant.now());
+                log.info("Total time for successful repoinit execution: {} miliseconds", duration.toMillis());
             } finally {
                 s.logout();
             }
diff --git a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java
index 24f1344..dc432cf 100644
--- a/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java
+++ b/src/main/java/org/apache/sling/jcr/repoinit/impl/RepositoryInitializerFactory.java
@@ -23,6 +23,8 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import java.io.StringReader;
+import java.time.Duration;
+import java.time.Instant;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
@@ -125,6 +127,7 @@ public class RepositoryInitializerFactory implements SlingRepositoryInitializer
             @SuppressWarnings("deprecation")
             final Session s = repo.loginAdministrative(null);
             try {
+                Instant start = Instant.now();
                 if (config.references() != null) {
                     final RepoinitTextProvider p = new RepoinitTextProvider();
                     for (final String reference : config.references()) {
@@ -163,6 +166,8 @@ public class RepositoryInitializerFactory implements SlingRepositoryInitializer
                         scriptIndex++;
                     }
                 }
+                Duration duration = Duration.between(start, Instant.now());
+                log.info("Total time for successful repoinit execution: {} miliseconds", duration.toMillis());
             } finally {
                 s.logout();
             }