edu.isi.pegasus.planner.code

## Class GridStartFactory

- java.lang.Object
- - edu.isi.pegasus.planner.code.GridStartFactory

    public class GridStartFactory
    extends java.lang.Object

An abstract factory class to load the appropriate type of GridStart implementations, and their corresponding POSTScript classes. This factory class is different from other factories, in the sense that it must be instantiated first and intialized first before calling out to any of the Factory methods.

Version:
  $Revision$
Author:
  Karan Vahi

### Field Summary

Fields
`static java.lang.String` `ALL_POST_SCRIPT_SCOPE` The postscript mode in which post scripts are added only for all jobs.
`static java.lang.String` `DEFAULT_PACKAGE_NAME` The package name where the implementations of this interface reside by default.
`static java.lang.String` `ESSENTIAL_POST_SCRIPT_SCOPE` The postscript mode in which post scripts are added only for essential jobs.
`static java.lang.String[]` `GRIDSTART_IMPLEMENTING_CLASSES` The known gridstart implementations.
`static java.lang.String[]` `GRIDSTART_SHORT_NAMES` The corresponding short names for the implementations.
`static int` `KICKSTART_INDEX` The index in the constant arrays for NoGridStart.
`private PegasusBag` `mBag` The bag of objects used for initialization.
`private ADag` `mDAG` The workflow object.
`private java.util.Map` `mGridStartImplementationTable` A table that maps short names of `GridStart` implementations with the implementations themselves.
`private boolean` `mInitialized` A boolean indicating that the factory has been initialized.
`private java.util.Map` `mPOSTScriptImplementationTable` A table that maps short names of `POSTScript` implementations with the implementations themselves.
`private PegasusProperties` `mProps` The properties object holding all the properties.
`private java.lang.String` `mSubmitDir` The submit directory where the submit files are being generated for the workflow.
`static int` `NO_GRIDSTART_INDEX` The index in the constant arrays for NoGridStart.
`private static java.util.Map` `POSTSCRIPT_IMPLEMENTING_CLASS_TABLE` A table that associates POSTScript implementing classes with their SHORT_NAMES.
`static int` `SEQEXEC_INDEX` The index in constant arrays for SeqExec

### Constructor Summary

Constructors
Constructor and Description
`GridStartFactory()` The default constructor.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`private static void` `associate(POSTScript ps)` Associates a shortname with the classname.
`private static void` `associate(java.lang.String shortName, java.lang.String className)` Associates a shortname with the classname.
`private GridStart` `gridStart(java.lang.String name)` Returns the cached implementation of GridStart from the implementing class table.
`private static java.lang.String` `implementingPOSTScriptClass(java.lang.String shortName)` Returns the name of the implementing POSTSCript class.
`void` `initialize(PegasusBag bag, ADag dag)` Initializes the factory with known GridStart implementations.
`GridStart` `loadGridStart(Job job, java.lang.String gridStartPath)` Loads the appropriate gridstart implementation for a job on the basis of the value of the GRIDSTART_KEY in the Pegasus namepsace.
`private GridStart` `loadGridStart(PegasusBag bag, ADag dag, java.lang.String className)` Loads the implementing class corresponding to the class.
`POSTScript` `loadPOSTScript(Job job, GridStart gridStart)` Loads the appropriate POST Script implementation for a job on the basis of the value of the Pegasus profile GRIDSTART_KEY, and the DAGMan profile POST_SCRIPT_KEY in the Pegasus namepsace.
`private POSTScript` `loadPOSTScript(PegasusProperties properties, java.lang.String submitDir, java.lang.String path, java.lang.String className)` Loads the implementing class corresponding to the class.
`private POSTScript` `postScript(java.lang.String type)` Returns the cached implementation of `POSTScript` from the implementing class table.
`private void` `registerGridStart(java.lang.String name, GridStart implementation)` Inserts an entry into the implementing class table.
`private void` `registerPOSTScript(java.lang.String name, POSTScript implementation)` Inserts an entry into the implementing class table.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### DEFAULT_PACKAGE_NAME

    public static final java.lang.String DEFAULT_PACKAGE_NAME

The package name where the implementations of this interface reside by default.

See Also:
  Constant Field Values

#### GRIDSTART_SHORT_NAMES

    public static java.lang.String[] GRIDSTART_SHORT_NAMES

The corresponding short names for the implementations.

#### KICKSTART_INDEX

    public static final int KICKSTART_INDEX

The index in the constant arrays for NoGridStart.

See Also:
  Constant Field Values

#### NO_GRIDSTART_INDEX

    public static final int NO_GRIDSTART_INDEX

The index in the constant arrays for NoGridStart.

See Also:
  Constant Field Values

#### SEQEXEC_INDEX

    public static final int SEQEXEC_INDEX

The index in constant arrays for SeqExec

See Also:
  Constant Field Values

#### ESSENTIAL_POST_SCRIPT_SCOPE

    public static final java.lang.String ESSENTIAL_POST_SCRIPT_SCOPE

The postscript mode in which post scripts are added only for essential jobs.

See Also:
  Constant Field Values

#### ALL_POST_SCRIPT_SCOPE

    public static final java.lang.String ALL_POST_SCRIPT_SCOPE

The postscript mode in which post scripts are added only for all jobs.

See Also:
  Constant Field Values

#### GRIDSTART_IMPLEMENTING_CLASSES

    public static java.lang.String[] GRIDSTART_IMPLEMENTING_CLASSES

The known gridstart implementations.

#### POSTSCRIPT_IMPLEMENTING_CLASS_TABLE

    private static java.util.Map POSTSCRIPT_IMPLEMENTING_CLASS_TABLE

A table that associates POSTScript implementing classes with their SHORT_NAMES.

#### mPOSTScriptImplementationTable

    private java.util.Map mPOSTScriptImplementationTable

A table that maps short names of `POSTScript` implementations with the implementations themselves.

#### mGridStartImplementationTable

    private java.util.Map mGridStartImplementationTable

A table that maps short names of `GridStart` implementations with the implementations themselves.

#### mBag

    private PegasusBag mBag

The bag of objects used for initialization.

#### mProps

    private PegasusProperties mProps

The properties object holding all the properties.

#### mSubmitDir

    private java.lang.String mSubmitDir

The submit directory where the submit files are being generated for the workflow.

#### mDAG

    private ADag mDAG

The workflow object.

#### mInitialized

    private boolean mInitialized

A boolean indicating that the factory has been initialized.

### Constructor Detail

#### GridStartFactory

    public GridStartFactory()

The default constructor.

### Method Detail

#### associate

    private static void associate(POSTScript ps)

Associates a shortname with the classname.

Parameters:
  `ps` - the `POSTScript` implementation.

#### associate

    private static void associate(java.lang.String shortName,
                                  java.lang.String className)

Associates a shortname with the classname.

Parameters:
  `shortName` - the shortName for the POSTScript implementation
  `className` - the fully qualified className of the implementing class.

#### implementingPOSTScriptClass

    private static java.lang.String implementingPOSTScriptClass(java.lang.String shortName)

Returns the name of the implementing POSTSCript class.

Parameters:
  `shortName` - the shortName for the POSTScript implementation
Returns:
  the className the fully qualified className of the implementing class, else null.

#### initialize

    public void initialize(PegasusBag bag,
                           ADag dag)

Initializes the factory with known GridStart implementations.

Parameters:
  `bag` - the bag of objects that is used for initialization.
  `dag` - the concrete dag so far.

#### loadGridStart

    public GridStart loadGridStart(Job job,
                                   java.lang.String gridStartPath)
                            throws GridStartFactoryException

Loads the appropriate gridstart implementation for a job on the basis of the value of the GRIDSTART_KEY in the Pegasus namepsace. If no value is specified then the value in the properties file is picked up.

Parameters:
  `job` - the job for which we want the gridstart handle.
  `gridStartPath` - the path to the gridstart from the site catalog.
Returns:
  a handle to appropriate GridStart implementation.
Throws:
  `GridStartFactoryException` - that nests any error that might occur during the instantiation of the implementation.
See Also:
  `org.griphyn.cPlanner.namespace.Pegasus#GRIDSTART_KEY`, `org.griphyn.cPlanner.common.PegasusProperties#getGridStart()`

#### loadPOSTScript

    public POSTScript loadPOSTScript(Job job,
                                     GridStart gridStart)
                              throws GridStartFactoryException

Loads the appropriate POST Script implementation for a job on the basis of the value of the Pegasus profile GRIDSTART_KEY, and the DAGMan profile POST_SCRIPT_KEY in the Pegasus namepsace. If no value is specified then the value in the properties file is picked up.

Parameters:
  `job` - the job for which we want the gridstart handle.
  `gridStart` - the `GridStart` for which we want to load the POSTSCRIPT implementation.
Returns:
  a handle to appropriate POSTScript implementation.
Throws:
  `GridStartFactoryException` - that nests any error that might occur during the instantiation of the implementation.
See Also:
  `org.griphyn.cPlanner.namespace.Pegasus#GRIDSTART_KEY`, `org.griphyn.cPlanner.namespace.Dagman#POST_SCRIPT_KEY`, `org.griphyn.cPlanner.common.PegasusProperties#getGridStart()`

#### loadGridStart

    private GridStart loadGridStart(PegasusBag bag,
                                    ADag dag,
                                    java.lang.String className)
                             throws GridStartFactoryException

Loads the implementing class corresponding to the class. If the package name is not specified with the class, then class is assumed to be in the DEFAULT_PACKAGE. The properties object passed should not be null.

Parameters:
  `bag` - the bag of initialization objects
  `dag` - the concrete dag so far.
  `className` - the name of the class that implements the mode. It is the name of the class, not the complete name with package. That is added by itself.
Returns:
  the instance of the class implementing this interface.
Throws:
  `GridStartFactoryException` - that nests any error that might occur during the instantiation of the implementation.
See Also:
  `DEFAULT_PACKAGE_NAME`

#### loadPOSTScript

    private POSTScript loadPOSTScript(PegasusProperties properties,
                                      java.lang.String submitDir,
                                      java.lang.String path,
                                      java.lang.String className)
                               throws GridStartFactoryException

Loads the implementing class corresponding to the class. If the package name is not specified with the class, then class is assumed to be in the DEFAULT_PACKAGE. The properties object passed should not be null.

Parameters:
  `properties` - the `PegasusProperties` object containing all the properties required by Pegasus.
  `submitDir` - the submit directory where the submit file for the job has to be generated.
  `path` - the path to the postscript on the submit host.
  `className` - the name of the class that implements the mode. It is the name of the class, not the complete name with package. That is added by itself.
Returns:
  the instance of the class implementing this interface.
Throws:
  `GridStartFactoryException` - that nests any error that might occur during the instantiation of the implementation.
See Also:
  `DEFAULT_PACKAGE_NAME`

#### postScript

    private POSTScript postScript(java.lang.String type)

Returns the cached implementation of `POSTScript` from the implementing class table.

Parameters:
  `type` - the short name for a `POSTScript` implementation
Returns:
  implementation the object class implementing that style, else null

#### registerPOSTScript

    private void registerPOSTScript(java.lang.String name,
                                    POSTScript implementation)

Inserts an entry into the implementing class table. The name is converted to lower case before being stored.

Parameters:
  `name` - the short name for a `POSTScript` implementation
  `implementation` - the object of the class implementing that style.

#### gridStart

    private GridStart gridStart(java.lang.String name)

Returns the cached implementation of GridStart from the implementing class table.

Parameters:
  `name` - the short name for a GridStart implementation
Returns:
  implementation the object of the class implementing that style, else null

#### registerGridStart

    private void registerGridStart(java.lang.String name,
                                   GridStart implementation)

Inserts an entry into the implementing class table. The name is converted to lower case before being stored.

Parameters:
  `name` - the short name for a GridStart implementation
  `implementation` - the object of the class implementing that style.