From 4f010c912f014d4db22cc5b1e4df290fd32f29c8 Mon Sep 17 00:00:00 2001 From: Marco Vogt Date: Mon, 20 Jun 2022 13:26:19 +0200 Subject: [PATCH] Do not cancel monitoring if unable to fetch status from chronos control --- .../dmi/dbis/chronos/agent/AbstractChronosAgent.java | 11 +++++++++-- .../dmi/dbis/chronos/agent/ChronosHttpClient.java | 2 -- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/unibas/dmi/dbis/chronos/agent/AbstractChronosAgent.java b/src/main/java/ch/unibas/dmi/dbis/chronos/agent/AbstractChronosAgent.java index e7a83b0..7f6c244 100644 --- a/src/main/java/ch/unibas/dmi/dbis/chronos/agent/AbstractChronosAgent.java +++ b/src/main/java/ch/unibas/dmi/dbis/chronos/agent/AbstractChronosAgent.java @@ -45,6 +45,7 @@ of this software and associated documentation files (the "Software"), to deal import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import lombok.extern.slf4j.Slf4j; import net.lingala.zip4j.ZipFile; import net.lingala.zip4j.model.ZipParameters; @@ -678,6 +679,8 @@ private class AbortedMonitorTask extends TimerTask { private final ChronosJob observable; + private final AtomicInteger getStatusErrorCounter = new AtomicInteger( 0 ); + /** * @@ -710,9 +713,13 @@ public void run() { // Quietly cancelObservation and de-register this observable since it is already finished cancelAndRemoveObservable(); } + getStatusErrorCounter.set( 0 ); } catch ( NoSuchElementException | ChronosException | IOException ex ) { - log.warn( "getStatus for \"" + this.observable + "\" failed. Canceling monitoring!", ex ); - cancelAndRemoveObservable(); + getStatusErrorCounter.incrementAndGet(); + if ( getStatusErrorCounter.get() % 10 == 0 ) { + log.warn( "Unable to get status of \"" + this.observable + "\" since quite a while.", ex ); + } + //cancelAndRemoveObservable(); } catch ( InterruptedException ex ) { log.warn( "We have been interrupted!", ex ); cancelAndRemoveObservable(); diff --git a/src/main/java/ch/unibas/dmi/dbis/chronos/agent/ChronosHttpClient.java b/src/main/java/ch/unibas/dmi/dbis/chronos/agent/ChronosHttpClient.java index d8b2788..44c20a9 100644 --- a/src/main/java/ch/unibas/dmi/dbis/chronos/agent/ChronosHttpClient.java +++ b/src/main/java/ch/unibas/dmi/dbis/chronos/agent/ChronosHttpClient.java @@ -567,7 +567,6 @@ private boolean notifyChronos( final ChronosJob job, final Properties uploadConf Exception lastException; do { - try { // NOTICE: intentional return! return this.doNotifyChronos( job, uploadConfiguration, parameters ); @@ -579,7 +578,6 @@ private boolean notifyChronos( final ChronosJob job, final Properties uploadConf if ( norifyChronosAttempt < maxAttempts ) { Thread.sleep( failedAttemptSleepTimeMillis ); } - } while ( norifyChronosAttempt++ < maxAttempts ); throw new IOException( "The maximum number of attempts reached. See above WARNINGs for details. The last exception was: ", lastException );