• Post Reply Bookmark Topic Watch Topic
  • New Topic

Runtime Monitoring of a file  RSS feed

 
Madhavan Sundararajan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have got a property file which I read once completely, create an object and make it as a cache service.
I need to monitor the property file(preferably a thread which watches it) continously such that when someone changes the contents in the file or add something, the program should fire an event about the change happened. On getting the trigger message I should refresh my cache object accordingly.
Can someone help me out in this issue?
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends how soon do you want to reload the properties. For example: you can simply have a thread that compare file length or timestamp every 30 secs. Or you can do it in realtime, I never done it in realtime before, so maybe someone else can help you. One thing to remember, if your property changed, you have to figrue out how to propagate the changes without causing data integrity issue. You don't want a force-reload while the program is doing some kind data manipulation that could potential cause a corrupted data issue. My old program simply call a paused when finished current execution on all threads, write a snapshot (like checkpoints in database) then reload the data, and then restart the data.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!