org.globus.cog.abstraction.interfaces
Interface Task

All Superinterfaces:
ExecutableObject
All Known Implementing Classes:
TaskImpl

public interface Task
extends ExecutableObject

A Task is the atomic unit of execution in cog-core. It represents a generic Grid functionality including remote job execution, file transfer request, file access operation, or information query.

It is a container object encapsulating the identity, execution status, protocol provider, specification, security contextm service contact, stdout, stderror, submission-, and completion-time.


Field Summary
static int FILE_OPERATION
          Represents a file operation task
static int FILE_TRANSFER
          Represents a file transfer task between two file resources
static int INFORMATION_QUERY
          Represents an information query task.
static int JOB_SUBMISSION
          Represents a remote job submission task
 
Fields inherited from interface org.globus.cog.abstraction.interfaces.ExecutableObject
TASK, TASKGRAPH
 
Method Summary
 void addOutputListener(OutputListener listener)
          Adds a listener to recieve the output events associated with this Task.
 void addService(Service service)
          Adds the Service to the tail of the ordered list of services.
 Enumeration getAllAttributes()
           
 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.
 String getProvider()
          Deprecated. Use Service.setProvider(String)instead.
 int getRequiredServices()
          Returns the maximum number of services required for this task.
 Service getService(int index)
          Returns the service at the given index
 Specification getSpecification()
          Returns the execution specification associated with this Task.
 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.
 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 service from the given position in the ordered list of Grid services.
 void setAttribute(String name, Object value)
          Sets an attribute for this Task.
 void setProvider(String provider)
          Deprecated. Use Service.setProvider(String)instead.
 void setRequiredService(int value)
          Sets the maximum number of services required for this task.
 void setService(int index, Service service)
          Sets one of the Service required to execute this task at the given position.A task can require more than one service for execution.
 void setSpecification(Specification specification)
          Sets the specification describing the execution parameters of this Task.
 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 interface org.globus.cog.abstraction.interfaces.ExecutableObject
addStatusListener, getIdentity, getName, getObjectType, getStatus, removeStatusListener, setIdentity, setName, setStatus, setStatus
 

Field Detail

JOB_SUBMISSION

public static final int JOB_SUBMISSION
Represents a remote job submission task

See Also:
Constant Field Values

FILE_TRANSFER

public static final int FILE_TRANSFER
Represents a file transfer task between two file resources

See Also:
Constant Field Values

INFORMATION_QUERY

public static final int INFORMATION_QUERY
Represents an information query task. Not implemented at this time

See Also:
Constant Field Values

FILE_OPERATION

public static final int FILE_OPERATION
Represents a file operation task

See Also:
Constant Field Values
Method Detail

setType

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

Parameters:
type - the type of this Task.

getType

public int getType()
Retruns the type of this Task.


setProvider

public void setProvider(String provider)
Deprecated. Use Service.setProvider(String)instead.


getProvider

public String getProvider()
Deprecated. Use Service.setProvider(String)instead.


setService

public void setService(int index,
                       Service service)
Sets one of the Service required to execute this task at the given position.A task can require more than one service for execution. Thus, services are an ordered list.

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)
Adds the Service to the tail of the ordered list of services.

Parameters:
service - the remote Grid service

removeService

public Service removeService(int index)
Removes the service from the given position in the ordered list of Grid services.

Parameters:
index - the index representing the position of the service in the ordered list.
Returns:
the remote Grid service.

removeAllServices

public Collection removeAllServices()
Removes all the services associated with this task.

Returns:
a Collection of services

removeService

public void removeService(Collection collection)
Removes all the services associated with this task that also belongs to the given Collection of services.

Returns:
a Collection of services

getService

public Service getService(int index)
Returns the service at the given index

Parameters:
index - the index representing the position of the service in the ordered list.
Returns:
the remote Grid service.

getAllServices

public Collection getAllServices()
Returns all the services associated with this task.

Returns:
a Collection of services

setRequiredService

public void setRequiredService(int value)
Sets the maximum number of services required for this task. For example, the JOB_SUBMISSION task requires a maximum of 1 service, where as the FILE_TRANSFER task requires a maximum of 2 services.

Parameters:
value - the maximum number of services required

getRequiredServices

public int getRequiredServices()
Returns the maximum number of services required for this task.

Returns:
number of services

setSpecification

public void setSpecification(Specification specification)
Sets the specification describing the execution parameters of this Task.

Parameters:
specification - the execution specification associated with this Task.

getSpecification

public Specification getSpecification()
Returns the execution specification associated with this Task.


setStdOutput

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


getStdOutput

public String getStdOutput()
Returns the standard output of the remote task execution.

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)
Sets the standard error produced by this Task. This method is used by the TaskHandler to store the stderr of the remote task execution if it is redirected to the local machine.


getStdError

public String getStdError()
Returns the standard error of the remote task execution.

Returns:
the standard error of the remote task execution. null if no error was produced on the remote stderr.

setAttribute

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

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)
Returns the value associated with the given attribute name.

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()

addOutputListener

public void addOutputListener(OutputListener listener)
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.

Parameters:
listener - the output listener for this Task.

removeOutputListener

public void removeOutputListener(OutputListener listener)
Removes the output listener.


toXML

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

Parameters:
file - the file to store the checkpointed task.
Throws:
MarshalException - during an error in XML translation.

toString

public String toString()

isUnsubmitted

public boolean isUnsubmitted()
Returns a boolean indicating if the task is unsubmitted.


isActive

public boolean isActive()
Returns a boolean indicating if the task is active.


isCompleted

public boolean isCompleted()
Returns a boolean indicating if the task is completed.


isSuspended

public boolean isSuspended()
Returns a boolean indicating if the task is suspended.


isFailed

public boolean isFailed()
Returns a boolean indicating if the task is failed.


isCanceled

public boolean isCanceled()
Returns a boolean indicating if the task is canceled.


getSubmittedTime

public Calendar getSubmittedTime()
Returns the time when this Task was submitted to the remote service.

Returns:
the Task submission time. null, if this Task is not yet submitted

getCompletedTime

public Calendar getCompletedTime()
Returns the time when this Task was completed.

Returns:
the Task completion time. null, if this Task is not yet complete.