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:
016: package org.griphyn.vdl.router;
017:
018: import org.griphyn.vdl.classes.*;
019:
020: /**
021: * create a Diamond DAG exmample structure in memory using VDL classes.
022: *
023: * @author Jens-S. Vöckler
024: * @version $Revision: 50 $
025: */
026: public class CreateDiamond {
027:
028: /**
029: * create a 4 node diamond DAG as in-memory data structures employing
030: * the VDL classes. This is a test module for the router, until the
031: * input (SAX) becomes available.
032: *
033: * @return a list of Transformations and Derivations, encapsulated
034: * as Definitions.
035: */
036: public static Definitions create() {
037: // create result vector
038: Definitions result = new Definitions("test", "1.0");
039:
040: try {
041: // create "generate" transformation
042: Transformation t1 = new Transformation("generate");
043: t1.addProfile(new Profile("hints", "pfnHint", new Text(
044: "generator.exe")));
045: t1.addDeclare(new Declare("a", Value.SCALAR, LFN.OUTPUT));
046: t1.addArgument(new Argument("stdout", new Use("a",
047: LFN.OUTPUT)));
048: result.addDefinition(t1);
049:
050: // create "findrange" transformation
051: Transformation t2 = new Transformation("findrange");
052: t2.addProfile(new Profile("hints", "pfnHint", new Text(
053: "findrange.exe")));
054: Argument t2_arg1 = new Argument("arg", new Text("-i "));
055: t2_arg1.addLeaf(new Use("p", LFN.NONE));
056: t2.addDeclare(new Declare("a", Value.SCALAR, LFN.INPUT));
057: t2.addDeclare(new Declare("b", Value.SCALAR, LFN.OUTPUT));
058: t2
059: .addDeclare(new Declare("p", new Scalar(new Text(
060: "0.0"))));
061: t2.addArgument(t2_arg1);
062: t2.addArgument(new Argument("stdin",
063: new Use("a", LFN.INPUT)));
064: t2.addArgument(new Argument("stdout", new Use("b",
065: LFN.OUTPUT)));
066: result.addDefinition(t2);
067:
068: // create "analyze" transformation
069: Transformation t3 = new Transformation("analyze");
070: t3.addProfile(new Profile("hints", "pfnHint", new Text(
071: "analyze.exe")));
072: t3.addArgument(new Argument("files", new Use("a", "", " ",
073: "")));
074: t3.addArgument(new Argument("stdout", new Use("c",
075: LFN.OUTPUT)));
076: t3.addDeclare(new Declare("a", Value.LIST, LFN.INPUT));
077: t3.addDeclare(new Declare("c", Value.SCALAR, LFN.OUTPUT));
078: result.addDefinition(t3);
079:
080: // create "top" node derivation of "generate"
081: Derivation d1 = new Derivation("top", "generate", new Pass(
082: "a", new Scalar(new LFN("f.a", LFN.OUTPUT))));
083: result.addDefinition(d1);
084:
085: // create "left" node derivation of "findrange"
086: Derivation d2 = new Derivation("left", "findrange");
087: d2.addPass(new Pass("b", new Scalar(new LFN("f.b",
088: LFN.OUTPUT))));
089: d2.addPass(new Pass("a", new Scalar(new LFN("f.a",
090: LFN.INPUT))));
091: d2.addPass(new Pass("p", new Scalar(new Text("0.5"))));
092: result.addDefinition(d2);
093:
094: // create "right" node derivation of "findrange"
095: Derivation d3 = new Derivation("right", "findrange");
096: d3.addPass(new Pass("a", new Scalar(new LFN("f.a",
097: LFN.INPUT))));
098: d3.addPass(new Pass("b", new Scalar(new LFN("f.c",
099: LFN.OUTPUT))));
100: d3.addPass(new Pass("p", new Scalar(new Text("1.0"))));
101: result.addDefinition(d3);
102:
103: // create "bottom" node derivation of "analyze"
104: Derivation d4 = new Derivation("bottom", "analyze");
105: List d4_list1 = new List();
106: d4_list1.addScalar(new Scalar(new LFN("f.b", LFN.INPUT)));
107: d4_list1.addScalar(new Scalar(new LFN("f.c", LFN.INPUT)));
108: d4.addPass(new Pass("a", d4_list1));
109: d4.addPass(new Pass("c", new Scalar(new LFN("f.d",
110: LFN.OUTPUT))));
111: result.addDefinition(d4);
112: } catch (IllegalArgumentException iae) {
113: System.err.println(iae.getMessage());
114: System.exit(1);
115: }
116:
117: // finally
118: return result;
119: }
120: }
|