net.kwfgrid.gwes
Class GWorkflowDLHandler

java.lang.Object
  extended by java.lang.Thread
      extended by net.kwfgrid.gwes.GenericWorkflowHandler
          extended by net.kwfgrid.gwes.GWorkflowDLHandler
All Implemented Interfaces:
Runnable

public class GWorkflowDLHandler
extends GenericWorkflowHandler

The GWorkflowDLHandler is the dynamic and interactive workflow enactment machine for workflows described with the Generic Workflow Description Language (GWorkflowDL).

Version:
$Id: GWorkflowDLHandler.java 1540 2011-08-17 13:30:37Z hoheisel $
Author:
Andreas Hoheisel (www.andreas-hoheisel.de), Dietmar Sommerfeld / GWDG (weight and rank part)

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static int FAULT_MANAGEMENT_ABORT_ON_ACTIVITY_TERMINATED
          Abort the whole workflow if a single activity terminates (0).
static int FAULT_MANAGEMENT_CONTINUE_ON_ACTIVITY_TERMINATED
          Continue to execute the workflow, even if one or more activities terminate (1).
static int FAULT_MANAGEMENT_SUSPEND_ON_ACTIVITY_TERMINATED
          Suspend the workflow if an activity terminates (2).
static int WORKFLOW_PERSISTENCE_FALSE
          Do not store workflows in database automatically (0).
static int WORKFLOW_PERSISTENCE_TRUE
          Store workflows in database automatically (1).
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
GWorkflowDLHandler(GWESEngine engine, String originalWorkflowDescriptionType, String workflowDescription, String userIdCredential)
          Constructor.
 
Method Summary
 void abortWorkflow()
          Abort this workflow.
 void abortWorkflowAsync()
          Abort this workflow asynchonously.
 List<net.kwfgrid.gworkflowdl.structure.Transition> getConflictTransitions()
           
 CredentialManager getCredentialManager(Activity activity)
           
 Map<String,net.kwfgrid.gworkflowdl.analysis.Decision> getCurrentDecisions()
           
 String[] getData(String placeID)
          Get specific data that is hold inside the workflow and that is referenced by a data place identifier.
 String getDescription()
          Get the human-readable description of the workflow.
 net.kwfgrid.gworkflowdl.structure.Workflow getWorkflow()
          get the workflow.
 String getWorkflowDescription()
          Get the current workflow description of this workflow.
 void incrementCompletedActivities(int completedActivities)
          Overrides method of GenericWorkflowHandler and writes property to workflow document
 void incrementTerminatedActivities(int terminatedActivities)
          Overrides method of GenericWorkflowHandler and writes property to workflow document
 void initiateWorkflow()
          K-Wf Grid specific implementation of GenericWorkflowHandler.initiateWorkflow()
protected  void logStatistics()
          Overrides method of GenericWorkflowHandler in order to include statistics in the workflow description files as well.
 void resumeWorkflow()
          Resume this workflow.
 void run()
          ************************************************************************************************************* This is the run method of the Thread, invoked by start().
 void setDescription(String description)
          Set the human-readable description of the workflow.
 void setFaultManagementPolicy(int faultManagementPolicy)
          Set the policy for the fault management.
protected  void setStatus(int status)
          Set status of the workflow and notify threads that wait for a status change.
 void setWorkflowDescription(String workflowDescription)
          Set the current workflow description of this workflow.
 void setWorkflowPersistence(int workflowPersistence)
          Set the policy for the workflow persistence.
 void setWorkflowPersistence(String workflowPersistence)
          Set the policy for the workflow persistence.
 void startWorkflow()
          K-Wf Grid specific implementation of GenericWorkflowHandler.startWorkflow().
 String storeWorkflow()
          Stores this workflow.
 void suspendWorkflow()
          Suspend this workflow.
 void suspendWorkflowAsync()
          Suspend this workflow asynchonously.
 void workflowErrorAndAbort(String error)
           
 void workflowErrorAndAbort(String error, Throwable e)
           
 void workflowWarn(String warning)
           
 void workflowWarnAndSuspend(String warning)
           
 
Methods inherited from class net.kwfgrid.gwes.GenericWorkflowHandler
createNewErrorID, getActivityTable, getBirthday, getCompletedActivities, getDurationActive, getDurationInitiated, getDurationRunning, getDurationSuspended, getDurationTotal, getDurationUndefined, getEndTime, getEngine, getGlog, getID, getNewActivityID, getOriginalWorkflowDescriptionType, getStatus, getStatusAsString, getTerminatedActivities, getUserID, getWorkflowStatus, newID, waitForStatusChangeFrom, waitForStatusChangeTo, waitForStatusChangeToCompletedOrTerminated
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FAULT_MANAGEMENT_ABORT_ON_ACTIVITY_TERMINATED

public static final int FAULT_MANAGEMENT_ABORT_ON_ACTIVITY_TERMINATED
Abort the whole workflow if a single activity terminates (0).

See Also:
Constant Field Values

FAULT_MANAGEMENT_CONTINUE_ON_ACTIVITY_TERMINATED

public static final int FAULT_MANAGEMENT_CONTINUE_ON_ACTIVITY_TERMINATED
Continue to execute the workflow, even if one or more activities terminate (1).

See Also:
Constant Field Values

FAULT_MANAGEMENT_SUSPEND_ON_ACTIVITY_TERMINATED

public static final int FAULT_MANAGEMENT_SUSPEND_ON_ACTIVITY_TERMINATED
Suspend the workflow if an activity terminates (2).

See Also:
Constant Field Values

WORKFLOW_PERSISTENCE_FALSE

public static final int WORKFLOW_PERSISTENCE_FALSE
Do not store workflows in database automatically (0).

See Also:
Constant Field Values

WORKFLOW_PERSISTENCE_TRUE

public static final int WORKFLOW_PERSISTENCE_TRUE
Store workflows in database automatically (1).

See Also:
Constant Field Values
Constructor Detail

GWorkflowDLHandler

public GWorkflowDLHandler(GWESEngine engine,
                          String originalWorkflowDescriptionType,
                          String workflowDescription,
                          String userIdCredential)
                   throws WorkflowSecurityException,
                          LoggingException
Constructor.

Parameters:
engine - The parent GWES Engine
originalWorkflowDescriptionType - The original type of workflow description, e.g., "GWorkflowDL version 2.0"
workflowDescription - The workflow description in GWorkflowDL format
userIdCredential - user identifier
Throws:
WorkflowSecurityException
LoggingException
Method Detail

initiateWorkflow

public void initiateWorkflow()
                      throws net.kwfgrid.gworkflowdl.structure.WorkflowFormatException,
                             StateTransitionException
K-Wf Grid specific implementation of GenericWorkflowHandler.initiateWorkflow()

Specified by:
initiateWorkflow in class GenericWorkflowHandler
Throws:
net.kwfgrid.gworkflowdl.structure.WorkflowFormatException
StateTransitionException

startWorkflow

public void startWorkflow()
                   throws StateTransitionException
K-Wf Grid specific implementation of GenericWorkflowHandler.startWorkflow(). Calls Thread.start().

Specified by:
startWorkflow in class GenericWorkflowHandler
Throws:
StateTransitionException

suspendWorkflow

public void suspendWorkflow()
                     throws StateTransitionException
Description copied from class: GenericWorkflowHandler
Suspend this workflow. Waits until status switches to SUSPENDED. Implement this method in all derived classes!

Specified by:
suspendWorkflow in class GenericWorkflowHandler
Throws:
StateTransitionException

suspendWorkflowAsync

public void suspendWorkflowAsync()
                          throws StateTransitionException
Description copied from class: GenericWorkflowHandler
Suspend this workflow asynchonously. This method does not wait until workflow switches to SUSPENDED. Implement this method in all derived classes!

Specified by:
suspendWorkflowAsync in class GenericWorkflowHandler
Throws:
StateTransitionException

resumeWorkflow

public void resumeWorkflow()
                    throws StateTransitionException
Description copied from class: GenericWorkflowHandler
Resume this workflow. Status should switch to RUNNING. Implement this method in all derived classes!

Specified by:
resumeWorkflow in class GenericWorkflowHandler
Throws:
StateTransitionException

abortWorkflow

public void abortWorkflow()
                   throws StateTransitionException
Description copied from class: GenericWorkflowHandler
Abort this workflow. Waits until status switches to TERMINATED. Implement this method in all derived classes!

Specified by:
abortWorkflow in class GenericWorkflowHandler
Throws:
StateTransitionException

abortWorkflowAsync

public void abortWorkflowAsync()
                        throws StateTransitionException
Description copied from class: GenericWorkflowHandler
Abort this workflow asynchonously. This method does not wait until status switches to TERMINATED. Implement this method in all derived classes!

Specified by:
abortWorkflowAsync in class GenericWorkflowHandler
Throws:
StateTransitionException

storeWorkflow

public String storeWorkflow()
                     throws DatabaseException
Stores this workflow. Implement this method in all derived classes!

Specified by:
storeWorkflow in class GenericWorkflowHandler
Returns:
The location identifier of the storage location.
Throws:
DatabaseException

getData

public String[] getData(String placeID)
Get specific data that is hold inside the workflow and that is referenced by a data place identifier.

Specified by:
getData in class GenericWorkflowHandler
Parameters:
placeID - The place identifier that refers to the data
Returns:
The data as an array of Strings or null if place ID is not valid.

getDescription

public String getDescription()
Get the human-readable description of the workflow.

Specified by:
getDescription in class GenericWorkflowHandler
Returns:
A String containing the description.

setDescription

public void setDescription(String description)
Set the human-readable description of the workflow.

Specified by:
setDescription in class GenericWorkflowHandler
Parameters:
description - The description.

getWorkflowDescription

public String getWorkflowDescription()
Get the current workflow description of this workflow. If the workflow description changes during runtime, you should override this method by the concrete implementation.

Overrides:
getWorkflowDescription in class GenericWorkflowHandler
Returns:
The workflow description

setWorkflowDescription

public void setWorkflowDescription(String workflowDescription)
                            throws net.kwfgrid.gworkflowdl.structure.WorkflowFormatException,
                                   StateTransitionException
Set the current workflow description of this workflow.

Overrides:
setWorkflowDescription in class GenericWorkflowHandler
Parameters:
workflowDescription - The new workflow description.
Throws:
net.kwfgrid.gworkflowdl.structure.WorkflowFormatException - If the workflow format is wrong.
StateTransitionException - If status of workflow is in final status STATUS_COMPLETED or STATUS_TERMINATED.

setStatus

protected void setStatus(int status)
Set status of the workflow and notify threads that wait for a status change.

Overrides:
setStatus in class GenericWorkflowHandler
See Also:
WorkflowStatus.STATUS_UNDEFINED, WorkflowStatus.STATUS_INITIATED, WorkflowStatus.STATUS_RUNNING, WorkflowStatus.STATUS_SUSPENDED, WorkflowStatus.STATUS_ACTIVE, WorkflowStatus.STATUS_TERMINATED, WorkflowStatus.STATUS_COMPLETED, GenericWorkflowHandler.waitForStatusChangeTo(int), GenericWorkflowHandler.waitForStatusChangeFrom(int)

run

public void run()
************************************************************************************************************* This is the run method of the Thread, invoked by start(). In order to abort this thread set abort = true. **************************************************************************************************************

Specified by:
run in interface Runnable
Specified by:
run in class GenericWorkflowHandler

workflowErrorAndAbort

public void workflowErrorAndAbort(String error)

workflowErrorAndAbort

public void workflowErrorAndAbort(String error,
                                  Throwable e)

workflowWarn

public void workflowWarn(String warning)

workflowWarnAndSuspend

public void workflowWarnAndSuspend(String warning)

getWorkflow

public net.kwfgrid.gworkflowdl.structure.Workflow getWorkflow()
get the workflow.

Overrides:
getWorkflow in class GenericWorkflowHandler
Returns:
The workflow

getCurrentDecisions

public Map<String,net.kwfgrid.gworkflowdl.analysis.Decision> getCurrentDecisions()

getConflictTransitions

public List<net.kwfgrid.gworkflowdl.structure.Transition> getConflictTransitions()

getCredentialManager

public CredentialManager getCredentialManager(Activity activity)
                                       throws LoggingException,
                                              GSSException
Throws:
LoggingException
GSSException

setFaultManagementPolicy

public void setFaultManagementPolicy(int faultManagementPolicy)
Set the policy for the fault management.

Parameters:
faultManagementPolicy - The integer code of the fault management policy.
See Also:
FAULT_MANAGEMENT_ABORT_ON_ACTIVITY_TERMINATED, FAULT_MANAGEMENT_CONTINUE_ON_ACTIVITY_TERMINATED, FAULT_MANAGEMENT_SUSPEND_ON_ACTIVITY_TERMINATED

setWorkflowPersistence

public void setWorkflowPersistence(int workflowPersistence)
Set the policy for the workflow persistence.

Parameters:
workflowPersistence - The integer code of the workflow persistence policy.
See Also:
WORKFLOW_PERSISTENCE_FALSE, WORKFLOW_PERSISTENCE_TRUE

setWorkflowPersistence

public void setWorkflowPersistence(String workflowPersistence)
                            throws net.kwfgrid.gworkflowdl.structure.WorkflowFormatException
Set the policy for the workflow persistence.

Parameters:
workflowPersistence - The string of the workflow persistence policy.
Throws:
net.kwfgrid.gworkflowdl.structure.WorkflowFormatException

incrementTerminatedActivities

public void incrementTerminatedActivities(int terminatedActivities)
Overrides method of GenericWorkflowHandler and writes property to workflow document

Overrides:
incrementTerminatedActivities in class GenericWorkflowHandler
Parameters:
terminatedActivities -

incrementCompletedActivities

public void incrementCompletedActivities(int completedActivities)
Overrides method of GenericWorkflowHandler and writes property to workflow document

Overrides:
incrementCompletedActivities in class GenericWorkflowHandler

logStatistics

protected void logStatistics()
Overrides method of GenericWorkflowHandler in order to include statistics in the workflow description files as well.

Overrides:
logStatistics in class GenericWorkflowHandler


Copyright © 2005-2011 Fraunhofer FIRST. All Rights Reserved.