dennis hu

Ranch Hand
+ Follow
since Aug 27, 2002
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 dennis hu

Hi guys:
I received the result from Sun web site and I knew I passed the exam.
Date Taken: 2002-12-16 03:56:14.043
Grade: P
Score: 145
Comment: This report shows the total points that could have been awarded in each section, and the actual number of points you were awarded. This is provided to give you per-section feedback on your strengths. The maximum possible score is 155; the minimum to pass is 124. General Considerations (maximum = 58): 54 Documentation (maximum = 20): 19 GUI (maximum = 24): 23 Server (maximum = 53): 49
Thanks Michael,Mark and other guys for yours help,I got many important imformation in this Saloon,thanks again.
I am going to get SCJA,where is the good web site and what are the good reference books?
17 years ago
Hi:
I uploaded my assignment last wednesday and took the essay exam last friday.
Before I upload it,I sent an emial to Sun and told him that I am going to upload my assignment. The Sun gave me the response that they ready to accepted my assignment.
Sun would not assess your assignment before your essay exam is taken.
Hi Tim:
You Server object has not done any bussinesses with Data class, how can you get the vriable?
could you say it clearly?
Maybe you need a refernce of Data object in your Server class, and you can get the FieldInfo[] through the reference!
Hi Mark and other guys:
In my implementation, I just modify the deprecated methods in Data class and add a little codes to verify the database file in his constructor.
I think the Data object is functional and effictively,I donot want to modify his main function, so create a new Remote Class have a reference refer to the Data object, I impletments the lock/unlock,findCriteria method in my remote oject.
Maybe means I had modified the Data class, but could somebody tell me its advantage and disadvantage??
Thanks!
Hi guys:
I also have this problem about test.
I test my application in a same machine,so
I spawn many threads to test my application.
On my client side I spwan 20 threads to book 20 different flights use different reference of of remote server and in each thread I spawn 20 threads again,means every fligh need to be booked 20 times,so there are 400 threas on my client side.But exception occured,there are follows:
java.rmi.ConnectionException Connection refused to host 218.242.2.51,nested exception:
java.rmi.ConnectionException Connection refused:connect
java.rmi.ConnectionException:Exception Creating Connection to host 218.242.2.51,nested exception:java.net.SocketException:Connect(Code:10055)
I think maybe the number of threads is too many,so
I only use one reference of remote server and spawn 50 threads to book different flights,but the same exception is still ocurred,and if only spawn 10 threads,it works well,I am so confused.

Anybody can help me,Thanks very much!
Hi guys:
I also have this problem about test.
I test my application in a same machine,so
I spawn many threads to test my application.
On my client side I spwan 20 threads to book 20 different flights use different reference of of remote server and in each thread I spawn 20 threads again,means every fligh need to be booked 20 times,so there are 400 threas on my client side.But exception occured,there are follows:
java.rmi.ConnectionException Connection refused to host 218.242.2.51,nested exception:
java.rmi.ConnectionException Connection refused:connect
java.rmi.ConnectionException:Exception Creating Connection to host 218.242.2.51,nested exception:java.net.SocketException:Connect(Code:10055)
I think maybe the number of threads is too many,so
I only use one reference of remote server and spawn 50 threads to book dofferemt flights,but the same exception is still ocurred,and if only spawn 10 threads,it works well,I am so confused.

Anybody can help me,Thanks very much!
Hi Michael:
Thanks for reply!

First off, you may be better off not putting the timer and timer task in the same class as the booking thread.


maybe you means: I should create a Timer and a Booking thread in controller class,in the run() method of Booking thread,create a TimerTask object and initialed the timer,after some times,the TimerTask object will run and invoke the timeOut() method in Booking thread.
Why cannot create all Timer and TimerTask in run() method of Booking thread?


So when your timer fires, it could call timedOut() one the booking thread and notfiy the client that the booking operation timed out.


But in this situation:
In my design,if the db locked,client have to wait until the db is unlocked.So maybe the Booking thread would wait for the record's lock for a long time.maybe the Booking thread is just blocking or waiting,donot do any other things,So I think the flag of "isTimeOut" is not useful to this Booking thread.


The problem here is that on a dead connection,the Socket is blocking and will continue to do so until an IOException is thrown.


I am confuse it,can you speak it clearly?
Thanks for your lots help!
Hi Michael:


You can then define an inner class the extends java.util.TimerTask which can interrupt the booking operating upon firing.


Every time a book button was clicked,two threads were created ne is BookingThread extends Thread,the other is MyTimerTask extends TimerTask.
In run() method of BookingThread,I define a Timer and MyTimerTask and scheduled the MyTimerTask should run delay 10 seconds.If the booking is successful in 10 seconds,the bookingThread will cancel the timerTask,otherwise the TimerTask will run and interrupte the BookingThread.
The question is:
when the booking thread had waited for the record lock for a long time,the TimerTask should interrupte the BookingThread,I invoke the BookingThread.interrupte() method in TimerTask,but no affect on BookingThread,it still running.
Michael,could you give me some suggestions?
Hi Michael:
Thanks for you reply!
Another question:
I want to define the subthread that want to book flghts only can run a fix times,
if the time is over,the booking thread will be interrupted.
Could you tell me some details?
Thanks!
Hi Michael:

In that case, a RemoteException should be thrown on the call to unlock(). In my implementation, notifyObservers() was called with a value of BOOK_UNLOCK_ERROR. This was considered a warning and not an error since presumably modify() had already been called. I just assumed that the booking was successful and popped up a warning dialog to the user that also stated that the booking had completed.


But my DataFacade class donot know this situation (just modified but not unlock record)on server side at all,do you need the clint to track it to distinguish different exception occured on server side?
Could you tell me some details about it and how to implements it?
Thanks!
Hi Michael:
Yes,it is difficult to change my originally design to suit the multiple booking,but it's necessary.Thanks for you help!


I just updated the number of seats in the JTable and popped up a dialog to notify the user that the booking had completed sucessfully or failed.


I am looking for a way to refresh the JTable living,maybe you can tell me it clearly.


Also, my booking panel kept a set of pending bookings so that if a booking took a long time and the user reselected that record then booking would be disabled.


It is necessary to deal with the booking atcion that had taken a long time,but how do you deal this situation: clinet create Thread A to book a flight and something forced the client to wait,but when the thread was just modifyed the flight and did not unlock it,the time of the Thread A is over,what should to do?
Thanks!
Hi Michael:
It is necessary to implements the multiple book function to a client at a time,is so helpful to improve my design,but there is a question:
I design a bookPanel to book flight,and there are JTextFields to show the suitable flight fields,so it is very clear for client to book flight.After the client click the book button,a message box was occured to tell client is successful or not.
If it is successful,the seat number JTextField will show the remained seat nubmers.
If a client book different flight at a time,it is very difficult to showback the information.Maybe only need to show a message box,but I think it is not friendly,do you think so?
And do you have any suggestions?
Hi Micheal:
Thanks for your help,it is very useful to me!
I will change my design on client side to implements the multiple book seat function at a time for one client.
So,I think the multithread is necessary,maybe the thread pool is better.Every time when client clicks the book seat button,a thread is created.
Is right?
Hi Mark/Michael:
Thanks for your reply!
It is very useful to define a HashSet for every Remote Connection Object(a client has unqiue one).
In my design,every client has a View,client can click the BookFlight button after he put in some necessary informations,then the BookFlight button is setEnabled(false).Client cannot click the button before server deal the request well.
So,the client cannot book two or more flights at a time,and I donot need to use HashSet for every client on server side.
After I readed your answers,I thought my design is different with your designs.
Could you tell me that my design is right or not?
can you give me some suggestions?
Thanks!
Hi Michael:
Thanks for your reply!
I had two remote object extends Unicast implements Remote,one is ConnectionFactoryImpl,another is FBNModelServerImpl.In ConnectionFactoryImpl,there is only one method to return a reference of FBNModelServerImpl,so different client has different Model reference.In Model,I define a variable HashSet to store the records that this client had locked ,so every client has his owned hashset.
And the FBNModelServerImpl class also implements Unreferenced interface,in unreferenced() method I only need to unlock the records in this client's hashset to reunlock and donot mind the record is locked or not.
In FBNModelServerImpl,I also had a static LockManager class to service for all clients.In this class,I defined a HashMap to store the locked records for all clients,and there are two method:lock(recNum,clientId) and unlock(recNum,clientId) in Manager class.If you want to unlock the record that alrealy in this HashMap,your clientId must equals the clientId in this HashMap,otherwise you can unlock the record.
As a word,I defined a HashSet for every client and a HashMap for all clients.
Is right?
Looks forward your reply!
Thanks!
~dennis hu~