uk.ac.ic.doc.automed.p2p.apps
Class MainApp

java.lang.Object
  extended by ow.tool.util.toolframework.AbstractDHTBasedTool<java.lang.String>
      extended by ow.tool.dhtshell.Main
          extended by uk.ac.ic.doc.automed.p2p.apps.MainApp
All Implemented Interfaces:
ow.tool.emulator.EmulatorControllable, ow.tool.util.shellframework.Interruptible
Direct Known Subclasses:
RemoteExecApp

public class MainApp
extends ow.tool.dhtshell.Main


Nested Class Summary
protected static class MainApp.SimpleWorkflow
          A workflow for stand-alone testing, it starts all the peers needed to run the test
 
Field Summary
private static java.lang.Class[] COMMANDS
           
static java.lang.String TYPE_BIBTEX
          simple
static java.lang.String TYPE_DSP
          a dsp peer
static java.lang.String TYPE_SIMPLE
          simple
static java.lang.String TYPE_SQL
           
static java.lang.String TYPE_USER
           
static java.lang.String TYPE_XML
           
private  P2PWorkflow wf
           
 
Fields inherited from class ow.tool.dhtshell.Main
COMMAND, ENCODING, mainThread, SHELL_PORT, XMLRPC_PORT_DIFF, XMLRPC_PORT_RANGE
 
Constructor Summary
MainApp()
           
 
Method Summary
 org.apache.commons.cli.Options getCmdOptions()
          AutoMed P2P options
 org.apache.commons.cli.CommandLine getCommandLine()
           
 ow.dht.DHT getDHT()
           
protected  org.apache.commons.cli.Options getDHTOptions()
          The default dht options required by OverlayWeaver's DHT implementation.
static P2PWorkflow getWorkflowInstance(org.apache.commons.cli.CommandLine cmd, boolean execute)
          Define an instance of the workflow (subclasses can customise this method to define their own AutoMed workflow)
 P2PWorkflow getWorkflowInstance(Peer p, AutoMedDHTImpl odht, java.lang.String dsType, java.lang.String... args)
          Create a workflow instance to run from a remote session.
protected static P2PWorkflow getWorkflowInstance(Peer peer, org.apache.commons.cli.CommandLine cmd, boolean execute)
           
 P2PWorkflow getWorkflowInstance(Peer peer, java.lang.String[] args, boolean execute)
           
static P2PWorkflow getWorkflowInstance(Peer peer, java.lang.String dsType, org.apache.commons.cli.CommandLine cmd, boolean execute)
           
 P2PWorkflow getWorkflowInstanceByID(java.lang.String pid, boolean execute)
          Create a new workflow instance from the command line arguments
protected  ow.tool.util.shellframework.Shell init(java.lang.String[] args, java.io.BufferedReader in, java.io.PrintStream out, boolean interactive)
          Extends the init() method of the super-class Main to start a shell using an existing DHT protocol instance.
This is invoked by the start() method of Main, which is in turn invoked by the startShell() method of this class.
static void main(java.lang.String[] args)
           
private static P2PWorkflow newWorkflowInstance(java.lang.String dsType, Peer peer, org.apache.commons.cli.CommandLine cmd)
           
 org.apache.commons.cli.CommandLine[] parseArgs(org.apache.commons.cli.Option[] existingOpts, org.apache.commons.cli.Options opts, int start, int end, java.io.InputStream fin)
          Read a set of peers from the source file
 org.apache.commons.cli.CommandLine parseArgs(org.apache.commons.cli.Options opts, java.lang.String[] args)
          Parse an array of arguments into a command line object
protected  void printHelp()
           
 org.apache.commons.cli.CommandLine readP2POptions(org.apache.commons.cli.Options existingOpts, java.lang.String pid)
           
protected  org.apache.commons.cli.CommandLine readP2POptions(org.apache.commons.cli.Options existingOpts, java.lang.String pid, java.io.InputStream fin)
           
 void startApp(java.lang.String pid)
           
 void startShell()
          A method to start a remote exection shell.
 
Methods inherited from class ow.tool.dhtshell.Main
interrupt, invoke, start, usage
 
Methods inherited from class ow.tool.util.toolframework.AbstractDHTBasedTool
getInitialOptions, initialize, initialize, usage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wf

private P2PWorkflow wf

COMMANDS

private static final java.lang.Class[] COMMANDS

TYPE_DSP

public static final java.lang.String TYPE_DSP
a dsp peer

See Also:
Constant Field Values

TYPE_SIMPLE

public static final java.lang.String TYPE_SIMPLE
simple

See Also:
Constant Field Values

TYPE_BIBTEX

public static final java.lang.String TYPE_BIBTEX
simple

See Also:
Constant Field Values

TYPE_SQL

public static final java.lang.String TYPE_SQL
See Also:
Constant Field Values

TYPE_XML

public static final java.lang.String TYPE_XML
See Also:
Constant Field Values

TYPE_USER

public static final java.lang.String TYPE_USER
See Also:
Constant Field Values
Constructor Detail

MainApp

public MainApp()
Method Detail

getDHTOptions

protected org.apache.commons.cli.Options getDHTOptions()
The default dht options required by OverlayWeaver's DHT implementation.

Returns:

getCmdOptions

public org.apache.commons.cli.Options getCmdOptions()
AutoMed P2P options

Returns:

printHelp

protected void printHelp()

startApp

public void startApp(java.lang.String pid)
              throws java.lang.Exception
Throws:
java.lang.Exception

getWorkflowInstanceByID

public P2PWorkflow getWorkflowInstanceByID(java.lang.String pid,
                                           boolean execute)
                                    throws AutoMedException
Create a new workflow instance from the command line arguments

Parameters:
args -
execute -
Returns:
Throws:
AutoMedException

getWorkflowInstance

public static P2PWorkflow getWorkflowInstance(org.apache.commons.cli.CommandLine cmd,
                                              boolean execute)
                                       throws AutoMedException
Define an instance of the workflow (subclasses can customise this method to define their own AutoMed workflow)

Returns:
Throws:
AutoMedException

getWorkflowInstance

public P2PWorkflow getWorkflowInstance(Peer p,
                                       AutoMedDHTImpl odht,
                                       java.lang.String dsType,
                                       java.lang.String... args)
                                throws IllegalOperationException
Create a workflow instance to run from a remote session.

Parameters:
p -
dht -
args -
Returns:
Throws:
IllegalOperationException

getWorkflowInstance

public P2PWorkflow getWorkflowInstance(Peer peer,
                                       java.lang.String[] args,
                                       boolean execute)

getWorkflowInstance

protected static P2PWorkflow getWorkflowInstance(Peer peer,
                                                 org.apache.commons.cli.CommandLine cmd,
                                                 boolean execute)
                                          throws AutoMedException
Throws:
AutoMedException

getWorkflowInstance

public static P2PWorkflow getWorkflowInstance(Peer peer,
                                              java.lang.String dsType,
                                              org.apache.commons.cli.CommandLine cmd,
                                              boolean execute)
                                       throws AutoMedException
Throws:
AutoMedException

newWorkflowInstance

private static P2PWorkflow newWorkflowInstance(java.lang.String dsType,
                                               Peer peer,
                                               org.apache.commons.cli.CommandLine cmd)

startShell

public void startShell()
A method to start a remote exection shell.


init

protected ow.tool.util.shellframework.Shell init(java.lang.String[] args,
                                                 java.io.BufferedReader in,
                                                 java.io.PrintStream out,
                                                 boolean interactive)
Extends the init() method of the super-class Main to start a shell using an existing DHT protocol instance.
This is invoked by the start() method of Main, which is in turn invoked by the startShell() method of this class.

Overrides:
init in class ow.tool.dhtshell.Main

getDHT

public ow.dht.DHT getDHT()

getCommandLine

public org.apache.commons.cli.CommandLine getCommandLine()

parseArgs

public org.apache.commons.cli.CommandLine parseArgs(org.apache.commons.cli.Options opts,
                                                    java.lang.String[] args)
                                             throws java.lang.Exception
Parse an array of arguments into a command line object

Parameters:
args -
Returns:
Throws:
java.lang.Exception

parseArgs

public org.apache.commons.cli.CommandLine[] parseArgs(org.apache.commons.cli.Option[] existingOpts,
                                                      org.apache.commons.cli.Options opts,
                                                      int start,
                                                      int end,
                                                      java.io.InputStream fin)
                                               throws AutoMedException
Read a set of peers from the source file

Parameters:
existingOpts -
pid -
fin -
Returns:
Throws:
AutoMedException

readP2POptions

public org.apache.commons.cli.CommandLine readP2POptions(org.apache.commons.cli.Options existingOpts,
                                                         java.lang.String pid)
                                                  throws AutoMedException
Throws:
AutoMedException

readP2POptions

protected org.apache.commons.cli.CommandLine readP2POptions(org.apache.commons.cli.Options existingOpts,
                                                            java.lang.String pid,
                                                            java.io.InputStream fin)
                                                     throws AutoMedException
Throws:
AutoMedException

main

public static void main(java.lang.String[] args)