001: /*
002: * This file or a portion of this file is licensed under the terms of
003: * the Globus Toolkit Public License, found in file GTPL, or at
004: * http://www.globus.org/toolkit/download/license.html. This notice must
005: * appear in redistributions of this file, with or without modification.
006: *
007: * Redistributions of this Software, with or without modification, must
008: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
009: * some other similar material which is provided with the Software (if
010: * any).
011: *
012: * Copyright 1999-2004 University of Chicago and The University of
013: * Southern California. All rights reserved.
014: */
015: package org.griphyn.cPlanner.classes;
016:
017: import java.util.Collection;
018: import java.util.List;
019: import java.util.ArrayList;
020: import java.util.Iterator;
021:
022: /**
023: * This class holds all the specifics of an aggregated job. An aggregated job
024: * or a clustered job is a job, that contains a collection of smaller jobs.
025: * An aggregated job during execution may explode into n smaller job executions.
026: * At present it does not store information about the dependencies between the
027: * jobs.
028: *
029: * @author Karan Vahi
030: * @version $Revision: 50 $
031: */
032:
033: public class AggregatedJob extends SubInfo {
034:
035: /**
036: * The collection of jobs that are contained in the aggregated job.
037: */
038: private Collection mConstituentJobs;
039:
040: /**
041: * The default constructor.
042: */
043: public AggregatedJob() {
044: super ();
045: mConstituentJobs = new ArrayList(3);
046: }
047:
048: /**
049: * The overloaded constructor.
050: *
051: * @param num the number of constituent jobs
052: */
053: public AggregatedJob(int num) {
054: super ();
055: mConstituentJobs = new ArrayList(num);
056: }
057:
058: /**
059: * The overloaded constructor.
060: *
061: * @param job the job whose shallow copy is created, and is the main job.
062: * @param num the number of constituent jobs.
063: */
064: public AggregatedJob(SubInfo job, int num) {
065: super ((SubInfo) job.clone());
066: mConstituentJobs = new ArrayList(num);
067: }
068:
069: /**
070: * Adds a job to the aggregated job.
071: *
072: * @param job the job to be added.
073: */
074: public void add(SubInfo job) {
075: mConstituentJobs.add(job);
076: }
077:
078: /**
079: * Returns a new copy of the Object. The constituent jobs are also cloned.
080: *
081: * @return Object
082: */
083: public Object clone() {
084: AggregatedJob newJob = new AggregatedJob((SubInfo) super
085: .clone(), mConstituentJobs.size());
086: for (Iterator it = this .mConstituentJobs.iterator(); it
087: .hasNext();) {
088: newJob.add((SubInfo) (((SubInfo) it.next()).clone()));
089: }
090: return newJob;
091: }
092:
093: /**
094: * Returns an iterator to the constituent jobs of the AggregatedJob.
095: *
096: * @return Iterator
097: */
098: public Iterator constituentJobsIterator() {
099: return mConstituentJobs.iterator();
100: }
101:
102: /**
103: * Returns a textual description of the object.
104: *
105: * @return textual description of the job.
106: */
107: public String toString() {
108: StringBuffer sb = new StringBuffer(32);
109: sb.append("\n").append("[MAIN JOB]").append(super .toString());
110: sb.append("\n").append("[CONSTITUENT JOBS]");
111: int num = 0;
112: for (Iterator it = mConstituentJobs.iterator(); it.hasNext(); ++num) {
113: sb.append("\n").append("[CONSTITUENT JOB] :").append(num);
114: sb.append(it.next());
115: }
116: return sb.toString();
117: }
118:
119: }
|