edu.washington.cs.pl_if.rpc.server
Class RpcServerFunctionsImpl

java.lang.Object
  extended by edu.washington.cs.pl_if.rpc.server.RpcServerFunctionsImpl
All Implemented Interfaces:
RpcFunctions

public class RpcServerFunctionsImpl
extends Object
implements RpcFunctions


Field Summary
 
Fields inherited from interface edu.washington.cs.pl_if.rpc.RpcFunctions
CONNECT_FAILED_POLICY_ANY, CONNECT_FAILED_POLICY_CLOSEST, CONNECT_FAILED_POLICY_SITE, PLANET_LAB_ADD_HOSTS_TO_SLICE, PLANET_LAB_ADD_RANDOM_HOSTS_FROM_PLC, PLANET_LAB_ADD_RANDOM_SITES_FROM_PLC, PLANET_LAB_CONNECT_TO_HOST, PLANET_LAB_DOWNLOAD, PLANET_LAB_FETCH_COMON_DATA, PLANET_LAB_GET_ALL_HOSTS, PLANET_LAB_GET_AVAILABLE_HOSTS, PLANET_LAB_GET_COMMAND, PLANET_LAB_GET_COMMAND_OVERVIEW, PLANET_LAB_GET_COMMAND_STATS, PLANET_LAB_GET_COMMAND_STATUS_OVERVIEW, PLANET_LAB_GET_COMON_PROGRESS, PLANET_LAB_GET_HOST_STATS, PLANET_LAB_GET_HOST_STATUS_OVERVIEW, PLANET_LAB_GET_HOSTNAME, PLANET_LAB_GET_HOSTS_NOT_IN_SLICE, PLANET_LAB_KILL_COMMAND, PLANET_LAB_QUEUE_COMMAND, PLANET_LAB_READ_CONSOLE, PLANET_LAB_SHUTDOWN, PLANET_LAB_TOTAL_COMMAND_NUM, PLANET_LAB_TOTAL_HOST_NUM, PLANET_LAB_UPLOAD, SPECIAL_COMMAND_DOWNLOAD_DIR, SPECIAL_COMMAND_UPLOAD_DIR
 
Constructor Summary
RpcServerFunctionsImpl()
           
 
Method Summary
 int addHostsToSlice(Map auth, Object[] hosts)
           
 int addRandomHostsFromPLC(Map auth, int numberOfHosts)
          Requests "numberOfHosts" random hosts from PLC and tries to connect to them.
 int addRandomSitesFromPLC(Map auth, int numberOfSites)
          Requests "numberOfSites" random sites from PLC and tries to connect to one random host in each site .
 double commandCompleted(Map auth, int commandId)
          Returns what percentage of hosts that has completed command "commandId"
 int connectToHost(Map credentials, String hostname)
          Request the controller to connect to host hostname.
 int download(Map auth, String remotePath, String localPath, String fileFilter, String localNamingType)
           
 int fetchCoMonData(Map auth)
           
 Object[] getAllHosts(Map auth)
           
 Object[] getAvailableHosts(Map auth)
           
 String getCommand(Map auth, int commandIndex)
          return the command associated with a certain commmandId
 Object[] getCommandOverview(Map auth, int commandId)
           
 Object[] getCommandStats(Map auth, int connectionId)
           
 Object[] getCommandStatusOverview(Map auth)
          used by the gui to get a summary of the status of each command
 double getCoMonProgress(Map auth)
           
 Object[] getConnectedHosts(Map auth)
          Queries the controller for the list of nodes currently connected to Lazy wrapper for PlanetLab.getSuccessfulHosts(auth,0)
 Map getExitStats(Map auth, int commandId)
          returns a map of exitcode=>count
 String getHostname(Map auth, int hostnum)
          returns the hostname given a connectionId
 Object[] getHostsNotInSlice(Map auth)
           
 Object[] getHostStats(Map auth, Object[] hosts)
           
 Object[] getHostStatusOverview(Map auth)
          used by the gui to get a summary of the status of each host
 Object[] getSuccessfulHosts(Map auth, int commandId)
          Queries the controller for a list of all nodes that succesfully have completed all commands.
 int kill(Map auth, int commandId)
           
 int queueCommand(Map credentials, String command)
          lazy wrapper for queueCommand(Map auth, String command, 0, false), Running "command" with no timeout and continuing with subsequent commands even if the command returns a non non-zero exit code
 int queueCommand(Map credentials, String command, double timeout)
          lazy wrapper for queueCommand(Map auth, String command, double timeout, false), Running the command until it completes, or gets killed because the timeout expired.
 int queueCommand(Map credentials, String command, double timeout, boolean stopOnError)
          Add the command "command" to the queue of command to execute Running the command until it completes, or gets killed because the timeout expired.
 int queueCommand(Map credentials, String command, double timeout, int stopOnError)
           
 int queueCommand(Map credentials, String command, int timeout)
          lazy wrapper for queueCommand(Map auth, String command, double timeout, false), Running the command until it completes, or gets killed because the timeout expired.
 Object[] readConsole(Map auth, int connectionId, int fromRow)
          Reads the consle from ssh connection,
 int shutdown(Map auth)
          stops the RPC Server and closes all current ssh connections, including any running scp transfers
 int totalCommandNum(Map auth)
          returns the total number of commands that have been queued on the controller
 int totalHostNum(Map auth)
          returns the total number of hosts assisated with the system
 int upload(Map auth, String path, double timeout, boolean stopOnError)
          Uploads a local file or directory to all hosts The upload is implemented as follows: First a md5 checksum is calculated of the file or on all files in the specified directory and subdirectories Secondly md5s are calculated on the destination to check if the file(s) already exists.
 int upload(Map auth, String path, double timeout, int stopOnError)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RpcServerFunctionsImpl

public RpcServerFunctionsImpl()
Method Detail

addRandomHostsFromPLC

public int addRandomHostsFromPLC(Map auth,
                                 int numberOfHosts)
Description copied from interface: RpcFunctions
Requests "numberOfHosts" random hosts from PLC and tries to connect to them. The connect failed policy used is "any"

Specified by:
addRandomHostsFromPLC in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server. The values checked are Username and AuthString. These can be provided in clear text or as md5 hashes. If md5 hashes are used, the Username field should contain the md5 hash of the username string, the AuthString field should contain the md5 hash of the username string concatenated with the password string. The use of md5 hashes makes it difficult for an attacker to get the password by monitoring the network. Keep in mind that the password can be extracted from the md5 hashes by an attacker by using a dictonary.
numberOfHosts - number of hosts to request
Returns:
number of hosts actually added, this can be less that "numberOfHosts" if, the total number of hosts available is less than "numberOfHosts"

addRandomSitesFromPLC

public int addRandomSitesFromPLC(Map auth,
                                 int numberOfSites)
Description copied from interface: RpcFunctions
Requests "numberOfSites" random sites from PLC and tries to connect to one random host in each site . The connect failed policy is "site" meaning that if the connect failed, the controller will try another host in the same site

Specified by:
addRandomSitesFromPLC in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server
numberOfSites - number of sites to request
Returns:
number of sites actually added, this can be less that "numberOfSites" if, the total number of sites available is less than "numberOfSites"

commandCompleted

public double commandCompleted(Map auth,
                               int commandId)
Description copied from interface: RpcFunctions
Returns what percentage of hosts that has completed command "commandId"

Specified by:
commandCompleted in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server
commandId - the id of the command to query
Returns:
double between 0 and 1, 1 meaning that all hosts have completed the command

connectToHost

public int connectToHost(Map credentials,
                         String hostname)
Description copied from interface: RpcFunctions
Request the controller to connect to host hostname. If the ip accociated with the hostname is recognized by PLC, information from PLC, like bandwidth cap, will be associated with the connection If any commands have bee queued on other hosts previously, those command will be queued on this hosts as well

Specified by:
connectToHost in interface RpcFunctions
Parameters:
credentials - authentication information that is matching the information on the server
hostname - hostname or ip address to connect to
Returns:
the connection id of the host (used to check host progress), or -1 on authentication failure

getCommand

public String getCommand(Map auth,
                         int commandIndex)
Description copied from interface: RpcFunctions
return the command associated with a certain commmandId

Specified by:
getCommand in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server
Returns:
the command associated with the commandId, or -1 on authentication failure

getCommandOverview

public Object[] getCommandOverview(Map auth,
                                   int commandId)
Specified by:
getCommandOverview in interface RpcFunctions

getCommandStats

public Object[] getCommandStats(Map auth,
                                int connectionId)
Specified by:
getCommandStats in interface RpcFunctions

getCommandStatusOverview

public Object[] getCommandStatusOverview(Map auth)
Description copied from interface: RpcFunctions
used by the gui to get a summary of the status of each command

Specified by:
getCommandStatusOverview in interface RpcFunctions
Returns:

getConnectedHosts

public Object[] getConnectedHosts(Map auth)
Description copied from interface: RpcFunctions
Queries the controller for the list of nodes currently connected to Lazy wrapper for PlanetLab.getSuccessfulHosts(auth,0)

Specified by:
getConnectedHosts in interface RpcFunctions
Parameters:
auth - authentication
Returns:
a String array of hostnames

getExitStats

public Map getExitStats(Map auth,
                        int commandId)
Description copied from interface: RpcFunctions
returns a map of exitcode=>count

Specified by:
getExitStats in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server
commandId - the id of the command to query
Returns:
counts of how many hosts that have each exitcode

getHostname

public String getHostname(Map auth,
                          int hostnum)
Description copied from interface: RpcFunctions
returns the hostname given a connectionId

Specified by:
getHostname in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server
hostnum - the connectionId of the host to get the hostname of
Returns:
The hostname

getHostStatusOverview

public Object[] getHostStatusOverview(Map auth)
Description copied from interface: RpcFunctions
used by the gui to get a summary of the status of each host

Specified by:
getHostStatusOverview in interface RpcFunctions
Returns:

getSuccessfulHosts

public Object[] getSuccessfulHosts(Map auth,
                                   int commandId)
Description copied from interface: RpcFunctions
Queries the controller for a list of all nodes that succesfully have completed all commands. The returned hosts must have completed command commandId with 0 exit status

Specified by:
getSuccessfulHosts in interface RpcFunctions
Parameters:
auth - authentication info
commandId - the command that must have completed succesfully, or -1 for all commands
Returns:
a String of hostnames

kill

public int kill(Map auth,
                int commandId)
Specified by:
kill in interface RpcFunctions

queueCommand

public int queueCommand(Map credentials,
                        String command)
Description copied from interface: RpcFunctions
lazy wrapper for queueCommand(Map auth, String command, 0, false), Running "command" with no timeout and continuing with subsequent commands even if the command returns a non non-zero exit code

Specified by:
queueCommand in interface RpcFunctions
Parameters:
credentials - authentication information that is matching the information on the server
command - the command to queue
Returns:
the index of the command, used to get for example exit-status when the command has completed, or -1 on authentication failure

queueCommand

public int queueCommand(Map credentials,
                        String command,
                        double timeout)
Description copied from interface: RpcFunctions
lazy wrapper for queueCommand(Map auth, String command, double timeout, false), Running the command until it completes, or gets killed because the timeout expired. Subsequent commands will be run even if the command returns a non non-zero exit code

Specified by:
queueCommand in interface RpcFunctions
Parameters:
credentials - authentication information that is matching the information on the server
command - the command to queue
timeout - the maximum number of seconds (or fractions of a second) the command can run, after this the command will get killed
Returns:
the index of the command, used to get for example exit-status when the command has completed, or -1 on authentication failure

queueCommand

public int queueCommand(Map credentials,
                        String command,
                        double timeout,
                        boolean stopOnError)
Description copied from interface: RpcFunctions
Add the command "command" to the queue of command to execute Running the command until it completes, or gets killed because the timeout expired. Subsequent commands will not run if stop on error is true

Specified by:
queueCommand in interface RpcFunctions
Parameters:
credentials - authentication information that is matching the information on the server
command - the command to queue
timeout - the maximum number of seconds (or fractions of a second) the command can run, after this the command will get killed
stopOnError - controller if execution of commands should stop if the commands exit with a non-zero exit code. If stop on error is enabled execution is halted until the user override.
Returns:
the index of the command, used to get for example exit-status when the command has completed, or -1 on authentication failure

queueCommand

public int queueCommand(Map credentials,
                        String command,
                        double timeout,
                        int stopOnError)
Specified by:
queueCommand in interface RpcFunctions

queueCommand

public int queueCommand(Map credentials,
                        String command,
                        int timeout)
Description copied from interface: RpcFunctions
lazy wrapper for queueCommand(Map auth, String command, double timeout, false), Running the command until it completes, or gets killed because the timeout expired. Subsequent commands will be run even if the command returns a non non-zero exit code

Specified by:
queueCommand in interface RpcFunctions
Parameters:
credentials - authentication information that is matching the information on the server
command - the command to queue
timeout - the maximum number of seconds the command can run, after this the command will get killed
Returns:
the index of the command, used to get for example exit-status when the command has completed, or -1 on authentication failure

readConsole

public Object[] readConsole(Map auth,
                            int connectionId,
                            int fromRow)
Description copied from interface: RpcFunctions
Reads the consle from ssh connection,

Specified by:
readConsole in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server
connectionId - The connection ID of the host to read the console of
fromRow - Row to start reading from, useful when only new information is interesting, like for example in a terminal like window
Returns:
Object[], each object in the array an instance of Map, where each Map contrains information about one row. "line"=>String, the output line "command"=> String, the command the resulted in the line "stderr"=> Boolean, true if the line was read from stderr, false if read from stdout "time"=>Double, the number of seconds since application start the line was received "execution_time"=>Double, number of seconds the command had been running when the line was received

shutdown

public int shutdown(Map auth)
Description copied from interface: RpcFunctions
stops the RPC Server and closes all current ssh connections, including any running scp transfers

Specified by:
shutdown in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server
Returns:
0 on successful shutdown and -1 on authentication failure

totalCommandNum

public int totalCommandNum(Map auth)
Description copied from interface: RpcFunctions
returns the total number of commands that have been queued on the controller

Specified by:
totalCommandNum in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server
Returns:
number of commands executed + in queue

totalHostNum

public int totalHostNum(Map auth)
Description copied from interface: RpcFunctions
returns the total number of hosts assisated with the system

Specified by:
totalHostNum in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server
Returns:
total number of hosts

upload

public int upload(Map auth,
                  String path,
                  double timeout,
                  boolean stopOnError)
Description copied from interface: RpcFunctions
Uploads a local file or directory to all hosts The upload is implemented as follows: First a md5 checksum is calculated of the file or on all files in the specified directory and subdirectories Secondly md5s are calculated on the destination to check if the file(s) already exists. If the md5 check fails, or the file doesn't exist, the file is uploaded. Thirdly a second md5 check is done on the uploaded file, if this fails the file is uploaded-and-checked two more times. If the md5 check fails the third time the command fail and execution of subsequent commands on the host will stop. All files are copied to ~/dir_name on the remote hosts, if for example /homes/isdal/bandwidth_experiment/bw_planetlab_bin/ is uplaoded, the directory ~/bw_planetlab_bin will be created on the remote hosts and all files will copied there

Specified by:
upload in interface RpcFunctions
Parameters:
auth - authentication information that is matching the information on the server
path - the local directory to upload
timeout - maximum time allowed for the upload
stopOnError - stop exection on command if the upload was unsuccessful
Returns:
0 if the local directory exists, 1 if the local directory doesn't exist or is unreachable, -1 on authentication failure

upload

public int upload(Map auth,
                  String path,
                  double timeout,
                  int stopOnError)
Specified by:
upload in interface RpcFunctions

download

public int download(Map auth,
                    String remotePath,
                    String localPath,
                    String fileFilter,
                    String localNamingType)
Specified by:
download in interface RpcFunctions

addHostsToSlice

public int addHostsToSlice(Map auth,
                           Object[] hosts)
Specified by:
addHostsToSlice in interface RpcFunctions

getHostsNotInSlice

public Object[] getHostsNotInSlice(Map auth)
Specified by:
getHostsNotInSlice in interface RpcFunctions

fetchCoMonData

public int fetchCoMonData(Map auth)
Specified by:
fetchCoMonData in interface RpcFunctions

getCoMonProgress

public double getCoMonProgress(Map auth)
Specified by:
getCoMonProgress in interface RpcFunctions

getHostStats

public Object[] getHostStats(Map auth,
                             Object[] hosts)
Specified by:
getHostStats in interface RpcFunctions

getAllHosts

public Object[] getAllHosts(Map auth)
Specified by:
getAllHosts in interface RpcFunctions

getAvailableHosts

public Object[] getAvailableHosts(Map auth)
Specified by:
getAvailableHosts in interface RpcFunctions