org.gridbus.broker.farming.common
Class GridbusFarmingEngine

java.lang.Object
  extended by org.gridbus.broker.farming.common.FarmingEngine
      extended by org.gridbus.broker.farming.common.GridbusFarmingEngine

public final 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.


Field Summary
static int COMPLETED
           
static int READY
           
static int STARTED
           
static int UNKNOWN
           
 
Constructor Summary
GridbusFarmingEngine()
          Constructor - initializes GridbusFarmingEngine
GridbusFarmingEngine(java.lang.Object config)
          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.
GridbusFarmingEngine(java.lang.Object config, boolean initRecovery)
          This constructor is called by the recovery process
 
Method Summary
 void addServer(ComputeServer s)
          Add a computational server to the Collection
 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
 float getBudgetSpent()
           
 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)
           
 long getJobCount(int status, java.lang.String serverID)
           
 java.util.Collection getJobs()
           
 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.Vector getNextNJobs(int N, int jobStatus)
           
 java.lang.String getPersistenceMode()
          Returns the type of persistence used (ie.
 Reader getPersistenceReader()
           
 Writer getPersistenceWriter()
           
 BrokerProperties getProperties()
          Returns a copy of configuration properties for the broker.
 java.lang.String getResourceDescriptionFile()
          Returns the name of the resource description file.
 Scheduler getScheduler()
           
 java.util.Date getStartDateStamp()
           
 java.lang.String getStats()
           
 int getStatus()
           
 java.lang.String getStatusString()
           
 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
 boolean isSchedulingStarted()
           
 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(float budget)
          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 setServers(java.util.Collection servers)
           
 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 storeJob(Job j)
           
 void storeJobs(java.util.Vector jobs)
           
 void storeServers(java.util.Vector servers)
           
 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, getServers, setJobs
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

STARTED

public static final int STARTED
See Also:
Constant Field Values

COMPLETED

public static final int COMPLETED
See Also:
Constant Field Values

READY

public static final int READY
See Also:
Constant Field Values
Constructor Detail

GridbusFarmingEngine

public GridbusFarmingEngine()
                     throws GridBrokerException
Constructor - initializes GridbusFarmingEngine

Throws:
GridBrokerException

GridbusFarmingEngine

public GridbusFarmingEngine(java.lang.Object config)
                     throws GridBrokerException
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.

Parameters:
config -
Throws:
GridBrokerException

GridbusFarmingEngine

public GridbusFarmingEngine(java.lang.Object config,
                            boolean initRecovery)
                     throws GridBrokerException
This constructor is called by the recovery process

Parameters:
config -
initRecovery -
Throws:
GridBrokerException
Method Detail

getProperties

public BrokerProperties getProperties()
Returns a copy of configuration properties for the broker. The properties cannot be changed using this reference.

Returns:
broker properties used by this broker

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

getPersistenceReader

public Reader getPersistenceReader()

getPersistenceWriter

public Writer getPersistenceWriter()

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(float budget)
               throws GridBrokerException
Sets the budget for the current grid-application running on the broker

Parameters:
budget -
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

isSchedulingStarted

public boolean isSchedulingStarted()
Returns:
whether scheduling has started yet

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.

addServer

public void addServer(ComputeServer s)
Add a computational server to the Collection

Overrides:
addServer in class FarmingEngine
Parameters:
s - - the server to be added.

setServers

public void setServers(java.util.Collection servers)
Overrides:
setServers in class FarmingEngine
Parameters:
servers - - Collection object of servers

getStats

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

setScheduler

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

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


getBrokerID

public java.lang.String getBrokerID()
Returns:
broker id

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.

getJobCount

public long getJobCount(int status)
Parameters:
status -
Returns:
count of jobs with given status

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:
active set

getJobs

public java.util.Collection getJobs()
Overrides:
getJobs in class FarmingEngine
Returns:
jobs - Collection of jobs available with the farming engine

getBudgetSpent

public float getBudgetSpent()
Returns:
Returns the budgetSpent.

getPersistenceMode

public java.lang.String getPersistenceMode()
Returns the type of persistence used (ie. database, xml, other..)

Returns:
persistence mode

getStatusString

public java.lang.String getStatusString()
Returns:
string format of the broker's status

getStatus

public int getStatus()
Returns:
the broker's status

storeServers

public void storeServers(java.util.Vector servers)
Parameters:
servers -

storeJobs

public void storeJobs(java.util.Vector jobs)
Parameters:
jobs -

storeJob

public void storeJob(Job j)
Parameters:
j -

getNextNJobs

public java.util.Vector getNextNJobs(int N,
                                     int jobStatus)
Parameters:
N -
jobStatus -
Returns:
list containing the next N jobs to be processed

getJobCount

public long getJobCount(int status,
                        java.lang.String serverID)
Parameters:
status -
serverID -
Returns:
job count for given status and server