org.globus.cog.abstraction.impl.common.task
Class TaskImpl

java.lang.Object
  extended byorg.globus.cog.abstraction.impl.common.task.TaskImpl
All Implemented Interfaces:
ExecutableObject, Task
Direct Known Subclasses:
FileOperationTask, FileTransferTask, JobSubmissionTask

public class TaskImpl
extends Object
implements Task


Field Summary
 
Fields inherited from interface org.globus.cog.abstraction.interfaces.Task
FILE_OPERATION, FILE_TRANSFER, INFORMATION_QUERY, JOB_SUBMISSION
 
Fields inherited from interface org.globus.cog.abstraction.interfaces.ExecutableObject
TASK, TASKGRAPH
 
Constructor Summary
TaskImpl()
           
TaskImpl(String name, int type)
           
 
Method Summary
 void addOutputListener(OutputListener listener)
          Adds a listener to recieve the output events associated with this Task.
 void addService(Service service)
          Adds the Serviceto the tail of the ordered list of services.
 void addStatusListener(StatusListener listener)
          Adds a listener to receive status events when the status of an ExecutableObject is changed.
 boolean equals(Object object)
           
 Enumeration getAllAttributes()
          Returns all the attribute names associated with this Task.
 Collection getAllServices()
          Returns all the services associated with this task.
 Object getAttribute(String name)
          Returns the value associated with the given attribute name.
 Calendar getCompletedTime()
          Returns the time when this Task was completed.
 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.
 String getProvider()
           
 int getRequiredServices()
          Returns the maximum number of services required for this task.
 Service getService(int index)
          Returns the Serviceat the given index of the ordered list of services
 Specification getSpecification()
          Returns the Specificationassociated with this Task.
 Status getStatus()
          Returns the current Status of this ExecutableObject.
 String getStdError()
          Returns the standard error of the remote task execution.
 String getStdOutput()
          Returns the standard output of the remote task execution.
 Calendar getSubmittedTime()
          Returns the time when this Task was submitted to the remote service.
 int getType()
          Retruns the type of this Task.
 int hashCode()
           
 boolean isActive()
          Returns a boolean indicating if the task is active.
 boolean isCanceled()
          Returns a boolean indicating if the task is canceled.
 boolean isCompleted()
          Returns a boolean indicating if the task is completed.
 boolean isFailed()
          Returns a boolean indicating if the task is failed.
 boolean isSuspended()
          Returns a boolean indicating if the task is suspended.
 boolean isUnsubmitted()
          Returns a boolean indicating if the task is unsubmitted.
 Collection removeAllServices()
          Removes all the services associated with this task.
 void removeOutputListener(OutputListener listener)
          Removes the output listener.
 void removeService(Collection collection)
          Removes all the services associated with this task that also belongs to the given Collection of services.
 Service removeService(int index)
          Removes the Servicefrom the given position in the ordered list of Grid services.
 void removeStatusListener(StatusListener listener)
          Removes the status listener from the list of active listeners.
 void setAttribute(String name, Object value)
          Sets an attribute for this Task.
 void setIdentity(Identity id)
          Sets a unique Identity for this ExecutableObject.
 void setName(String name)
          Sets the name of this ExecutableObject.
 void setProvider(String provider)
           
 void setRequiredService(int value)
          Sets the maximum number of services required for this task.
 void setService(int index, Service service)
          Sets one of the Servicerequired to execute this task.
 void setSpecification(Specification specification)
          Sets the Specificationdescribing the execution parameters of this Task.
 void setStatus(int status)
          Sets the current status of this ExecutableObject.
 void setStatus(Status status)
          Sets the current Status of this ExecutableObject.
 void setStdError(String error)
          Sets the standard error produced by this Task.
 void setStdOutput(String output)
          Sets the standard output produced by this Task.
 void setType(int type)
          Sets the type of this Task.
 String toString()
           
 void toXML(File file)
          Checkpoints the current state of this Task in XML format.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaskImpl

public TaskImpl()

TaskImpl

public TaskImpl(String name,
                int type)
Method Detail

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

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

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

setType

public void setType(int type)
Description copied from interface: Task
Sets the type of this Task. Supported task types include: JOB_SUBMISSION,FILE_TRANSFER, and FILE_OPERATION.

Specified by:
setType in interface Task
Parameters:
type - the type of this Task.

getType

public int getType()
Description copied from interface: Task
Retruns the type of this Task.

Specified by:
getType in interface Task

setProvider

public void setProvider(String provider)
Specified by:
setProvider in interface Task

getProvider

public String getProvider()
Specified by:
getProvider in interface Task

setService

public void setService(int index,
                       Service service)
Description copied from interface: Task
Sets one of the Servicerequired to execute this task. The index at which this service is inserted determines its semantic role in the execution of the task. A task can require more than one service for execution. Thus, services are an ordered list.

Specified by:
setService in interface Task
Parameters:
index - the index representing the position of the service in the ordered list.
service - the remote Grid service.

addService

public void addService(Service service)
Description copied from interface: Task
Adds the Serviceto the tail of the ordered list of services.

Specified by:
addService in interface Task
Parameters:
service - the remote Grid service

removeService

public Service removeService(int index)
Description copied from interface: Task
Removes the Servicefrom the given position in the ordered list of Grid services.

Specified by:
removeService in interface Task
Parameters:
index - the index representing the position of the service in the ordered list.
Returns:
the remote Grid service.

getService

public Service getService(int index)
Description copied from interface: Task
Returns the Serviceat the given index of the ordered list of services

Specified by:
getService in interface Task
Parameters:
index - the index representing the position of the service in the ordered list.
Returns:
the remote Grid service.

removeAllServices

public Collection removeAllServices()
Description copied from interface: Task
Removes all the services associated with this task.

Specified by:
removeAllServices in interface Task
Returns:
a Collection of services

removeService

public void removeService(Collection collection)
Description copied from interface: Task
Removes all the services associated with this task that also belongs to the given Collection of services.

Specified by:
removeService in interface Task
Returns:
a Collection of services

getAllServices

public Collection getAllServices()
Description copied from interface: Task
Returns all the services associated with this task.

Specified by:
getAllServices in interface Task
Returns:
a Collection of services

setRequiredService

public void setRequiredService(int value)
Description copied from interface: Task
Sets the maximum number of services required for this task. For example, the JOB_SUBMISSION task requires a maximum of 1 service by default, where as the FILE_TRANSFER task requires a maximum of 2 services by default.

Specified by:
setRequiredService in interface Task
Parameters:
value - the maximum number of services required

getRequiredServices

public int getRequiredServices()
Description copied from interface: Task
Returns the maximum number of services required for this task.

Specified by:
getRequiredServices in interface Task
Returns:
number of services

setSpecification

public void setSpecification(Specification specification)
Description copied from interface: Task
Sets the Specificationdescribing the execution parameters of this Task.

Specified by:
setSpecification in interface Task
Parameters:
specification - the execution specification associated with this Task.

getSpecification

public Specification getSpecification()
Description copied from interface: Task
Returns the Specificationassociated with this Task.

Specified by:
getSpecification in interface Task

setStdOutput

public void setStdOutput(String output)
Description copied from interface: Task
Sets the standard output produced by this Task. This method is used by the TaskHandlerto store the stdout of the remote task execution if it is redirected to the local machine.

Specified by:
setStdOutput in interface Task

getStdOutput

public String getStdOutput()
Description copied from interface: Task
Returns the standard output of the remote task execution.

Specified by:
getStdOutput in interface Task
Returns:
the standard out of the remote task execution. null if no output was produced on the remote stdOut.

setStdError

public void setStdError(String error)
Description copied from interface: Task
Sets the standard error produced by this Task. This method is used by the TaskHandlerto store the stderr of the remote task execution if it is redirected to the local machine.

Specified by:
setStdError in interface Task

getStdError

public String getStdError()
Description copied from interface: Task
Returns the standard error of the remote task execution.

Specified by:
getStdError in interface Task
Returns:
the standard error of the remote task execution. null if no error was produced on the remote stderr.

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

setAttribute

public void setAttribute(String name,
                         Object value)
Description copied from interface: Task
Sets an attribute for this Task. The interpretation of these attributes are TaskHandlerspecific and may not be utilized at all by some handlers.

Specified by:
setAttribute in interface Task
Parameters:
name - a string representing the name of the attribute value an object representing the value of this attribute

getAttribute

public Object getAttribute(String name)
Description copied from interface: Task
Returns the value associated with the given attribute name.

Specified by:
getAttribute in interface Task
Parameters:
name - the name of the desired attribute
Returns:
the value of the given attribute name. null if attribute not available

getAllAttributes

public Enumeration getAllAttributes()
Description copied from interface: Task
Returns all the attribute names associated with this Task.

Specified by:
getAllAttributes in interface Task
Returns:
an enumeration of all the attribute names. null if no attribute available

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

addOutputListener

public void addOutputListener(OutputListener listener)
Description copied from interface: Task
Adds a listener to recieve the output events associated with this Task. The listener reveives events related to the changes in the stdout of this Task.

Specified by:
addOutputListener in interface Task
Parameters:
listener - the output listener for this Task.

removeOutputListener

public void removeOutputListener(OutputListener listener)
Description copied from interface: Task
Removes the output listener.

Specified by:
removeOutputListener in interface Task

toXML

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

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

toString

public String toString()
Specified by:
toString in interface Task

isUnsubmitted

public boolean isUnsubmitted()
Description copied from interface: Task
Returns a boolean indicating if the task is unsubmitted.

Specified by:
isUnsubmitted in interface Task

isActive

public boolean isActive()
Description copied from interface: Task
Returns a boolean indicating if the task is active.

Specified by:
isActive in interface Task

isCompleted

public boolean isCompleted()
Description copied from interface: Task
Returns a boolean indicating if the task is completed.

Specified by:
isCompleted in interface Task

isSuspended

public boolean isSuspended()
Description copied from interface: Task
Returns a boolean indicating if the task is suspended.

Specified by:
isSuspended in interface Task

isFailed

public boolean isFailed()
Description copied from interface: Task
Returns a boolean indicating if the task is failed.

Specified by:
isFailed in interface Task

isCanceled

public boolean isCanceled()
Description copied from interface: Task
Returns a boolean indicating if the task is canceled.

Specified by:
isCanceled in interface Task

getSubmittedTime

public Calendar getSubmittedTime()
Description copied from interface: Task
Returns the time when this Task was submitted to the remote service.

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

getCompletedTime

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

Specified by:
getCompletedTime in interface Task
Returns:
the Task completion time. null, if this Task is not yet complete.

equals

public boolean equals(Object object)

hashCode

public int hashCode()