camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/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:47 GMT
CAMEL-7034: Ensure quartz scheduler instance name is unique in JVMs and assigned ththe same
way when using Camels quartz component.

Conflicts:
	components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
	components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzComponent.java


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

Branch: refs/heads/camel-2.12.x
Commit: b275fb6a48fc565a37e7075f4a34f78817f022c3
Parents: 52aa7a1
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:56:37 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/b275fb6a/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 0ea7a85..93eb93c 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
@@ -440,6 +440,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);
+
             answer = new StdSchedulerFactory(prop);
         } else {
             // read default props to be able to use a single scheduler per camel context
@@ -459,14 +463,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)
@@ -482,6 +479,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/b275fb6a/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 701b966..b4c2510 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
@@ -113,6 +113,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);
+
             answer = new StdSchedulerFactory(prop);
         } else {
             // read default props to be able to use a single scheduler per camel context
@@ -132,14 +136,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)
@@ -156,6 +153,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