• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Ejb cache with singelton implementation

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would appreciate your advice about an issue I have.

I'm working with jboss, EJB 3.1 environment.

each time the user entering a specific screen, it should be a trigger for creating a tree data type which based on a data that saved on the database. this tree calculation can take some time, and it's can be heavy on performance.

the following requests are sent from UI :

  • 1. refreshTree - a trigger for building the tree
    2. isTreeReady - indicating whether the tree is ready to use, and called every x amount of time
    3. getTree - return the tree.


  • when building this I should take into consideration that multiple users can try to perform each one of those actions simultaneously. it's also true that 2 users share the same tree if any refresh hasn't been done.

    I've thought about implementing it as a cache as follow :



    the issue I have with that is that there can be a scenario in which :

    first user refreshing the tree - and the tree is built.
    then second user start to build the tree, and initialize the isReady flag to false, before the first user has noticed about the tree calculation - in this case the first user will need to wait to the calculation to be completed (even though he could have use the tree).

    I'm trying to think a bout using a read lock in some way (instead of the isTreeReady flag), but I can't think about any that will fit my needs.

    do you have an idea what can I do?

    thanks.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic