summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntje Fuhrmann2013-02-08 04:47:33 (EST)
committerSven Rottstock2013-03-11 04:54:16 (EDT)
commit4c6a24342da2aeb04e46f946bf74ef65f3560751 (patch)
treeca55ad878fceb8d078d717f89d4f2c97bf846bde
parentef6dd836688a0e2d235b72f6d3c2ad113bb16d5c (diff)
downloadorg.eclipse.stardust.engine-4c6a24342da2aeb04e46f946bf74ef65f3560751.zip
org.eclipse.stardust.engine-4c6a24342da2aeb04e46f946bf74ef65f3560751.tar.gz
org.eclipse.stardust.engine-4c6a24342da2aeb04e46f946bf74ef65f3560751.tar.bz2
Jira-ID: CRNT-27756
Improve Logging in FiFoJobManager git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/engine@62856 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--stardust-engine-spring/src/main/java/org/eclipse/stardust/engine/spring/threading/FiFoJobManager.java60
1 files changed, 53 insertions, 7 deletions
diff --git a/stardust-engine-spring/src/main/java/org/eclipse/stardust/engine/spring/threading/FiFoJobManager.java b/stardust-engine-spring/src/main/java/org/eclipse/stardust/engine/spring/threading/FiFoJobManager.java
index 7337a02..a617429 100644
--- a/stardust-engine-spring/src/main/java/org/eclipse/stardust/engine/spring/threading/FiFoJobManager.java
+++ b/stardust-engine-spring/src/main/java/org/eclipse/stardust/engine/spring/threading/FiFoJobManager.java
@@ -12,6 +12,7 @@ package org.eclipse.stardust.engine.spring.threading;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.stardust.common.error.PublicException;
import org.eclipse.stardust.common.log.LogManager;
@@ -42,6 +43,15 @@ public class FiFoJobManager implements IJobManager, ApplicationListener, Initial
private Thread shutdownHook;
+ private String threadSuffix = "Thread";
+
+ private final AtomicLong threadSeqNumber = new AtomicLong();
+
+ private long nextThreadID()
+ {
+ return threadSeqNumber.incrementAndGet();
+ }
+
public FiFoJobManager()
{
this.dispatcher = new JobDispatcher();
@@ -60,9 +70,10 @@ public class FiFoJobManager implements IJobManager, ApplicationListener, Initial
{
try
{
- this.dispatcherThread = new Thread(dispatcher);
+ this.dispatcherThread = new Thread(dispatcher, getThreadSuffix() + nextThreadID());
dispatcherThread.setDaemon(true);
- trace.info("Starting dispatcher thread ...");
+ trace.warn("This configuration is not supported for productive use and a XA enabled messaging configuration should be used instead.");
+ trace.info("Starting dispatcher thread for " + getThreadSuffix() + "...");
dispatcherThread.start();
}
catch (Throwable t)
@@ -111,12 +122,18 @@ public class FiFoJobManager implements IJobManager, ApplicationListener, Initial
{
if ((null == dispatcherThread) || !dispatcherThread.isAlive())
{
- this.dispatcherThread = new Thread(dispatcher);
- trace.info("Starting new dispatcher thread ...");
+ this.dispatcherThread = new Thread(dispatcher, getThreadSuffix() + nextThreadID());
+ trace.info("Starting new dispatcher thread for " + getThreadSuffix()
+ + "...");
dispatcherThread.start();
}
scheduledJobs.add(job);
+ if (trace.isInfoEnabled())
+ {
+ trace.info("Enqueued job " + job + ". Scheduled queue length is now "
+ + scheduledJobs.size());
+ }
dispatcher.notify();
}
}
@@ -143,6 +160,11 @@ public class FiFoJobManager implements IJobManager, ApplicationListener, Initial
}
activeJobs.remove(job);
+ if (trace.isDebugEnabled())
+ {
+ trace.debug("Finished job " + job
+ + ". Active jobs queue length is now " + activeJobs.size());
+ }
}
}
@@ -154,7 +176,7 @@ public class FiFoJobManager implements IJobManager, ApplicationListener, Initial
{
public void run()
{
- trace.info("Dispatcher thread was started ...");
+ trace.info("Dispatcher thread was started for "+getThreadSuffix()+"...");
Job nextJob = null;
do
@@ -174,16 +196,26 @@ public class FiFoJobManager implements IJobManager, ApplicationListener, Initial
}
nextJob = (Job) scheduledJobs.remove(0);
+ if (trace.isDebugEnabled())
+ {
+ trace.debug("Dequened next job " + nextJob
+ + ". Scheduled queue length is now " + scheduledJobs.size());
+ }
}
if (SHUTDOWN_REQUEST != nextJob)
{
try
{
- Thread jobThread = new Thread(new JobRunner(nextJob));
+ Thread jobThread = new Thread(new JobRunner(nextJob), getThreadSuffix() + nextThreadID());
synchronized (activeJobs)
{
activeJobs.add(nextJob);
+ if (trace.isInfoEnabled())
+ {
+ trace.info("Adding job " + nextJob
+ + ". Active jobs queue length is now " + activeJobs.size());
+ }
}
jobThread.start();
}
@@ -228,6 +260,10 @@ public class FiFoJobManager implements IJobManager, ApplicationListener, Initial
{
try
{
+ if (trace.isDebugEnabled())
+ {
+ trace.debug("Executing job " + job);
+ }
job.runnable.run();
notifyJobCompleted(job, null);
@@ -240,5 +276,15 @@ public class FiFoJobManager implements IJobManager, ApplicationListener, Initial
// terminate thread
}
}
-
+
+ public String getThreadSuffix()
+ {
+ return threadSuffix;
+ }
+
+ public void setThreadSuffix(String threadSuffix)
+ {
+ this.threadSuffix = threadSuffix;
+ }
+
}