Fola Fadairo

Ranch Hand
+ Follow
since Feb 16, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Fola Fadairo

If a client is aware of the records it is presently locking, it should not be a problem preventing it from trying to lock a record it has already locked.
I simply return the existing lock cookie when the client owning the lock on the record tries to lock the same record again.
The specs say:

Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file



Examples of when Record not found Exception would occur:
1) Trying to read a deleted record.
2) Trying to update a deleted record.
3) Trying to delete an already deleted record.
4) Trying to lock a deleted record.
5) Trying to unlock a deleted record! (The only exception here would be: a client tries to unlock a method it locked after deleting it!)
I think that satisfies the requirements, but I know there are other opinions. I think it is a design issue.

after I use delete() method, then the record is marked deleted, in unlock() there is some checking code like this
if (isDelete(recNo)){throw new RNFException;} because isDelete(recNo) will always return true after I use delete() method, unlock() method will always throw RNFException。



You could modify your code:


You could also check if the record is not locked before throwing RNFException.



You should also check that the client attempting to unlock the record is the same client who locked it.



Hi Sergy,
1) You still have some work to do to satisfy the requirements. You may find this link helpful.

2) The server interface does not have to provide the same methods as Data. You should only expose the methods you wish (or need) to.

3) Quoting fully... "In either case, the program must allow the user to specify the location of the database, and it must also accept an indication that a local database is to be used, in which case, the networking must be bypassed entirely." I understand this to mean the command line argument should specify the start mode, standalone mode or connecting to a remote database.
Sure Roel, you are right. Extra filtering is required.
What K means by ".... way will depend on how you present your search ..." is: Some people do not allow input text, they display the possible data and the user chooses...
findByCriteria;
Seems straight forward from the name;
If criteria is true
return found record(s)
else
-Do what your requirements say.

Like Roel wrote, post what you presently have...
1) If the record does not exist, why does it have to be unlocked?
2) What are you doing about this

If the specified record is already locked by a different client, the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked.



The following steps should be fine

Step 1) check if record exists
(a) if record exists, go to next step
(b) if record does not exist, throw exception
Step 2) check if record is locked by another client
(a) if record is locked by another client, give up the CPU and consume no CPU cycles until the record is unlocked.
(b) if record is not locked by another client, go to next step
Step 3) lock the record

Search for "lock method" on the forum, there are very many extensive descriptions on the topic. In my opinion, the old posts on this topic are the best.

Regards.
It depends on what is in your specs. Offhand, I would say you are missing two things:

1.) You will have to catch InterruptedException.
2.) Call notify or notifyAll before leaving the lock method.



Sure, another customer might try to book a reserved record but should not be able to do so. My understanding is that a booked record should have the owner field populated. So it should not be possible for a customer to book a record when the owner field is populated.
Hello Kevin,
I have URLyBird. The thread is about the search requirements on the business side. Part of the requirements state:

"It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user"



I understand this to mean, String.equals(...) or String.equalsIgnoreCase(...). The code I posted demonstrates the way which appears most intuitive to me. There are probably easier and more efficient ways to do it, but I like the simplicity of the code.

The find method returns an array of integers, so the code will not work as posted, one will still have some fun providing a working implementation.

Regards,
Fola



Looks okay to me. I find it readable and easy to understand, especially for a junior programmer.


I found the solution and it goes:



The code should be called for the cell where the owner id is entered. I make the call in the EventListener whenever the 'Book' button is clicked.