Camel
  1. Camel
  2. CAMEL-3867

camel-cache- improve ehcache configuration by reference RegisteredEventListeners and CacheLoaders

    Details

      Description

      The thing is, that cache names can be a dynamic list. But ehcache is expecting to get static list (known before start) on it's xml configuration file. Ehcache provides some defaults config. for new caches with some exceptions. One of them are cache listeners (like replication listeners).
      So the thing is, to give ability to define listeners and cache loaders (via spring/blueprint ref.) during endpoint construction.
      This will ease configuration of listeners/loaders as xml static list of listeners (per cache) will not be needed anymore. Instead of very long list which you have to keep up to date, you could define one list of listeners/loaders for all cache endpoints!

      SO SIMPLE!

      1. camel-itest-osgi.CacheRouteManagementTest.patch
        6 kB
        Piotr Klimczak
      2. camel-itest-osgi.CacheRouteManagementTest.patch
        6 kB
        Piotr Klimczak
      3. camel-itest-osgi.CacheManagerFactoryRefTest.patch
        1 kB
        Piotr Klimczak
      4. camel-itest-osgi.CacheManagerFactoryRefTest.patch
        2 kB
        Piotr Klimczak
      5. camel-cache.cleanupAndLitenersRef.patch
        36 kB
        Piotr Klimczak
      6. camel-cache.cleanupAndLitenersRef.patch
        36 kB
        Piotr Klimczak
      There are no Sub-Tasks for this issue.

        Activity

        Hide
        Piotr Klimczak added a comment - - edited

        In my opinion it will be really useful. And of course I'll prepare the patch soon
        For now configuring ehcache is very painful as there is no wildcards.

        BTW. How can i change the docs or make a patch to Apache docs?

        Show
        Piotr Klimczak added a comment - - edited In my opinion it will be really useful. And of course I'll prepare the patch soon For now configuring ehcache is very painful as there is no wildcards. BTW. How can i change the docs or make a patch to Apache docs?
        Hide
        Claus Ibsen added a comment -

        See here about improving docs
        http://camel.apache.org/contributing.html

        Show
        Claus Ibsen added a comment - See here about improving docs http://camel.apache.org/contributing.html
        Hide
        Piotr Klimczak added a comment -

        I've made a little more changes- I've done some code cleanup.
        I do understand that code cleanups are dificult to analize but it is still better option than improving bad code.

        Here is the list what I've done in this patch:

        • added URI configuration option named: eventListenerRegistry which is a ref to CacheEventListenerRegistry type
        • added unit test to test event listener behaviour- to make sure that referenced listeners are invoked (CacheEventListenerRegistryTest)
        • cleaned up consumer and producer by moving same code do the CacheEndpoint
        • removed cache stop from consumer/producer and moved to the endpoint- as I understand the camel it will prevent removing cache when route is stopped manually.
        • added unit test to test route manual shutdown and cache being still alive

        If you don't like those changes, then please give me a sign.

        Plese note that i did not want to divide it to 2 improvements as it'll be quite complicated.
        Plese also note that applying this patch to trunk will casuse the my last osgi unit test to stop working, as the cache manager factory will not be initialized until first routing will be done.

        Will attach a patch soon.
        Should I make new issue for that? or simply attach a patch to itest here?

        Hope you like it
        HAVE A FUN!

        Show
        Piotr Klimczak added a comment - I've made a little more changes- I've done some code cleanup. I do understand that code cleanups are dificult to analize but it is still better option than improving bad code. Here is the list what I've done in this patch: added URI configuration option named: eventListenerRegistry which is a ref to CacheEventListenerRegistry type added unit test to test event listener behaviour- to make sure that referenced listeners are invoked (CacheEventListenerRegistryTest) cleaned up consumer and producer by moving same code do the CacheEndpoint removed cache stop from consumer/producer and moved to the endpoint- as I understand the camel it will prevent removing cache when route is stopped manually. added unit test to test route manual shutdown and cache being still alive If you don't like those changes, then please give me a sign. Plese note that i did not want to divide it to 2 improvements as it'll be quite complicated. Plese also note that applying this patch to trunk will casuse the my last osgi unit test to stop working, as the cache manager factory will not be initialized until first routing will be done. Will attach a patch soon. Should I make new issue for that? or simply attach a patch to itest here? Hope you like it HAVE A FUN!
        Hide
        Claus Ibsen added a comment -

        Keep 'em coming Piotr. Its fine to just attach a 2nd patch for the change in that other test.
        I will review and apply this patch in a bit.

        Show
        Claus Ibsen added a comment - Keep 'em coming Piotr. Its fine to just attach a 2nd patch for the change in that other test. I will review and apply this patch in a bit.
        Hide
        Piotr Klimczak added a comment -

        Patch to osgi test cases due to start/stop logic change. Now test will do some route before any assertion

        Show
        Piotr Klimczak added a comment - Patch to osgi test cases due to start/stop logic change. Now test will do some route before any assertion
        Hide
        Piotr Klimczak added a comment -

        An OSGi copy of camel-cache unit test that test manual shutdown cache route.
        Apply it if you want'em more (i mean more osgi tests )

        Show
        Piotr Klimczak added a comment - An OSGi copy of camel-cache unit test that test manual shutdown cache route. Apply it if you want'em more (i mean more osgi tests )
        Hide
        Piotr Klimczak added a comment -

        This patch is a continuation of bringing camel-cache to clustered world. I guess 75% is already done. Those 25% is:

        • making a patch to smx ehcache bundle (done but patch not prepared yet, will upload the patch in parallel with below osgi unit test)
        • provide osgi unit test to test jms replication (not started yet)

        Then I will prepare a working example for tutorial purpose and of course a full tutorial telling about how to use ehcache and replication in real life

        Show
        Piotr Klimczak added a comment - This patch is a continuation of bringing camel-cache to clustered world. I guess 75% is already done. Those 25% is: making a patch to smx ehcache bundle (done but patch not prepared yet, will upload the patch in parallel with below osgi unit test) provide osgi unit test to test jms replication (not started yet) Then I will prepare a working example for tutorial purpose and of course a full tutorial telling about how to use ehcache and replication in real life
        Hide
        Piotr Klimczak added a comment -

        CacheLoaders are also needed. The patch needs small reworking.

        Show
        Piotr Klimczak added a comment - CacheLoaders are also needed. The patch needs small reworking.
        Hide
        Piotr Klimczak added a comment -

        reworked adding cacheLoaderRegistry.
        Also fixed 1 possible patch conflict on eventListenereRegistry.

        Show
        Piotr Klimczak added a comment - reworked adding cacheLoaderRegistry. Also fixed 1 possible patch conflict on eventListenereRegistry.
        Hide
        Claus Ibsen added a comment -

        Piotr do you mind summarize which patches is needed to be applied (based on whats diff from the trunk). Just to be sure we do it right.

        Show
        Claus Ibsen added a comment - Piotr do you mind summarize which patches is needed to be applied (based on whats diff from the trunk). Just to be sure we do it right.
        Hide
        Piotr Klimczak added a comment -

        Summary
        All files are diffs to current trunk, where

        1. camel-cache.cleanupAndLitenersRef.patch- apply to https://svn.apache.org/repos/asf/camel/trunk/components/camel-cache
        contains:

        • added URI configuration option named: eventListenerRegistry which is a ref to CacheEventListenerRegistry type
        • added URI configuration option named: cacheLoaderRegistry which is a ref to CacheLoaderRegistry type
        • added unit test to test cache event listener/loader behaviour- to make sure that referenced listeners/loaders are invoked
        • cleaned up consumer and producer by moving same code do the CacheEndpoint
        • removed cache stop from consumer/producer and moved to the endpoint- as I understand the camel it will prevent removing cache when route is stopped manually.
        • added unit test to test route manual shutdown and cache being still alive

        2. camel-itest-osgi.CacheRouteManagementTest.patch- osgi test of manual managing routes (manual shutdown test using context.stopRoute).
        3. camel-itest-osgi.CacheManagerFactoryRefTest.patch- simple osgi test of referencing CacheManagerFactory and configuring ehcache using xml file.

        The 2. and 3. both are optional and if you want to apply them to: https://svn.apache.org/repos/asf/camel/trunk/tests/camel-itest-osgi
        both adds osgi unit test

        That's it.

        But there is still one thing that puzzles me, it is:

        • added URI configuration option named: cacheLoaderRegistry which is a ref to CacheLoaderRegistry type
          During writing an osgi test for jms replication i have found that the cacheLoaderRegistry will be more usable with some more improvements.
          So we have 2 options now:
          a) we will wait until i will write fully working jms replication osgi unit test (using cacheLoaders and cacheEventListeners)
          b) you can apply the patch to trun and then will wait for another patch.

        Decision is your. Just teake a look at the code.

        Show
        Piotr Klimczak added a comment - Summary All files are diffs to current trunk, where 1. camel-cache.cleanupAndLitenersRef.patch- apply to https://svn.apache.org/repos/asf/camel/trunk/components/camel-cache contains: added URI configuration option named: eventListenerRegistry which is a ref to CacheEventListenerRegistry type added URI configuration option named: cacheLoaderRegistry which is a ref to CacheLoaderRegistry type added unit test to test cache event listener/loader behaviour- to make sure that referenced listeners/loaders are invoked cleaned up consumer and producer by moving same code do the CacheEndpoint removed cache stop from consumer/producer and moved to the endpoint- as I understand the camel it will prevent removing cache when route is stopped manually. added unit test to test route manual shutdown and cache being still alive 2. camel-itest-osgi.CacheRouteManagementTest.patch- osgi test of manual managing routes (manual shutdown test using context.stopRoute). 3. camel-itest-osgi.CacheManagerFactoryRefTest.patch- simple osgi test of referencing CacheManagerFactory and configuring ehcache using xml file. The 2. and 3. both are optional and if you want to apply them to: https://svn.apache.org/repos/asf/camel/trunk/tests/camel-itest-osgi both adds osgi unit test That's it. But there is still one thing that puzzles me, it is: added URI configuration option named: cacheLoaderRegistry which is a ref to CacheLoaderRegistry type During writing an osgi test for jms replication i have found that the cacheLoaderRegistry will be more usable with some more improvements. So we have 2 options now: a) we will wait until i will write fully working jms replication osgi unit test (using cacheLoaders and cacheEventListeners) b) you can apply the patch to trun and then will wait for another patch. Decision is your. Just teake a look at the code.
        Hide
        Piotr Klimczak added a comment - - edited

        If my summary is not sufficient, please do not hesitate to ask me about anything...

        BTW. It would be much easier for all if I could work on my own branch

        Show
        Piotr Klimczak added a comment - - edited If my summary is not sufficient, please do not hesitate to ask me about anything... BTW. It would be much easier for all if I could work on my own branch
        Hide
        Piotr Klimczak added a comment - - edited

        Final version as got jms replication working with osgi test.
        Please note that this patch do not contains any jms replication functionality. It is just prepared to let you do it using spring ref functionality.

        Sorry for uploading same file many times. Working at nights is not a good idea for longer period of time.

        Please let me know if you have any questions.

        Show
        Piotr Klimczak added a comment - - edited Final version as got jms replication working with osgi test. Please note that this patch do not contains any jms replication functionality. It is just prepared to let you do it using spring ref functionality. Sorry for uploading same file many times. Working at nights is not a good idea for longer period of time. Please let me know if you have any questions.
        Hide
        Piotr Klimczak added a comment -

        This patch is needed by: https://issues.apache.org/jira/browse/CAMEL-3880

        To finalize all I will prepare changes in camel-cache component documentation soon.
        The latest step will be a full tutorial.

        Have a FUN!

        Show
        Piotr Klimczak added a comment - This patch is needed by: https://issues.apache.org/jira/browse/CAMEL-3880 To finalize all I will prepare changes in camel-cache component documentation soon. The latest step will be a full tutorial. Have a FUN!
        Hide
        Claus Ibsen added a comment -

        There has been some changes on trunk in camel-cache in terms of cache keys.

        Do you mind re-creating patches from trunk?

        Show
        Claus Ibsen added a comment - There has been some changes on trunk in camel-cache in terms of cache keys. Do you mind re-creating patches from trunk?
        Hide
        Piotr Klimczak added a comment - - edited

        No problem. Will do that this afternoon.
        I'm very happy to see some activity here

        BTW. I did not received an email with your comment :/ Found Ben O'Day changes accidentally. So i guess it is better idea to periodically review unresolved issues than waiting for email notification.

        Show
        Piotr Klimczak added a comment - - edited No problem. Will do that this afternoon. I'm very happy to see some activity here BTW. I did not received an email with your comment :/ Found Ben O'Day changes accidentally. So i guess it is better idea to periodically review unresolved issues than waiting for email notification.
        Hide
        Piotr Klimczak added a comment - - edited

        Recreated patches to let it work with latest trunk changes.

        Have a FUN!

        Show
        Piotr Klimczak added a comment - - edited Recreated patches to let it work with latest trunk changes. Have a FUN!
        Hide
        Piotr Klimczak added a comment -

        Now i can say i am very happy
        Thank you guys!

        One more thing. I am going to edit camel-cache docs, i have already sent ICLA to apache and send an information to camel dev forum. What else do i have to do to be able to edit great apache docs?

        Thanks in advance!

        Show
        Piotr Klimczak added a comment - Now i can say i am very happy Thank you guys! One more thing. I am going to edit camel-cache docs, i have already sent ICLA to apache and send an information to camel dev forum. What else do i have to do to be able to edit great apache docs? Thanks in advance!
        Hide
        Piotr Klimczak added a comment -

        Please note that i already have a confluence account but when i click edit on the bottom of page I get: Not Permitted.

        Show
        Piotr Klimczak added a comment - Please note that i already have a confluence account but when i click edit on the bottom of page I get: Not Permitted.
        Hide
        Claus Ibsen added a comment -

        Whats your username on confluence? I can assign you karma so you can edit.

        Show
        Claus Ibsen added a comment - Whats your username on confluence? I can assign you karma so you can edit.
        Hide
        Piotr Klimczak added a comment -

        Thanks Claus for response!
        My username on confluence is: nannou9
        Same as in JIRA.

        Show
        Piotr Klimczak added a comment - Thanks Claus for response! My username on confluence is: nannou9 Same as in JIRA.
        Hide
        Claus Ibsen added a comment -

        Piotr can you point out your name on the Apache CLA site?
        http://people.apache.org/committer-index.html#unlistedclas

        Show
        Claus Ibsen added a comment - Piotr can you point out your name on the Apache CLA site? http://people.apache.org/committer-index.html#unlistedclas
        Hide
        Piotr Klimczak added a comment -

        Well, i am not listed there yet. Not sure why.
        I have received a message from Sam Ruby that my ICLA was filed in ASF records and I should advise the project PMC.

        Do you have any idea why am i not listed yet?

        Show
        Piotr Klimczak added a comment - Well, i am not listed there yet. Not sure why. I have received a message from Sam Ruby that my ICLA was filed in ASF records and I should advise the project PMC. Do you have any idea why am i not listed yet?
        Hide
        Willem Jiang added a comment -

        Applied patch with thanks to Piotr.

        Show
        Willem Jiang added a comment - Applied patch with thanks to Piotr.

          People

          • Assignee:
            Willem Jiang
            Reporter:
            Piotr Klimczak
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development