camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] git commit: CAMEL-7034: Ensure quartz scheduler instance name is unique in JVMs and assigned ththe same way when using Camels quartz component.
Date Tue, 03 Dec 2013 10:55:46 GMT
Updated Branches:
  refs/heads/camel-2.12.x 52aa7a119 -> b275fb6a4
  refs/heads/master 126c312c2 -> b26df9f01


CAMEL-7034: Ensure quartz scheduler instance name is unique in JVMs and assigned ththe same
way when using Camels quartz component.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b26df9f0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b26df9f0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b26df9f0

Branch: refs/heads/master
Commit: b26df9f012568fe1d6997e06d05c78570db21a3e
Parents: 126c312
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Dec 3 11:55:21 2013 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Dec 3 11:55:21 2013 +0100

----------------------------------------------------------------------
 .../camel/component/quartz/QuartzComponent.java | 28 ++++++++++++++------
 .../component/quartz2/QuartzComponent.java      | 28 ++++++++++++++------
 2 files changed, 40 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b26df9f0/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
index acfafbb..f852115 100644
--- a/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
+++ b/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
@@ -449,6 +449,10 @@ public class QuartzComponent extends DefaultComponent implements StartupListener
             // force disabling update checker (will do online check over the internet)
             prop.put("org.quartz.scheduler.skipUpdateCheck", "true");
 
+            // camel context name will be a suffix to use one scheduler per context
+            String instName = createInstanceName(prop);
+            prop.setProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, instName);
+
             // enable jmx unless configured to not do so
             if (enableJmx && !prop.containsKey("org.quartz.scheduler.jmx.export"))
{
                 LOG.info("Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s)
will be enlisted in JMX.");
@@ -474,14 +478,7 @@ public class QuartzComponent extends DefaultComponent implements StartupListener
             }
 
             // camel context name will be a suffix to use one scheduler per context
-            String identity = getCamelContext().getName();
-
-            String instName = prop.getProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME);
-            if (instName == null) {
-                instName = "scheduler-" + identity;
-            } else {
-                instName = instName + "-" + identity;
-            }
+            String instName = createInstanceName(prop);
             prop.setProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, instName);
 
             // force disabling update checker (will do online check over the internet)
@@ -503,6 +500,21 @@ public class QuartzComponent extends DefaultComponent implements StartupListener
         return answer;
     }
 
+    protected String createInstanceName(Properties prop) {
+        String instName = prop.getProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME);
+
+        // camel context name will be a suffix to use one scheduler per context
+        String identity = getCamelContext().getManagementName();
+        if (identity != null) {
+            if (instName == null) {
+                instName = "scheduler-" + identity;
+            } else {
+                instName = instName + "-" + identity;
+            }
+        }
+        return instName;
+    }
+
     protected Scheduler createScheduler() throws SchedulerException {
         Scheduler scheduler = getFactory().getScheduler();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/b26df9f0/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java
b/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java
index 5d5c308..cfaf801 100644
--- a/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java
+++ b/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java
@@ -129,6 +129,10 @@ public class QuartzComponent extends DefaultComponent implements StartupListener
             prop.put("org.quartz.scheduler.skipUpdateCheck", "true");
             prop.put("org.terracotta.quartz.skipUpdateCheck", "true");
 
+            // camel context name will be a suffix to use one scheduler per context
+            String instName = createInstanceName(prop);
+            prop.setProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, instName);
+
             // enable jmx unless configured to not do so
             if (enableJmx && !prop.containsKey("org.quartz.scheduler.jmx.export"))
{
                 prop.put("org.quartz.scheduler.jmx.export", "true");
@@ -154,14 +158,7 @@ public class QuartzComponent extends DefaultComponent implements StartupListener
             }
 
             // camel context name will be a suffix to use one scheduler per context
-            String identity = getCamelContext().getManagementName();
-
-            String instName = prop.getProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME);
-            if (instName == null) {
-                instName = "scheduler-" + identity;
-            } else {
-                instName = instName + "-" + identity;
-            }
+            String instName = createInstanceName(prop);
             prop.setProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, instName);
 
             // force disabling update checker (will do online check over the internet)
@@ -184,6 +181,21 @@ public class QuartzComponent extends DefaultComponent implements StartupListener
         return answer;
     }
 
+    protected String createInstanceName(Properties prop) {
+        String instName = prop.getProperty(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME);
+
+        // camel context name will be a suffix to use one scheduler per context
+        String identity = getCamelContext().getManagementName();
+        if (identity != null) {
+            if (instName == null) {
+                instName = "scheduler-" + identity;
+            } else {
+                instName = instName + "-" + identity;
+            }
+        }
+        return instName;
+    }
+
     /**
      * Is the quartz scheduler clustered?
      */


Mime
View raw message