camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject git commit: CAMEL-6797: Fixed the failing SpringQuartzConsumerTwoAppsClusteredFailoverTest test. Also polished the codebase a bit.
Date Mon, 30 Sep 2013 09:37:18 GMT
Updated Branches:
  refs/heads/camel-2.12.x c82a8d037 -> b5a54186c


CAMEL-6797: Fixed the failing SpringQuartzConsumerTwoAppsClusteredFailoverTest test. Also
polished the codebase a bit.


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

Branch: refs/heads/camel-2.12.x
Commit: b5a54186c2de5a3e05157d330611820689fcd592
Parents: c82a8d0
Author: Babak Vahdat <bvahdat@apache.org>
Authored: Mon Sep 30 11:29:30 2013 +0200
Committer: Babak Vahdat <bvahdat@apache.org>
Committed: Mon Sep 30 11:30:53 2013 +0200

----------------------------------------------------------------------
 .../camel/component/quartz2/QuartzEndpoint.java | 30 +++++++++-----------
 ...rtzConsumerTwoAppsClusteredFailoverTest.java | 14 ++++-----
 .../src/test/resources/log4j.properties         |  3 +-
 3 files changed, 22 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b5a54186/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzEndpoint.java
b/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzEndpoint.java
index 9d37cd8..0fc6cb5 100644
--- a/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzEndpoint.java
+++ b/components/camel-quartz2/src/main/java/org/apache/camel/component/quartz2/QuartzEndpoint.java
@@ -46,7 +46,8 @@ import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
 
 /**
  * This endpoint represent each job to be created in scheduler. When consumer is started
or stopped, it will
- * call back into doConsumerStart()/Stop() to pause/resume the scheduler trigger.
+ * call back into {@link #onConsumerStart(QuartzConsumer)} to add/resume or {@link #onConsumerStop(QuartzConsumer)}
+ * to pause the scheduler trigger.
  */
 public class QuartzEndpoint extends DefaultEndpoint {
     private static final Logger LOG = LoggerFactory.getLogger(QuartzEndpoint.class);
@@ -203,7 +204,9 @@ public class QuartzEndpoint extends DefaultEndpoint {
 
         // Decrement camel job count for this endpoint
         AtomicInteger number = (AtomicInteger) scheduler.getContext().get(QuartzConstants.QUARTZ_CAMEL_JOBS_COUNT);
-        number.decrementAndGet();
+        if (number != null) {
+            number.decrementAndGet();
+        }
     }
 
     private void addJobInScheduler() throws Exception {
@@ -219,25 +222,20 @@ public class QuartzEndpoint extends DefaultEndpoint {
 
             // Schedule it now. Remember that scheduler might not be started it, but we can
schedule now.
             Date nextFireDate = scheduler.scheduleJob(jobDetail, trigger);
-            LOG.info("Job {} (triggerType={}, jobClass={}) is scheduled. Next fire date is
{}",
-                     new Object[] {trigger.getKey(), trigger.getClass().getSimpleName(),
-                          jobDetail.getJobClass().getSimpleName(), nextFireDate});
+            if (LOG.isInfoEnabled()) {
+                LOG.info("Job {} (triggerType={}, jobClass={}) is scheduled. Next fire date
is {}",
+                         new Object[] {trigger.getKey(), trigger.getClass().getSimpleName(),
+                                       jobDetail.getJobClass().getSimpleName(), nextFireDate});
+            }
         } else {
             ensureNoDupTriggerKey();
-
-            // Update existing jobDetails with current endpoint data to jobDataMap.
-            jobDetail = scheduler.getJobDetail(trigger.getJobKey());
-            updateJobDataMap(jobDetail);
-            scheduler.addJob(jobDetail, true);
-            Date nextFireDate = trigger.getNextFireTime();
-            LOG.info("Reuse existing Job {} (triggerType={}, jobType={}) is scheduled. Next
fire date is {}",
-                     new Object[] {trigger.getKey(), trigger.getClass().getSimpleName(),
-                                   jobDetail.getJobClass().getSimpleName(), nextFireDate});
         }
 
         // Increase camel job count for this endpoint
         AtomicInteger number = (AtomicInteger) scheduler.getContext().get(QuartzConstants.QUARTZ_CAMEL_JOBS_COUNT);
-        number.incrementAndGet();
+        if (number != null) {
+            number.incrementAndGet();
+        }
 
         jobAdded.set(true);
     }
@@ -343,7 +341,7 @@ public class QuartzEndpoint extends DefaultEndpoint {
         jobPaused.set(true);
 
         Scheduler scheduler = getComponent().getScheduler();
-        if (scheduler != null) {
+        if (scheduler != null && !scheduler.isShutdown()) {
             LOG.info("Pausing trigger {}", triggerKey);
             scheduler.pauseTrigger(triggerKey);
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/b5a54186/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzConsumerTwoAppsClusteredFailoverTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzConsumerTwoAppsClusteredFailoverTest.java
b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzConsumerTwoAppsClusteredFailoverTest.java
index 5a6f607..2ccb4aa 100644
--- a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzConsumerTwoAppsClusteredFailoverTest.java
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzConsumerTwoAppsClusteredFailoverTest.java
@@ -21,7 +21,6 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Predicate;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.TestSupport;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -31,7 +30,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
  * 
  * @version
  */
-@Ignore("CAMEL-6797")
 public class SpringQuartzConsumerTwoAppsClusteredFailoverTest extends TestSupport {
 
     @Test
@@ -70,12 +68,12 @@ public class SpringQuartzConsumerTwoAppsClusteredFailoverTest extends
TestSuppor
         // wait long enough until the second app takes it over...
         Thread.sleep(20000);
         // inside the logs one can then clearly see how the route of the second CamelContext
gets started:
-        // 2013-09-28 19:50:43,900 [main           ] WARN  ntTwoAppsClusteredFailoverTest
- Crashed...
-        // 2013-09-28 19:50:43,900 [main           ] WARN  ntTwoAppsClusteredFailoverTest
- Crashed...
-        // 2013-09-28 19:50:43,900 [main           ] WARN  ntTwoAppsClusteredFailoverTest
- Crashed...
-        // 2013-09-28 19:50:58,892 [_ClusterManager] INFO  LocalDataSourceJobStore      
 - ClusterManager: detected 1 failed or restarted instances.
-        // 2013-09-28 19:50:58,892 [_ClusterManager] INFO  LocalDataSourceJobStore      
 - ClusterManager: Scanning for instance "app-one"'s failed in-progress jobs.
-        // 2013-09-28 19:50:58,913 [eduler_Worker-1] INFO  triggered                    
 - Exchange[ExchangePattern: InOnly, BodyType: String, Body: clustering PONGS!]
+        // 2013-09-30 11:22:20,349 [main           ] WARN  erTwoAppsClusteredFailoverTest
- Crashed...
+        // 2013-09-30 11:22:20,349 [main           ] WARN  erTwoAppsClusteredFailoverTest
- Crashed...
+        // 2013-09-30 11:22:20,349 [main           ] WARN  erTwoAppsClusteredFailoverTest
- Crashed...
+        // 2013-09-30 11:22:35,340 [_ClusterManager] INFO  LocalDataSourceJobStore      
 - ClusterManager: detected 1 failed or restarted instances.
+        // 2013-09-30 11:22:35,340 [_ClusterManager] INFO  LocalDataSourceJobStore      
 - ClusterManager: Scanning for instance "app-one"'s failed in-progress jobs.
+        // 2013-09-30 11:22:35,369 [eduler_Worker-1] INFO  triggered                    
 - Exchange[ExchangePattern: InOnly, BodyType: String, Body: clustering PONGS!]
 
         CamelContext camel2 = app2.getBean("camelContext2", CamelContext.class);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/b5a54186/components/camel-quartz2/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/resources/log4j.properties b/components/camel-quartz2/src/test/resources/log4j.properties
index 1199657..84ee500 100644
--- a/components/camel-quartz2/src/test/resources/log4j.properties
+++ b/components/camel-quartz2/src/test/resources/log4j.properties
@@ -29,7 +29,8 @@ log4j.rootLogger=INFO, file
 # CONSOLE appender not used by default
 log4j.appender.out=org.apache.log4j.ConsoleAppender
 log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1}:%-4L - %m%n
+#log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
 
 # File appender
 log4j.appender.file=org.apache.log4j.FileAppender


Mime
View raw message