Source Code Cross Referenced for VDSPOSTScript.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » code » gridstart » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » pegasus 2.1.0 » org.griphyn.cPlanner.code.gridstart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         */package org.griphyn.cPlanner.code.gridstart;
015:
016:        import org.griphyn.cPlanner.classes.SubInfo;
017:
018:        import org.griphyn.cPlanner.common.PegasusProperties;
019:        import org.griphyn.cPlanner.common.LogManager;
020:
021:        import org.griphyn.cPlanner.namespace.Dagman;
022:
023:        import org.griphyn.cPlanner.code.POSTScript;
024:
025:        /**
026:         * An abstract implementation of the interface, that is a superclass for
027:         * all the VDS supplied postscripts. These postscripts work can parse
028:         * kickstart records.
029:         *
030:         * @author Karan Vahi vahi@isi.edu
031:         * @version $Revision: 50 $
032:         */
033:
034:        public abstract class VDSPOSTScript implements  POSTScript {
035:
036:            /**
037:             * The suffix for the exitcode output file, that is generated at the
038:             * submit host.
039:             */
040:            public static final String EXITCODE_OUTPUT_SUFFIX = "exit.log";
041:
042:            /**
043:             * The LogManager object which is used to log all the messages.
044:             */
045:            protected LogManager mLogger;
046:
047:            /**
048:             * The object holding all the properties pertaining to Pegasus.
049:             */
050:            protected PegasusProperties mProps;
051:
052:            /**
053:             * The path to the exitcode client that parses the exit status of
054:             * the kickstart. The client is run as a postscript. It also
055:             * includes the option to the command since at present it is same for all.
056:             * It is $PEGASUS_HOME/bin/exitcode (no -n)!
057:             */
058:            protected String mExitParserPath;
059:
060:            /**
061:             * A boolean indicating whether to turn the debug on for the postscript or
062:             * not.
063:             */
064:            protected boolean mPostScriptDebug;
065:
066:            /**
067:             * The properties that need to be passed to the postscript invocation
068:             * on the command line in the java format.
069:             */
070:            protected String mPostScriptProperties;
071:
072:            /**
073:             * The submit directory where the submit files are being generated for
074:             * the workflow.
075:             */
076:            protected String mSubmitDir;
077:
078:            /**
079:             * Returns the path to exitcode that is to be used on the kickstart
080:             * output.
081:             *
082:             * @return the path to the exitcode script to be invoked.
083:             */
084:            protected abstract String getDefaultExitCodePath();
085:
086:            /**
087:             * The default constructor.
088:             */
089:            public VDSPOSTScript() {
090:                mLogger = LogManager.getInstance();
091:            }
092:
093:            /**
094:             * Initialize the POSTScript implementation.
095:             *
096:             * @param properties the <code>PegasusProperties</code> object containing all
097:             *                   the properties required by Pegasus.
098:             * @param path       the path to the POSTScript on the submit host.
099:             * @param submitDir  the submit directory where the submit file for the job
100:             *                   has to be generated.
101:             */
102:            public void initialize(PegasusProperties properties, String path,
103:                    String submitDir) {
104:                mProps = properties;
105:                mSubmitDir = submitDir;
106:
107:                //construct the exitcode paths and arguments
108:                mExitParserPath = (path == null) ? getDefaultExitCodePath()
109:                        : path;
110:                mPostScriptDebug = mProps.setPostSCRIPTDebugON();
111:                mPostScriptProperties = getPostScriptProperties(properties);
112:
113:            }
114:
115:            /**
116:             * Constructs the postscript that has to be invoked on the submit host
117:             * after the job has executed on the remote end. The postscript usually
118:             * works on the xml output generated by kickstart. The postscript invoked
119:             * is exitcode that is shipped with VDS, and can usually be found at
120:             * $PEGASUS_HOME/bin/exitcode.
121:             * <p>
122:             * The postscript is constructed and populated as a profile
123:             * in the DAGMAN namespace.
124:             *
125:             *
126:             * @param job  the <code>SubInfo</code> object containing the job description
127:             *             of the job that has to be enabled on the grid.
128:             * @param key  the key for the profile that has to be inserted.
129:             *
130:             * @return boolean true if postscript was generated,else false.
131:             */
132:            public boolean construct(SubInfo job, String key) {
133:                String postscript = mExitParserPath;
134:
135:                //        //NO NEED TO REMOVE AS WE ARE HANDLING CORRECTLY IN DAGMAN NAMESPACE
136:                //        //NOW. THERE THE ARGUMENTS AND KEY ARE COMBINED. Karan May 11,2006
137:                //        //arguments are already taken
138:                //        //care of in the profile incorporation
139:                //        postscript += " " +
140:                //                     (String)job.dagmanVariables.removeKey(
141:                //                                              Dagman.POST_SCRIPT_ARGUMENTS_KEY);
142:
143:                //check if the initialdir condor key has been set
144:                //for the job or not
145:                //      This is no longer required, as to support
146:                //      submit host execution , all kickstart outputs
147:                //      are propogated back to the submit directory
148:                //      Karan Aug 22, 2005
149:                //        if(job.condorVariables.containsKey("initialdir") &&
150:                //           !job.executionPool.equalsIgnoreCase("local")){
151:                //            String dir = (String)job.condorVariables.get("initialdir");
152:                //            //means that the kickstart output is being
153:                //            //generated in the initialdir instead of the directory
154:                //            //from where the dag is submitted
155:                //            sb.append(dir).append(File.separator);
156:                //        }
157:                //        //append the name of kickstart output
158:                //        sb.append(job.jobName).append(".out");
159:
160:                //pick up whatever output has been set and set it
161:                //as a corresponding  DAGMAN profile. Bug Fix for VDS Bug 144
162:                //        postscript += " " + (String)job.condorVariables.get("output");
163:                job.dagmanVariables.construct(Dagman.OUTPUT_KEY,
164:                        (String) job.condorVariables.get("output"));
165:
166:                StringBuffer extraOptions = new StringBuffer();
167:                if (mPostScriptDebug) {
168:                    //add in the debug options
169:                    appendProperty(extraOptions, "pegasus.log.default",
170:                            getPostScriptLogFile(job));
171:                    appendProperty(extraOptions, "pegasus.verbose", "5");
172:                }
173:                //put in the postscript properties if any
174:                extraOptions.append(this .mPostScriptProperties);
175:
176:                //put the extra options into the exitcode arguments
177:                //in the correct order.
178:                Object args = job.dagmanVariables
179:                        .get(Dagman.POST_SCRIPT_ARGUMENTS_KEY);
180:                StringBuffer arguments = (args == null) ?
181:                //only have extra options
182:                extraOptions
183:                        :
184:                        //have extra options in addition to existing args
185:                        new StringBuffer().append(extraOptions).append(" ")
186:                                .append(args);
187:                job.dagmanVariables.construct(Dagman.POST_SCRIPT_ARGUMENTS_KEY,
188:                        arguments.toString());
189:
190:                //put in the postscript
191:                mLogger.log("Postscript constructed is " + postscript,
192:                        LogManager.DEBUG_MESSAGE_LEVEL);
193:                job.dagmanVariables.checkKeyInNS(key, postscript);
194:
195:                return true;
196:            }
197:
198:            /**
199:             * Returns the path to the postscript log file for a job.
200:             *
201:             * @param job  the <code>SubInfo</code> containing job description
202:             */
203:            protected String getPostScriptLogFile(SubInfo job) {
204:                StringBuffer sb = new StringBuffer();
205:                sb.append(job.getName()).append(".").append(
206:                        this .EXITCODE_OUTPUT_SUFFIX);
207:                return sb.toString();
208:            }
209:
210:            /**
211:             * Returns the properties that need to be passed to the the postscript
212:             * invocation in the java format. It is of the form
213:             * "-Dprop1=value1 -Dprop2=value2 .."
214:             *
215:             * @param properties   the properties object
216:             *
217:             * @return the properties list, else empty string.
218:             */
219:            protected String getPostScriptProperties(
220:                    PegasusProperties properties) {
221:                StringBuffer sb = new StringBuffer();
222:                appendProperty(sb, "pegasus.user.properties", properties
223:                        .getPropertiesInSubmitDirectory());
224:                return sb.toString();
225:
226:            }
227:
228:            /**
229:             * Appends a property to the StringBuffer, in the java command line format.
230:             *
231:             * @param sb    the StringBuffer to append the property to.
232:             * @param key   the property.
233:             * @param value the property value.
234:             */
235:            protected void appendProperty(StringBuffer sb, String key,
236:                    String value) {
237:                sb.append(" ").append("-D").append(key).append("=").append(
238:                        value);
239:            }
240:
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.