Bug 9238: DataStoreJobCoordinator now logs JobEntry before thread death 66/63966/4
authorMichael Vorburger <vorburger@redhat.com>
Wed, 4 Oct 2017 23:20:44 +0000 (01:20 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Fri, 6 Oct 2017 09:37:47 +0000 (09:37 +0000)
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 <vorburger@redhat.com>
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/datastoreutils/DataStoreJobCoordinator.java

index 76cc192428a4b9cf5f5bfc5d81be20826dcc1b2b..5100dce7aceaf35936fb6ac55f3ce9b392bbb887 100755 (executable)
@@ -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<ListenableFuture<Void>> 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<ListenableFuture<Void>> futures = null;
             long jobStartTimestamp = System.currentTimeMillis();
             LOG.trace("Running job {}", jobEntry.getKey());