edu.wpi.prc.tools.shutdown
Class ShutdownController

java.lang.Object
  extended by edu.wpi.prc.tools.shutdown.ShutdownController

public class ShutdownController
extends java.lang.Object

Reads the proejct configuration and shuts down the project server or client by sending an XML-RPC request.

Author:
James Baldassari

Field Summary
private static int EXIT_ERROR
           
private static int EXIT_SUCCESS
           
private static Project project
           
private static org.apache.xmlrpc.XmlRpcClient xmlrpcClient
           
 
Constructor Summary
ShutdownController()
           
 
Method Summary
private static boolean emergencyShutdown(java.lang.String serverAddress, java.lang.String password)
          Executes the "server.kill" RPC on the project server using the given server address and password.
static void main(java.lang.String[] args)
          Determines which process to shut down by parsing command-line arguments.
private static boolean sendRPC(java.lang.String cmd, java.util.Vector params)
          Executes the given XML-RPC command with the given parameters.
private static boolean shutdownClient(int port)
          Executes the "client.shutdown" RPC on the project client.
private static boolean shutdownServer(java.lang.String serverAddress, java.lang.String password)
          Executes the "server.shutdown" RPC on the project server using the given server address and password.
private static boolean shutdownTransitioner(java.lang.String transitionerAddress, java.lang.String password)
          Executes the "transitioner.shutdown" RPC on the project server using the given server address and password.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXIT_SUCCESS

private static final int EXIT_SUCCESS
See Also:
Constant Field Values

EXIT_ERROR

private static final int EXIT_ERROR
See Also:
Constant Field Values

project

private static Project project

xmlrpcClient

private static org.apache.xmlrpc.XmlRpcClient xmlrpcClient
Constructor Detail

ShutdownController

public ShutdownController()
Method Detail

shutdownServer

private static boolean shutdownServer(java.lang.String serverAddress,
                                      java.lang.String password)
Executes the "server.shutdown" RPC on the project server using the given server address and password.

Parameters:
serverAddress - The server address.
password - The project password.
Returns:
Returns true if the XML-RPC call was successful, the password was correct, and the server began shutting down; false otherwise.

emergencyShutdown

private static boolean emergencyShutdown(java.lang.String serverAddress,
                                         java.lang.String password)
Executes the "server.kill" RPC on the project server using the given server address and password. This RPC does not wait for all transactions to be completed before shutting down the server, and should only be used in the event that one or more RPCs are "stuck," preventing the server from shutting down normally.

Parameters:
serverAddress - The server address.
password - The project password.
Returns:
Returns true if the XML-RPC call was successful, the password was correct, and the server began shutting down; false otherwise.

shutdownTransitioner

private static boolean shutdownTransitioner(java.lang.String transitionerAddress,
                                            java.lang.String password)
Executes the "transitioner.shutdown" RPC on the project server using the given server address and password.

Parameters:
transitionerAddress - The remote transitioner address.
password - The project password.
Returns:
Returns true if the XML-RPC call was successful, the password was correct, and the server began shutting down; false otherwise.

shutdownClient

private static boolean shutdownClient(int port)
Executes the "client.shutdown" RPC on the project client.

Parameters:
port - The port on which the client is listening for XML-RPC connections.
Returns:
Returns true if the RPC was executed successfully, false otherwise.

sendRPC

private static boolean sendRPC(java.lang.String cmd,
                               java.util.Vector params)
Executes the given XML-RPC command with the given parameters.

Parameters:
cmd - The command to send.
params - The parameters to pass.
Returns:
True if the command was sent successfully, false otherwise.

main

public static void main(java.lang.String[] args)
Determines which process to shut down by parsing command-line arguments. If the user wants to shut down the server, the user is prompted for the project password. The project configuration file is parsed to determine address/port, then the XML-RPC request is sent.

Parameters:
args - Command-line arguments.