aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Notifying waiting clients when the database is shutdowned Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Notifying waiting clients when the database is shutdowned" Watch "Notifying waiting clients when the database is shutdowned" New topic
Author

Notifying waiting clients when the database is shutdowned

Liviu Carausu
Ranch Hand

Joined: Oct 07, 2004
Posts: 158
Hi,

I wondered how have you handled the clients that were waiting for
some record to be unlocked when the database is shutdowned.

In my opinion the only two possibilities to wake up the waiting threads are either to use notifyAll or to send them an InterruptedException. Before trying to wait again for the record to be unlocked, the value of a "shutdowned" flag must be read . In case that the flag is set, an exception must come to the client, telling it that the database was shutdowned..

What do you think about this scenario ?

What is the expert opinion : use notify or use InterruptedException. Which one is theoretically better suited for such a cancellation task ?

Thanks,
Liviu


Oracle Certified Master Java SE6 Developer(SCJD),
OCE JEE 6 JSP and Servlets Developer.
Muhammad Shafique
Ranch Hand

Joined: Sep 30, 2006
Posts: 59
Does your assignment say to handle these scenarios:
-Server shutdown.
-Client Crash.
Liviu Carausu
Ranch Hand

Joined: Oct 07, 2004
Posts: 158
No, client crashes and database shutdown are not mentioned in my specifications. But you are never sure how much is expected from you....
Muhammad Shafique
Ranch Hand

Joined: Sep 30, 2006
Posts: 59
Read This!
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Hi Guys,

We deal here with two problems :
1.The close server - waiting clients
2.Crash clients

1.The close server - waiting clients
Well the problem is simple that it seams. The sever close process must wait until all the clients are ready with them tasks, more precisely if there are no locked records. If a client tries to gain access to a record and the record is locked the client must wait until the record is free but the client does not lock the record so it is not involved in a transaction - he just wait to be involved. So it is acceptable to end this threads with an exception. Even more precisely if there are waiting threads, this threads must be wake up, so before the you interrupt thread work flow (with an Exception) you must notify the rest of the (possible) waiting threads.

2.Crash clients

I am not shore if this is part of the exam but I am not so shore. I use RMI and I have th possibility to use the Unref. interface, but I am not so shore about. Any way you must document your decisions so at least you must mention in your choiches.txt how/why/etc with Crashed clients.

Regards M.


SCJP, SCJD, SCWCD, OCPJBCD
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
No, client crashes and database shutdown are not mentioned in my specifications. But you are never sure how much is expected from you....

Please notice an important issue that do what are asking to do with.

If you implement extra features correctly, NO bonus point is given.

However, if you implement extra features incorrectly, points will be deducted.

So, be careful.

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
 
 
subject: Notifying waiting clients when the database is shutdowned