SMILA (incubation) API documentation

org.eclipse.smila.jobmanager.persistence
Class DefinitionValidator

java.lang.Object
  extended by org.eclipse.smila.jobmanager.persistence.DefinitionValidator

public class DefinitionValidator
extends java.lang.Object

Helper class for validating asynchronous workflow elements.


Constructor Summary
DefinitionValidator(DefinitionAccessor definitionAccessor, JobManager jobManager, ObjectStoreService objectStoreService)
           
 
Method Summary
 void checkJobRemove(java.lang.String jobName)
          Checks if the job can be removed.
 void checkRemoveBucket(java.lang.String name)
          Check if the bucket can be safely removed without compromising data integrity.
 void checkRemoveWorkflow(java.lang.String name)
          Check if the workflow can be safely removed without compromising data integrity.
protected  void fillUnresolvedVariables(Any parameter, java.lang.String key, java.lang.String container, java.util.Map<java.lang.String,java.lang.String> variableReferencingParameters)
           
protected  java.util.Map<java.lang.String,java.lang.String> removeDefinedVariables(AnyMap topLevelParameters, java.util.Map<java.lang.String,java.lang.String> unresolvedParams)
           
 void validateBucket(BucketDefinition bucketDefinition)
          check if bucket definition is valid.
 void validateBucketWorkflows(BucketDefinition bucketDefinition)
          Check if the bucket can be safely added without compromising data integrity.
 void validateJob(JobDefinition job)
          check the the workflow referenced by this job.
protected  void validateParameterDefinitionForMap(ParameterDefinition paramDef, Any parameter, boolean allParametersResolved, java.lang.String workflowName, java.lang.String workerName)
          Validates a MAP parameter against its definition.
protected  void validateParameterDefinitionForSimpleType(ParameterDefinition paramDef, Any parameter, java.lang.String workflowName, java.lang.String workerName)
           
protected  void validateParameterUndefined(ParameterDefinition paramDef, Any parameter, boolean allParametersResolved, java.lang.String workflowName, java.lang.String workerName)
          Validates that parameter is not undefined unless the definition allows so.
 void validateWorkflow(WorkflowDefinition workflow)
          check if workflow definition is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefinitionValidator

public DefinitionValidator(DefinitionAccessor definitionAccessor,
                           JobManager jobManager,
                           ObjectStoreService objectStoreService)
Parameters:
definitionAccessor - accessor for reading user-submitted or configured definitions.
jobManager - needed for accessing task generators needed for validation
objectStoreService - the reference to the object store service.
Method Detail

validateJob

public void validateJob(JobDefinition job)
                 throws InvalidConfigException,
                        PersistenceException
check the the workflow referenced by this job.

Parameters:
job - job definition
Throws:
InvalidConfigException - validation error.
PersistenceException - error reading definition(s).

validateWorkflow

public void validateWorkflow(WorkflowDefinition workflow)
                      throws InvalidConfigException,
                             PersistenceException
check if workflow definition is valid.

Parameters:
workflow - workflow definition
Throws:
InvalidConfigException - validation error.
PersistenceException - error accessing storage

validateBucket

public void validateBucket(BucketDefinition bucketDefinition)
                    throws InvalidConfigException,
                           PersistenceException
check if bucket definition is valid.

Parameters:
bucketDefinition - bucket definition
Throws:
InvalidConfigException - validation error.
PersistenceException - the bucket names cannot be retrieved.

validateBucketWorkflows

public void validateBucketWorkflows(BucketDefinition bucketDefinition)
                             throws PersistenceException,
                                    InvalidConfigException
Check if the bucket can be safely added without compromising data integrity. I.e. if there is an existing workflow definition that already references a bucket with the same name, it must still be valid after the update.

Parameters:
bucketDefinition - The bucket to check
Throws:
PersistenceException - error reading workflow definition(s)
InvalidConfigException - error adding definition due to dependency constraints

validateParameterDefinitionForMap

protected void validateParameterDefinitionForMap(ParameterDefinition paramDef,
                                                 Any parameter,
                                                 boolean allParametersResolved,
                                                 java.lang.String workflowName,
                                                 java.lang.String workerName)
                                          throws InvalidConfigException
Validates a MAP parameter against its definition.

Parameters:
paramDef - the parameterDefinition to check with the given parameter
parameter - the parameter to check against the worker's parameter description
allParametersResolved - 'true' if all parameters are resolved and also missing parameters must be reported, 'false' if parameters might still be resolved or incomplete.
workflowName - the name of the workflow
workerName - the name of the worker
Throws:
InvalidConfigException - parameter invalid

validateParameterUndefined

protected void validateParameterUndefined(ParameterDefinition paramDef,
                                          Any parameter,
                                          boolean allParametersResolved,
                                          java.lang.String workflowName,
                                          java.lang.String workerName)
                                   throws InvalidConfigException
Validates that parameter is not undefined unless the definition allows so.

Parameters:
paramDef - the parameterDefinition to check with the given parameter
parameter - the parameter to check against the worker's parameter description
allParametersResolved - 'true' if all parameters are resolved and also missing parameters must be reported, 'false' if parameters might still be resolved or incomplete.
workflowName - the name of the workflow
workerName - the name of the worker
Throws:
InvalidConfigException - parameter invalid

validateParameterDefinitionForSimpleType

protected void validateParameterDefinitionForSimpleType(ParameterDefinition paramDef,
                                                        Any parameter,
                                                        java.lang.String workflowName,
                                                        java.lang.String workerName)
                                                 throws InvalidConfigException
Parameters:
paramDef - the parameterDefinition to check with the given parameter
parameter - the parameter to check against the worker's parameter description
workflowName - the name of the workflow
workerName - the name of the worker
Throws:
InvalidConfigException

removeDefinedVariables

protected java.util.Map<java.lang.String,java.lang.String> removeDefinedVariables(AnyMap topLevelParameters,
                                                                                  java.util.Map<java.lang.String,java.lang.String> unresolvedParams)
Parameters:
topLevelParameters - the parameters map
unresolvedParams - the map of unresolved parameters

fillUnresolvedVariables

protected void fillUnresolvedVariables(Any parameter,
                                       java.lang.String key,
                                       java.lang.String container,
                                       java.util.Map<java.lang.String,java.lang.String> variableReferencingParameters)
Parameters:
parameter - the parameter (SEQ, MAP or value) that potentially references a variable
variableReferencingParameters - the parameters which are referencing variables

checkRemoveWorkflow

public void checkRemoveWorkflow(java.lang.String name)
                         throws InvalidConfigException,
                                PersistenceException
Check if the workflow can be safely removed without compromising data integrity. I.e. if there is an existing job definition that still references this workflow, it must not be removed.

Parameters:
name - The name of the workflow to check
Throws:
PersistenceException - error reading job definition(s)
InvalidConfigException - error deleting definition due to dependency constraints

checkRemoveBucket

public void checkRemoveBucket(java.lang.String name)
                       throws InvalidConfigException,
                              PersistenceException
Check if the bucket can be safely removed without compromising data integrity. I.e. if there is an existing workflow definition that still references this bucket, it must not be removed.

Parameters:
name - The name of the bucket to check
Throws:
PersistenceException - error reading workflow definition(s)
InvalidConfigException - error deleting definition due to dependency constraints

checkJobRemove

public void checkJobRemove(java.lang.String jobName)
                    throws JobManagerException
Checks if the job can be removed.

Parameters:
jobName - The name of the job to be removed.
Throws:
JobManagerException - Some error occurred while checking if job is currently running.

SMILA (incubation) API documentation