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 2021/02/11 15:44:30 UTC
[sling-org-apache-sling-distribution-journal] branch master updated
(5a5b3af -> dd655d8)
This is an automated email from the ASF dual-hosted git repository.
cschneider pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-distribution-journal.git.
discard 5a5b3af GRANITE-32725 - Improve logging
new dd655d8 SLING-10066 - Improve logging
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (5a5b3af)
\
N -- N -- N refs/heads/master (dd655d8)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../apache/sling/distribution/journal/bookkeeper/PackageHandler.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[sling-org-apache-sling-distribution-journal] 01/01: SLING-10066 -
Improve logging
Posted by cs...@apache.org.
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 dd655d8de4189b5e43ddbc54342dfade9ccdde3b
Author: Christian Schneider <cs...@adobe.com>
AuthorDate: Thu Feb 11 16:44:16 2021 +0100
SLING-10066 - Improve logging
---
.../journal/bookkeeper/BookKeeper.java | 31 +++++++++++++++-------
.../journal/bookkeeper/PackageHandler.java | 2 +-
.../impl/publisher/DistributionPublisher.java | 4 +--
3 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/src/main/java/org/apache/sling/distribution/journal/bookkeeper/BookKeeper.java b/src/main/java/org/apache/sling/distribution/journal/bookkeeper/BookKeeper.java
index 30e761b..3d87eb2 100644
--- a/src/main/java/org/apache/sling/distribution/journal/bookkeeper/BookKeeper.java
+++ b/src/main/java/org/apache/sling/distribution/journal/bookkeeper/BookKeeper.java
@@ -28,6 +28,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
@@ -140,8 +141,9 @@ public class BookKeeper implements Closeable {
* once, thanks to the order in which the content updates are applied.
*/
public void importPackage(PackageMessage pkgMsg, long offset, long createdTime) throws DistributionException {
- log.info("Importing distribution package {} of type {} at offset {}",
- pkgMsg.getPkgId(), pkgMsg.getReqType(), offset);
+ String firstPath = getFirstPath(pkgMsg);
+ log.info("Importing distribution package {} of type {} at offset {} first path {} url {}",
+ pkgMsg.getPkgId(), pkgMsg.getReqType(), offset, firstPath, pkgMsg.getPkgBinaryRef());
addPackageMDC(pkgMsg);
try (Timer.Context context = distributionMetricsService.getImportedPackageDuration().time();
ResourceResolver importerResolver = getServiceResolver(SUBSERVICE_IMPORTER)) {
@@ -191,16 +193,22 @@ public class BookKeeper implements Closeable {
String pubAgentName = pkgMsg.getPubAgentName();
int retries = packageRetries.get(pubAgentName);
- if (errorQueueEnabled && retries >= config.getMaxRetries()) {
- log.warn("Failed to import distribution package {} at offset {} after {} retries, removing the package. Url {}",
- pkgMsg.getPkgId(), offset, retries, pkgMsg.getPkgBinaryRef());
+ boolean giveUp = errorQueueEnabled && retries >= config.getMaxRetries();
+ String retriesSt = errorQueueEnabled ? Integer.toString(config.getMaxRetries()) : "infinite";
+ String action = giveUp ? "removing the package" : "retrying";
+ String firstPath = getFirstPath(pkgMsg);
+ String msg = format("Error processing distribution package %s at offset %d first path %s. Retry attempts %s/%s. Url: %s, %s, Message: %s", pkgMsg.getPkgId(), offset, firstPath, retries, retriesSt, pkgMsg.getPkgBinaryRef(), action, e.getMessage());
+ try {
+ LogMessage logMessage = getLogMessage(pubAgentName, msg, e);
+ logSender.accept(logMessage);
+ } catch (Exception e2) {
+ log.warn("Error sending log message", e2);
+ };
+ if (giveUp) {
+ log.warn(msg, e);
removeFailedPackage(pkgMsg, offset);
} else {
packageRetries.increase(pubAgentName);
- String retriesSt = errorQueueEnabled ? Integer.toString(config.getMaxRetries()) : "infinite";
- String msg = format("Error processing distribution package %s. Retry attempts %s/%s. Url: {}, Message: %s", pkgMsg.getPkgId(), retries, retriesSt, pkgMsg.getPkgBinaryRef(), e.getMessage());
- LogMessage logMessage = getLogMessage(pubAgentName, msg, e);
- logSender.accept(logMessage);
throw new DistributionException(msg, e);
}
}
@@ -339,6 +347,11 @@ public class BookKeeper implements Closeable {
private ResourceResolver getServiceResolver(String subService) throws LoginException {
return resolverFactory.getServiceResourceResolver(singletonMap(SUBSERVICE, subService));
}
+
+ private String getFirstPath(PackageMessage pkg) {
+ Iterator<String> it = pkg.getPaths().iterator();
+ return it.hasNext() ? it.next() : "";
+ }
static void retryDelay() {
try {
diff --git a/src/main/java/org/apache/sling/distribution/journal/bookkeeper/PackageHandler.java b/src/main/java/org/apache/sling/distribution/journal/bookkeeper/PackageHandler.java
index 2847468..7ee64f9 100644
--- a/src/main/java/org/apache/sling/distribution/journal/bookkeeper/PackageHandler.java
+++ b/src/main/java/org/apache/sling/distribution/journal/bookkeeper/PackageHandler.java
@@ -71,7 +71,7 @@ class PackageHandler {
private void installAddPackage(ResourceResolver resolver, PackageMessage pkgMsg)
throws DistributionException {
- LOG.info("Importing paths {}",pkgMsg.getPaths());
+ LOG.debug("Importing paths {}",pkgMsg.getPaths());
InputStream pkgStream = null;
try {
pkgStream = stream(resolver, pkgMsg, binaryStore);
diff --git a/src/main/java/org/apache/sling/distribution/journal/impl/publisher/DistributionPublisher.java b/src/main/java/org/apache/sling/distribution/journal/impl/publisher/DistributionPublisher.java
index 83a7dcf..84aa594 100644
--- a/src/main/java/org/apache/sling/distribution/journal/impl/publisher/DistributionPublisher.java
+++ b/src/main/java/org/apache/sling/distribution/journal/impl/publisher/DistributionPublisher.java
@@ -27,7 +27,6 @@ import static org.apache.sling.distribution.DistributionRequestType.TEST;
import static org.apache.sling.distribution.journal.shared.DistributionMetricsService.timed;
import java.io.Closeable;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
@@ -275,7 +274,8 @@ public class DistributionPublisher implements DistributionAgent {
);
distributionMetricsService.getExportedPackageSize().update(pkg.getPkgLength());
distributionMetricsService.getAcceptedRequests().mark();
- String msg = String.format("Distribution request accepted with type %s paths %s ", request.getRequestType(), Arrays.toString(request.getPaths()));
+ String firstPath = pkg.getPaths().iterator().next();
+ String msg = String.format("Distribution request accepted with type %s paths %s, url %s", request.getRequestType(), firstPath, pkg.getPkgBinaryRef());
log.info(msg);
return new SimpleDistributionResponse(ACCEPTED, msg);
} catch (Throwable e) {