You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/07/23 10:50:06 UTC

[1/3] git commit: CAMEL-6443: Fixed quickfix engines to only be reused when they are properly started, to avoid using broken engines.

Updated Branches:
  refs/heads/camel-2.10.x f0749e913 -> 224b675a6
  refs/heads/camel-2.11.x 5e8235a80 -> 736db12a2
  refs/heads/master 651709060 -> b2a4b54bc


CAMEL-6443: Fixed quickfix engines to only be reused when they are properly started, to avoid using broken engines.


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

Branch: refs/heads/master
Commit: b2a4b54bc1da56e0cd71316cdd1d296e1582e92d
Parents: 6517090
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 23 10:48:23 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 23 10:48:23 2013 +0200

----------------------------------------------------------------------
 .../component/quickfixj/QuickfixjComponent.java | 20 +++++++++++++++++++-
 .../quickfixj/QuickfixjComponentTest.java       | 18 +++++++++++-------
 2 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b2a4b54b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
index 6267613..9e9c7f1 100644
--- a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
+++ b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
@@ -36,6 +36,7 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
 
     private final Object engineInstancesLock = new Object();
     private final Map<String, QuickfixjEngine> engines = new HashMap<String, QuickfixjEngine>();
+    private final Map<String, QuickfixjEngine> provisionalEngines = new HashMap<String, QuickfixjEngine>();
     private final Map<String, QuickfixjEndpoint> endpoints = new HashMap<String, QuickfixjEndpoint>();
 
     private MessageStoreFactory messageStoreFactory;
@@ -53,6 +54,9 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
             if (endpoint == null) {
                 engine = engines.get(remaining);
                 if (engine == null) {
+                    engine = provisionalEngines.get(remaining);
+                }
+                if (engine == null) {
                     QuickfixjConfiguration configuration = configurations.get(remaining);
                     if (configuration != null) {
                         SessionSettings settings = configuration.createSessionSettings();
@@ -60,12 +64,15 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
                     } else {
                         engine = new QuickfixjEngine(uri, remaining, messageStoreFactory, logFactory, messageFactory);
                     }
-                    engines.put(remaining, engine);
 
                     // only start engine if CamelContext is already started, otherwise the engines gets started
                     // automatic later when CamelContext has been started using the StartupListener
                     if (getCamelContext().getStatus().isStarted()) {
                         startQuickfixjEngine(engine);
+                        engines.put(remaining, engine);
+                    } else {
+                        // engines to be started later
+                        provisionalEngines.put(remaining, engine);
                     }
                 }
 
@@ -99,6 +106,7 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
     protected void doShutdown() throws Exception {
         // cleanup when shutting down
         engines.clear();
+        provisionalEngines.clear();
         endpoints.clear();
         super.doShutdown();
     }
@@ -113,6 +121,11 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
         return Collections.unmodifiableMap(engines);
     }
 
+    // Test Support
+    Map<String, QuickfixjEngine> getProvisionalEngines() {
+        return Collections.unmodifiableMap(provisionalEngines);
+    }
+
     public void setMessageFactory(MessageFactory messageFactory) {
         this.messageFactory = messageFactory;
     }
@@ -147,6 +160,11 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
             for (QuickfixjEngine engine : engines.values()) {
                 startQuickfixjEngine(engine);
             }
+            for (Map.Entry<String, QuickfixjEngine> entry : provisionalEngines.entrySet()) {
+                startQuickfixjEngine(entry.getValue());
+                engines.put(entry.getKey(), entry.getValue());
+                provisionalEngines.remove(entry.getKey());
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b2a4b54b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
index 0193ba7..ca3ab79 100644
--- a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
+++ b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
@@ -162,21 +162,24 @@ public class QuickfixjComponentTest {
         writeSettings();
 
         Endpoint e1 = component.createEndpoint(getEndpointUri(settingsFile.getName(), null));
-        assertThat(component.getEngines().size(), is(1));
-        assertThat(component.getEngines().get(settingsFile.getName()), is(notNullValue()));
-        assertThat(component.getEngines().get(settingsFile.getName()).isStarted(), is(false));
+        assertThat(component.getProvisionalEngines().size(), is(1));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()), is(notNullValue()));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()).isStarted(), is(false));
         assertThat(((QuickfixjEndpoint)e1).getSessionID(), is(nullValue()));
         
         // Should used cached QFJ engine
         Endpoint e2 = component.createEndpoint(getEndpointUri(settingsFile.getName(), sessionID));
         
-        assertThat(component.getEngines().size(), is(1));
-        assertThat(component.getEngines().get(settingsFile.getName()), is(notNullValue()));
-        assertThat(component.getEngines().get(settingsFile.getName()).isStarted(), is(false));
+        assertThat(component.getProvisionalEngines().size(), is(1));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()), is(notNullValue()));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()).isStarted(), is(false));
         assertThat(((QuickfixjEndpoint)e2).getSessionID(), is(sessionID));
 
         // will start the component
         camelContext.start();
+
+        assertThat(component.getProvisionalEngines().size(), is(0));
+        assertThat(component.getEngines().size(), is(1));
         assertThat(component.getEngines().get(settingsFile.getName()).isStarted(), is(true));
         
         // Move these too an endpoint testcase if one exists
@@ -331,7 +334,8 @@ public class QuickfixjComponentTest {
 
         component.createEndpoint(getEndpointUri(settingsFile.getName(), null));
 
-        component.start();
+        // will start the component
+        camelContext.start();
 
         assertThat(component.getEngines().size(), is(1));
         QuickfixjEngine engine = component.getEngines().values().iterator().next();


[2/3] git commit: CAMEL-6443: Fixed quickfix engines to only be reused when they are properly started, to avoid using broken engines.

Posted by da...@apache.org.
CAMEL-6443: Fixed quickfix engines to only be reused when they are properly started, to avoid using broken engines.


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

Branch: refs/heads/camel-2.11.x
Commit: 736db12a2915841b4c21cb2e6c285b00c31cd508
Parents: 5e8235a
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 23 10:48:23 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 23 10:49:11 2013 +0200

----------------------------------------------------------------------
 .../component/quickfixj/QuickfixjComponent.java | 20 +++++++++++++++++++-
 .../quickfixj/QuickfixjComponentTest.java       | 18 +++++++++++-------
 2 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/736db12a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
index 6267613..9e9c7f1 100644
--- a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
+++ b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
@@ -36,6 +36,7 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
 
     private final Object engineInstancesLock = new Object();
     private final Map<String, QuickfixjEngine> engines = new HashMap<String, QuickfixjEngine>();
+    private final Map<String, QuickfixjEngine> provisionalEngines = new HashMap<String, QuickfixjEngine>();
     private final Map<String, QuickfixjEndpoint> endpoints = new HashMap<String, QuickfixjEndpoint>();
 
     private MessageStoreFactory messageStoreFactory;
@@ -53,6 +54,9 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
             if (endpoint == null) {
                 engine = engines.get(remaining);
                 if (engine == null) {
+                    engine = provisionalEngines.get(remaining);
+                }
+                if (engine == null) {
                     QuickfixjConfiguration configuration = configurations.get(remaining);
                     if (configuration != null) {
                         SessionSettings settings = configuration.createSessionSettings();
@@ -60,12 +64,15 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
                     } else {
                         engine = new QuickfixjEngine(uri, remaining, messageStoreFactory, logFactory, messageFactory);
                     }
-                    engines.put(remaining, engine);
 
                     // only start engine if CamelContext is already started, otherwise the engines gets started
                     // automatic later when CamelContext has been started using the StartupListener
                     if (getCamelContext().getStatus().isStarted()) {
                         startQuickfixjEngine(engine);
+                        engines.put(remaining, engine);
+                    } else {
+                        // engines to be started later
+                        provisionalEngines.put(remaining, engine);
                     }
                 }
 
@@ -99,6 +106,7 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
     protected void doShutdown() throws Exception {
         // cleanup when shutting down
         engines.clear();
+        provisionalEngines.clear();
         endpoints.clear();
         super.doShutdown();
     }
@@ -113,6 +121,11 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
         return Collections.unmodifiableMap(engines);
     }
 
+    // Test Support
+    Map<String, QuickfixjEngine> getProvisionalEngines() {
+        return Collections.unmodifiableMap(provisionalEngines);
+    }
+
     public void setMessageFactory(MessageFactory messageFactory) {
         this.messageFactory = messageFactory;
     }
@@ -147,6 +160,11 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
             for (QuickfixjEngine engine : engines.values()) {
                 startQuickfixjEngine(engine);
             }
+            for (Map.Entry<String, QuickfixjEngine> entry : provisionalEngines.entrySet()) {
+                startQuickfixjEngine(entry.getValue());
+                engines.put(entry.getKey(), entry.getValue());
+                provisionalEngines.remove(entry.getKey());
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/736db12a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
index f0239f2..ad939e6 100644
--- a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
+++ b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
@@ -162,21 +162,24 @@ public class QuickfixjComponentTest {
         writeSettings();
 
         Endpoint e1 = component.createEndpoint(getEndpointUri(settingsFile.getName(), null));
-        assertThat(component.getEngines().size(), is(1));
-        assertThat(component.getEngines().get(settingsFile.getName()), is(notNullValue()));
-        assertThat(component.getEngines().get(settingsFile.getName()).isStarted(), is(false));
+        assertThat(component.getProvisionalEngines().size(), is(1));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()), is(notNullValue()));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()).isStarted(), is(false));
         assertThat(((QuickfixjEndpoint)e1).getSessionID(), is(nullValue()));
         
         // Should used cached QFJ engine
         Endpoint e2 = component.createEndpoint(getEndpointUri(settingsFile.getName(), sessionID));
         
-        assertThat(component.getEngines().size(), is(1));
-        assertThat(component.getEngines().get(settingsFile.getName()), is(notNullValue()));
-        assertThat(component.getEngines().get(settingsFile.getName()).isStarted(), is(false));
+        assertThat(component.getProvisionalEngines().size(), is(1));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()), is(notNullValue()));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()).isStarted(), is(false));
         assertThat(((QuickfixjEndpoint)e2).getSessionID(), is(sessionID));
 
         // will start the component
         camelContext.start();
+
+        assertThat(component.getProvisionalEngines().size(), is(0));
+        assertThat(component.getEngines().size(), is(1));
         assertThat(component.getEngines().get(settingsFile.getName()).isStarted(), is(true));
         
         // Move these too an endpoint testcase if one exists
@@ -329,7 +332,8 @@ public class QuickfixjComponentTest {
 
         component.createEndpoint(getEndpointUri(settingsFile.getName(), null));
 
-        component.start();
+        // will start the component
+        camelContext.start();
 
         assertThat(component.getEngines().size(), is(1));
         QuickfixjEngine engine = component.getEngines().values().iterator().next();


[3/3] git commit: CAMEL-6443: Fixed quickfix engines to only be reused when they are properly started, to avoid using broken engines.

Posted by da...@apache.org.
CAMEL-6443: Fixed quickfix engines to only be reused when they are properly started, to avoid using broken engines.


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

Branch: refs/heads/camel-2.10.x
Commit: 224b675a6742bbfbb7ba422d99a18afd155c955c
Parents: f0749e9
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 23 10:48:23 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 23 10:49:25 2013 +0200

----------------------------------------------------------------------
 .../component/quickfixj/QuickfixjComponent.java | 20 +++++++++++++++++++-
 .../quickfixj/QuickfixjComponentTest.java       | 18 +++++++++++-------
 2 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/224b675a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
index 01be138..48a2325 100644
--- a/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
+++ b/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
@@ -36,6 +36,7 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
 
     private final Object engineInstancesLock = new Object();
     private final Map<String, QuickfixjEngine> engines = new HashMap<String, QuickfixjEngine>();
+    private final Map<String, QuickfixjEngine> provisionalEngines = new HashMap<String, QuickfixjEngine>();
     private final Map<String, QuickfixjEndpoint> endpoints = new HashMap<String, QuickfixjEndpoint>();
 
     private MessageStoreFactory messageStoreFactory;
@@ -54,6 +55,9 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
             if (endpoint == null) {
                 engine = engines.get(remaining);
                 if (engine == null) {
+                    engine = provisionalEngines.get(remaining);
+                }
+                if (engine == null) {
                     QuickfixjConfiguration configuration = configurations.get(remaining);
                     if (configuration != null) {
                         SessionSettings settings = configuration.createSessionSettings();
@@ -61,12 +65,15 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
                     } else {
                         engine = new QuickfixjEngine(uri, remaining, forcedShutdown, messageStoreFactory, logFactory, messageFactory);
                     }
-                    engines.put(remaining, engine);
 
                     // only start engine if CamelContext is already started, otherwise the engines gets started
                     // automatic later when CamelContext has been started using the StartupListener
                     if (getCamelContext().getStatus().isStarted()) {
                         startQuickfixjEngine(engine);
+                        engines.put(remaining, engine);
+                    } else {
+                        // engines to be started later
+                        provisionalEngines.put(remaining, engine);
                     }
                 }
 
@@ -100,6 +107,7 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
     protected void doShutdown() throws Exception {
         // cleanup when shutting down
         engines.clear();
+        provisionalEngines.clear();
         endpoints.clear();
         super.doShutdown();
     }
@@ -114,6 +122,11 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
         return Collections.unmodifiableMap(engines);
     }
 
+    // Test Support
+    Map<String, QuickfixjEngine> getProvisionalEngines() {
+        return Collections.unmodifiableMap(provisionalEngines);
+    }
+
     public void setMessageFactory(MessageFactory messageFactory) {
         this.messageFactory = messageFactory;
     }
@@ -145,6 +158,11 @@ public class QuickfixjComponent extends DefaultComponent implements StartupListe
             for (QuickfixjEngine engine : engines.values()) {
                 startQuickfixjEngine(engine);
             }
+            for (Map.Entry<String, QuickfixjEngine> entry : provisionalEngines.entrySet()) {
+                startQuickfixjEngine(entry.getValue());
+                engines.put(entry.getKey(), entry.getValue());
+                provisionalEngines.remove(entry.getKey());
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/224b675a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
index f0239f2..ad939e6 100644
--- a/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
+++ b/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjComponentTest.java
@@ -162,21 +162,24 @@ public class QuickfixjComponentTest {
         writeSettings();
 
         Endpoint e1 = component.createEndpoint(getEndpointUri(settingsFile.getName(), null));
-        assertThat(component.getEngines().size(), is(1));
-        assertThat(component.getEngines().get(settingsFile.getName()), is(notNullValue()));
-        assertThat(component.getEngines().get(settingsFile.getName()).isStarted(), is(false));
+        assertThat(component.getProvisionalEngines().size(), is(1));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()), is(notNullValue()));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()).isStarted(), is(false));
         assertThat(((QuickfixjEndpoint)e1).getSessionID(), is(nullValue()));
         
         // Should used cached QFJ engine
         Endpoint e2 = component.createEndpoint(getEndpointUri(settingsFile.getName(), sessionID));
         
-        assertThat(component.getEngines().size(), is(1));
-        assertThat(component.getEngines().get(settingsFile.getName()), is(notNullValue()));
-        assertThat(component.getEngines().get(settingsFile.getName()).isStarted(), is(false));
+        assertThat(component.getProvisionalEngines().size(), is(1));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()), is(notNullValue()));
+        assertThat(component.getProvisionalEngines().get(settingsFile.getName()).isStarted(), is(false));
         assertThat(((QuickfixjEndpoint)e2).getSessionID(), is(sessionID));
 
         // will start the component
         camelContext.start();
+
+        assertThat(component.getProvisionalEngines().size(), is(0));
+        assertThat(component.getEngines().size(), is(1));
         assertThat(component.getEngines().get(settingsFile.getName()).isStarted(), is(true));
         
         // Move these too an endpoint testcase if one exists
@@ -329,7 +332,8 @@ public class QuickfixjComponentTest {
 
         component.createEndpoint(getEndpointUri(settingsFile.getName(), null));
 
-        component.start();
+        // will start the component
+        camelContext.start();
 
         assertThat(component.getEngines().size(), is(1));
         QuickfixjEngine engine = component.getEngines().values().iterator().next();