Kevin Mc Cusker

Greenhorn
+ Follow
since Aug 06, 2003
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 Kevin Mc Cusker

Hi all,
Im about to submit and was wondering what was the latest jdk we can say we used in our version.txt.

I developed my project using 1.4.2 but this has been replaced for over 18 months now, right?

If thats the case I'll just test against 1.5 or 1.6 and put that into version.txt.

wish me luck!!
Hi all,
My marking breakdown includes 80 points for locking, 40 points for server and 40 points for data class.

Using RMI I have a remotedbimpl class which basically calls the methods in data.java, which does all the work (locking, reading, writing etc). I understand the locking marks will be based on the two lock\unlock methods.

BUT my "Server" doesnt really do much outside of this data class so i am wondering what should i be concentrating on outside of data.java in order to get full marks for the server part?

I know this should be obvious but please comment as i am feeling a little confused right now trying to distinguish from the server and the data class. It could hardly be 40 marks for the simple RMI implmentation could it?
Hi,
My design is pretty simple, but could you have a read through this and let me know your opinions on 2 points in particular?

Point 1.
OK, my Data.java has a few methods like for example, update, which requires a lockCookie as a parameter. Because of this I think i am forced to perform locking in both local and remote mode, which i am doing.

I dont want my GUI to call locks directly on my records so I have two other classes, localDBImp and RemoteDBImp which each hold a reference to my Data.java object. It is these classes only that call the locking methods of Data.java. Incidentally, these two classes can only perform search, read and update(for booking record).

Point 2.
I am using RMI. the remote object is RemoteDBImp which has a reference to Data.java, as i mentioned earlier. Here is where i am a little confused though.

In RemoteDBImp's constructor it calls:
private Data db = new Data();

My data.java has a few static lists for lockedrecords etc.

Say I have multiple remote clients. Are they all referencing the one UnicastRemoteObject RemoteDBImp and therefore the one Data.java object or should I somehow be creating a new Data.java object per client (therefore justifying my static lists)?
So i'm resigned to locking in local mode, right?
But what about booking a record? updateRecord also requires a lockCookie.
Im not intending on implementing it twice, I just cant see how I can delete a record in local mode without having to also perform a lock, as the delete record method requires a lockCookie as a parameter.
Hi all,
When in local mode i must not use any networking. I want to go beyond this andremove the unnecessay locking\unlocking for local mode too.

my data access class, data.java, implements a DBAccess which for example has the following method:

public void deleteRecord(long recNo, long lockCookie)...

Am I stuck now with having to implement the locking in local mode too? If not how can i get around it?

Thanks!
A shutdown hook? Time for some investigating!!

Thank You all for your replies!
Hi there,
No reason, but i think the only place i could do it is in the finalize() method of my data class. as far as i am aware this is pretty dodgy so was hoping i wouldnt need to do call close() at all.
Is the risk of the finalize not being called large? What are the consequences of implementing it this way?
Is there another way of safely doing this on server shutdown?

Thanks
If I open the file in this mode does it mean I dont need to call Close() on it since the data is getting wrote to file?

Thanks.
Thanks Adam,
Ive looked into it and agree, a singleton oblect is the way to go. A nice clean implementation.
Im also going with the update file on every change.
My head is much clearer now, Thank You!
I think a static method called from a static block in my constructor would stop unwanted data re-initialization.

But does anyone think its good idea to immediately persist changes to the .db file? if not, how else could i implement it? ie, when would the updated records get wrote to file.
Hi all,
My database object (one per client) has some static lists holding records etc. When (and how) should I persist any updates to disk? At the minute I'm doing it with every option thats changing data but it means lots of I\O, but on the other hand is safer in case of the server crashing and changes getting lost for example (could this be a reason for keeping with my design?).

Also,
My database constructor populates the static lists, by reading the file:

class Database
{
static List records = new ArrayList();
public Database
{
try{
//read file, and add to records
}
catch{}
}
}

Now, take this scenario:

Client A connects, creates first database instance and static list gets populated, Client A then updates the Static list.
At the same time client B connects, before Client A persists changes to file.
Because client B created its database object before Client A updated the file the static list is repopulated with old data.

Basically i need suggestions as to how, after initial db object creation, I can stop subsequent database objects re-populating my static list. I dont see how i can take the try\catch clause out of the constructor.

Thanks.
Hi all,
Im using an arraylist to add all matches i get in the searchcriteria method. Say for example I have two matches. I then use the following line of code to change it into an array:

Object[] toArray = myArrayList.toArray();

I dont know why but the size of this array is always 10 times larger than the arraylist - 20 in this example!!.

Any comments welcome
Hi all,
Im having a small problem. Basically I have 6 String which represent a record I want to write to the database.
I declare a byte aray the exact length that i need but arent sure of the best approach to get my strings at the exact positions in the array that are required.
For example, String2 needs to start at pos 32, but String1 is only 10 characters long.
Even then im not sure how to write to the file.

Any help is welcome.