Andriy Pererva

Ranch Hand
+ Follow
since Jul 19, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Andriy Pererva

Roel, thank you for the quick answer!
I think, I very overcomplicated my solution
Hi guys,
My Data class is also a facade, and it contains DBFileAccess and ReentrantLockingManager instances to handle the corresponding tasks.
I this case I decided to add a service to DBFileAccess for record availability checking:



Because my DBFileAccess and ReentrantLockingManager know nothing about each other (so can be separately unit-tested), all the checking logic performed in the Data class, which makes it a kind of "thick facade" :-)


But if you use thick client approach:
1/ user hits book-button, record is locked, dialog opens, user enters customer-id, user confirms dialog/booking and record is updated and unlocked
2/ user hits book-button, dialog opens, user enters customer-id, user confirms dialog/booking and record is locked, updated and unlocked



Hello, Roel!
I was going to ask exactly the same question about these two locking strategies :-)
I want to implement the first approach and these are my argumentations:
- When the CSR select the record and click "Book..." button, the record will be re-readed from database (to ensure that it is not stale), after that the records gets locked and booking dialog window opens, where only Owner ID field is editable. During this operation CSR will be confident that another CSR (who probably type faster) will not "intercept" his record in it's process of booking.
- because of slow typing or coffe break the lock may be held pretty long time, so I implemented the timed version of my lock record (beyound the base interface, of course) which tries to get lock no longer than n seconds (2sec. <= n <= 5sec.) and if this method return false, the message like "This record is temporarily locked by another CSR. Try again later" will appear.

approach 2 is easier in implementation, but IMO it has serious drawback: CSR certainly will not be happy if he picked up a free record, opened the booking dialog, type the client number, and after pressing "Confirm booking" button suddenly get an error, because another faster CSR has already booked the same record couple of seconds ago :-(

Please, answer me:
1) is my described approach sensible?
2) will I not be punished for using my timed version of lock() method, instead of timeless version provided by assignment interface? Of course, I created both versions to implement interface.
3) My GUI client will not allow to lock more than one record at a time, but what about business service layer? What if the same client already has a lock and is trying to obtain another record's lock? What do I need to do:
a) simply allow to obtain multiple lock but write some warning message to log about possible deadlock?
b) silently release the previous lock before obtaining the new one?
c) throw some kind of RuntimeException and do not allow to aquire second lock?

Thank you in advance for your valuable answers!

Hi, Roberto!

Thank you for your clear example of how to make remote services.

My question is about this piece of code:



In this example your RMIRemoteServices extends DefaultServices, not UnicastRemoteObject, as it is recommended in Andrew's book.
If I understand correctly, you are using UnicastRemoteObject.exportObject() method instead of inheritance?


What does MDD stand for?



Model-Driven Design
Roberto,
I have the same issue with my B&S assignment about record numbering strategy.


so the record number is the position that each record appears in the .db file.



What the position means?
a) the real byte position of the data block in the db file that used as argument in RAF.seek() method
b) simply ordinal position of the record in file (i.e. 1, 2, 3... etc)

In case of b) how should I treat deleted records? Simply skip them and don't include in numeration order or keep their numbers and throw RNFE when the number of deleted record is requested?
Hi, Bernd!
Thank you for the solution with Unreferenced interface. Couple of days ago I also tried to get it work, but encountered the same problem.

In my opinion, to avoid such lost locks it will be reasonable to implement timeout (for example, 5 sec.) for the time of lock holding. This means that if client didn't release the lock within specified timeout the operation should throw an exception and lock should be released by timeout.
Hi, chandan!

The purpose of the logo is that you can use it on your business (visiting) card, in case if in future you will want to make them

The wallet card is the convenient form of certificate. For example, the main certification "diploma" you may hang on the wall near your working desk, while yor wallet card you can bring on your job interview to prove that you really have certificates mentioned in your CV.
As for me, the SCJP exam was much harder than subsequent SCWCD, because it was my first certification exam and the questions were so tricky!
After hours of preparation with different exam simulators I felt myself in the role of compiler :-)
Hi, Adam!

Welcome to the Javaranch forum!
First of all you should consider taking SCJP exam in order to go ahead and take more complicated examinations, like SCJD, SCWCD, SCBCD etc.

With best regards,
Andriy
Hello,

you don't need to define the start() method inside your class, because it is just Runnable, not a Thread.
If you want to start your anonymous Runable, you need to pass it to the constructor of the thread, then start this thread.
In case if you want to use your Thread3 class, you need to provide additional constructor:



after that you can do in your main method something like this:

Congratulations!

I think you don't need to re-take this exam once again. Passing of SCJP opened for you many new examination directions, in which you can take effort and try to achieve more confident results. For example, try SCJD or SCWCD as your next challenge.

With best regards,
Andriy
14 years ago
Just to be on the safe side it would be reasonable to use Singleton not directly, but in combination with DAOFactory.
This approach gives you freedom to change an implementation of Data class instantiation without changes in clients code.