Add task termination traces 66/82566/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 19 Jun 2019 10:57:35 +0000 (12:57 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 8 Jul 2019 10:58:46 +0000 (10:58 +0000)
This adds trace messages to discern when execution of callbacks
is completed.

Change-Id: I61cee9098c9ef29e1e02b6e87edd06ade9178370
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/nodeconfigurator/NodeConfiguratorImpl.java

index c51eec0bc65b19b5f36fed3ab8f5eb2ebb0a1055..d2d384442190934a6d35e9760143985cfe7b2873 100644 (file)
@@ -38,8 +38,9 @@ public class NodeConfiguratorImpl implements NodeConfigurator {
                 .setUncaughtExceptionHandler((thread, ex) -> LOG.error("Uncaught exception {}", thread, ex))
                 .build());
         manager = QueuedNotificationManager.create(syncThreadPool, (key, entries) -> {
-            LOG.trace("Executing job with key: {}", key);
+            LOG.trace("Executing jobs with key: {}", key);
             entries.forEach(jobEntry -> new MainTask<>(jobEntry).run());
+            LOG.trace("Finished executing jobs with key: {}", key);
         }, 4096, "nc-jobqueue");
     }
 
@@ -84,22 +85,24 @@ public class NodeConfiguratorImpl implements NodeConfigurator {
                 LOG.error("Direct Exception (not failed Future) when executing job, won't even retry: {}", jobEntry, e);
             }
 
-            if (future == null) {
+            if (future != null) {
+                Futures.addCallback(future, new FutureCallback<T>() {
+                    @Override
+                    public void onSuccess(final T result) {
+                        LOG.trace("Job completed successfully: {}", jobEntry.getKey());
+                        jobEntry.setResultFuture(result);
+                    }
+
+                    @Override
+                    public void onFailure(final Throwable cause) {
+                        LOG.error("Job {} failed", jobEntry.getKey(), cause);
+                    }
+                }, MoreExecutors.directExecutor());
+            } else {
                 jobEntry.setResultFuture(null);
-                return;
             }
-            Futures.addCallback(future, new FutureCallback<T>() {
-                @Override
-                public void onSuccess(final T result) {
-                    LOG.trace("Job completed successfully: {}", jobEntry.getKey());
-                    jobEntry.setResultFuture(result);
-                }
 
-                @Override
-                public void onFailure(final Throwable cause) {
-                    LOG.error("Job {} failed", jobEntry.getKey(), cause);
-                }
-            }, MoreExecutors.directExecutor());
+            LOG.trace("Finished running job with key: {}", jobEntry.getKey());
         }
     }
 }