IntelliJ Java IDE
The moose likes I/O and Streams and the fly likes too hard for me - multi-process file synchronization Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "too hard for me - multi-process file synchronization" Watch "too hard for me - multi-process file synchronization" New topic
Author

too hard for me - multi-process file synchronization

Jeff Caswell
Greenhorn

Joined: Mar 20, 2002
Posts: 6
Can someone please tell me how to do this or where to find information on how to do it? I have a general idea but don't want to waste time going down the wrong path. Here's my problem:
I have three separate JVMs running on the same or different machines and they all read/write the same file, which resides on one of the machines. (Right now, they are all on one machine.) My problem is they are not all writing to the file properly. Some information from each process gets in, but a lot is not.
My idea - please comment or suggest other ways:
Use a separate class to control that file on the machine it resides on and include an RMI "server" in it to control read/write to the file. The other JVMs should go through this class to access the file.
I don't know how to go about writing the class though. Just a few pointers is all I need.
Thanks.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Jeff,
You're right on the idea of using RMI and encapsulating the file into a single class which should be a Singleton. As for using RMI, it is fairly simple once you get the basics down. There is another forum on this site named Distributed Java and I believe there is a very good tutorial on RMI there by one of Sun's gurus. Also, there are various books which cover RMI. One of the bartenders here, Michael Ernest is co-author of The Complete Java 2 Certification Study Guide which has some excellent material on RMI in the Developer's section of the book.
Hope this helps
Michael Morris
SCJP


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
 
subject: too hard for me - multi-process file synchronization
 
Threads others viewed
Coordinating Processes Over Network
What happens to the static variable here ? Threads !
Accesing two synchronized methods
Tracking separate thread java/jsp/struts
Running server/client separately in runme.jar
IntelliJ Java IDE