org.iges.grads.server
Class GradsTaskModule

java.lang.Object
  |
  +--org.iges.anagram.AbstractModule
        |
        +--org.iges.grads.server.GradsTaskModule
All Implemented Interfaces:
Module

public class GradsTaskModule
extends AbstractModule

This module handles invoking GrADS as an external process.


Field Summary
protected static java.lang.String[] binaryNames
           
protected  boolean completeGrads
           
protected  java.io.File[] gradsBinaries
           
protected  java.io.File gradsBinary
           
protected  java.io.File scriptDir
           
protected  long timeLimit
           
protected  GradsTool tool
           
protected  boolean useNice
           
 
Fields inherited from class org.iges.anagram.AbstractModule
log, moduleName, parent, server
 
Constructor Summary
GradsTaskModule(GradsTool tool)
           
 
Method Summary
protected  void checkOutput(int gradsBinaryType, java.io.File binary)
          Does the actual work for verifyGrads()
 void configure(Setting setting)
          Configures the module according to the settings provided.
protected  void findGrads(Setting setting)
          Attempts to locate a GrADS executable using settings given.
 java.lang.String getModuleID()
          Returns an ID for this module.
 long getTimeLimit()
           
 Task task(int gradsBinaryType, java.lang.String taskName, java.lang.String[] args)
          Creates a Task object that will run a GrADS script.
protected  void verifyGrads()
          Checks that the GrADS executable specified is, in fact, a GrADS executable by running a little do-nothing GrADS script.
 
Methods inherited from class org.iges.anagram.AbstractModule
configModule, debug, debug, error, fail, fail, fail, getModuleName, info, init, toString, verbose, verbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tool

protected GradsTool tool

binaryNames

protected static final java.lang.String[] binaryNames

completeGrads

protected boolean completeGrads

useNice

protected boolean useNice

scriptDir

protected java.io.File scriptDir

timeLimit

protected long timeLimit

gradsBinary

protected java.io.File gradsBinary

gradsBinaries

protected java.io.File[] gradsBinaries
Constructor Detail

GradsTaskModule

public GradsTaskModule(GradsTool tool)
Method Detail

getModuleID

public java.lang.String getModuleID()
Description copied from interface: Module
Returns an ID for this module. This ID should be a legal XML tag name. It has two uses: as a tag name in the server's configuration file, and as the final element of the complete module name.

Specified by:
getModuleID in interface Module
Specified by:
getModuleID in class AbstractModule

configure

public void configure(Setting setting)
               throws ConfigException
Description copied from class: AbstractModule
Configures the module according to the settings provided. The server supports dynamic reconfiguration. Thus this method may be called at any time in the life of the module. If the module cannot be reconfigured, it should throw an exception.

Specified by:
configure in interface Module
Specified by:
configure in class AbstractModule
ConfigException

findGrads

protected void findGrads(Setting setting)
                  throws ConfigException
Attempts to locate a GrADS executable using settings given. Order of search is: 1) file specified in grads_bin setting, if it exists; 2) full distribution given by grads_dir setting, if all four GrADS binaries (gradsc, gradsnc, gradshdf, gradsdods) are present ; 3) file xgrads in grads_dir (this is obsolete with GrADS 1.9 since the build system no longer generates an intermediate executable called xgrads)

ConfigException

verifyGrads

protected void verifyGrads()
                    throws ConfigException
Checks that the GrADS executable specified is, in fact, a GrADS executable by running a little do-nothing GrADS script.

ConfigException

checkOutput

protected void checkOutput(int gradsBinaryType,
                           java.io.File binary)
                    throws ConfigException
Does the actual work for verifyGrads()

ConfigException

task

public Task task(int gradsBinaryType,
                 java.lang.String taskName,
                 java.lang.String[] args)
          throws ModuleException
Creates a Task object that will run a GrADS script. The actual command will be of the form: [nice] grads_binary -bpcx "script_dir/task_name.gs args"

Parameters:
gradsBinaryType - Which of the four GrADS binaries to run (gradsc, hgradsnc, gradshdf, or gradsdods)
taskName - The name of the GrADS script to run. The actual filename of the script will be generated by prepending the script_dir setting, and appending ".gs.
args - Arguments to the script
ModuleException

getTimeLimit

public long getTimeLimit()
Returns:
Maximum time a GrADS process is allowed to run