• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Several new issues about UrlyBird project

 
Greenhorn
Posts: 14
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Experts,
I have the following several new issues while developing the project, pl help look into them. Really appreciate your help.

1.In the provided DB interface, no exception is included in findByCriteria() method signature, or only special excpeiton is defined(e.g. readRecord()), what we should do for other exceptions, e.g. IOException or our self defined exception?
e.g.
public long[] findByCriteria(String[] criteria);
public String [] readRecord(long recNo) throws RecordNotFoundException;

But we know, we may encounter IOException while reading the data, I think of the ways to handle this
a.Swallow the exception and log it, but I think this is the correct way to handle it, as this is sever exception.
b.Wrap it with Runtime Exception, but I have no idea which runtime exception I should use. Or we should create our own runtime exception to wrap it? If so, how to handle these exceptions in caller method?
c.Wrap it with RecordNotFoundException, but it seems we should not do that, as the instructions says we can throw this exception for the following case.
'Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.'

2.Locking issue, the instructions says ' therefore your locking system only needs to be concerned with multiple concurrent clients of your server.  Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.'

a.should we consider timeout for this case? or else, the waiting thread maybe keep waiting for ever.
b.Should we consider potential deadlock here? as if Thread A lock record R1, then try to acquire Lock R2; But Thread B locked R2, and try to lock R1; If we need to handle deadlock, Pl share your solution if possible.

3.In Application Overview section of the instructions, it said 'They take bookings only within 48 hours of the start of room occupancy.', should we take this into account why showing the record list or update the the record, or just leave it?

4.Do we need to implement validation against every field while updating or creating a new record, e.g. the length or format of every field.

5.Which fields are primary key of vacancy record? As the interface requires us to throw DuplicateKeyException for creating, but didn't mention which fields are primary key. And all other method mainly used RecNo as method signature, as it is not an actual field, so I don't think we could use it as primary key to perform duplicate validation.

 // Creates a new record in the database (possibly reusing a
 // deleted entry). Inserts the given data, and returns the record
 // number of the new record.
 public long createRecord(String [] data)
   throws DuplicateKeyException;

6.Regarding RMI restrictions, it said 'You must provide all classes pre-installed so that no dynamic class downloading occurs.', does that mean we need to generate stub and skeleton even we are developing with JDK8 which could generating and downloading stubs?  how about skeleton? since client side doesn't use skeleton, so it seems we don't need to generate that. and it seems only JAVA 1 need skeleton, and we are using JDK8 new feature.
 
Bartender
Posts: 2237
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. You may not add any new exceptions to the method signature. My solution was to read the file to memory when the server started. That way when findByCriteria was called IOException was not possible.
2a. If your requirements don't state you must consider timeout then it is up to you to decide and justify your decision in the text file.
2b. Yes, a deadlocking blocking mechanism can make your fail.
3. I didn't consider this as a requirement. I passed.
4. You should not break the file so validation is a good idea.
5. As there was no primary key defined in the requirements I assumed there is no primary key at all so I never threw DuplicateKeyException.
 
jasn hofy
Greenhorn
Posts: 14
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paweł Baczyński wrote:1. You may not add any new exceptions to the method signature. My solution was to read the file to memory when the server started. That way when findByCriteria was called IOException was not possible.
2a. If your requirements don't state you must consider timeout then it is up to you to decide and justify your decision in the text file.
2b. Yes, a deadlocking blocking mechanism can make your fail.
3. I didn't consider this as a requirement. I passed.
4. You should not break the file so validation is a good idea.
5. As there was no primary key defined in the requirements I assumed there is no primary key at all so I never threw DuplicateKeyException.



1.Good idea. Will use solution as cache.
2a. Ok.
2b. I didn't get it. Do we need to implement that? If we need, can you pl give me some clue on this?
3.OK.
4.Ok. So I need to create my own defined runtime exception for these validation?
5.Ok.
6.is there any idea on point 6?
 
Paweł Baczyński
Bartender
Posts: 2237
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2b. You mustn't write a blocking mechanism that could result in a deadlock. It is up to you how you will do that. Just don't allow one path of execution to require multiple blocks.
4. Again, sorry, the same answer. It is up to you to decide. It might be a good idea to introduce a new exception for this check.
6. Honestly, I don't remember. I'll check what I did later.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

jasn hofy wrote:I have the following several new issues while developing the project, pl help look into them. Really appreciate your help.


There are no issues or problems, there are only challenges :p

jasn hofy wrote:1.In the provided DB interface, no exception is included in findByCriteria() method signature, or only special excpeiton is defined(e.g. readRecord()), what we should do for other exceptions, e.g. IOException or our self defined exception?


Some of the "must" requirements will definitely limit your possible choices. One of the requirements clearly state you can't change the given interface. That means it would be impossible to throw a new checked exception. What you definitely can do, is extend the given interface to add additional methods. That's what I did and I passed (with full marks).

jasn hofy wrote:2.Locking issue, the instructions says ' therefore your locking system only needs to be concerned with multiple concurrent clients of your server.  Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.'


That's up to you to decide how you implement your locking mechanism. If a deadlock can occur, you'll probably fail the exam. I didn't consider a timeout. In the OcmjdFaq you'll find some useful programs to test your locking mechanism.

jasn hofy wrote:3.In Application Overview section of the instructions, it said 'They take bookings only within 48 hours of the start of room occupancy.', should we take this into account why showing the record list or update the the record, or just leave it?


It's not a "must" requirement, so you can safely ignore it. And maybe you can explain in choices.txt why you did ignore it (And because Roel said it on the CodeRanch forum is not a good reason ).

jasn hofy wrote:4.Do we need to implement validation against every field while updating or creating a new record, e.g. the length or format of every field.


You don't want a corrupt data file, so a minimum of validation (e.g. field length) is always a good idea!

jasn hofy wrote:5.Which fields are primary key of vacancy record? As the interface requires us to throw DuplicateKeyException for creating, but didn't mention which fields are primary key. And all other method mainly used RecNo as method signature, as it is not an actual field, so I don't think we could use it as primary key to perform duplicate validation.


Again that's up to you to decide if you use a primary key in your data file and perform a check. You can do (almost) everything you want. The world is your oyster!

jasn hofy wrote:6.Regarding RMI restrictions, it said 'You must provide all classes pre-installed so that no dynamic class downloading occurs.', does that mean we need to generate stub and skeleton even we are developing with JDK8 which could generating and downloading stubs?  how about skeleton? since client side doesn't use skeleton, so it seems we don't need to generate that. and it seems only JAVA 1 need skeleton, and we are using JDK8 new feature.


That's a very old requirement! With very old JDK versions, you had to generate the stub and skeleton classes. But from JDK 6 (I believe), it's not a requirement anymore and I can remember many people passing this certification without having generated these classes. If I remember correctly, it's only one (simple) command you had to execute on the command line. In the OcmjdFaq you'll find a link to an Ant build script I used to generate all the deliverables.
 
jasn hofy
Greenhorn
Posts: 14
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is very useful, thanks a lot.
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic