org.gridbus.broker.farming.common
Class GridbusFarmingEngine

java.lang.Object
  |
  +--org.gridbus.broker.farming.common.FarmingEngine
        |
        +--org.gridbus.broker.farming.common.GridbusFarmingEngine
Direct Known Subclasses:
State

public class GridbusFarmingEngine
extends FarmingEngine

This class is a place holder for the jobs and the server objects and is the main interface to applications that talk to the Broker.


Constructor Summary
GridbusFarmingEngine()
          Constructor - initializes GridbusFarmingEngine If the BrokerProperties are not set, then it sets it up by looking at the Broker.properties file If Broker.properties is not found, then default configuration properties are used.
 
Method Summary
 java.lang.String getAppDescriptionFile()
          Returns the name of the app-description file
 java.lang.String getBrokerID()
           
 float getBudget()
          Returns the budget for the jobs currently scheduled / being scheduled
 State getCurrentState()
          Returns the current state of the farming engine as a "State" object.
 java.util.Collection getDataFileList()
          Collection of Data Files
 java.util.Hashtable getDataHostTable()
          Collection of Data Hosts
 long getDeadline()
          Returns the deadline for the jobs currently scheduled / being scheduled
 long getJobCount(int status)
           
 java.util.Collection getJobs(int status)
          Gets all the jobs with the given status from the active-set.
 java.lang.String getLocalDirectory()
          Returns the local directory the broker, where the inputs and other job dependencies are found
 java.util.Collection getNextNJobs(int n)
           
 java.util.Collection getNextNJobs(int n, int status)
           
 java.lang.String getResourceDescriptionFile()
          Returns the name of the resource description file.
 Scheduler getScheduler()
           
 java.util.Date getStartDateStamp()
           
 java.lang.String getStats()
           
 java.lang.String getTempDirectory()
           
 long getTotalJobCount()
           
 java.lang.String getUsername()
           
 void init()
          This method performs initialisation tasks for the farming engine.
 void initJobs()
           
 void initResources()
           
 boolean isFeasible()
          Returns whether the current schedule is feasible or not, depending on the given budget,deadline constraints
 boolean isInputDataFilePresent()
          True / False based on whether the input data file is present
 boolean isSchedulingComplete()
           
 boolean isSchedulingFailed()
          Returns if the scheduler has failed due to some reason
 boolean isSchedulingFinished()
          Returns if all the jobs have been scheduled on the grid
 void schedule()
          Initialises the appropriate scheduler based on the broker properties, and starts the scheduler on a seperate thread
 void setAppDescriptionFile(java.lang.String filename)
          Sets the app-description task file name
 void setBudget(java.lang.String bud)
          Sets the budget for the current grid-application running on the broker
 void setDataFileList(java.util.Collection dataFileList)
           
 void setDataHostTable(java.util.Hashtable dataHostTable)
           
 void setDeadline(java.lang.String date)
          Sets the deadline for the current grid-application running on the broker
 void setFeasible(boolean b)
          Sets the feasibility of the broker schedule
 void setLocalDirectory(java.lang.String val)
          Sets the LocalDir variable within the Broker Properties.
 void setResourceDescriptionFile(java.lang.String s)
          Sets the resource description file
 void setScheduler(Scheduler scheduler)
           
 void setStartDateStamp(java.util.Date startDateStamp)
           
 void setTempDirectory(java.lang.String tempdir)
          Sets the broker's temporary directory to the specified path.
 void setUsername(java.lang.String username)
           
 void store()
          Saves the State to persistent storage using the specified Writer
 void storeJobs(java.util.Collection jobs)
          Saves the jobs collection to persistent store
 void storeServers(java.util.Collection servers)
          Saves the servers collection to persistent store
 boolean terminate()
          Terminates the execution by stopping all the running jobs
 void terminateJob(java.lang.String jobID)
          Terminates the job, whose identifier has been passed, if it is running
 
Methods inherited from class org.gridbus.broker.farming.common.FarmingEngine
addJob, addServer, getJobs, getServers, setJobs, setServers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridbusFarmingEngine

public GridbusFarmingEngine()
                     throws GridBrokerException
Constructor - initializes GridbusFarmingEngine If the BrokerProperties are not set, then it sets it up by looking at the Broker.properties file If Broker.properties is not found, then default configuration properties are used.

Throws:
GridBrokerException
Method Detail

setTempDirectory

public void setTempDirectory(java.lang.String tempdir)
                      throws GridBrokerException
Sets the broker's temporary directory to the specified path. It also re-configures the logger to start using this new location for the log files. Throws a GridBrokerException if the scheduler is already running.

Parameters:
tempdir -
Throws:
GridBrokerException

init

public void init()
          throws java.lang.Exception
This method performs initialisation tasks for the farming engine. This includes preparing jobs, probing servers and setting appropriate attributes for the jobs, servers and other internal data structures This method should be called only if using the application and resource description files. If using the broker via the API, please donot call this method, unless it is desired to setup the application/resources using files. The resources need to be set up *before* the application. This is because the discovery of datahosts etc., depend on the knowledge of services such as information catalogs.

Throws:
java.lang.Exception

initJobs

public void initJobs()
              throws GridBrokerException
Throws:
GridBrokerException

initResources

public void initResources()
                   throws GridBrokerException
Throws:
GridBrokerException

getResourceDescriptionFile

public java.lang.String getResourceDescriptionFile()
Returns the name of the resource description file.

Returns:

getAppDescriptionFile

public java.lang.String getAppDescriptionFile()
Returns the name of the app-description file

Returns:
app-description file name

setResourceDescriptionFile

public void setResourceDescriptionFile(java.lang.String s)
Sets the resource description file

Parameters:
s -

setAppDescriptionFile

public void setAppDescriptionFile(java.lang.String filename)
Sets the app-description task file name

Parameters:
filename - of type string representing the app-description task filename

isInputDataFilePresent

public boolean isInputDataFilePresent()
True / False based on whether the input data file is present

Returns:
True / False based on whether the input data file is present for the app-description task file the farming engine is operating on.

getDataFileList

public java.util.Collection getDataFileList()
Collection of Data Files

Returns:
data file collection object

getDataHostTable

public java.util.Hashtable getDataHostTable()
Collection of Data Hosts

Returns:
data host collection object

schedule

public void schedule()
              throws java.lang.Exception
Initialises the appropriate scheduler based on the broker properties, and starts the scheduler on a seperate thread

Throws:
java.lang.Exception

terminateJob

public void terminateJob(java.lang.String jobID)
                  throws java.lang.Exception
Terminates the job, whose identifier has been passed, if it is running

Parameters:
jobID -
Throws:
java.lang.Exception

terminate

public boolean terminate()
Terminates the execution by stopping all the running jobs

Returns:

getLocalDirectory

public java.lang.String getLocalDirectory()
                                   throws GridBrokerException
Returns the local directory the broker, where the inputs and other job dependencies are found

Returns:
property value for local directory
Throws:
GridBrokerException

setLocalDirectory

public void setLocalDirectory(java.lang.String val)
                       throws GridBrokerException
Sets the LocalDir variable within the Broker Properties. The LocalDir is used when there are >1 Brokers running within a VM. To distinguish between the inputs and outputs for each Broker, all the files belonging to a Broker can be put into a single LocalDir and specified here. The Broker will grab the files from LocalDir.

Parameters:
val -
Throws:
GridBrokerException

getTempDirectory

public java.lang.String getTempDirectory()
Returns:
temporary directory

getDeadline

public long getDeadline()
                 throws GridBrokerException
Returns the deadline for the jobs currently scheduled / being scheduled

Returns:
deadline
Throws:
GridBrokerException

setDeadline

public void setDeadline(java.lang.String date)
                 throws GridBrokerException
Sets the deadline for the current grid-application running on the broker

Parameters:
date - expressed in the format: dd MMM yyyy hh:mm:ss eg: 30 Dec 2010 11:34:40
Throws:
GridBrokerException

getBudget

public float getBudget()
                throws GridBrokerException
Returns the budget for the jobs currently scheduled / being scheduled

Returns:
budget
Throws:
GridBrokerException

setBudget

public void setBudget(java.lang.String bud)
               throws GridBrokerException
Sets the budget for the current grid-application running on the broker

Parameters:
bud -
Throws:
GridBrokerException

isFeasible

public boolean isFeasible()
Returns whether the current schedule is feasible or not, depending on the given budget,deadline constraints

Returns:
feasibility

setFeasible

public void setFeasible(boolean b)
Sets the feasibility of the broker schedule

Parameters:
b -

isSchedulingFinished

public boolean isSchedulingFinished()
Returns if all the jobs have been scheduled on the grid

Returns:
whether scheduling is finished

isSchedulingFailed

public boolean isSchedulingFailed()
Returns if the scheduler has failed due to some reason

Returns:
whether scheduling is finished

isSchedulingComplete

public boolean isSchedulingComplete()
Returns:
true if the scheduling is completed Scheduling is considered to be complete, if it is finished or failed. i.e Scheduling is complete if all the jobs that have been scheduled to the grid nodes, and have returned. This doesnt specify if the jobs have succeeded or not.

getScheduler

public Scheduler getScheduler()
Returns:
Returns the scheduler.

getStats

public java.lang.String getStats()
Returns:
a 2-D String array representing the stats as: status : # of jobs

setScheduler

public void setScheduler(Scheduler scheduler)
Parameters:
scheduler - The scheduler to set.

getUsername

public java.lang.String getUsername()
Returns:
Returns the username.

setUsername

public void setUsername(java.lang.String username)
Parameters:
username - The username to set.

getStartDateStamp

public java.util.Date getStartDateStamp()
Returns:
Returns the startDateStamp.

store

public void store()
Saves the State to persistent storage using the specified Writer


storeServers

public void storeServers(java.util.Collection servers)
Saves the servers collection to persistent store

Parameters:
servers -

storeJobs

public void storeJobs(java.util.Collection jobs)
Saves the jobs collection to persistent store

Parameters:
jobs -

getCurrentState

public State getCurrentState()
                      throws java.lang.Exception
Returns the current state of the farming engine as a "State" object.

Returns:
Throws:
java.lang.Exception

getBrokerID

public java.lang.String getBrokerID()
Returns:

setStartDateStamp

public void setStartDateStamp(java.util.Date startDateStamp)
Parameters:
startDateStamp - The startDateStamp to set.

setDataFileList

public void setDataFileList(java.util.Collection dataFileList)
Parameters:
dataFileList - The dataFileList to set.

setDataHostTable

public void setDataHostTable(java.util.Hashtable dataHostTable)
Parameters:
dataHostTable - The dataHostTable to set.

getNextNJobs

public java.util.Collection getNextNJobs(int n)
                                  throws GridBrokerException
Parameters:
n -
Returns:
Throws:
GridBrokerException - if the farming engine is not persistent (since ActiveSet cannot be initialized in that case)

getNextNJobs

public java.util.Collection getNextNJobs(int n,
                                         int status)
                                  throws GridBrokerException
Parameters:
n -
status -
Returns:
Throws:
GridBrokerException - if the farming engine is not persistent (since ActiveSet cannot be initialized in that case)

getJobCount

public long getJobCount(int status)
Parameters:
status -
Returns:

getTotalJobCount

public long getTotalJobCount()
Returns:
the total number of jobs

getJobs

public java.util.Collection getJobs(int status)
Gets all the jobs with the given status from the active-set. The "ActiveSet" is a class which has methods to retrieve a sub-set of the total jobs to make it easier to work with large applications.

Parameters:
status -
Returns: