|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.ac.rdg.resc.jstyx.client.CStyxFileChangeAdapter
uk.ac.rdg.resc.jstyx.gridservice.client.SGSInstanceClient
public class SGSInstanceClient
A client for a Styx Grid Service Instance. The client interacts with the SGS instance and fires events when data arrives or the service data change.
| Constructor Summary | |
|---|---|
SGSInstanceClient(SGSClient client,
CStyxFile instanceRoot)
Creates a new SGSInstanceClient for an instance that has its root in the given CStyxFile. |
|
SGSInstanceClient(java.lang.String instanceURL)
Gets an SGSInstanceClient, given the full URL to the root of the new instance, e.g. |
|
| Method Summary | |
|---|---|
void |
addChangeListener(SGSInstanceClientChangeListener listener)
Adds a listener that will be notified of changes to this SGS. |
void |
close()
Closes the underlying StyxConnection |
void |
dataArrived(CStyxFile file,
TreadMessage tReadMsg,
org.apache.mina.common.ByteBuffer data)
This is called when we have read data asynchronously using readDataAsync(). |
void |
dataWritten(CStyxFile file,
TwriteMessage tWriteMsg)
Required by the CStyxFileChangeListener interface. |
void |
error(CStyxFile file,
java.lang.String message)
Required by the StyxFileChangeListener interface. |
java.lang.String |
getArguments()
Gets the command line arguments that will be executed. |
void |
getArgumentsAsync()
Sends a message to get the command line arguments that will be executed. |
StyxConnection |
getConnection()
Gets the underlying connection object |
java.util.Vector |
getInputs()
|
java.lang.String |
getInstanceID()
|
CStyxFile |
getInstanceRoot()
|
java.lang.String |
getName()
|
java.lang.String[] |
getOutputFileNames()
Gets the names of all the output files |
java.lang.String |
getOutputFileURL(java.lang.String filename)
|
java.util.Vector |
getParameters()
|
java.lang.String[] |
getServiceDataNames()
|
java.util.Hashtable |
getServiceDataValues()
Gets the values of all service data elements as a Hashtable, in which the keys are the service data element names (Strings) and the values are the service data values (also Strings). |
java.lang.String[] |
getSteerableParameterNames()
|
CachedStreamReader |
getStreamReader(CStyxFile stream)
Gets a CachedStreamReader that can be used to read from the given stream This is not used in the current implementation of SGS but might be in the future, perhaps to support GUI applications |
void |
readAllParameterValuesAsync()
Sends messages to get the current value of all parameters. |
void |
readAllServiceDataValuesAsync()
Sends messages to get the current value of all pieces of service data. |
void |
readAllSteerableParameterValuesAsync()
Sends messages to get the current value of all steerable parameters. |
void |
readServiceDataValueAsync(java.lang.String sdeName)
Sends a message to get the current value of the given piece of service data. |
void |
redirectOutput(java.lang.String outputFileName,
java.io.File file)
Starts reading data from the given output file and redirects the data to the given local File. |
void |
redirectOutput(java.lang.String outputFileName,
java.io.PrintStream dest)
Starts reading data from the given output file and redirects the data to the given PrintStream. |
void |
removeChangeListener(SGSInstanceClientChangeListener listener)
Removes a SGSInstanceChangeListener. |
void |
setInputSource(SGSInput inputFile,
java.io.File file)
Sets the local file from which an input file will get its data. |
void |
setInputSource(SGSInput inputFile,
java.lang.String filenameOrUrl)
Sets the file or URL from which an input file will get its data. |
void |
setLifetime(double lifetimeInMinutes)
Set the lifetime of this SGS instance. |
void |
setParameterValue(SGSParam param,
java.lang.String value)
Sets the value of the parameter with the given name to the given value. |
void |
setParameterValue(SGSParam param,
java.lang.String[] vals)
Sets the value of the parameter with the given name to the given value. |
void |
setParameterValueAsync(SGSParam param,
java.lang.String value)
Sets the value of the parameter with the given name to the given value. |
void |
setSteerableParameterValueAsync(java.lang.String name,
java.lang.String value)
Sets the value of the steerable parameter with the given name to the given value. |
void |
startService()
Starts the service. |
void |
startServiceAsync()
Sends a message to start the service. |
void |
stopService()
Stops the service. |
void |
stopServiceAsync()
Sends a message to stop the service. |
void |
uploadInputFiles()
Uploads the input files to the server. |
void |
uploadInputFilesAsync()
Uploads the input files to the server. |
| Methods inherited from class uk.ac.rdg.resc.jstyx.client.CStyxFileChangeAdapter |
|---|
childrenFound, downloadComplete, fileCreated, fileOpen, statChanged, uploadComplete |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SGSInstanceClient(SGSClient client,
CStyxFile instanceRoot)
throws StyxException
client - The SGSClient to which this instance belongsinstanceRoot - The file representing the root of this instance
StyxException - if there was an error creating the client (for
example, there is no instance with the given ID or there was an error
reading the directory contents from the server)
public SGSInstanceClient(java.lang.String instanceURL)
throws StyxException
styx://thehost.com:9092/mySGS/instances/1234567890abcde
StyxException - if there was an error creating the client object| Method Detail |
|---|
public CStyxFile getInstanceRoot()
public java.lang.String getName()
public void startServiceAsync()
public void startService()
throws StyxException
StyxException - if the service could not be startedpublic StyxConnection getConnection()
public void stopServiceAsync()
public void stopService()
throws StyxException
StyxException - if the service could not be stoppedpublic java.lang.String[] getServiceDataNames()
public java.util.Vector getParameters()
public java.lang.String[] getSteerableParameterNames()
public java.util.Vector getInputs()
public java.lang.String[] getOutputFileNames()
throws StyxException
StyxExceptionpublic java.lang.String getOutputFileURL(java.lang.String filename)
java.lang.IllegalArgumentException - if there is no file with the given namepublic void getArgumentsAsync()
public java.lang.String getArguments()
throws StyxException
StyxException - if there was an error getting the contents
public void setLifetime(double lifetimeInMinutes)
throws StyxException
lifetimeInMinutes - the lifetime of this instance in minutes. The instance will
automatically be destroyed at this time after the instance was created.
StyxException - if the lifetime could not be setpublic void readServiceDataValueAsync(java.lang.String sdeName)
exitCode, as soon as the server replies
with the new service data value, a message will be sent to read the value
again immediately and automatically. Therefore you only need to call this
method once for each element of service data. In the case of exitCode
there is no need to read the value more than once because the server will
only reply when the remote service has stopped running: the exit code will
never change after this reply.
sdeName - the name of the service data element to read
java.lang.IllegalArgumentException - if there is no element of service data
with the given namepublic void readAllServiceDataValuesAsync()
exitCode, as soon as the server replies
with the new service data value, a message will be sent to read the value
again immediately and automatically. Therefore you only need to call this
method once for each element of service data. In the case of exitCode
there is no need to read the value more than once because the server will
only reply when the remote service has stopped running: the exit code will
never change after this reply.
public void readAllParameterValuesAsync()
public void readAllSteerableParameterValuesAsync()
public void setInputSource(SGSInput inputFile,
java.lang.String filenameOrUrl)
throws java.io.FileNotFoundException
inputFile - SGSInput object representing the input file, as
read using getInputs()filenameOrUrl - If this String starts with the string "readfrom:",
this will be interpreted as a URL from which the server will read
the input file. If not, this will be interpreted as the name of a local
file.
java.lang.IllegalStateException - if there is an attempt to set more than
one file or URL for a fixed input file or the standard input
java.io.FileNotFoundException - if filenameOrUrl represents
the name of a file that does not exist.
public void setInputSource(SGSInput inputFile,
java.io.File file)
throws java.io.FileNotFoundException
inputFile - SGSInput object representing the input file, as
read using getInputs()file - The file from which this input file will get its data
java.io.FileNotFoundException - if file does not exist
java.lang.IllegalStateException - if there is an attempt to set more than
one file or URL for a fixed input file or the standard input
public void redirectOutput(java.lang.String outputFileName,
java.io.PrintStream dest)
outputFileName - Name of the output file (as returned by
getOutputFileNames())dest - The PrintStream (e.g. System.out) to which the data will be
written.
java.lang.IllegalArgumentException - if there is no output file with the
given name
public void redirectOutput(java.lang.String outputFileName,
java.io.File file)
throws java.io.FileNotFoundException
outputFileName - Name of the output file (as returned by
getOutputFileNames())file - the local file to which the data will be written.
java.io.FileNotFoundException - if the local target file could not be
created.
java.lang.IllegalArgumentException - if there is no output file with the
given name
public void setParameterValue(SGSParam param,
java.lang.String value)
throws java.io.FileNotFoundException,
StyxException
param - The SGSParam object representing this parameter (as returned
by this.getParameters()value - The value of this parameter.
java.io.FileNotFoundException - if the parameter represents an input file
and the value represents a file that does not exist
StyxException - if there was an error writing to the parameter file,
or if the new value was invalid
public void setParameterValue(SGSParam param,
java.lang.String[] vals)
throws java.io.FileNotFoundException,
StyxException
param - The SGSParam object representing this parameter (as returned
by this.getParameters()vals - String array representing all the values for this parameter
java.io.FileNotFoundException - if the parameter represents an input file
and the value represents a file that does not exist
StyxException - if there was an error writing to the parameter file,
or if the new value was invalid
public void setParameterValueAsync(SGSParam param,
java.lang.String value)
throws java.io.FileNotFoundException
java.io.FileNotFoundException - if the parameter represents an input file
and the value represents a file that does not exist
public void setSteerableParameterValueAsync(java.lang.String name,
java.lang.String value)
java.lang.IllegalArgumentException - if a parameter with the given name
does not exist.
public void uploadInputFiles()
throws StyxException
StyxExceptionpublic void uploadInputFilesAsync()
public java.util.Hashtable getServiceDataValues()
throws StyxException
Gets the values of all service data elements as a Hashtable, in which the keys are the service data element names (Strings) and the values are the service data values (also Strings). The first time this method is called it will return immediately with the data. Subsequent calls will block until any one of the service data values change.
The procedure followed is to open each file for reading, then send a message to read each file, returning the data when it arrives. The files are not closed between calls to this function (but they might be closed through the use of other functions)
StyxExceptionpublic java.lang.String getInstanceID()
public CachedStreamReader getStreamReader(CStyxFile stream)
public void dataArrived(CStyxFile file,
TreadMessage tReadMsg,
org.apache.mina.common.ByteBuffer data)
dataArrived in interface CStyxFileChangeListenerdataArrived in class CStyxFileChangeAdapterfile - The CStyxFile containing the datatReadMsg - The original TreadMessage that was sent (contains the offset,
tag etc of the message)data - The new data that have been read from the file
public void dataWritten(CStyxFile file,
TwriteMessage tWriteMsg)
dataWritten in interface CStyxFileChangeListenerdataWritten in class CStyxFileChangeAdapterfile - The CStyxFile containing the datatWriteMsg - The TwriteMessage that caused this event to be fired
public void error(CStyxFile file,
java.lang.String message)
error in interface CStyxFileChangeListenererror in class CStyxFileChangeAdapterfile - the CStyxFile from which the error originatedmessage - the error messagepublic void close()
public void addChangeListener(SGSInstanceClientChangeListener listener)
public void removeChangeListener(SGSInstanceClientChangeListener listener)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||