From b8194b9bff386ad3e46bfc0901fc394b58a43cff Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 19 Jun 2019 12:57:35 +0200 Subject: [PATCH] Add task termination traces This adds trace messages to discern when execution of callbacks is completed. Change-Id: I61cee9098c9ef29e1e02b6e87edd06ade9178370 Signed-off-by: Robert Varga --- .../NodeConfiguratorImpl.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/nodeconfigurator/NodeConfiguratorImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/nodeconfigurator/NodeConfiguratorImpl.java index c51eec0bc6..d2d3844421 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/nodeconfigurator/NodeConfiguratorImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/nodeconfigurator/NodeConfiguratorImpl.java @@ -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() { + @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() { - @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()); } } } -- 2.36.6