Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Smooth way to kill Server

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Someone would tell me a way to kill (and load) the server using
RMI?
Thx in adv
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kill server? for what?

Originally posted by Ricardo Polero:
Hi
Someone would tell me a way to kill (and load) the server using
RMI?
Thx in adv


 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What the hell else do you want to kill?
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ricardo,
Soft way of kill server (unexport).
You might look for:
RunTime.addShutdownHook(Thread hook)

Bye,
Ban
PS: Don, watch your mouth! Please.
 
Ricardo Polero
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , just want to shutwon the server when no more client are working ! that's all
 
Andras Nemeth
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ricardo Polero:
Hi , just want to shutwon the server when no more client are working ! that's all



And why?
What will happen when a new client try to connect to your
shutdowned server. :O
(Does your server activatable?)
BR,
Ban
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was wresting with this too. I wanted to be sure to get a global lock and shut down the Data class safely.
I accomplished it by making a very simple Server GUI. It displays messages about what the server is doing and has a "Stop FBN Server" button. That button locks the DB and shuts down cleanly. No nasty Ctrl-c shutdown while a client is modifying a record.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree that you can run the server with a nice GUI, which allows the user to monitor the execution and everything, but I personally dislike the approach.
I believe that a server should be a command-line based utility that can be kept running in "background" (if your OS supports this), and should be shut down in a clean way.
I implemented graceful shutdown using RMI. My server binds a DatabaseService object to a RMI Registry. When this object receives a remote invocation of the shutdown() method, all open client connections, which are also Remote objects bound to the registry are unexported (forced). Finally, the DatabaseService is also unexported. As the RMI registry contains no more objects, the thread managing RMI finishes, and the server stops executing.
By the way, the call to shut down the server (in my case) is something like:
java -Dsuncertify.port="4444" suncertify.server.Server -s
where the -s switch implies a shutdown, and the previous defined property is the port on the local machine (obvious) that the server is running on. This means that YOU CAN ONLY SHUT DOWN A SERVER RUNNING ON THE SAME MACHINE, NOT A REMOTE ONE (eventhough you apply RMI to achieve this)...
Hope this helps...
Benjam´┐Żn
 
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic