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 fully connected fake Diamond DAG exmample structure in
022: * memory using VDL classes.<p>
023: * <pre>
024: * C --<-- A
025: * |\ /|
026: * | \ _ / |
027: * V | L V
028: * | /\ |
029: * | / \ |
030: * | / \|
031: * D --<-- B
032: * </pre>
033: *
034: * @author Jens-S. Vöckler
035: * @version $Revision: 50 $
036: */
037: public class CreateFullDiamond {
038:
039: /**
040: * create a 4 node diamond DAG as in-memory data structures employing
041: * the VDL classes. This is a test module for some sample concrete planning
042: * modules.
043: *
044: * @return a list of Transformations and Derivations, encapsulated
045: * as Definitions.
046: */
047: public static Definitions create() {
048: // create result vector
049: Definitions result = new Definitions("test", "1.0");
050:
051: try {
052: // create "generate" transformation
053: Transformation t1 = new Transformation("generate");
054: t1.addProfile(new Profile("hints", "pfnHint", new Text(
055: "keg.exe")));
056: t1.addDeclare(new Declare("a", Value.SCALAR, LFN.OUTPUT));
057: t1.addArgument(new Argument(null, new Text(
058: "-a generate -o ")));
059: t1
060: .addArgument(new Argument(null, new Use("a",
061: LFN.OUTPUT)));
062: result.addDefinition(t1);
063:
064: // create "gobble" transformation
065: Transformation t2 = new Transformation("take1");
066: t2.addProfile(new Profile("hints", "pfnHint", new Text(
067: "keg.exe")));
068: t2.addDeclare(new Declare("a", Value.SCALAR, LFN.INPUT));
069: t2.addDeclare(new Declare("b", Value.SCALAR, LFN.OUTPUT));
070: Argument t2a1 = new Argument();
071: t2a1.addLeaf(new Text("-a "));
072: t2a1.addLeaf(new Text("take1"));
073: t2.addArgument(t2a1);
074: Argument t2a2 = new Argument();
075: t2a2.addLeaf(new Text("-i "));
076: t2a2.addLeaf(new Use("a", LFN.INPUT));
077: t2.addArgument(t2a2);
078: t2.addArgument(new Argument(null, new Text("-o")));
079: t2
080: .addArgument(new Argument(null, new Use("b",
081: LFN.OUTPUT)));
082: result.addDefinition(t2);
083:
084: Transformation t3 = new Transformation("take2");
085: t3.addProfile(new Profile("hints", "pfnHint", new Text(
086: "keg.exe")));
087: t3.addDeclare(new Declare("a", Value.SCALAR, LFN.INPUT));
088: t3.addDeclare(new Declare("b", Value.SCALAR, LFN.INPUT));
089: t3.addDeclare(new Declare("c", Value.SCALAR, LFN.OUTPUT));
090: // you can do it thus...
091: Argument t3a1 = new Argument();
092: t3a1.addLeaf(new Text("-a take2 -i "));
093: t3a1.addLeaf(new Use("a", LFN.INPUT));
094: t3.addArgument(t3a1);
095: // ...or thus...
096: // NOTE: the space is now unnecessary, since argumentSeparator
097: // defaults to one space. The argumentSeparator will be applied
098: // when constructing the commandline from two <argument> elements.
099: //// t3.addArgument( new Argument( null, new Text(" ") ) );
100: t3.addArgument(new Argument(null, new Use("b", LFN.INPUT)));
101: // ...or thus again
102: Argument t3a2 = new Argument();
103: t3a2.addLeaf(new Text("-o "));
104: t3a2.addLeaf(new Use("c", LFN.OUTPUT));
105: t3.addArgument(t3a2);
106: result.addDefinition(t3);
107:
108: Transformation t4 = new Transformation("analyze");
109: t4.addProfile(new Profile("hints", "pfnHint", new Text(
110: "keg.exe")));
111: t4.addDeclare(new Declare("abc", Value.LIST, LFN.INPUT));
112: t4.addDeclare(new Declare("d", Value.SCALAR, LFN.OUTPUT));
113: t4
114: .addArgument(new Argument(null, new Text(
115: "-a analyze -i")));
116: t4.addArgument(new Argument("files", new Use("abc", "\"",
117: " ", "\"")));
118: t4.addArgument(new Argument(null, new Text("-o")));
119: t4
120: .addArgument(new Argument(null, new Use("d",
121: LFN.OUTPUT)));
122: result.addDefinition(t4);
123:
124: // create "top" node derivation of "generate"
125: Derivation d1 = new Derivation("A", "generate");
126: d1.addPass(new Pass("a", new Scalar(new LFN("f.a",
127: LFN.OUTPUT))));
128: result.addDefinition(d1);
129:
130: // create "left" node derivation of "findrange"
131: Derivation d2 = new Derivation("B", "take1");
132: d2.addPass(new Pass("b", new Scalar(new LFN("f.b",
133: LFN.OUTPUT))));
134: d2.addPass(new Pass("a", new Scalar(new LFN("f.a",
135: LFN.INPUT))));
136: result.addDefinition(d2);
137:
138: // create "right" node derivation of "findrange"
139: Derivation d3 = new Derivation("C", "take2");
140: d3.addPass(new Pass("a", new Scalar(new LFN("f.a",
141: LFN.INPUT))));
142: d3.addPass(new Pass("b", new Scalar(new LFN("f.b",
143: LFN.INPUT))));
144: d3.addPass(new Pass("c", new Scalar(new LFN("f.c",
145: LFN.OUTPUT))));
146: result.addDefinition(d3);
147:
148: // create "bottom" node derivation of "analyze"
149: Derivation d4 = new Derivation("D", "analyze");
150: List d4_list1 = new List();
151: d4_list1.addScalar(new Scalar(new LFN("f.a", LFN.INPUT)));
152: d4_list1.addScalar(new Scalar(new LFN("f.b", LFN.INPUT)));
153: d4_list1.addScalar(new Scalar(new LFN("f.c", LFN.INPUT)));
154: d4.addPass(new Pass("abc", d4_list1));
155: d4.addPass(new Pass("d", new Scalar(new LFN("f.d",
156: LFN.OUTPUT))));
157: result.addDefinition(d4);
158: } catch (IllegalArgumentException iae) {
159: System.err.println(iae.getMessage());
160: System.exit(1);
161: }
162:
163: // finally
164: return result;
165: }
166: }
|