org.jlab.coda.afecs.supervisor
Class CoolServiceExecutor

java.lang.Object
  extended by org.jlab.coda.afecs.supervisor.CoolServiceExecutor

public class CoolServiceExecutor
extends java.lang.Object

JSA: Thomas Jefferson National Accelerator Facility
This software was developed under a United States Government license,
described in the NOTICE file included as part of this distribution.
Copyright (c), 5/12/11

This class provides a collection of utility methods to analyse cool configuration description, including methods analysing cool state machine descriptions.


Constructor Summary
CoolServiceExecutor(SupervisorAgent owner)
          Constructor
 
Method Summary
 boolean checkStatesRequired(ACondition condition)
          Gets all described action statements and for every statement extracts the component and required state.
 boolean checkStatesRequired(java.lang.String state)
          Overloaded method which does the same but uses state name to go over all agents under the control and find the processes required to achieve the state and check the received package text fields with the recorded data in the HashMap
 java.lang.String decodeCodaSMServiceName(java.lang.String s)
          Decodes coda state machine state transition service names and returns short state name, assuming that service names include coda state names.
 void executeActionStatements(java.util.ArrayList<AStatement> al)
          Methods executes action statements of a cool service
 int executeCondition(ACondition condition)
          Executes the conditional statement described in Cool
 boolean executeShellScript(AScript scr, java.lang.String sn, boolean before)
          Method executes shell scripts.
 java.util.ArrayList<java.lang.String> getAgentNamesByCoolType(java.lang.String coolType)
          Return arrayList of agents names that are described to take part in the COOl conditional statement.
 java.util.ArrayList<java.lang.String> getAgentNamesByPriority(int p)
           
 java.lang.StringBuffer getNotTransitioned(ACondition cond)
          Gets all described action statements and for every statement extracts the component and required state.
 java.lang.StringBuffer getNotTransitioned(java.lang.String state)
          Returns the names of all components that are not transitioned to the required state
 boolean isTrueConditionStatement(ACondition condition)
          Combines statements based on conditional operators ( && or || for e.g.
 void loadStatesServices(AControl c)
          Basic differentiation of the supervisor agent.
 void sortForReporting()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoolServiceExecutor

public CoolServiceExecutor(SupervisorAgent owner)
Constructor

Parameters:
owner - SupervisorAgent object
Method Detail

executeCondition

public int executeCondition(ACondition condition)
Executes the conditional statement described in Cool

Parameters:
condition - ACondition object
Returns:
co integer indicating which of the conditional statement were executed. 1- if, 2- elseif, 3 - else , 4 - while

executeActionStatements

public void executeActionStatements(java.util.ArrayList<AStatement> al)
Methods executes action statements of a cool service

Parameters:
al - arrayList of AStatement objects

executeShellScript

public boolean executeShellScript(AScript scr,
                                  java.lang.String sn,
                                  boolean before)
Method executes shell scripts. N.B. All the processes define before of after state transitions as usually are executed as shell scripts.

Parameters:
scr - AScript object
sn - The name of the state
before - Boolean value defines if script is running before (true) or after (false) state transition
Returns:
status of the execution

isTrueConditionStatement

public boolean isTrueConditionStatement(ACondition condition)
Combines statements based on conditional operators ( && or || for e.g. statement_1 && (||) statement_2), and defines if combined conditional statement is true or false.

Parameters:
condition - ACondition object reference
Returns:
true or false

checkStatesRequired

public boolean checkStatesRequired(ACondition condition)
Gets all described action statements and for every statement extracts the component and required state. Checks the local myCompReportingStates map for consistency (comparing current state and the required one). N.B. expected state is described as a text of the package received (this is the result of execution of the process necessary to achieve the required state). If there are more then one process necessary to be executed to achieve the state all must define the same received text.

Parameters:
condition - ACondition object
Returns:
true if state in the myCompReportingStates is equal to the cool required ( action statement) state.

checkStatesRequired

public boolean checkStatesRequired(java.lang.String state)
Overloaded method which does the same but uses state name to go over all agents under the control and find the processes required to achieve the state and check the received package text fields with the recorded data in the HashMap

Parameters:
state - the name of the state
Returns:
true/false

getNotTransitioned

public java.lang.StringBuffer getNotTransitioned(java.lang.String state)
Returns the names of all components that are not transitioned to the required state

Parameters:
state - required state name
Returns:
StringBuffer containing comma separated names of components

getNotTransitioned

public java.lang.StringBuffer getNotTransitioned(ACondition cond)
Gets all described action statements and for every statement extracts the component and required state. Returns the names of all components that are not transitioned to the required state Checks the local myCompStates map for consistency.

Parameters:
cond - ACondition object
Returns:
StringBuffer containing comma separated names of components

decodeCodaSMServiceName

public java.lang.String decodeCodaSMServiceName(java.lang.String s)
Decodes coda state machine state transition service names and returns short state name, assuming that service names include coda state names.

Parameters:
s - coda state machine service name
Returns:
coda state name

getAgentNamesByCoolType

public java.util.ArrayList<java.lang.String> getAgentNamesByCoolType(java.lang.String coolType)
Return arrayList of agents names that are described to take part in the COOl conditional statement.

Parameters:
coolType - Cool defines type like "type_EMU" representing specific coda type.
Returns:
ArrayList of agents names.

getAgentNamesByPriority

public java.util.ArrayList<java.lang.String> getAgentNamesByPriority(int p)

loadStatesServices

public void loadStatesServices(AControl c)
Basic differentiation of the supervisor agent. Records components under the control of this supervisor. Completes basic subscriptions specific for supervisor agents. Compiles and stores described services and their rules/conditions, using CCompiler

Parameters:
c - AControl object as a result parsing rdf configuration file for the control.

sortForReporting

public void sortForReporting()