[Logo]
Forums Register Login
server gui ? and safe shutdown
Hi guys,
I have completed the assignment but I have a doubt. In my present implementation the output area for the server is the command window from where it is started. Additionally there is no provision of safe server shutdown (i.e. you have to press ctrl + c to stop server) and no way to save servers log into a file.
I really doubt if this a very good implementation, so I am thinking about using a gui for logging the information and providing some mechanism for safe server shutdown and saving log.
Any suggetions ??
Vishal Sinha
I wrote the code below to shut down gracefully. When the user types EXIT and presses Enter, I call Naming.unbound() to remove the bound remote object.
I am interested to hear from others the need to have a GUI on the server side. It is not mentioned as the requirement as far as I can tell.

[ May 02, 2002: Message edited by: Sai Prasad ]
I made a *really* simple GUI for the server( probably on the borderline of sloppy ) but it worked.
Two buttons and a text box that simply displayed what was going on. One button locked all the records(or unlocked it if all were locked) the other started a timer for 60 seconds(the timeout to each thread) ,locked all records then exited.
Hi Sai,
I have doubt about your implementation. If you are jamming the output of your server console into one readline statement then I guess that you are not displaying any server log. Am I right.
Thanks,
Abhinav
Hi adam,
I am also thinking about using the same sort of gui implementation on the server side. I have designed a menu system containing the options server and log. The server menu contains one option, shutdown. The log menu contains two options, clear log, save log to file. The menu system is supported by a tool bar containnig shortcut buttons to the above said options. The main display area is dominated by a jtextarea in which all the activities of the server is logged.
This gui is displayed only when the server is started for networked mode otherwise I don't display any gui.
Any suggetions are welcome.
Thanks,
Abhinav.
Hi,
I'm using a JFrame with 2 button and a JTextField.
2 Button for - Start, Stop server
TextField for - message e.g. server bind to port number xxx or server failed to start due to xxxx.
What you need to do to start the server is simply
LocateRegistry.createRegistry(portNumber);
String url = new String("rmi://localhost:" + portNumber + "/" + SERVICE_NAME);
Naming.rebind(url, this);
To stop,
Lock the whole database,
Naming.unbind(url);
Unlock the whole database.

However, I'm not sure what do you mean by the gui is displayed only when the server is started up for network mode.
My interpretation is that once you start your server, you'll want to connect it through the network.
Hope this helps.
Cheers.

Han Ming
Hi,
I start my server when I have to use networked mode access i.e. the server is running on one computer and the client connects to it from a different computer. In this case the server is running as a standalone program with a proper gui and is started by a command from the console.
However when no networking is to be performed the server is not at all started instead an instance of it is created by the client. In this case the server is not running as a standalone program so no gui is displayed.
Any suggetions are always welcome.
Thanks.
 

Sai Prasad posted:


I would guess that code would waste a LOT of cpu cycles. Having said that, I can't think of a better way to shut down the server.
Eugene Kononov.
I moved away from the console design to a server side GUI with one Stop button, couple of JTextArea(s) in a JSplitPane and couple of menu items.
When the user stops the server, I lock the entire database and terminate the server VM process. I think this is a better way to do it than a console window waiting for the user to type "EXIT".
Hello All,

Guys i have gone through the above postings. Here i have a doubt, As per most of ur design if u have GUI to start the server and stop a server. How to start the server in a console(Non GUI) mode.

I just like to know wheather we have to provide both(console,GUI) the ways to start, stop the server. So that the user can start the server in eaither mode he is intrested in.
comments are welcome.

thanks & regards,
-rameshkumar
I have only gui version for the admin to start the server. I don't see any reason to have two ways to stop the server.
just wondering what is the difference between lookup, bind, rebind methods in Naming class and the methods with same name in the Registry class ?
If you want to use those methods in the Registry class, you need to get an instance of the Registry object. Methods in those classes serve the same purpose.
I guess you can not use the methods in Registry directly because it is an Interface not a class.
Surprisingly I don't find any class that implements Registry Interface. Even though Naming has exactly same methods as Registry, it does not implement Registry Interface.
When I started thinking about having GUI for
server, the first thing that came to my mind was
do I write a separate class (probably extends
JFrame) that creates GUI and instantiate the
DBServer (the class that extends UnicastRemoteObject and implements DBRemoteInterface) or add methods in DBServer to create GUI and add actionListeners for 'start server' and 'stop server' buttons ?
I personally prefer creating a separate class. What do you guys think ??
thanks in advance for your response.
I have a seperate class to handle the GUI on the server which then instantiates the Remote object.
[ May 10, 2002: Message edited by: Sai Prasad ]
I have implemented server GUI now, with two
buttons to start and stop the server and a label.
But the problem I am facing now is if I start the
server once and then stop the server, and then try
to start the server second time, I get
ExportException. Any idea why this is happening ?
thanks
Yes. You don't need a "Start" button. Bind the
remote connection object to the RMI Registry
when you start the server and when Stop is
pressed, lock the entire database and terminate
the entire server VM process. If you don't kill
the server process and if a client has a
reference to the remote object, the client can
still invoke methods on it.
[ May 10, 2002: Message edited by: Sai Prasad ]
I have completely encapsulated the server gui from the actual implementation of the server. The server gui is contained in a different class and it is concerned with only one type of tasks that is to display messages, save messages to file and clear excessive messages. If the user tries to close the gui then the gui confirms whether the user wants to shutdown the server. If the user confirms that he wants to shutdown the server then the gui class simply notifies all the classes that had requested to be notified of the server shutdown. Any class that wants to receive notification of server shutdown has to request so by activating the notifyOfServerShutdown method of the gui class. The server gui simply activates the shutdown methods of these classes when the user confirms of server shutdown.
Now it depends upon the notified classes as to what to do. In my present implementation the DataServer class simply locks the whole database, unbinds the data instance from the rmiregistry and exits the program.
Please comment !!
Any suggetions are always welcome.
How do you guys handle any exception thrown by
Naming.unbind while stopping the server ?
System.exit(0); There is nothing the user can do to handle this exception. Right?
Hi,
When the unbind method throws an error I simply log an error message in the console and exit the program by executing...
System.exit(1);
Any suggetions are welcome

This thread has been viewed 1161 times.

All times above are in ranch (not your local) time.
The current ranch time is
Nov 13, 2018 21:18:40.