001: /**
002: * This file or a portion of this file is licensed under the terms of
003: * the Globus Toolkit Public License, found at $PEGASUS_HOME/GTPL or
004: * http://www.globus.org/toolkit/download/license.html.
005: * This notice must appear in redistributions of this file
006: * with or without modification.
007: *
008: * Redistributions of this Software, with or without modification, must reproduce
009: * the GTPL in:
010: * (1) the Software, or
011: * (2) the Documentation or
012: * some other similar material which is provided with the Software (if any).
013: *
014: * Copyright 1999-2004
015: * University of Chicago and The University of Southern California.
016: * All rights reserved.
017: */package org.griphyn.cPlanner.selector.site;
018:
019: import org.griphyn.cPlanner.classes.SubInfo;
020: import org.griphyn.cPlanner.classes.PegasusBag;
021:
022: import org.griphyn.cPlanner.common.LogManager;
023:
024: import org.griphyn.cPlanner.selector.site.heft.HeftBag;
025: import org.griphyn.cPlanner.selector.site.heft.Algorithm;
026:
027: import org.griphyn.cPlanner.partitioner.graph.Graph;
028: import org.griphyn.cPlanner.partitioner.graph.GraphNode;
029:
030: import java.util.List;
031: import java.util.Iterator;
032:
033: /**
034: * The HEFT based site selector. The runtime for the job in seconds is picked
035: * from the pegasus profile key runtime in the transformation catalog for a
036: * transformation.
037: *
038: * The data communication costs between jobs if scheduled on different sites
039: * is assumed to be fixed. Later on if required, the ability to specify this
040: * value will be exposed via properties.
041: *
042: * The number of processors in a site is picked by the attribute idle-nodes
043: * associated with the vanilla jobmanager for a site in the site catalog.
044: *
045: * @author Karan Vahi
046: * @version $Revision: 300 $
047: *
048: * @see Algorithm#AVERAGE_BANDWIDTH
049: * @see Algorithm#RUNTIME_PROFILE_KEY
050: * @see Algorithm#DEFAULT_NUMBER_OF_FREE_NODES
051: * @see Algorithm#AVERAGE_DATA_SIZE_BETWEEN_JOBS
052: * @see org.griphyn.cPlanner.classes.JobManager.IDLE_NODES
053: */
054: public class Heft extends Abstract {
055:
056: /**
057: * An instance of the class that implements the HEFT algorithm.
058: */
059: private Algorithm mHeftImpl;
060:
061: /**
062: * The default constructor.
063: */
064: public Heft() {
065: super ();
066: }
067:
068: /**
069: * Initializes the site selector.
070: *
071: * @param bag the bag of objects that is useful for initialization.
072: */
073: public void initialize(PegasusBag bag) {
074: super .initialize(bag);
075: mHeftImpl = new Algorithm(bag);
076: }
077:
078: /**
079: * Maps the jobs in the workflow to the various grid sites.
080: * The jobs are mapped by setting the site handle for the jobs.
081: *
082: * @param workflow the workflow in a Graph form.
083: *
084: * @param sites the list of <code>String</code> objects representing the
085: * execution sites that can be used.
086: */
087: public void mapWorkflow(Graph workflow, List sites) {
088:
089: //schedule the workflow, till i fix the interface
090: mHeftImpl.schedule(workflow, sites);
091:
092: //get the makespan of the workflow
093: mLogger.log("Makespan of scheduled workflow is "
094: + mHeftImpl.getMakespan(),
095: LogManager.DEBUG_MESSAGE_LEVEL);
096:
097: //iterate through the jobs and just set the site handle
098: //accordingly
099: for (Iterator it = workflow.nodeIterator(); it.hasNext();) {
100: GraphNode node = (GraphNode) it.next();
101: SubInfo job = (SubInfo) node.getContent();
102: job.setSiteHandle((String) node.getBag().get(
103: HeftBag.SCHEDULED_SITE));
104: }
105:
106: }
107:
108: /**
109: * This method returns a String describing the site selection technique
110: * that is being implemented by the implementing class.
111: *
112: * @return String
113: */
114: public String description() {
115: return "Heft based Site Selector";
116: }
117:
118: }
|