Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Did anybody's program can work both locally and remotely at the same time?

 
michael opto
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did anybody's program can work both locally and remotely at the same time? It seemed that I have a problem with the lock method. If I lock a record through a remote client, I still can book tickets through the local client. I am using RMI and the local client just uses a instance of the remote interface implementation.
Thanks in advance!
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have to allow the user to change the mode once it is selected during the application startup. You were able to do it because you may be working with two different instances of Data. But this kind of test is unnecessary.
 
michael opto
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sai. But what I am thinking about is that if an administrator wants to change the database on the server, he can start a client as a local client. He just needs to lock the whole database so that other remotely connected clients can't modify the database. And the remote clients don't need to be disconnected. In this case, the remote clients and the local client are working at the same time.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But what I am thinking about is that if an administrator wants to change the database on the server

You don't need to worry about this, it isn't a requirement.
Mark
 
michael opto
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark:
I guess my thought is quite reasonable. Server needs administrator. Please help me think about any solution. My problem is that when I have my Server running, if I start a local client, it seems that this local client is using a different DataServerImpl object from that used by the remote client. So the locks are different too. Is there anything to do with RMI here?
Another thing is: can you tell me why we need singleton?
Thanks.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First local mode would access it's own database and db, no rmi, no server.
Whereas the server remote is on it's own serving other clients, not the one that is running local.
You need to seperate them in your mind. There will never be a time when the server is running with the db.db and at the same time a client local running to the same db.db file.
You do not need Singleton in this assignment.

Mark
 
michael opto
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark:
Could you take a look at my design? My design is very simple. No lock manager, no Facade. It works. But I don't know if I miss anything. Maybe need more work on the Server class.
Thanks.
DB:
Data{
//implements the lock, unlock, and search methods here
}
Server side:
DataRemote extends Remote{
//defines all the public methods in Data and other own-designed methods
}
DataRemoteImpl implements DataRemote{
//RMI implementation
//forword mothods to Data
}
Server{
//get the instance of DataRemoteImpl and export it;
//rebind it to the rmiregistry
//need anything else here?
}
Client side:
Client{
//GUI
//invoke methods on DataServer returned by a Factory
}
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really think you should look into the Facade class, it isn't very difficult to create. As a matter of fact you already have the methods written, it is just in your client code.
The reason I say this, is because say latter down the road they go with a different database scheme, but then that would mean you need to change the client code. But with the Facade, you just need to change it, and the client stays the same.
What about your design for Local mode?
Mark
 
michael opto
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me specify a little about my design. All the real work is handled at the server side. The client has no idea what the database is. The client only knows the DataServer which knows the Data that deals with the database. Do you mean that I need to change the Data class? But how?
If the client is in local mode, the DataServer object at the client side is actually a DataServerImpl instance. Although it implements Remote, since Remote is just an interface without any method, I assume there is little overhead. But is it a neat design or a complicated one? What do you think?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic