From 805d22a98f5040c2c3e859a10cbe97966310e9da Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Thu, 5 Oct 2017 01:20:44 +0200 Subject: [PATCH] Bug 9238: DataStoreJobCoordinator now logs JobEntry before thread death This is just the "port" of https://git.opendaylight.org/gerrit/#/c/63965/ from infrautils to genius. This is the last time I maintain this code in both places! https://git.opendaylight.org/gerrit/#/q/topic:genius.DJC-to-infra.JC coming real soon, now. Change-Id: Ia73c1bc9036fa099a0ae49dc227a98d24acd9bb6 Signed-off-by: Michael Vorburger --- .../datastoreutils/DataStoreJobCoordinator.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/datastoreutils/DataStoreJobCoordinator.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/datastoreutils/DataStoreJobCoordinator.java index 76cc19242..5100dce7a 100755 --- a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/datastoreutils/DataStoreJobCoordinator.java +++ b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/datastoreutils/DataStoreJobCoordinator.java @@ -25,6 +25,7 @@ import java.util.concurrent.locks.ReentrantLock; import javax.annotation.concurrent.GuardedBy; import org.opendaylight.infrautils.utils.concurrent.LoggingThreadUncaughtExceptionHandler; +import org.opendaylight.infrautils.utils.concurrent.LoggingUncaughtThreadDeathContextRunnable; import org.opendaylight.infrautils.utils.concurrent.ThreadFactoryProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -227,16 +228,17 @@ public class DataStoreJobCoordinator { * RollbackTask is used to execute the RollbackCallable provided by the * application in the eventuality of a failure. */ - private class RollbackTask implements Runnable { + private class RollbackTask extends LoggingUncaughtThreadDeathContextRunnable { private final JobEntry jobEntry; RollbackTask(JobEntry jobEntry) { + super(LOG, jobEntry::toString); this.jobEntry = jobEntry; } @Override @SuppressWarnings("checkstyle:IllegalCatch") - public void run() { + public void runWithUncheckedExceptionLogging() { RollbackCallable callable = jobEntry.getRollbackWorker(); callable.setFutures(jobEntry.getFutures()); List> futures = null; @@ -261,17 +263,18 @@ public class DataStoreJobCoordinator { /** * Execute the MainWorker callable. */ - private class MainTask implements Runnable { + private class MainTask extends LoggingUncaughtThreadDeathContextRunnable { private static final int LONG_JOBS_THRESHOLD = 1000; // MS private final JobEntry jobEntry; MainTask(JobEntry jobEntry) { + super(LOG, jobEntry::toString); this.jobEntry = jobEntry; } @Override @SuppressWarnings("checkstyle:illegalcatch") - public void run() { + public void runWithUncheckedExceptionLogging() { List> futures = null; long jobStartTimestamp = System.currentTimeMillis(); LOG.trace("Running job {}", jobEntry.getKey()); -- 2.36.6