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

lockRecord question

 
Robert Alden
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone. I need help

My project is B&S. Have question about following specification.



#1 Does is mean, when client#1 books a service and updates record#1 and sits idle for two days, client#2 will block for 2 days if it wanted to book same service (record#1) which is not available?

So, does this 'lock' correspond to
a) booking a record in business sense ? OR
b) getting the object lock of the record (in true Java object lock sense) ?


Is it OK to implement a solution where Client#1 has the ownership of record#1 (i.e booked the record in business sense) , but Client#1 does not
have the java object lock of record#1 ?
e.g. Client#1 synchronizes on a collection which holds reserved(booked) records and uses java object lock on the collection, rather than on the record ?

Thanks in advance.
Rob

[Andrew: Changed wrapping on code so that horizontal scrolling is (hopefully) not required]
[ February 11, 2006: Message edited by: Andrew Monkhouse ]
 
Robert Alden
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys , give some response
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12012
218
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,

Welcome to JavaRanch and this forum.
#1 Does is mean, when client#1 books a service and updates record#1 and sits idle for two days, client#2 will block for 2 days if it wanted to book same service (record#1) which is not available?
If client#1 had locked the record and not unlocked it for two days, then client#2 will indeed be blocked for the two days.
So, does this 'lock' correspond to
a) booking a record in business sense ? OR
b) getting the object lock of the record (in true Java object lock sense) ?
It might not be an object lock on a record (how you implement the lock is up to you - some candidates do lock individual records, but others do not).

What is important is that you have some logical locking mechanism in place so that only one client can modify a record at any given time (assuming they both conform to the locking procedure). Note that locking a record can also be used for deleting records (and there might be other uses as well).
Is it OK to implement a solution where Client#1 has the ownership of record#1 (i.e booked the record in business sense) , but Client#1 does not have the java object lock of record#1 ?
e.g. Client#1 synchronizes on a collection which holds reserved(booked) records and uses java object lock on the collection, rather than on the record ?
Having a collection of logically-locked records can make sense, but remember my earlier comment that a locked record does not necessarily relate to a booked record. A locked record is just that - one that has been locked (presumably to stop any other client from modifying it). A locked record does not necessarily have to be booked or deleted.

Regards, Andrew
 
Robert Alden
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew

So, 'locked' is the temporary state (logical lock) of record while client updates it( which is short period, unless system hangs).

An unlocked record might be booked.

lock ->book(or delete) -> unlock is a valid sequence.

Is that correct?

Thanks
-tapas
 
Robert Alden
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew

So, 'locked' is the temporary state (logical lock) of record while client updates it( which is short period, unless system hangs).

An unlocked record might be booked.

lock ->book(or delete) -> unlock is a valid sequence.

Is that correct?

Thanks
-tapas
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12012
218
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,

Yep, that's correct.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic