From 40a963541dd906011258be84cfa67224dfb83ddc Mon Sep 17 00:00:00 2001 From: hanna Date: Mon, 19 Jul 2010 00:58:54 +0000 Subject: [PATCH] Uniquify the registered MXBean by adding an instanceNumber=... tag to the ObjectName. In the Queue-enabled future, we might want to come up with GUIDs (or at least semi-unique IDs) so that we could use JMX to track runtime attributes for multiple jobs running simultaneously. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3825 348d0f76-0448-11de-a6fe-93d51630548a --- .../executive/HierarchicalMicroScheduler.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java b/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java index a6ed2f2b4..44f3730c6 100755 --- a/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java +++ b/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java @@ -30,6 +30,11 @@ import net.sf.picard.reference.IndexedFastaSequenceFile; * Requires a special walker tagged with a 'TreeReducible' interface. */ public class HierarchicalMicroScheduler extends MicroScheduler implements HierarchicalMicroSchedulerMBean, ReduceTree.TreeReduceNotifier { + /** + * Counts the number of instances of the class that are currently alive. + */ + private static int instanceNumber = 0; + /** * How many outstanding output merges are allowed before the scheduler stops * allowing new processes and starts merging flat-out. @@ -85,9 +90,17 @@ public class HierarchicalMicroScheduler extends MicroScheduler implements Hierar this.threadPool = Executors.newFixedThreadPool(nThreadsToUse); + // JMX does not allow multiple instances with the same ObjectName to be registered with the same platform MXBean. + // To get around this limitation and since we have no job identifier at this point, register a simple counter that + // will count the number of instances of this object that have been created in this JVM. + int thisInstance; + synchronized(HierarchicalMicroScheduler.class) { + thisInstance = instanceNumber++; + } + try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); - ObjectName name = new ObjectName("org.broadinstitute.sting.gatk.executive:type=HierarchicalMicroScheduler"); + ObjectName name = new ObjectName("org.broadinstitute.sting.gatk.executive:type=HierarchicalMicroScheduler,instanceNumber="+thisInstance); mbs.registerMBean(this, name); } catch (JMException ex) {