WorkContext

From Web Computing Documentation
Jump to: navigation, search

class WorkContext implements Persistent

  • web2grid
    • web2grid.core
      • web2grid.core.work
        • web2grid.core.work.WorkContext

Class overview

A WorkContext object contains all required data of a WorkUnit including executable code, input data, execution status, checkpoint data and further information about the object itself. The object is handled by the WorkExecutor class.

Public functions

new ()

addFile (name : String, fs : FileStream)

name The name of the FileStream.
fs A FileStream containing the required data.

WorkUnits consist of executable code and input data. Input data is contained in FileStreams in the WorkContext. The WorkExecutor presents these files so that the executable code can read them by their name given in the first parameter.

The WorkContext contains streams that can be accessed from the WorkUnit code as well as through the WorkContext functions. You can see the role of streams in the Developing distributed applications in JavaScript section.

write (name : String, s : String)

name The name of the selected stream.
s A string to be added to the stream.

Appends the content of the FileStream selected by the name parameter. If such FileStream doesn't exist it will be created.

read (name : String) : String

name The name of the selected stream.

Returns the content of the FileStream selected by the name parameter. If such FileStream doesn't exist an empty String will be returned.

clear (name : String) : String

name The name of the selected stream.

Clears the content of the selected FileStream. If no such stream exists it creates one with empty content.

setCheckpoint (data : Dynamic)

data An object of arbitrary type.

Stores data as checkpoint data. It will be saved to the persistent storage at the next operate call.

getCheckpoint () : Dynamic

Returns the actual checkpoint data associated with the WorkContext object.

getCreatedDate () : Date

Returns a Date object containing the time of creation.

setProgress (progress : Float)

progress 0.0 corresponds to 0% while 1.0 corresponds to 100%.

Sets the progress of the WorkContext.

getProgress () : Float

Returns the progress of the WorkContext.

setProgram (program : FileStream)

program A FileStream object containing executable code.

Sets the executable code of the WorkContext.

setProgramCode (program : String)

program A String object containing the executable code.

Sets the executable code of the WorkContext.

getProgramCode () : String

Returns the executable program code.

getFileList () : Array<String>

Returns an Array<String> containing a list of filenames associated with the WorkContext. These names are the same that you can set in addFile's name patameter.

log (level : LogLevel, message : String, ?data : Dynamic, ?source : LogSource, ?pos : PosInfos)

level A String object containing the executable code.
message The log message.
data (optional) Object of any type.
source (optional) The source of the message.
pos (optional)

Used for logging purposes.

addWorktime (time : Float)

time The time elapsed since the last addition.

The function increments the private worktime variable by the given time in seconds.

getWorktime () : Float

Returns the total time spent working in seconds.

setExitStatus (status : Int)

status Exit status.

Sets the WorkContext's exit status. Using a value of 0 for successful completion and -1 for errors is customary.

getExitStatus (status : Int)

Returns the WorkContext's exit status.

isCompleted () : Bool

Returns whether the WorkContext has completed the job.

setCompleted ()

Sets the WorkContext's state. If set true further operate calls won't affect the WorkContext.

copyFrom (context : WorkContext)

context Another WorkContext object.

Copies all properties of another WorkContext object.

isChanged () : Bool

Returns true if either the inputs or the outputs of the WorkContext has changed since the last persistent save.

Implemented interface functions

hxSerialize (s : haxe.Serializer) from Persistent

hxUnserialize (s : haxe.Unserializer) from Persistent

Personal tools
Modules