• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

B&S: Same Questions

 
Laura Pecoraro
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all agains

I have same question, because my solution don't satisfy me fully

Lock
I implements a simple locks (using the Lock interface & List of records locked)... so

For my opinion the read function CAN reads a record lock, but, possible incoherence of data occurs...
Same ideas

RMI
I implements a RMI connection (an direct connection), manages by a Connector class (returns DBMain reference by specified connection type)...
I must implements the DBMain (by Sun) & implements DBMainRmi (by me) for manage the RMI service

But, this way, I must "RE"mapping the DBMain interface into DBMainRmi because the RecordNotFoundException not match with RemoteException... I would like NOT "re"mapping the DBMain

It is possible??

Thanks...

Laura



 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Laura, you seem to make some progress

About the locking - What do you think? Will the read thread able to get the "latest" or "updated" value? IMO as long as some thread "updates" the data, any threads that read AFTER the update will get the upated value. It's all in the timing.

About the RMI, you do need to figure out the architecture - meaning what methods are exposed to the clients. Have a look at these thread A and thread B. When deciding what methods to expose really includes if the client can access the lock and unlock methods of the Data class.
 
Laura Pecoraro
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:Hello Laura, you seem to make some progress

About the locking - What do you think? Will the read thread able to get the "latest" or "updated" value? IMO as long as some thread "updates" the data, any threads that read AFTER the update will get the upated value. It's all in the timing.

About the RMI, you do need to figure out the architecture - meaning what methods are exposed to the clients. Have a look at these thread A and thread B. When deciding what methods to expose really includes if the client can access the lock and unlock methods of the Data class.


Thanks for your supports

About the locking the Sun specifications say


If I to understand, no CPU cycles, NO WAIT UNLOCK RECORD... Its true

Or I notify all to waits this unlocked record

I make some progress... My solution is 80% completed... so and so...
 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK think about this. Where do you wait? If a record is already locked, do you need to wait in order to unlock it? Same goes for update/delete methods. How do you ensure only one record is locked? How to make it thread-safe?
 
Laura Pecoraro
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:OK think about this. Where do you wait? If a record is already locked, do you need to wait in order to unlock it? Same goes for update/delete methods. How do you ensure only one record is locked? How to make it thread-safe?


Ok... a solution is notifyAll when a record is unlocked, but, in this case an operation must be waits... I don't like...

I thinks notify immediately if a record is Locked (for delete/update) operation using the Exception (RecordNotFoundException)... for reads, notify when an record is unlocked...

Do you think about this

Laura

 
K. Tsang
Bartender
Posts: 3583
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Laura Pecoraro wrote:Ok... a solution is notifyAll when a record is unlocked, but, in this case an operation must be waits... I don't like...

I thinks notify immediately if a record is Locked (for delete/update) operation using the Exception (RecordNotFoundException)... for reads, notify when an record is unlocked...


First you need to decide these things:
* How many threads can read at the same time?
* How many threads can write at the same time?
* Do read operations (eg read, find, getXXX) need to wait/notify?

Most threads do reads more often than writes. In my approach, I only allow 1 thread to write. Since locking is required for writes (lock -> update/delete -> unlock) I wait until the record is locked.

For the notify in the unlock method, can you control which thread to notify? No so notifyAll is the appropriate way to go - not necessarily the best approach.

Just a reminder, for the create menthod, locking should be done internally.

Oh don't think about performance or speed like you are tending to do. The goal is to get the app works and do the correct functionalities correctly. The Data class/server/locking together is worth 160 points. And without locking you can't pass (80 points).
 
Julio Cesar Marques
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Laura! It seems your problem is about Lock, my question is about C/S communication algorithm. Locking is a thing that you have to write only by Server side. My problem is how the best way to do a C/S comm and not lose points on this item.
 
Julio Cesar Marques
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ops!! My bad! I had seen another post and just mixing everything...
;)
 
Laura Pecoraro
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks All
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic