org.globus.cog.abstraction.impl.common.taskgraph
Class TaskGraphImpl

java.lang.Object
  extended byorg.globus.cog.abstraction.impl.common.taskgraph.TaskGraphImpl
All Implemented Interfaces:
ExecutableObject, TaskGraph
Direct Known Subclasses:
QueueImpl, SetImpl

public class TaskGraphImpl
extends Object
implements TaskGraph


Field Summary
 
Fields inherited from interface org.globus.cog.abstraction.interfaces.TaskGraph
AbortOnFailure, ContinueOnFailure
 
Fields inherited from interface org.globus.cog.abstraction.interfaces.ExecutableObject
TASK, TASKGRAPH
 
Constructor Summary
TaskGraphImpl()
           
TaskGraphImpl(Identity id)
           
 
Method Summary
 void add(ExecutableObject node)
          Adds the ExecutableObject(Task or TaskGraph) to this TaskGraph.
 void addChangeListener(ChangeListener listener)
          Adds the listener to receive graph change events produced by this TaskGraph.
 void addDependency(ExecutableObject from, ExecutableObject to)
          Adds a single dependency between the given nodes.
 void addStatusListener(StatusListener listener)
          Adds a listener to receive status events when the status of an ExecutableObject is changed.
 boolean contains(Identity id)
          Returns a boolean indicating whether this TaskGraph contains a node with the given Identity
 Enumeration elements()
          Returns all the ExecutableObject(s) that is encapsulated by this TaskGraph.
 boolean equals(Object object)
           
 ExecutableObject get(Identity id)
          Returns the ExecutableObjectthat is represented by the given identity.
 int getActiveCount()
          Returns the number of ExecutableObjects that have their status as Status.ACTIVE
 Enumeration getAllAttributes()
           
 Object getAttribute(String name)
           
 int getCanceledCount()
          Returns the number of ExecutableObjects that have their status as Status.CANCELED
 int getCompletedCount()
          Returns the number of ExecutableObjects that have their status as Status.COMPLETED
 Calendar getCompletedTime()
          Returns the time when this TaskGraph was completed
 Dependency getDependency()
          Returns the dependency object associated with this TaskGraph.
 int getFailedCount()
          Returns the number of ExecutableObjects that have their status as Status.FAILED
 int getFailureHandlingPolicy()
          Returns the failure handling policy of this TaskGraph.
 Identity getIdentity()
          Returns the unique Identity assigned to this ExecutableObject.
 String getName()
          Returns the user-friendly name assigned to this ExecutableObject.
 int getObjectType()
          Returns the type of this ExecutableObject.
 int getResumedCount()
          Returns the number of ExecutableObjects that have their status as Status.RESUMED
 int getSize()
          Returns the total number of ExecutableObjectencapsulated by this TaskGraph
 Status getStatus()
          Returns the current Status of this ExecutableObject.
 int getSubmittedCount()
          Returns the number of ExecutableObjects that have their status as Status.SUBMITTED
 Calendar getSubmittedTime()
          Returns the time when this TaskGraph was submitted
 int getSuspendedCount()
          Returns the number of ExecutableObjects that have their status as Status.SUSPENDED
 int getUnsubmittedCount()
          Returns the number of ExecutableObjects that have their status as Status.UNSUBMITTED
 int hashCode()
           
 boolean isEmpty()
          Returns a boolean indicating whether this TaskGraph contains any node
 ExecutableObject remove(Identity id)
          Removes the ExecutableObjectthat is represented by the given identity.
 void removeChangeListener(ChangeListener listener)
          Removes the change listener for this TaskGraph.
 boolean removeDependency(ExecutableObject from, ExecutableObject to)
          Removes the dependency between the given nodes.
 void removeStatusListener(StatusListener listener)
          Removes the status listener from the list of active listeners.
 void setAttribute(String name, Object value)
           
 void setDependency(Dependency dependency)
          Sets all the dependencies associated with this TaskGraph.
 void setFailureHandlingPolicy(int policy)
          Sets the policy adopted by this TaskGraph when any Task fails.
 void setIdentity(Identity id)
          Sets a unique Identity for this ExecutableObject.
 void setName(String name)
          Sets the name of this ExecutableObject.
 void setStatus(int status)
          Sets the current status of this ExecutableObject.
 void setStatus(Status status)
          Sets the current Status of this ExecutableObject.
 ExecutableObject[] toArray()
          Returns all the ExecutableObject(s) that is encapsulated by this TaskGraph.
 void toXML(File file)
          Checkpoints the current state of this TaskGraph in XML format.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskGraphImpl

public TaskGraphImpl()

TaskGraphImpl

public TaskGraphImpl(Identity id)
Method Detail

setIdentity

public void setIdentity(Identity id)
Description copied from interface: ExecutableObject
Sets a unique Identity for this ExecutableObject.

Specified by:
setIdentity in interface ExecutableObject
Parameters:
id - the unique Identity.

getIdentity

public Identity getIdentity()
Description copied from interface: ExecutableObject
Returns the unique Identity assigned to this ExecutableObject.

Specified by:
getIdentity in interface ExecutableObject

setName

public void setName(String name)
Description copied from interface: ExecutableObject
Sets the name of this ExecutableObject. Defines a user-friendly name which need not be unique.

Specified by:
setName in interface ExecutableObject
Parameters:
name - a string specifying the name of this ExecutableObject.

getName

public String getName()
Description copied from interface: ExecutableObject
Returns the user-friendly name assigned to this ExecutableObject.

Specified by:
getName in interface ExecutableObject

getObjectType

public int getObjectType()
Description copied from interface: ExecutableObject
Returns the type of this ExecutableObject. Currently, two types are supported: Taskand TaskGraph. Additional types can be supported by classes implementing this interface.

Specified by:
getObjectType in interface ExecutableObject

add

public void add(ExecutableObject node)
         throws Exception
Description copied from interface: TaskGraph
Adds the ExecutableObject(Task or TaskGraph) to this TaskGraph. By default the added node is an unconnected node without dependencies on any of the existing nodes in this TaskGraph.

Specified by:
add in interface TaskGraph
Parameters:
node - an ExecutableObjectto be added as a node
Throws:
Exception

remove

public ExecutableObject remove(Identity id)
Description copied from interface: TaskGraph
Removes the ExecutableObjectthat is represented by the given identity.

Specified by:
remove in interface TaskGraph
Parameters:
id - the identity of the node to be removed
Returns:
the removed ExecutableObject

get

public ExecutableObject get(Identity id)
Description copied from interface: TaskGraph
Returns the ExecutableObjectthat is represented by the given identity.

Specified by:
get in interface TaskGraph
Parameters:
id - the identity of the node to be returned
Returns:
the ExecutableObjectrepresented by the given Identity

toArray

public ExecutableObject[] toArray()
Description copied from interface: TaskGraph
Returns all the ExecutableObject(s) that is encapsulated by this TaskGraph.

Specified by:
toArray in interface TaskGraph
Returns:
the array containing all the nodes of this TaskGraph

elements

public Enumeration elements()
Description copied from interface: TaskGraph
Returns all the ExecutableObject(s) that is encapsulated by this TaskGraph.

Specified by:
elements in interface TaskGraph
Returns:
the enumeration containing all the nodes of this TaskGraph

setDependency

public void setDependency(Dependency dependency)
Description copied from interface: TaskGraph
Sets all the dependencies associated with this TaskGraph.

Specified by:
setDependency in interface TaskGraph

getDependency

public Dependency getDependency()
Description copied from interface: TaskGraph
Returns the dependency object associated with this TaskGraph.

Specified by:
getDependency in interface TaskGraph

addDependency

public void addDependency(ExecutableObject from,
                          ExecutableObject to)
Description copied from interface: TaskGraph
Adds a single dependency between the given nodes.

Specified by:
addDependency in interface TaskGraph
Parameters:
from - the ExecutableObjectrepresenting the parent node
to - the ExecutableObjectrepresenting the child node

removeDependency

public boolean removeDependency(ExecutableObject from,
                                ExecutableObject to)
Description copied from interface: TaskGraph
Removes the dependency between the given nodes.

Specified by:
removeDependency in interface TaskGraph
Parameters:
from - the ExecutableObjectrepresenting the parent node
to - the ExecutableObjectrepresenting the child node

setStatus

public void setStatus(Status status)
Description copied from interface: ExecutableObject
Sets the current Status of this ExecutableObject.

Specified by:
setStatus in interface ExecutableObject
Parameters:
status - the latest status of this ExecutableObject.

setStatus

public void setStatus(int status)
Description copied from interface: ExecutableObject
Sets the current status of this ExecutableObject. Supported status are: Status.UNSUBMITTED, Status.SUBMITTED, Status.ACTIVE, Status.SUSPENDED,Status.RESUMED,Status.FAILED, Status.CANCELED,Status.COMPLETED, Status.UNKNOWN

Specified by:
setStatus in interface ExecutableObject

getStatus

public Status getStatus()
Description copied from interface: ExecutableObject
Returns the current Status of this ExecutableObject.

Specified by:
getStatus in interface ExecutableObject

getSize

public int getSize()
Description copied from interface: TaskGraph
Returns the total number of ExecutableObjectencapsulated by this TaskGraph

Specified by:
getSize in interface TaskGraph

setAttribute

public void setAttribute(String name,
                         Object value)
Specified by:
setAttribute in interface TaskGraph

getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface TaskGraph

getAllAttributes

public Enumeration getAllAttributes()
Specified by:
getAllAttributes in interface TaskGraph

addStatusListener

public void addStatusListener(StatusListener listener)
Description copied from interface: ExecutableObject
Adds a listener to receive status events when the status of an ExecutableObject is changed.

Specified by:
addStatusListener in interface ExecutableObject
Parameters:
listener - the status listener

removeStatusListener

public void removeStatusListener(StatusListener listener)
Description copied from interface: ExecutableObject
Removes the status listener from the list of active listeners.

Specified by:
removeStatusListener in interface ExecutableObject

contains

public boolean contains(Identity id)
Description copied from interface: TaskGraph
Returns a boolean indicating whether this TaskGraph contains a node with the given Identity

Specified by:
contains in interface TaskGraph
Parameters:
id - the Identity of the desired node

isEmpty

public boolean isEmpty()
Description copied from interface: TaskGraph
Returns a boolean indicating whether this TaskGraph contains any node

Specified by:
isEmpty in interface TaskGraph

getUnsubmittedCount

public int getUnsubmittedCount()
Description copied from interface: TaskGraph
Returns the number of ExecutableObjects that have their status as Status.UNSUBMITTED

Specified by:
getUnsubmittedCount in interface TaskGraph

getSubmittedCount

public int getSubmittedCount()
Description copied from interface: TaskGraph
Returns the number of ExecutableObjects that have their status as Status.SUBMITTED

Specified by:
getSubmittedCount in interface TaskGraph

getActiveCount

public int getActiveCount()
Description copied from interface: TaskGraph
Returns the number of ExecutableObjects that have their status as Status.ACTIVE

Specified by:
getActiveCount in interface TaskGraph

getCompletedCount

public int getCompletedCount()
Description copied from interface: TaskGraph
Returns the number of ExecutableObjects that have their status as Status.COMPLETED

Specified by:
getCompletedCount in interface TaskGraph

getSuspendedCount

public int getSuspendedCount()
Description copied from interface: TaskGraph
Returns the number of ExecutableObjects that have their status as Status.SUSPENDED

Specified by:
getSuspendedCount in interface TaskGraph

getResumedCount

public int getResumedCount()
Description copied from interface: TaskGraph
Returns the number of ExecutableObjects that have their status as Status.RESUMED

Specified by:
getResumedCount in interface TaskGraph

getFailedCount

public int getFailedCount()
Description copied from interface: TaskGraph
Returns the number of ExecutableObjects that have their status as Status.FAILED

Specified by:
getFailedCount in interface TaskGraph

getCanceledCount

public int getCanceledCount()
Description copied from interface: TaskGraph
Returns the number of ExecutableObjects that have their status as Status.CANCELED

Specified by:
getCanceledCount in interface TaskGraph

toXML

public void toXML(File file)
           throws MarshalException
Description copied from interface: TaskGraph
Checkpoints the current state of this TaskGraph in XML format. Using the TaskGraphUnmarshaller, the checkpointed TaskGraph can once again be re-instantiated.

Specified by:
toXML in interface TaskGraph
Parameters:
file - the file to store the checkpointed task graph.
Throws:
MarshalException - during an error in XML translation.

getSubmittedTime

public Calendar getSubmittedTime()
Description copied from interface: TaskGraph
Returns the time when this TaskGraph was submitted

Specified by:
getSubmittedTime in interface TaskGraph
Returns:
the TaskGraph submission time. null, if it is not yet submitted

getCompletedTime

public Calendar getCompletedTime()
Description copied from interface: TaskGraph
Returns the time when this TaskGraph was completed

Specified by:
getCompletedTime in interface TaskGraph
Returns:
the TaskGraph completion time. null, if it is not yet completed

setFailureHandlingPolicy

public void setFailureHandlingPolicy(int policy)
Description copied from interface: TaskGraph
Sets the policy adopted by this TaskGraph when any Task fails. This policy determines the execution behaviour of the nodes dependent on the failed nodes.

For example, if the policy is TaskGraph.AbortOnFailure, then dependents of a failed ExecutableObject are not executed at all. On the other hand, if the policy is TaskGraph.ContinueOnFailure, then the dependents are executed irrespective to the final status of the parents.

Specified by:
setFailureHandlingPolicy in interface TaskGraph

getFailureHandlingPolicy

public int getFailureHandlingPolicy()
Description copied from interface: TaskGraph
Returns the failure handling policy of this TaskGraph.

Specified by:
getFailureHandlingPolicy in interface TaskGraph

addChangeListener

public void addChangeListener(ChangeListener listener)
Description copied from interface: TaskGraph
Adds the listener to receive graph change events produced by this TaskGraph. Change events are generated when an ExecutableObject is either added or removed from this TaskGraph.

Specified by:
addChangeListener in interface TaskGraph

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Description copied from interface: TaskGraph
Removes the change listener for this TaskGraph.

Specified by:
removeChangeListener in interface TaskGraph

equals

public boolean equals(Object object)

hashCode

public int hashCode()