• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

confusion

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have some questions:
1>I have 3 ComboBox in GUI and will be refreshed after calling the searchButton,but when I use "frame.repaint()" ,there is still no changes.Why and how to do?
2>If the server is shutdown,need I inform the client?
3>After the user A clicked the booking button,should A's table show that his seats is reduced?
4>According the instructions:

"carrier='speedyAir',"origin = 'SFA'"


Could I use "carrier='speedyAir',"Origin Airport='SFA'"?
5>Need I deal with the dead client?
I make the RemoteAccessData.class implements the
Unreferenced.But I don't know how to implement the unreferenced() in detail?
Thanks
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
#4. No because you have three double quotes, so therefore one of the sets is not closed.
#1

I have 3 ComboBox in GUI and will be refreshed after calling the searchButton


Why are your refreshing the comboboxes? There is no need for you to do that. The comboboxes I assume are the unique values of Carrier, etc.
#2. I would think that if the server shutsdown and the client is still thinking it is connected and tries to do something remotely, then an Exception will be thrown and therefore you catch it and show a pretty message, which is telling the client that the server has shutdown.
#3, it would be nice to display their own changes.
#5. I had each client connection object holding a HashSet of it's locks, so in unreferenced it got an iterator and iterated through the locks and unlocked the records it had locked. That is all that I needed.
Hope that helps
Mark
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark and other guys:
I am confused about unreference,can you tell me clearly?
I had two classes( ConnectionFactoryImpl and FBNModelServerImpl ) extends Unicast and implements Remote interface,ConnectionFactoryImpl has one method getConnection() to new a FBNModelServerImpl and return it.
Only the ConnectionFactory bind to the gistry,all the clients lookup ConnectionFactoryImpl and invoke the method getConnection() in this class to get a reference of FBNModelServerImpl.There is a static LockManager in FBNModelServerImpl class to lock and unlock the record.
Is right?
Look forwar your reply!
Thanks!
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it looks right.
Unreferenced is an interface to clean up a remote object after a period of time when nothing happens. For instance the client side goes down, but there is still an instance of the remote object on the server. Unreferenced gives you a chance to clean up for the remote object that is hanging around and holding locks on records that would otherwise never been unlocked.
Mark
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark:
Thanks for your reply!
I am confused about this:


Unreferenced gives you a chance to clean up for the remote object that is hanging around and holding locks on records that would otherwise never been unlocked.


Maybe you means that if a thread locked a record but is hanging around, the unreference interface will unlock the record.Is right?
But do I need to write the Unreferenced interface by myself,and whick class should I implements the interface,if so,how can I imple it?
Look forward your reply!
Thanks!
~dennis hu~
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,


But do I need to write the Unreferenced interface by myself,and whick class should I implements the interface,if so,how can I imple it?
Look forward your reply!
Thanks!


The Unreferenced interface is defined in the java.rmi.server package. It has one method unreferenced(). Once the RMI runtime determines that there are no more remote references, ie clients, connected to the Unreferenced object, the RMI runtime calls the unreferenced() method. Assuming you are using a ConnectionFactory to issue unique connection objects to each client, then you should implement the unreferenced() method in the class for those objects to perform any clean up. Specifically, you should keep a set of owned locks for each of those remote connection objects and in the unreferenced() method, iterate thru that set and call unlock() on each.
Hope this clears it up,
Michael Morris
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michael:
Thanks for your reply!


Specifically, you should keep a set of owned locks for each of those remote connection objects and in the unreferenced() method, iterate thru that set and call unlock() on each.


I am confused: do every client has a HashSet to hold the its locked records,but each client only has a locked record,why use the HashSet for every client.
Maybe you means that:there is only one HashSet in ConnectionFactoryImpl class to hold the locked records and Client ID for all clients. And in unreferenced() method,I only need to iterate the HashSet,but how can I find the suitable locked record in the HashSet,because I donnot know the Cliend Id,this unreferenced() is invoked by RMI runtime!
Look forward your reply.
Thanks!
~dennis hu~
 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
1>

No because you have three double quotes, so therefore one of the sets is not closed.


How about ?
2>

Why are your refreshing the comboboxes? There is no need for you to do that. The comboboxes I assume are the unique values of Carrier, etc.


But when add a new record ,there will add some new origin airport... .
3>

so in unreferenced it got an iterator and iterated through the locks and unlocked the records it had locked.


If I have an iterator and iterated through the locks,how can I find which lock should be unlock?
Thanks
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,


I am confused: do every client has a HashSet to hold the its locked records,but each client only has a locked record,why use the HashSet for every client.


If your remote connection object can only lock one record at a time, you may want to rethink your design for scalability. In my overall design a client could theoretically hold any number of locks, since multiple bookings could occur asynchronously. In my design, the lock manager held a master set (actually map) of locks for all locked records. Each remote connection object held a set of locks that were held only by that client. Probably 99% of the time, that set only had 0 or 1 members, but in the rare occasions that more bookings were backed up because of server load, it would contain more than 1.


Maybe you means that:there is only one HashSet in ConnectionFactoryImpl class to hold the locked records and Client ID for all clients. And in unreferenced() method,I only need to iterate the HashSet,but how can I find the suitable locked record in the HashSet,because I donnot know the Cliend Id,this unreferenced() is invoked by RMI runtime!


If you use a lock manager and design similar to what I stated above, then you just implement unreferenced() in the remote connection object and iterate thru its set of locks.
Hope this helps,
Michael Morris
 
dennis hu
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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~
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dennis,


As a word,I defined a HashSet for every client and a HashMap for all clients.
Is right?


So long as you are sure that records locked by stale clients will be unlocked when their unreferenced() is called, then your way is as good as mine.
Michael Morris
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Yes that is better
2. You will not be adding any new records in this assignment.
3. In my submission, the Remote Connection Object which is unique to each client kept it's own HashSet of locked records that that one client has, therefore the iterator comes form this HashSet, so it has to unlock all those records.
This is not the Collection that the LockManager or Data class has. Which ever one you have.
Mark
 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
Thanks for reply.
My Factory.class will return a new object of the RemoteDataAccess.class .I will have a HashSet which will store the locks of one client in the RemoteDataAccess.class.Is that right?
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that is what I did.
Mark
 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
I'm still a little confusion.

I will have a HashSet which will store the locks of one client in the RemoteDataAccess.class


What is store the in the HashSet,object or record number?
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

What is store the in the HashSet,object or record number?


try, recordnumber (as a wrapped object) and a clientID.
cheers,
friso
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, what friso said. You wrap the record number into a Integer or Long object.
mark
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic