aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Local mode an d remote mode 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 "Local mode an d remote mode" Watch "Local mode an d remote mode" New topic
Author

Local mode an d remote mode

Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
I am a bit confused about LOcal and remote access and the files allocation. The following is my understanding, and I hope you can correct me if I am wrong.
For example, There are 3 computers: ServerBox (used as server), ClientBox1, ClientBox2 (used by clients). The db.db, code for starting server and code for gui and for accessing db.db should be in ServerBox. code for gui and accessing db.db should also be in ClientBox1 and ClientBox2. When a user run the gui from ServerBox, it is Local mode. When the users run gui from ClientBox1 and CLientBox2, it is remote.
Is this corrent?


Thanks,<br />Mike
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Close, but also give the man a cigar.
Remote is a client accessing the server, this could be on the same machine or two different machines. In local mode there is no server running. The client accesses the data directly, there is no need to lock in local mode either. That is the definition of "stand-alone" Think of stand alone as MS Word, your document that you are working on is on your hard drive, you need no server to store your documents, or to run Word.

Mark


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

Joined: Nov 17, 2001
Posts: 175
Hi Mark,
Thank you for your help. I have two more questions further to your answer:
(1) The local mode and remote mode use different command line commands. If a user access the database using local mode, then the server doesn't have to be started or the server must not be started?
(2) If the database doesn't need to be locked in local mode, then server must not be started, otherwise, remote users will access to the database while the local user is using the database. Also, only one local access is allowed at any time. Is it correct? The Sun's instruction doesn't mention this at all.
Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
Hi Kathy Sierra and Mehran Habibi,
Can you answer the last post in this thread?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Ummm, Kathy doesn't normally visit this forum, and Max is somewhat busy at the moment.
(1) The local mode and remote mode use different command line commands. If a user access the database using local mode, then the server doesn't have to be started or the server must not be started?
If a machine is running in local mode, no additional server is necessary. And we have been told that only one program will be accessing a given data file at a time, so we can assume the user will not try to start a server and a local mode program using the same file. So you don't need to worry about it.
(2) If the database doesn't need to be locked in local mode, then server must not be started, otherwise, remote users will access to the database while the local user is using the database. Also, only one local access is allowed at any time. Is it correct? The Sun's instruction doesn't mention this at all.
Look under "Locking" in Sun's instructions. "You may assume that at any moment, at most one program is accessing the database file".


"I'm not back." - Bill Harding, Twister
Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
Hi Jim,
Thank youi for your reply.
My assignment is Flight By Night downloaded in Oct 2002.
In my instruction, it doesn't say "You may assume that at any moment, at most one program is accessing the database file". or "only one program will be accessing a given data file at a time".
My instruction says: "These methods are required to allow concurrent use of the database when booking flights from multiple clients."
Perhaps, I can assume that only one program can access database file at any given time.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
My assignment is Flight By Night downloaded in Oct 2002.
Oops, I shouldn't have assumed.
Perhaps, I can assume that only one program can access database file at any given time.
My guess is that's what was intended, unless you can find other quotes that contradict this. I suspect that they added explicit instructions about this to later assignments, because some people might have made their solutions more complex than intended, trying to guard against other programs accessing the DB. But others more familiar with this assignment are more qualified than I to comment...
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11460
    
  94

Hi Mike
[Mike]: Perhaps, I can assume that only one program can access database file at any given time.
[Jim]: My guess is that's what was intended, unless you can find other quotes that contradict this. I suspect that they added explicit instructions about this to later assignments, because some people might have made their solutions more complex than intended, trying to guard against other programs accessing the DB.

I agree with Jim as to the probable reason for the explicit instruction in later assignments.
You will have noticed that most of the methods of Data class call invariant() to verify that nothing untoward has happened to the database between accesses. I think that this is all Sun require in the way of verifying that only one application is modifying the database at any given time.
Personally I think it would be very difficult to guarantee that only one application could access the database at any given time. There are some things you could do, but most of them would require changing the provided classes. Sun have told us that those classes "are complete". I take that as meaning that we should not go changing existing functionality if we can avoid it.
I did not have any checks or any restrictions on having the standalone GUI and the server running simultaneously. I think I had some comment in either my README.txt file or in my user documentation telling the user not to do this, but that was all.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
Sorry .. I posted in the worng forum!!!
[ August 15, 2003: Message edited by: Nandini Sriram ]

Discipline, Dedication and Determination define Destiny.
Eugene Sun
Greenhorn

Joined: Aug 09, 2003
Posts: 17
Andrew,

[Andrew]: You will have noticed that most of the methods of Data class call invariant() to verify that nothing untoward has happened to the database between accesses. I think that this is all Sun require in the way of verifying that only one application is modifying the database at any given time.

Your comment is saying this invariant() method isn't much of a rigid check against muliple applications accessing the data file ?
Can you elaborate on the holes in this mechasim as to when it could fail to guard against multiple applications accessing the data file?

[Andrew]: Personally I think it would be very difficult to guarantee that only one application could access the database at any given time. There are some things you could do, but most of them would require changing the provided classes. Sun have told us that those classes "are complete". I take that as meaning that we should not go changing existing functionality if we can avoid it.

I am very curious about what you could do as you mentioned above. Can you elaborate on that ?
Thanks,
Eugene
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11460
    
  94

Hi Eugene,
I can but I don't want to. My point was that I didnt think we need to do anything to guard against the possibility of two applications modifying the data file at once.
Oh, alright, just as a technical exercise .....
Your comment is saying this invariant() method isn't much of a rigid check against muliple applications accessing the data file ?
Can you elaborate on the holes in this mechasim as to when it could fail to guard against multiple applications accessing the data file?

invariant() is only checking that file size is correct. Any modification at all that does not change the file size will not be picked up by invariant().
[Andrew]: Personally I think it would be very difficult to guarantee that only one application could access the database at any given time. There are some things you could do, but most of them would require changing the provided classes. Sun have told us that those classes "are complete". I take that as meaning that we should not go changing existing functionality if we can avoid it.
[Eugene]: I am very curious about what you could do as you mentioned above. Can you elaborate on that ?

The first thing you would probably want to look at is the java.nio.channels.FileLock options - but whether this guarantees you exclusive access or not is not guaranteed. But to use this would require you to change the provided classes to use NIO.
Regards, Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Local mode an d remote mode