uk.ac.rdg.resc.jstyx.gridservice.client
Class SGSRun

java.lang.Object
  extended by uk.ac.rdg.resc.jstyx.gridservice.client.SGSInstanceClientChangeAdapter
      extended by uk.ac.rdg.resc.jstyx.gridservice.client.SGSRun
All Implemented Interfaces:
StyxConnectionListener, SGSInstanceClientChangeListener

public class SGSRun
extends SGSInstanceClientChangeAdapter
implements StyxConnectionListener

Simple program that logs on to an SGS server, creates a new service instance, runs it and redirects the output streams to the console and local files

Author:
Jon Blower $Revision: 609 $ $Date: 2006-03-31 18:09:42 +0100 (Fri, 31 Mar 2006) $ $Log: SGSRun.java,v $ Revision 1.20 2006/02/22 08:52:57 jonblower Added debug code and support for setting service lifetime Revision 1.19 2006/02/20 17:35:01 jonblower Implemented correct handling of output files/streams (not fully tested yet) Revision 1.18 2006/02/17 17:34:44 jonblower Implemented (but didn't test) proper handling of output files Revision 1.17 2006/02/17 09:27:50 jonblower Working towards handling output files properly Revision 1.16 2006/02/16 17:34:16 jonblower Working towards handling output files and references thereto Revision 1.15 2006/01/05 16:06:34 jonblower SGS clients now deal with possibility that client could be created on a different server Revision 1.14 2006/01/04 11:24:57 jonblower Implemented time directory in the SGS instance namespace Revision 1.13 2005/12/09 18:41:56 jonblower Continuing to simplify client interface to SGS instances Revision 1.12 2005/12/07 17:53:31 jonblower Added type to SGSParam (STRING, INPUT_FILE and OUTPUT_FILE) Revision 1.11 2005/12/07 08:56:32 jonblower Refactoring SGS client code Revision 1.10 2005/12/01 17:17:07 jonblower Simplifying client interface to SGS instances Revision 1.9 2005/12/01 08:29:47 jonblower Refactored XML config handling to simplify clients Revision 1.8 2005/11/28 17:20:18 jonblower Fixed bug with not exiting cleanly when error occurs Revision 1.7 2005/11/14 21:31:54 jonblower Got SGSRun working for SC2005 demo Revision 1.6 2005/11/11 21:57:21 jonblower Implemented passing of URLs to input files Revision 1.5 2005/11/10 19:50:43 jonblower Added code to handle output files Revision 1.4 2005/11/09 18:00:24 jonblower Implemented automatic uploading of input files Revision 1.3 2005/10/18 14:41:32 jonblower Closed PrintStreams properly Revision 1.2 2005/10/16 22:05:28 jonblower Improved handling of output streams (mapped CStyxFiles to PrintStreams) Revision 1.1 2005/10/14 17:57:18 jonblower Added SGSRun and associated shell scripts

Field Summary
static int INTERNAL_SGS_ERROR
          The exit code that signals an internal error in the SGS mechanism, rather than an error code from the executable that is running on the SGS server
 
Constructor Summary
SGSRun(java.lang.String hostname, int port, java.lang.String serviceName)
          Creates a new SGSRun object
 
Method Summary
 void allOutputDataDownloaded()
          Called when all the output data have been downloaded
 void checkArguments(java.lang.String[] args)
          Checks the command-line arguments: makes sure they can be parsed and checks for the existence of all input files
 void connect()
          Connects to the SGS server and downloads the configuration of this SGS.
 void connectionClosed(StyxConnection conn)
          Called when the connection to the SGS instance has been closed
 void connectionError(StyxConnection conn, java.lang.String message)
          Called when an error has occurred when connecting.
 void connectionReady(StyxConnection conn)
          Called when the relevant handshaking has been performed and the connection is ready for Styx messages to be sent.
 void createNewServiceInstance()
          Creates a new service instance
 void gotExitCode(int exitCode)
          Called when the exit code from the service is received: this signals that the remote executable has completed.
 void gotServiceDataValue(java.lang.String sdName, java.lang.String newData)
          Called when the given service data element changes
static void main(java.lang.String[] args)
           
 void readOutputFiles()
          Starts reading from the output files.
 void setInputSources()
          Sets the input sources for the Styx Grid Service
 void setParameters()
          Sets the values of all the parameters
 void start()
          Starts the service and begins reading from the output streams
 
Methods inherited from class uk.ac.rdg.resc.jstyx.gridservice.client.SGSInstanceClientChangeAdapter
error, gotArguments, gotParameterValue, gotSteerableParameterValue, inputFilesUploaded, serviceAborted, serviceStarted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERNAL_SGS_ERROR

public static final int INTERNAL_SGS_ERROR
The exit code that signals an internal error in the SGS mechanism, rather than an error code from the executable that is running on the SGS server

See Also:
Constant Field Values
Constructor Detail

SGSRun

public SGSRun(java.lang.String hostname,
              int port,
              java.lang.String serviceName)
Creates a new SGSRun object

Parameters:
hostname - The name (or IP address) of the SGS server
port - The port of the SGS server
serviceName - The name of the SGS to invoke
Method Detail

connect

public void connect()
             throws StyxException,
                    java.net.UnknownHostException
Connects to the SGS server and downloads the configuration of this SGS.

Throws:
StyxException - if there was an error connecting to the server or getting the configuration of the SGS
java.net.UnknownHostException - (from SGSServerClient.getSGSClient())

checkArguments

public void checkArguments(java.lang.String[] args)
                    throws StyxException
Checks the command-line arguments: makes sure they can be parsed and checks for the existence of all input files

Throws:
StyxException - if the arguments are not valid

createNewServiceInstance

public void createNewServiceInstance()
                              throws StyxException
Creates a new service instance

Throws:
StyxException

setParameters

public void setParameters()
                   throws StyxException,
                          java.io.FileNotFoundException
Sets the values of all the parameters

Throws:
StyxException
java.io.FileNotFoundException

setInputSources

public void setInputSources()
                     throws StyxException
Sets the input sources for the Styx Grid Service

Throws:
StyxException

start

public void start()
           throws StyxException
Starts the service and begins reading from the output streams

Throws:
StyxException - if there was an error starting the service

readOutputFiles

public void readOutputFiles()
                     throws StyxException,
                            java.io.FileNotFoundException
Starts reading from the output files. Note that we have already set the destinations for the outputs that are set via a parameter in the setParameters() method

Throws:
StyxException
java.io.FileNotFoundException

gotServiceDataValue

public void gotServiceDataValue(java.lang.String sdName,
                                java.lang.String newData)
Called when the given service data element changes

Specified by:
gotServiceDataValue in interface SGSInstanceClientChangeListener
Overrides:
gotServiceDataValue in class SGSInstanceClientChangeAdapter

gotExitCode

public void gotExitCode(int exitCode)
Called when the exit code from the service is received: this signals that the remote executable has completed.

Specified by:
gotExitCode in interface SGSInstanceClientChangeListener
Overrides:
gotExitCode in class SGSInstanceClientChangeAdapter

allOutputDataDownloaded

public void allOutputDataDownloaded()
Called when all the output data have been downloaded

Specified by:
allOutputDataDownloaded in interface SGSInstanceClientChangeListener
Overrides:
allOutputDataDownloaded in class SGSInstanceClientChangeAdapter

connectionClosed

public void connectionClosed(StyxConnection conn)
Called when the connection to the SGS instance has been closed

Specified by:
connectionClosed in interface StyxConnectionListener

connectionReady

public void connectionReady(StyxConnection conn)
Called when the relevant handshaking has been performed and the connection is ready for Styx messages to be sent. Required by StyxConnectionListener interface.

Specified by:
connectionReady in interface StyxConnectionListener

connectionError

public void connectionError(StyxConnection conn,
                            java.lang.String message)
Called when an error has occurred when connecting. Required by StyxConnectionListener interface.

Specified by:
connectionError in interface StyxConnectionListener
Parameters:
message - String describing the problem

main

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


Copyright © 2004-2006 Reading e-Science Centre. All Rights Reserved.