gr.uoa.di.madgik.execution.plan.element
Class ShellPlanElement

java.lang.Object
  extended by gr.uoa.di.madgik.execution.plan.element.PlanElementBase
      extended by gr.uoa.di.madgik.execution.plan.element.ShellPlanElement
All Implemented Interfaces:
IPlanElement, Observer

public class ShellPlanElement
extends PlanElementBase

This class acts as an invocation wrapper of a shell script, or in general an external executable, enabling it to be directly included in the execution of a plan. The executable is defined using its absolute or relative path in the Command field. Any parameters it may require to be provided are specified in the ArgumentParameters. Additionally, any environmental variables that need to be present for the execution of the command can be defined in Environment. The execution of the external executable is done using a ProcessBuilder. It is also possible to define the data that will be written to the processe's standard input using the StdInParameter. The standard output and standard error of the process can be retrieved by setting the StdOutParameter and StdErrParameter respectively. these inputs and outputs can be retrieved / dumped from /to files by setting the respective flags StdInIsFile, StdOutIsFile and StdErrIsFile

Author:
gpapanikos

Nested Class Summary
 
Nested classes/interfaces inherited from class gr.uoa.di.madgik.execution.plan.element.PlanElementBase
PlanElementBase.ClockType
 
Nested classes/interfaces inherited from interface gr.uoa.di.madgik.execution.plan.element.IPlanElement
IPlanElement.PlanElementType
 
Field Summary
 List<AttributedInputParameter> ArgumentParameters
          The parameters that should be provided to the process's executable
 String Command
          The executable that is to be started
 List<EnvironmentKeyValue> Environment
          The environmental variables that must be set for the process being started
 List<ExceptionExitCodeMaping> ExitCodeErrors
          A mapping of exit codes to the respective errors they should produce
 boolean StdErrIsFile
          A flag indicating that the standard error output should be stored in a file
 ParameterFilterBase StdErrOnlineFilter
          A filter that can be applied on the fly in the output of the element's standard error
 IInputOutputParameter StdErrParameter
          The parameter to store the product of the standard error output.
 IOutputParameter StdExitValueParameter
          The parameter where to store the exit value of the process
 boolean StdInIsFile
          A flag indicating that the standard input should be retrieved by a file
 IInputParameter StdInParameter
          The parameter to retrieve the products of the standard input.
 boolean StdOutIsFile
          A flag indicating that the standard output products should be stored in a file
 ParameterFilterBase StdOutOnlineFilter
          A filter that can be applied on the fly in the output of the element's standard output
 IInputOutputParameter StdOutParameter
          The parameter to store the product of the standard error output.
 List<ContingencyTrigger> Triggers
          The Triggers this element supports
 
Constructor Summary
ShellPlanElement()
           
 
Method Summary
 void ExecuteExtender(ExecutionHandle Handle)
          Execute extender.
 void FromXML(Element XML)
          Populate the element from its xml serialization as returned by IPlanElement.ToXML()
 void FromXML(String XML)
          Populate the element from its xml serialization as returned by IPlanElement.ToXML()
 List<ContingencyTrigger> GetContingencyTriggers()
          Gets the contingency triggers.
 Logger GetExtenderLogger()
          Gets the extender logger.
 String GetID()
          Gets the id.
 Set<String> GetModifiedVariableNames()
          Gets the modified variable names of the element and of the elements contained.
 String GetName()
          Gets the name.
 Set<String> GetNeededVariableNames()
          Gets the needed variable names of the element and of the elements contained.
 IPlanElement.PlanElementType GetPlanElementType()
          Gets the plan element type.
 IPlanElement Locate(String ID)
          Locate the plan element with the provided id.
 Set<IPlanElement> LocateActionElements()
          Retrieves the Action elements under this elements
 void SetContingencyResourcePick(ExecutionHandle Handle, String Pick)
          Sets the picked resource in case the IContingencyReaction.ReactionType#Pick reaction is supported
 void SetName(String Name)
          Sets the name.
 IContingencyReaction.ReactionType[] SupportedContingencyTriggers()
          Retrieves the supported contingency triggers.
 boolean SupportsContingencyTriggers()
          Checks if the element supports contingency triggers.
 String ToXML()
          Serialize to xml the element and all its contained elements
 void Validate()
          Validate the element and any sub element it contains
 void ValidatePreExecution(ExecutionHandle Handle)
          Validate the element and any sub element it contains before it is executed
 
Methods inherited from class gr.uoa.di.madgik.execution.plan.element.PlanElementBase
CheckStatus, Execute, ExecuteWithStateAwareness, GetPerformanceEvent, RegisterToRunningActionElementsRestriction, ResetClocks, StartClock, StopClock, UnregisterToRunningActionElementsRestriction, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Triggers

public List<ContingencyTrigger> Triggers
The Triggers this element supports


Command

public String Command
The executable that is to be started


ArgumentParameters

public List<AttributedInputParameter> ArgumentParameters
The parameters that should be provided to the process's executable


StdInParameter

public IInputParameter StdInParameter
The parameter to retrieve the products of the standard input. If the StdInIsFile is set then this parameter will hold the file that the input should be read from


StdInIsFile

public boolean StdInIsFile
A flag indicating that the standard input should be retrieved by a file


StdOutParameter

public IInputOutputParameter StdOutParameter
The parameter to store the product of the standard error output. If the StdOutIsFile is set then this parameter will hold the file that the output was dumped to


StdOutIsFile

public boolean StdOutIsFile
A flag indicating that the standard output products should be stored in a file


StdOutOnlineFilter

public ParameterFilterBase StdOutOnlineFilter
A filter that can be applied on the fly in the output of the element's standard output


StdErrParameter

public IInputOutputParameter StdErrParameter
The parameter to store the product of the standard error output. If the StdErrIsFile is set then this parameter will hold the file that the output was dumped to


StdErrIsFile

public boolean StdErrIsFile
A flag indicating that the standard error output should be stored in a file


StdErrOnlineFilter

public ParameterFilterBase StdErrOnlineFilter
A filter that can be applied on the fly in the output of the element's standard error


StdExitValueParameter

public IOutputParameter StdExitValueParameter
The parameter where to store the exit value of the process


ExitCodeErrors

public List<ExceptionExitCodeMaping> ExitCodeErrors
A mapping of exit codes to the respective errors they should produce


Environment

public List<EnvironmentKeyValue> Environment
The environmental variables that must be set for the process being started

Constructor Detail

ShellPlanElement

public ShellPlanElement()
Method Detail

FromXML

public void FromXML(String XML)
             throws ExecutionSerializationException
Description copied from interface: IPlanElement
Populate the element from its xml serialization as returned by IPlanElement.ToXML()

Parameters:
XML - the xML serialization
Throws:
ExecutionSerializationException - A serialization error occurred

FromXML

public void FromXML(Element XML)
             throws ExecutionSerializationException
Description copied from interface: IPlanElement
Populate the element from its xml serialization as returned by IPlanElement.ToXML()

Parameters:
XML - the xML serialization
Throws:
ExecutionSerializationException - A serialization error occurred

GetID

public String GetID()
Description copied from interface: IPlanElement
Gets the id.

Returns:
the id of the element

GetName

public String GetName()
Description copied from interface: IPlanElement
Gets the name.

Returns:
the name

GetPlanElementType

public IPlanElement.PlanElementType GetPlanElementType()
Description copied from interface: IPlanElement
Gets the plan element type.

Returns:
the plan element type

Locate

public IPlanElement Locate(String ID)
Description copied from interface: IPlanElement
Locate the plan element with the provided id. If this is the element requested return this instance. Otherwise forward the request to any sub elements contained. If the element does not belong to the hierarchy under this element, return null

Parameters:
ID - the iD
Returns:
the plan element with the provided id. or null if not found

LocateActionElements

public Set<IPlanElement> LocateActionElements()
Description copied from interface: IPlanElement
Retrieves the Action elements under this elements

Returns:
The action ELements

SetName

public void SetName(String Name)
Description copied from interface: IPlanElement
Sets the name.

Parameters:
Name - the name

ToXML

public String ToXML()
             throws ExecutionSerializationException
Description copied from interface: IPlanElement
Serialize to xml the element and all its contained elements

Returns:
the serialization
Throws:
ExecutionSerializationException - A serialization error occurred

Validate

public void Validate()
              throws ExecutionValidationException
Description copied from interface: IPlanElement
Validate the element and any sub element it contains

Throws:
ExecutionValidationException - A validation error occurred

ValidatePreExecution

public void ValidatePreExecution(ExecutionHandle Handle)
                          throws ExecutionValidationException
Description copied from interface: IPlanElement
Validate the element and any sub element it contains before it is executed

Parameters:
Handle - the execution handle
Throws:
ExecutionValidationException - A validation error occurred

SupportedContingencyTriggers

public IContingencyReaction.ReactionType[] SupportedContingencyTriggers()
Description copied from interface: IPlanElement
Retrieves the supported contingency triggers.

Returns:
the supported contingency triggers types.

SupportsContingencyTriggers

public boolean SupportsContingencyTriggers()
Description copied from interface: IPlanElement
Checks if the element supports contingency triggers.

Returns:
true, if it does

GetContingencyTriggers

public List<ContingencyTrigger> GetContingencyTriggers()
Description copied from interface: IPlanElement
Gets the contingency triggers.

Returns:
the list of contingency trigger that are applicable to the element.

SetContingencyResourcePick

public void SetContingencyResourcePick(ExecutionHandle Handle,
                                       String Pick)
                                throws ExecutionRunTimeException
Description copied from interface: IPlanElement
Sets the picked resource in case the IContingencyReaction.ReactionType#Pick reaction is supported

Parameters:
Handle - the execution handle handle
Pick - the picked resource
Throws:
ExecutionRunTimeException - A runtime error occurred

GetModifiedVariableNames

public Set<String> GetModifiedVariableNames()
Description copied from interface: IPlanElement
Gets the modified variable names of the element and of the elements contained. These include the variables that are modified by the element and its hierarchy when executed.

Returns:
the set of the variable names that are modified by this element and its contained elements

GetNeededVariableNames

public Set<String> GetNeededVariableNames()
Description copied from interface: IPlanElement
Gets the needed variable names of the element and of the elements contained. These include the variables that are needed to be present for the element and its hierarchy to be executed.

Returns:
the set of the variable names that are needed by this element and its contained elements

GetExtenderLogger

public Logger GetExtenderLogger()
Description copied from class: PlanElementBase
Gets the extender logger.

Specified by:
GetExtenderLogger in class PlanElementBase
Returns:
the logger

ExecuteExtender

public void ExecuteExtender(ExecutionHandle Handle)
                     throws ExecutionRunTimeException,
                            ExecutionInternalErrorException,
                            ExecutionCancelException,
                            ExecutionBreakException
Description copied from class: PlanElementBase
Execute extender. This class is implemented by extenders of the class

Specified by:
ExecuteExtender in class PlanElementBase
Parameters:
Handle - the execution handle
Throws:
ExecutionRunTimeException - A runtime error occurred
ExecutionInternalErrorException - An internal error occurred
ExecutionCancelException - The execution was canceled
ExecutionBreakException - The execution was terminated


Copyright © 2012. All Rights Reserved.