• 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

Restarting the server

 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi:
How can I restart the server withen the same thread?
I have a window for server administration. The administrator should be able to restart the server, shutdown the server, reinitialize the properties file, and change the center database location.
I want to know how can I shutdown, and then restart the server withen the same thread(same window).
I searched the previous posts, but I couldn't find anything.
thanks
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But why do you need that ? Whats the reason to restart server? If you mean that admin may want to choose another database file and restart with that file, then he can just restart program. Why do you want to keep it in the same thread?
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Denis:
I think it is easer this way. I don't want to make the admin restart the whole program manually. I can spwan different threads, but I don't want to deal with that right now.
I am using the follwing lines to unbound the remote objects and the remot registry.

UnicastRemoteObject.unexportObject(data, true);
UnicastRemoteObject.unexportObject(reg, true);

It is working fine uptill now, the catch with that is any other clients connecting to the server at that time, need to reconnect.
I know it makes sense, but it would be nice if the clients don't need to reconnect.
any ideas?
 
Denis Spirin
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still cant get it. What do you mean by saying "restart"? If you want to change datatbase file the server serves to client, then you need to put some 'switch' in corresponding class and add button to GUI, so that admin could call some method to chande db file. However you will also need locking on case if client was doing something with db while another file was opened.
It would be good for real program, but for scjd youre not REQUIRED to do that. You will get NO EXTRA POINTS for that, you may only LOSE points if examiner will find a bug or simply will not like code.
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Denis:


If you want to change datatbase file the server serves to client, then you need to put some 'switch' in corresponding class and add button to GUI, so that admin could call some method to chande db file.


If I use switch statement to change the database the server servs, I am limiting the number of database files programatically. I want to give the option to the admin to choose any database file he liks.
My remote data access object needs the data file location in its constructor, then I bind this object to the registery.
the reasons I am providing this function:
1) My instruction is not clear it says:


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.


What I understand from this is that the user must be able to choose a database file in either mode.

2)The application doesn't know anything about the database. It configuers everthing at runtime. So, one can plug in a database file with differnt fields length or names, as long as the database file has correct metadata section. it would be nice to be able to use this property.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hanna,
As far as I understand you want your clients to redirect to the new server. So if a client is not able to perform the remote call(the original remote object is no longer there, you have restarted the server), it can try to acquire a new remote object reference from the registry(in the catch section). You can also define its maximum retries.

In this case(running clients) you will have to implement a safe server stop so you can start the server again.

And finally, as Denis said, you will not gain any points of additionally complicating your tasks.

Thanks, Pafka
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Pavel :
Thanks for the informative response. It is not exactly what I want to do. I created a frame to admin the server, like restart or shuting it down. I did it by unbounding the remote objects. In this case, I need to notify all connected clients that the server is shutting down, or restarting, so that the clients can reconnect manually.

How can I let the clients know?
How can I send a message to all connected clients?
any ideas?

I imagen it will be a popup window with the message, but I don't know how to message clients.

As far as points and grades, I am not very concered about it. I am doing this project for learning. I did not know anything about RMI or Swing before, and I am taking advantage to learn and explore as much as I can. At my job, I use J2EE, so maybe I will never get another chance to learn it.
 
Denis Spirin
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose you want to switch database. Admin can press button "change database" and choose it (JFileChooser). Once he has chosen db file, server calls corresponding method on your RemoteDatabaseImpl (your class which extends UnicastRemoteObject) and passes file name. This method
1. blocks entire db and read access
2. reads data from file
But there is the problem - how to let users know that db file has changed?
1. Kick off all users which are trying to book record
2. Call method to make them to refresh their data. Use RMI callback. http://www.ryerson.ca/~dgrimsha/courses/cps841/RMICallbacks.html
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Denis:
that was a very helpful link. I searched the web before, but I didn't know the term callback.
thanks again
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hanna & others,

Just a cautionary note - this does seem to be going well beyond the requirements of the instructions. You might want to think about whether you really want to go to that level of complexity.

Ooops, I am sounding like Mark

Regards, Andrew
 
reply
    Bookmark Topic Watch Topic
  • New Topic