• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Cache recover on failover

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Experts,
I need your advice on Cache recover machanishm if there is a JVM failover.
I am thinking to serializing the cache every time it is updated, but the problem is, it will write the entire object every time and wich is very expensive.

Could you please suggest me some technique to achive this?

Thank you!
 
Damodar Mukhopadhyay
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help please?
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PatienceIsAVirtue!

Serializing everything isn't an option since that will be a huge bottleneck. But what is exactly the problem? What is being cached? What kind of caching solution are you using? And why do you want cache recovery? Why not build the cache up as requests come in?
 
Damodar Mukhopadhyay
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Wouter,
I have a SingleTon class which has a HashMap.
The Hashmap is the Cache in my application and I want to serialize it so that if my application goes down for any reason I can able to repopulate the cache.

Thanks,
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please go through with following link if it can help you -
Serializing classes with hashmaps
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oke but then why not rebuild the cache as the requests come in? Saves you a lot of added complexity.
 
Damodar Mukhopadhyay
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually the values of the messages (which are in cache) are required for some calculation when a new request comes in.
That means the new requests/messages requires the old messages.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then it is not a cache. You could write a shutdown hook that writes everything to the disk but then in a hard failure (e.g. no electricity) then those messages will be lost.
If you really need it be always be available then you need to think about clustering and replication. However those aren't easy to implement and should only be used when
absolutely necessary.
reply
    Bookmark Topic Watch Topic
  • New Topic