Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Local mode an d remote mode

 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kathy Sierra and Mehran Habibi,
Can you answer the last post in this thread?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nandini Sriram
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry .. I posted in the worng forum!!!
[ August 15, 2003: Message edited by: Nandini Sriram ]
 
Eugene Sun
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic