vgrid.server
Class FileSystemExecutingPlodderServer

java.lang.Object
  extended by vgrid.server.FileSystemExecutingPlodderServer
All Implemented Interfaces:
ExecutingPlodderServer
Direct Known Subclasses:
TestFileServerEmpty

public class FileSystemExecutingPlodderServer
extends java.lang.Object
implements ExecutingPlodderServer

Implementation of the server interface, using the local filesystem to manage the tasks.


Field Summary
protected  java.io.File errorDir
           
protected  java.io.File finishedDir
           
protected  java.io.File libDir
           
protected  java.io.File requestedDir
           
static java.lang.String TASK_FILE_EXTENSION
           
protected  java.io.File unfinishedDir
           
 
Constructor Summary
FileSystemExecutingPlodderServer(java.io.File baseDir, int nullTaskTimeout)
          Creates an instance of the server.
 
Method Summary
 void clear()
          Removes all tasks and libraries from the server.
 void deleteLibrary(java.lang.String name)
          Deletes a library from the server.
 void deleteTask(java.lang.String id)
          Deletes a task from the server.
 java.lang.String getConfiguration()
          Returns a html string describing the server.
 java.util.Collection getLibraryNames()
          Returns a list of the names of the files located in the libraries directory.
 java.util.Collection getLibraryUrls()
          Returns a collection of urls (java.net.URL) which describe the urls in that contain the code for the currently avaylable tasks.
 java.lang.String getNextId()
          Returns a unique ID to be used as Job- or Taskid.
 java.lang.String getState()
          A string describing the state of the server.
 java.io.InputStream getTask(java.lang.String id)
          Returns a task by id.
 java.util.Collection getTaskIds(TaskState state)
          Returns a collection of strings containing the task-ids beeing in a given state on the server.
 java.io.InputStream getUnfinishedTask()
          Returns a task out of the unfinished tasks directory.
 java.lang.String getVersion()
          Returns the version of the server.
 void setErrorTask(java.io.InputStream in)
          Receives an error task from a client.
 void setFinishedTask(java.io.InputStream in)
          Receives a finished task from a client.
 void setLibrary(java.lang.String name, java.io.InputStream in)
          Stores a library in the libraries directory.
 void setUnfinishedTask(java.io.InputStream in)
          Receives an unfinished task from a plodder or dispenser.
 java.lang.String toDescriptionString()
          Returns a string describing the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TASK_FILE_EXTENSION

public static final java.lang.String TASK_FILE_EXTENSION
See Also:
Constant Field Values

unfinishedDir

protected java.io.File unfinishedDir

finishedDir

protected java.io.File finishedDir

requestedDir

protected java.io.File requestedDir

errorDir

protected java.io.File errorDir

libDir

protected java.io.File libDir
Constructor Detail

FileSystemExecutingPlodderServer

public FileSystemExecutingPlodderServer(java.io.File baseDir,
                                        int nullTaskTimeout)
Creates an instance of the server.

Parameters:
baseDir - The base directory where to store all data.
nullTaskTimeout - The time (in ms) after which a NullTask will be finished (stop sleeping) and the client requests a new task.
Method Detail

getUnfinishedTask

public java.io.InputStream getUnfinishedTask()
                                      throws VgridException
Returns a task out of the unfinished tasks directory. If it is empty it returnes one out of the requested tasks directory.

Specified by:
getUnfinishedTask in interface ExecutingPlodderServer
Returns:
The task in serialized form.
Throws:
VgridException
See Also:
ExecutingPlodderServer.getUnfinishedTask()

getTask

public java.io.InputStream getTask(java.lang.String id)
                            throws VgridException
Returns a task by id. If no task with the specific id is found an InputStream containing no chars is returned.

Specified by:
getTask in interface ExecutingPlodderServer
Parameters:
id - The id of the task to be downloaded.
Returns:
The task in serialized form.
Throws:
VgridException

setFinishedTask

public void setFinishedTask(java.io.InputStream in)
                     throws VgridException
Receives a finished task from a client. Puts it into the finished tasks directory, from where it is no longer redistributed to other clients.

Specified by:
setFinishedTask in interface ExecutingPlodderServer
Parameters:
in - The task in serialized form.
Throws:
VgridException
See Also:
ExecutingPlodderServer.setFinishedTask(java.io.InputStream)

setErrorTask

public void setErrorTask(java.io.InputStream in)
                  throws VgridException
Receives an error task from a client. Puts it into the finished tasks directory, from where it is no longer redistributed to other clients.

Specified by:
setErrorTask in interface ExecutingPlodderServer
Parameters:
in - The task in serialized form.
Throws:
VgridException
See Also:
ExecutingPlodderServer.setErrorTask(java.io.InputStream)

getConfiguration

public java.lang.String getConfiguration()
Returns a html string describing the server. Is used in the server jsp.

Specified by:
getConfiguration in interface ExecutingPlodderServer
Returns:
The current configuration of the server..

toDescriptionString

public java.lang.String toDescriptionString()
Returns a string describing the server.


setUnfinishedTask

public void setUnfinishedTask(java.io.InputStream in)
Receives an unfinished task from a plodder or dispenser. Puts it into the unfinished tasks directory from where it is (re)distributed to (other) clients.

Specified by:
setUnfinishedTask in interface ExecutingPlodderServer
Parameters:
in - The task in serialized form.

getLibraryUrls

public java.util.Collection getLibraryUrls()
                                    throws VgridException
Returns a collection of urls (java.net.URL) which describe the urls in that contain the code for the currently avaylable tasks. The urls point to files on the local filesystem. file:/..

Specified by:
getLibraryUrls in interface ExecutingPlodderServer
Returns:
A collection of strings containing urls.
Throws:
VgridException

getLibraryNames

public java.util.Collection getLibraryNames()
Returns a list of the names of the files located in the libraries directory.

Specified by:
getLibraryNames in interface ExecutingPlodderServer
Returns:
Collection of java.net.URL.

setLibrary

public void setLibrary(java.lang.String name,
                       java.io.InputStream in)
                throws VgridException
Stores a library in the libraries directory.

Specified by:
setLibrary in interface ExecutingPlodderServer
Parameters:
name - The name of the library. E.g. mylib.jar, lib.jar, ... . The name must be unique. Therefore a prefix spezifying the vendor and the vendor project should be used.
in - A stream containing the library.
Throws:
VgridException

deleteTask

public void deleteTask(java.lang.String id)
                throws VgridException
Description copied from interface: ExecutingPlodderServer
Deletes a task from the server. This method should be used from the vendor to delete the finished tasks from the server.

Specified by:
deleteTask in interface ExecutingPlodderServer
Parameters:
id - The id of the task to be deleted.
Throws:
VgridException

getTaskIds

public java.util.Collection getTaskIds(TaskState state)
                                throws VgridException
Description copied from interface: ExecutingPlodderServer
Returns a collection of strings containing the task-ids beeing in a given state on the server. Should be used by the vendor to find out if his tasks are finished.

Specified by:
getTaskIds in interface ExecutingPlodderServer
Parameters:
state - The state what whos ids should be requested. Possible values: Server.TASK_STATE_UNFINISHED, Server.TASK_STATE_UNFINISHED, Server.TASK_STATE_REQUESTED, Server.TASK_STATE_ERROR, Server.TASK_STATE_ABSENT
Returns:
Collection of Strings.
Throws:
VgridException

deleteLibrary

public void deleteLibrary(java.lang.String name)
                   throws VgridException
Description copied from interface: ExecutingPlodderServer
Deletes a library from the server. Should be used by the vendor to delete libraries that are no longer needed because no mor tasks are deployed using it.

Specified by:
deleteLibrary in interface ExecutingPlodderServer
Parameters:
name - The name of the libray to be deleted.
Throws:
VgridException

getVersion

public java.lang.String getVersion()
Description copied from interface: ExecutingPlodderServer
Returns the version of the server.

Specified by:
getVersion in interface ExecutingPlodderServer

getNextId

public java.lang.String getNextId()
                           throws VgridException
Description copied from interface: ExecutingPlodderServer
Returns a unique ID to be used as Job- or Taskid.

Specified by:
getNextId in interface ExecutingPlodderServer
Throws:
VgridException

clear

public void clear()
Description copied from interface: ExecutingPlodderServer
Removes all tasks and libraries from the server.

Specified by:
clear in interface ExecutingPlodderServer

getState

public java.lang.String getState()
Description copied from interface: ExecutingPlodderServer
A string describing the state of the server.

Specified by:
getState in interface ExecutingPlodderServer


vgrid the vienna grid project