Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unlock a record with DGC

 
Jack Zhang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To my understanding, all clients are sharing the same remote Data objet. How can you use unreferenced() to unlock a locked record when the locking client disappears, while other clients (and the jndi tree) are still holding references to the remote Data object?
 
Jack Zhang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any comments on this will be appreciated!
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this case, there is no way.
But, if each client has his own remote Data - you could do it.
 
R Bischof
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about this strcuture: Each client has it's own remote DataServer object. All these DataServers share the same dataobject.
Each DataServer uses a reference to itself as the client identifier when locking records.
When the client disappears its DataServer is finalized and cann then call a method on the DataObject that removes all ocks it currently holds.
Rainer
 
Jack Zhang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response! I still have the following question:
When a remote client lookup() a remote DataServer through RMI, (1) does it use the existing object (referenced by the jndi tree),
or (2) is a new object created ?
In case (1): the DataServer.finallize() won't be called when the client disappears, because the tree (and other clients) still have references to the object.
In case (2): how can multiple DataServer objects share a single DataObject?

 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jack Zhang:
When a remote client lookup() a remote DataServer through RMI, (1) does it use the existing object (referenced by the jndi tree), or (2) is a new object created ?
A new proxy is created, but it references the very same remote DataServer object. But in the Connection approach you would of course not bind a Connection in the RMI registry! Instead, you bind a ConnectionFactory (another GoF buzzword for your design docs). The client would retrieve the factory and call it to create their very own database Connection.
In case (1): the DataServer.finallize() won't be called when the client disappears, because the tree (and other clients) still have references to the object.
Do not rely on finalize(). Use RMI distributed garbage collection (specifically, look up the javadoc for Unreferenced).
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic