You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Mark Ford (JIRA)" <ji...@apache.org> on 2010/10/19 22:09:40 UTC

[jira] Created: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
-----------------------------------------------------------------------------------------

                 Key: CAMEL-3255
                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
             Project: Apache Camel
          Issue Type: New Feature
          Components: camel-core
    Affects Versions: 2.4.0, 2.3.0, 2.2.0
            Reporter: Mark Ford
            Priority: Minor


The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 

The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62683#action_62683 ] 

Claus Ibsen commented on CAMEL-3255:
------------------------------------

Hmm I still don't think its good to have synchronized blocks in the default case.
type converters is a bottleneck and hence there should be no contention issues at runtime.

Instead we should provide 2 kinds of type converters. The default, and the Lazy version. Then the lazy can use synchronized blocks in the code.

> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3255
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Assignee: Claus Ibsen
>            Priority: Minor
>         Attachments: patch.txt
>
>
> The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-3255:
----------------------------------

    Assignee: Claus Ibsen

> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3255
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Assignee: Claus Ibsen
>            Priority: Minor
>         Attachments: patch.txt
>
>
> The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-3255.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 2.5.0

davsclaus:(svn)camel[trunk:1024541]/$ svn commit --message "CAMEL-3255: Type converters can now be lazy loaded. Thanks to Mark Ford for patch which I can leverage pieces from."
Sending        camel-core/src/main/java/org/apache/camel/CamelContext.java
Sending        camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Adding         camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
Replacing      camel-core/src/main/java/org/apache/camel/impl/converter/DefaultTypeConverter.java
Adding         camel-core/src/main/java/org/apache/camel/impl/converter/LazyLoadingTypeConverter.java
Sending        camel-core/src/main/java/org/apache/camel/spi/TypeConverterAware.java
Sending        camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java
Adding         camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextLazyLoadTypeConvertersTest.java
Sending        camel-core/src/test/resources/log4j.properties
Sending        components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
Sending        components/camel-blueprint/src/test/resources/test.xml
Sending        components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
Sending        components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Adding         components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextLazyLoadTypeConvertersTest.java
Sending        components/camel-spring/src/test/resources/log4j.properties
Adding         components/camel-spring/src/test/resources/org/apache/camel/spring/CamelContextLazyLoadTypeConvertersTest.xml
Transmitting file data ................
Committed revision 1024542.

> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3255
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.5.0
>
>         Attachments: patch.txt
>
>
> The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Posted by "Mark Ford (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62726#action_62726 ] 

Mark Ford commented on CAMEL-3255:
----------------------------------

Claus,

I respectively disagree that having a base class makes it easier for a future variation. I think the strategy pattern works better here than inheritance since it isolates the differences in behavior. It's conceivable that additional variations would want to change behavior in your base class but also have variations on their resource loading strategies. Inheritance will result in a proliferation of classes.

The problem I see with both implementations is that the check for whether the types converters are loaded is in many places. I based my restoration of the checks on the diff from CAMEL-2392. I'm assuming you did the same either by following my changes or referring back to the issue. In my solution it's troubling since the calls are hard to find since they're buried in method bodies in some places (as was done originally). In yours, it's obvious but awkward since the subclass does nothing but override a number of methods to do the check before calling super. It's not a good use of inheritance here.

A better solution in both cases would be to refactor the code to have a single point for accessing the type mappings. This single point could then invoke the strategy method to see if they were loaded or not. I was going to do this in a second pass after I had a little more time but figured I'd start with a smaller change. If there's interest on your part, I'm willing to submit another patch along these lines.

> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3255
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.5.0
>
>         Attachments: patch.txt
>
>
> The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62728#action_62728 ] 

Claus Ibsen commented on CAMEL-3255:
------------------------------------

Yeah

We love contributions so you are welcome to work on improved patch.
I can also see your point.

But my solution ensure all access to the type converter ensures the lazy loading has occurred.
In your solution this check is buried in the code and you could potentially miss a couple of checks and then its flawed.

As the type converter is a bottleneck in Camel we must ensure the default setting is as fast as possible.
The lazy loading option is a niche feature.

> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3255
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.5.0
>
>         Attachments: patch.txt
>
>
> The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Posted by "Mark Ford (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62693#action_62693 ] 

Mark Ford commented on CAMEL-3255:
----------------------------------

Thanks for implementing this and adding the xml support. 

I'm just curious about your comment where you saw synchronization in the default case. While both states for the DefaultTypeConverter required invoking the accessing method at various times, only the strategy for the lazy load implemented a synchronized method for accessing. The result is that there was no synchronization for the default case.



> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3255
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.5.0
>
>         Attachments: patch.txt
>
>
> The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62682#action_62682 ] 

Claus Ibsen commented on CAMEL-3255:
------------------------------------

We should expose this option in the XML as well. I will work on that.

> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3255
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Assignee: Claus Ibsen
>            Priority: Minor
>         Attachments: patch.txt
>
>
> The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62696#action_62696 ] 

Claus Ibsen commented on CAMEL-3255:
------------------------------------

And the logger now logs the classname with the version you use

> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3255
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.5.0
>
>         Attachments: patch.txt
>
>
> The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62695#action_62695 ] 

Claus Ibsen commented on CAMEL-3255:
------------------------------------

Mark my bad, yeah it was only sync on the lazy.

Anyway we got a base class now and 2 diff impls. Easier in the future for a new variation.

> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3255
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.5.0
>
>         Attachments: patch.txt
>
>
> The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAMEL-3255) Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter

Posted by "Mark Ford (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Ford updated CAMEL-3255:
-----------------------------

    Attachment: patch.txt

Patch adds the property to the context and encapsulates the loading of the type converters using the strategy pattern. Unit test is included.

For example:

    protected static interface LoadTypeConvertersStrategy {
        public void starting() throws Exception;
        public void accessing();
        public void stopping();
    }

The default implementation of loading up front loads the type converters when the DefaultTypeConverter is started and is a no-op for the accessing method. The stopping method clears the type mappings. The benefit of the up front loading is that there are no synchronization points at runtime. The cost is that it takes longer to initialize the context.

The lazy load implementation defers the loading until the synchronized accessing method is invoked. The benefit of the lazy loading is that the context initializes faster. The cost is that there are synchronization points at runtime.


> Add property to DefaultCamelContext to allow for lazy loading of the DefaultTypeConverter
> -----------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3255
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3255
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-core
>    Affects Versions: 2.2.0, 2.3.0, 2.4.0
>            Reporter: Mark Ford
>            Priority: Minor
>         Attachments: patch.txt
>
>
> The loading of type converters was changed from a lazy loading to an up front loading in a Camel 2.2. See issue CAMEL-2392 for details. Accordingly to the logging, it takes approximately 300 millis for this process to complete. 
> The proposal is to allow the configuration of this loading strategy for cases where the initialization time of contexts is more important than the loading of type converters. The "lazyLoadTypeConverters" property on the context will default to false to preserve the current up front loading behavior as the default. If this value is set to true, then the loading of the type converters will happen when accessed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.