aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes running standalone and caching issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "running standalone and caching issue" Watch "running standalone and caching issue" New topic
Author

running standalone and caching issue

Charles Dupin
Ranch Hand

Joined: Oct 18, 2002
Posts: 94
Hi,
I have implemented some caching on the server to make sure that the data in the database is not re-read from the disk storage if no modifications was made to this data. This poses a problem when I run two times the application in standalone mode (no RMI): it starts two local servers, one server does not know the caching status of the other one. Of course this is not a natural situation as there is no controller running the two servers. What should I do: document the situation, remove the cache...?


Charles.<br />(SCJD2)
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Two Data instances running against a single file in separate JVMs will not work correctly anyhow, whether you have caching or not. Race condition galore. So don't worry.
Nevertheless, consider removing the cache. It goes straight against the requirement not to complicate the design for performance's sake.
- Peter
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

This poses a problem when I run two times the application in standalone mode (no RMI): it starts two local servers,

Servers in Local mode? Maybe you are referring to something else.
Mark
[ January 28, 2003: Message edited by: Mark Spritzler ]

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Brian Blignaut
Ranch Hand

Joined: Jan 08, 2003
Posts: 61
I would remove the cache as there is no requirement for it. Also the spec states that when in local mode the client and database run in the same vm, which means you will have no way of keeping two instances in sync.
Charles Dupin
Ranch Hand

Joined: Oct 18, 2002
Posts: 94
Servers in Local mode? Maybe you are referring to something else

Of course I am referring to the DataModelServer that is directly connected to the client by a method factory in local mode. In remote client/server mode this method factory connects the client to a DataModelClient.
Both data models are extending a DataModelAdapter.
By the way when I remove my cache the answers to the client are a lot slower.
Charles.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Charles, that kind of confuses me. Maybe I am getting caught up in the class naming that makes me misunderstand.
You see in my design I have two classes DataAccessLocal and DataAccessRemote, both of these classes will be wrapped into a DataAccessFacade. This is the only class that the client gets in Local or in Remote mode, so the client never really knows what mode it is in. This might match what you have, but I am thrown off by the "DataModelServer" class name.
I apologize if I am misinterpretting things.
Mark
Charles Dupin
Ranch Hand

Joined: Oct 18, 2002
Posts: 94
You are right Mark, my naming for these method is not very good. I will review it.
By the way my method factory is returning depending on the local or remote connection:
The server itself always connects to the DataModelServer.
DataModelServer is in the server.jar
DataModelClient is in the client.jar
To be able to run the client in local mode I put the path of server.jar in the manifest of the client.jar .
Charles.
Chandra Peri
Ranch Hand

Joined: Sep 18, 2002
Posts: 46
To Avoid starting two instances on same db file, I used filelock from FileChannel "java.nio" api package.
Ofcourse you need jdk 1.4!
 
Consider Paul's rocket mass heater.
 
subject: running standalone and caching issue