edu.washington.cs.pl_if.ssh
Class ConnectionController

java.lang.Object
  extended by java.lang.Thread
      extended by edu.washington.cs.pl_if.ssh.ConnectionController
All Implemented Interfaces:
Runnable

public class ConnectionController
extends Thread


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ConnectionController(Credentials cred)
           
 
Method Summary
 int addHostsToSlice(String[] hostnames)
           
 int addRandomHostsFromPLC(int num)
          requests num randomly selected hosts from PLC and tries to connect to them.
 int addRandomSitesFromPLC(int num)
          requests num randomly selected sites from PLC and tries to connect to a random host in each of the sites them.
 int connectToHost(PlanetLabHost host, String connectFailedPolicy)
          initiate the connection sequece to host "host"
 void disconnectAll()
          Disconnect from all hosts
 boolean disconnectHost(int connectionId)
          disconnect one host specified with the connection ID
 int download(String remotePath, String localPath, String fileFilter, String localNamingType)
           
 PlanetLabHost[] getAllHosts()
           
 PlanetLabHost[] getAvailableHosts()
           
 String getCommand(int commandId)
          returns the command string assiciated with the specified command id
 Map<Integer,Integer> getCommandExitStats(int commandIndex)
          Sends a query for exitcode stats for executed commands
 int getCommandNum()
          get the total number of commands queued and executed
 void getCoMonData()
           
 double getCoMonProgress()
           
 double getCompletionStats(int commandId)
          queries for what ratio of hosts that have completed the command specified by command id
 Credentials getCredentials()
          get the credentials used
 PlanetLabHost getHostInfo(int plcHostId)
           
 PlanetLabHost getHostInfo(String hostname)
          returns a PlanetLabHost with the same ip as the ip of the host specified by hostname.
 int getHostNum()
          get the total number of hosts, including disconencted hosts
 PlanetLabHost[] getHostsNotInSlice()
           
 PlanetLabHost getPlanetLabHost(int connectionId)
           
 PlanetLabSite getPlanetLabSite(PlanetLabHost host)
           
 SshConnection getSshConnection(int connectionId)
           
 void handleFailedConnect(PlanetLabHost host)
           
 int killCommand(int commandId)
           
 int queueCommand(String command, double timeout, boolean stopOnError)
           
 void shutdown()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectionController

public ConnectionController(Credentials cred)
Method Detail

addRandomHostsFromPLC

public int addRandomHostsFromPLC(int num)
requests num randomly selected hosts from PLC and tries to connect to them. The policy used if the connect attempt fails is "any", meaning that it will try another host instead

Parameters:
num - number of hosts to add
Returns:
returns the total number of hosts

addRandomSitesFromPLC

public int addRandomSitesFromPLC(int num)
requests num randomly selected sites from PLC and tries to connect to a random host in each of the sites them. The hosts are connected with the "site" policy on unsuccessful connections, meaning that if there is an error while conecting to the host, another host from the same site will be tried

Parameters:
num - number of hosts to add
Returns:
returns the total number of hosts

connectToHost

public int connectToHost(PlanetLabHost host,
                         String connectFailedPolicy)
initiate the connection sequece to host "host"

Parameters:
host - the fully qualified hostname
connectFailedPolicy - the policy to use if the connect fails
Returns:
the connection id of the host

disconnectAll

public void disconnectAll()
Disconnect from all hosts


disconnectHost

public boolean disconnectHost(int connectionId)
disconnect one host specified with the connection ID

Parameters:
connectionId - the id of the connection
Returns:
true if the connection id is valid, false otherwise

getCommand

public String getCommand(int commandId)
returns the command string assiciated with the specified command id

Parameters:
commandId - the id of the command
Returns:
the command, or null if no command exists with that command id

getCommandExitStats

public Map<Integer,Integer> getCommandExitStats(int commandIndex)
Sends a query for exitcode stats for executed commands

Parameters:
commandIndex - the index of the command queried
Returns:
a hashtable

getCommandNum

public int getCommandNum()
get the total number of commands queued and executed

Returns:
the total number of commands executed and queued

getCompletionStats

public double getCompletionStats(int commandId)
queries for what ratio of hosts that have completed the command specified by command id

Parameters:
commandId - the command id
Returns:
double between 0 and 1, 1 means that all hosts have completed the command

getCredentials

public Credentials getCredentials()
get the credentials used

Returns:
the credentials used

getHostInfo

public PlanetLabHost getHostInfo(String hostname)
returns a PlanetLabHost with the same ip as the ip of the host specified by hostname. Note that the hostname contained if the PlanetLabHost class might differ from the hostname specified as "hostname". The hostname in the PlanetLabHost class will always be the hostname provided by PLC, the fully qualified hostname.

Parameters:
hostname - The hostname of the host to query for, or the ip address in quad dot format
Returns:
The PlanetLabHost with the same ip as the hostname resolves to, or null if no planetlab host with that ip is found

getHostInfo

public PlanetLabHost getHostInfo(int plcHostId)

getHostNum

public int getHostNum()
get the total number of hosts, including disconencted hosts

Returns:
total number of hosts

getPlanetLabHost

public PlanetLabHost getPlanetLabHost(int connectionId)

getCoMonData

public void getCoMonData()

getCoMonProgress

public double getCoMonProgress()

getPlanetLabSite

public PlanetLabSite getPlanetLabSite(PlanetLabHost host)

getHostsNotInSlice

public PlanetLabHost[] getHostsNotInSlice()

getAllHosts

public PlanetLabHost[] getAllHosts()

getAvailableHosts

public PlanetLabHost[] getAvailableHosts()

addHostsToSlice

public int addHostsToSlice(String[] hostnames)

getSshConnection

public SshConnection getSshConnection(int connectionId)

handleFailedConnect

public void handleFailedConnect(PlanetLabHost host)

queueCommand

public int queueCommand(String command,
                        double timeout,
                        boolean stopOnError)

killCommand

public int killCommand(int commandId)

shutdown

public void shutdown()

download

public int download(String remotePath,
                    String localPath,
                    String fileFilter,
                    String localNamingType)