Source Code Cross Referenced for PlannerOptions.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » classes » 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.classes 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * This file or a portion of this file is licensed under the terms of
0003:         * the Globus Toolkit Public License, found in file GTPL, or at
0004:         * http://www.globus.org/toolkit/download/license.html. This notice must
0005:         * appear in redistributions of this file, with or without modification.
0006:         *
0007:         * Redistributions of this Software, with or without modification, must
0008:         * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
0009:         * some other similar material which is provided with the Software (if
0010:         * any).
0011:         *
0012:         * Copyright 1999-2004 University of Chicago and The University of
0013:         * Southern California. All rights reserved.
0014:         */
0015:        package org.griphyn.cPlanner.classes;
0016:
0017:        import org.griphyn.cPlanner.common.LogManager;
0018:
0019:        import java.io.File;
0020:
0021:        import java.util.Collection;
0022:        import java.util.Date;
0023:        import java.util.Iterator;
0024:        import java.util.List;
0025:        import java.util.Set;
0026:        import java.util.HashSet;
0027:        import java.util.StringTokenizer;
0028:        import org.griphyn.common.util.Currently;
0029:
0030:        /**
0031:         * Holds the information about thevarious options which user specifies to
0032:         * the Concrete Planner at runtime.
0033:         *
0034:         * @author Karan Vahi
0035:         * @author Gaurang Mehta
0036:         * @version $Revision: 464 $
0037:         */
0038:        public class PlannerOptions extends Data implements  Cloneable {
0039:
0040:            /**
0041:             * The base submit directory.
0042:             */
0043:            private String mBaseDir;
0044:
0045:            /**
0046:             * The relative submit directory.
0047:             */
0048:            private String mRelativeDir;
0049:
0050:            /**
0051:             * This is the directory where the submit files are generated on the submit
0052:             * host (the site running the concrete planner).
0053:             */
0054:            //private String mSubmitFileDir ;
0055:            /**
0056:             * The dax file which contains the abstract dag. This dax is created by the
0057:             * Abstract Planner using the gendax command.
0058:             */
0059:            private String mDAXFile;
0060:
0061:            /**
0062:             * The path to the pdax file that contains the partition graph.
0063:             */
0064:            private String mPDAXFile;
0065:
0066:            /**
0067:             * List of execution pools on which the user wants the Dag to be executed.
0068:             */
0069:            private Set mvExecPools;
0070:
0071:            /**
0072:             * Set of cache files that need to be used, to determine the location of the
0073:             * transiency files.
0074:             */
0075:            private Set mCacheFiles;
0076:
0077:            /**
0078:             * The output pool on which the data products are needed to be transferred to.
0079:             */
0080:            private String mOutputPool;
0081:
0082:            /**
0083:             * If specified, then it submits to the underlying CondorG using the
0084:             * kickstart-Condorscript provided.
0085:             */
0086:            private boolean mSubmit;
0087:
0088:            /**
0089:             * The force option to make a build dag from scratch. Leads to no reduction
0090:             * of dag occuring.
0091:             */
0092:            private boolean mForce;
0093:
0094:            /**
0095:             * A boolean indicating whether to do cleanup or not.
0096:             */
0097:            private boolean mCleanup;
0098:
0099:            /**
0100:             * To Display help or not.
0101:             */
0102:            private boolean mDisplayHelp;
0103:
0104:            /**
0105:             * Denotes the logging level that is to be used for logging the messages.
0106:             */
0107:            private int mLoggingLevel;
0108:
0109:            /**
0110:             * Whether to create a random directory in the execution directory that is
0111:             * determined from the exec mount point in the pool configuration file.
0112:             * This forces Pegasus to do runs in a unique random directory just below
0113:             * the execution mount point at a remote pool.
0114:             */
0115:            private boolean mGenRandomDir;
0116:
0117:            /**
0118:             * Whether to attempt authentication against the jobmanagers for the pools
0119:             * specified at runtime.
0120:             */
0121:            private boolean mAuthenticate;
0122:
0123:            /**
0124:             * The megadag generation mode.
0125:             */
0126:            private String mMegadag;
0127:
0128:            /**
0129:             * The list of VDS properties set at runtime by the user on commandline.
0130:             * It is a list of <code>NameValue</code> pairs, with name as vds property
0131:             * name and value as the corresponding value.
0132:             */
0133:            private List mVDSProps;
0134:
0135:            /**
0136:             * Denotes what type of clustering needs to be done
0137:             */
0138:            private String mClusterer;
0139:
0140:            /**
0141:             * If the genRandomDir flag is set, then this contains the name of
0142:             * the random directory. Else it can be a null or an empty string.
0143:             */
0144:            private String mRandomDirName;
0145:
0146:            /**
0147:             * Designates if the optional argument to the random directory was given.
0148:             */
0149:            private boolean mOptArg;
0150:
0151:            /**
0152:             * The basename prefix that is to be given to the per workflow file, like
0153:             * the log file, the .dag file, the .cache files etc.
0154:             */
0155:            private String mBasenamePrefix;
0156:
0157:            /**
0158:             * A boolean indicating whether the planner invocation is part of a larger
0159:             * deferred planning run.
0160:             */
0161:            private boolean mDeferredRun;
0162:
0163:            /**
0164:             * Boolean indicating whether to spawn off a monitoring process or not
0165:             * for the workflow.
0166:             */
0167:            private boolean mMonitor;
0168:
0169:            /**
0170:             * The VOGroup to which the user belongs to.
0171:             */
0172:            private String mVOGroup;
0173:
0174:            /**
0175:             * Stores the time at which the planning process started.
0176:             */
0177:            private Date mDate;
0178:
0179:            /**
0180:             * Stores the type of partitioning to be done.
0181:             */
0182:            private String mPartitioningType;
0183:
0184:            /**
0185:             * Default Constructor.
0186:             */
0187:            public PlannerOptions() {
0188:                //        mSubmitFileDir    = ".";
0189:                mBaseDir = ".";
0190:                mRelativeDir = null;
0191:                mDAXFile = null;
0192:                mPDAXFile = null;
0193:                mvExecPools = new java.util.HashSet();
0194:                mCacheFiles = new java.util.HashSet();
0195:                mOutputPool = null;
0196:                mDisplayHelp = false;
0197:                mLoggingLevel = 0;
0198:                mForce = false;
0199:                mSubmit = false;
0200:                mGenRandomDir = false;
0201:                mRandomDirName = null;
0202:                mOptArg = false;
0203:                mAuthenticate = false;
0204:                mMegadag = null;
0205:                mVDSProps = null;
0206:                mClusterer = null;
0207:                mBasenamePrefix = null;
0208:                mMonitor = false;
0209:                mCleanup = true;
0210:                mVOGroup = "pegasus";
0211:                mDeferredRun = false;
0212:                mDate = new Date();
0213:                mPartitioningType = null;
0214:            }
0215:
0216:            /**
0217:             * Returns the authenticate option for the planner.
0218:             *
0219:             * @return boolean indicating if it was set or not.
0220:             */
0221:            public boolean authenticationSet() {
0222:                return mAuthenticate;
0223:            }
0224:
0225:            /**
0226:             * Returns the cache files.
0227:             *
0228:             * @return Set of fully qualified paths to the cache files.
0229:             *
0230:             */
0231:            public Set getCacheFiles() {
0232:                return mCacheFiles;
0233:            }
0234:
0235:            /**
0236:             * Returns whether to do clustering or not.
0237:             *
0238:             * @return boolean
0239:             */
0240:            //    public boolean clusteringSet(){
0241:            //        return mCluster;
0242:            //    }
0243:            /**
0244:             * Returns the clustering technique to be used for clustering.
0245:             *
0246:             * @return the value of clustering technique if set, else null
0247:             */
0248:            public String getClusteringTechnique() {
0249:                return mClusterer;
0250:            }
0251:
0252:            /**
0253:             * Returns the basename prefix for the per workflow files that are to be
0254:             * generated by the planner.
0255:             *
0256:             * @return the basename if set, else null.
0257:             */
0258:            public String getBasenamePrefix() {
0259:                return mBasenamePrefix;
0260:            }
0261:
0262:            /**
0263:             * Returns the path to the dax file being used by the planner.
0264:             *
0265:             * @return path to DAX file.
0266:             */
0267:            public String getDAX() {
0268:                return mDAXFile;
0269:            }
0270:
0271:            /**
0272:             * Returns the names of the execution sites where the concrete workflow can
0273:             * be run.
0274:             *
0275:             * @return  <code>Set</code> of execution site names.
0276:             */
0277:            public Collection getExecutionSites() {
0278:                return mvExecPools;
0279:            }
0280:
0281:            /**
0282:             * Returns the force option set for the planner.
0283:             *
0284:             * @return the boolean value indicating the force option.
0285:             */
0286:            public boolean getForce() {
0287:                return mForce;
0288:            }
0289:
0290:            /**
0291:             * Returns the option indicating whether to do cleanup or not.
0292:             *
0293:             * @return the boolean value indicating the cleanup option.
0294:             */
0295:            public boolean getCleanup() {
0296:                return mCleanup;
0297:            }
0298:
0299:            /**
0300:             * Returns the time at which planning started in a ISO 8601 format.
0301:             *
0302:             * @param extendedFormat  will use the extended ISO 8601 format which
0303:             * separates the different timestamp items. If false, the basic
0304:             * format will be used. In UTC and basic format, the 'T' separator
0305:             * will be omitted.
0306:             *
0307:             * @return String
0308:             */
0309:            public String getDateTime(boolean extendedFormat) {
0310:
0311:                StringBuffer sb = new StringBuffer();
0312:                sb.append(Currently
0313:                        .iso8601(false, extendedFormat, false, mDate));
0314:                return sb.toString();
0315:
0316:            }
0317:
0318:            /**
0319:             * Returns whether to display or not.
0320:             *
0321:             * @return help boolean value.
0322:             */
0323:            public boolean getHelp() {
0324:                return mDisplayHelp;
0325:            }
0326:
0327:            /**
0328:             * Increments the logging level by 1.
0329:             */
0330:            public void incrementLogging() {
0331:                mLoggingLevel++;
0332:            }
0333:
0334:            /**
0335:             * Returns the logging level.
0336:             *
0337:             * @return  the logging level.
0338:             */
0339:            public int getLoggingLevel() {
0340:                return mLoggingLevel;
0341:            }
0342:
0343:            /**
0344:             * Returns the megadag generation option .
0345:             *
0346:             * @return the mode if mode is set
0347:             *         else null
0348:             */
0349:            public String getMegaDAGMode() {
0350:                return this .mMegadag;
0351:            }
0352:
0353:            /**
0354:             * Returns the output site where to stage the output .
0355:             *
0356:             * @return the output site.
0357:             */
0358:            public String getOutputSite() {
0359:                return mOutputPool;
0360:            }
0361:
0362:            /**
0363:             * Returns the path to the PDAX file being used by the planner.
0364:             *
0365:             * @return path to PDAX file.
0366:             */
0367:            public String getPDAX() {
0368:                return mPDAXFile;
0369:            }
0370:
0371:            /**
0372:             * Returns whether to generate a random directory or not.
0373:             *
0374:             * @return boolean
0375:             */
0376:            public boolean generateRandomDirectory() {
0377:                return mGenRandomDir;
0378:            }
0379:
0380:            /**
0381:             * Returns the random directory option.
0382:             *
0383:             * @return  the directory name
0384:             *          null if not set.
0385:             */
0386:            public String getRandomDir() {
0387:                return mRandomDirName;
0388:            }
0389:
0390:            /**
0391:             * Returns whether to submit the workflow or not.
0392:             *
0393:             * @return boolean indicating whether to submit or not.
0394:             */
0395:            public boolean submitToScheduler() {
0396:                return mSubmit;
0397:            }
0398:
0399:            /**
0400:             * Returns the VDS properties that were set by the user.
0401:             *
0402:             * @return  List of <code>NameValue</code> objects each corresponding to a
0403:             *          property key and value.
0404:             */
0405:            public List getVDSProperties() {
0406:                return mVDSProps;
0407:            }
0408:
0409:            /**
0410:             * Returns the VO Group to which the user belongs
0411:             *
0412:             * @return VOGroup
0413:             */
0414:            public String getVOGroup() {
0415:                return mVOGroup;
0416:            }
0417:
0418:            /**
0419:             * Returns the base submit directory
0420:             *
0421:             * @return the path to the directory.
0422:             */
0423:            public String getBaseSubmitDirectory() {
0424:                return mBaseDir;
0425:            }
0426:
0427:            /**
0428:             * Returns the relative submit directory.
0429:             *
0430:             * @return the relative submit directory
0431:             */
0432:            public String getRelativeSubmitDirectory() {
0433:                return mRelativeDir;
0434:
0435:                //        return ( mBaseDir == null ) ?
0436:                //                 mSubmitFileDir:
0437:                //                 mSubmitFileDir.substring( mBaseDir.length() );
0438:            }
0439:
0440:            /**
0441:             * Returns the path to the directory where the submit files are to be
0442:             * generated.
0443:             *
0444:             * @return the path to the directory.
0445:             */
0446:            public String getSubmitDirectory() {
0447:                return (mRelativeDir == null) ? new File(mBaseDir)
0448:                        .getAbsolutePath() : new File(mBaseDir, mRelativeDir)
0449:                        .getAbsolutePath();
0450:            }
0451:
0452:            /**
0453:             * Sets the authenticate flag to the value passed.
0454:             *
0455:             * @param value  boolean value passed.
0456:             */
0457:            public void setAuthentication(boolean value) {
0458:                mAuthenticate = value;
0459:            }
0460:
0461:            /**
0462:             * Sets the basename prefix for the per workflow files.
0463:             *
0464:             * @param prefix  the prefix to be set.
0465:             */
0466:            public void setBasenamePrefix(String prefix) {
0467:                mBasenamePrefix = prefix;
0468:            }
0469:
0470:            /**
0471:             * Sets the flag to denote that the optional argument for the random was
0472:             * specified.
0473:             *
0474:             * @param value boolean indicating whether the optional argument was given
0475:             *              or not.
0476:             */
0477:            public void setOptionalArg(boolean value) {
0478:                this .mOptArg = value;
0479:            }
0480:
0481:            /**
0482:             * Returns the flag to denote whether the optional argument for the random was
0483:             * specified or not.
0484:             *
0485:             * @return boolean indicating whether the optional argument was supplied or not.
0486:             */
0487:            public boolean optionalArgSet() {
0488:                return this .mOptArg;
0489:            }
0490:
0491:            /**
0492:             * Sets the flag to denote whether we want to monitor the workflow or not.
0493:             *
0494:             * @param value boolean.
0495:             */
0496:            public void setMonitoring(boolean value) {
0497:                this .mMonitor = value;
0498:            }
0499:
0500:            /**
0501:             * Returns boolean indicating whether we want to monitor or not.
0502:             *
0503:             * @return boolean indicating whether monitoring was set or not.
0504:             */
0505:            public boolean monitorWorkflow() {
0506:                return this .mMonitor;
0507:            }
0508:
0509:            /**
0510:             * Sets the partitioning type in case of partition and plan.
0511:             *
0512:             * @param type   the type of partitioning technique
0513:             */
0514:            public void setPartitioningType(String type) {
0515:                mPartitioningType = type;
0516:            }
0517:
0518:            /**
0519:             * Returns the partitioning type in case of partition and plan.
0520:             *
0521:             * @return   the type of partitioning technique
0522:             */
0523:            public String getPartitioningType() {
0524:                return mPartitioningType;
0525:            }
0526:
0527:            /**
0528:             * Sets the flag to denote that the run is part of a larger deferred run.
0529:             *
0530:             * @param value the value
0531:             */
0532:            public void setPartOfDeferredRun(boolean value) {
0533:                mDeferredRun = value;
0534:            }
0535:
0536:            /**
0537:             * Returns a boolean indicating whether this invocation is part of a
0538:             * deferred execution or not.
0539:             *
0540:             * @return boolean
0541:             */
0542:            public boolean partOfDeferredRun() {
0543:                return mDeferredRun;
0544:            }
0545:
0546:            /**
0547:             * Sets the caches files. If cache files have been already specified it
0548:             * adds to the existing set of files. It also sanitizes the paths. Tries
0549:             * to resolve the path, if the path given is relative instead of absolute.
0550:             *
0551:             * @param cacheList  comma separated list of cache files.
0552:             */
0553:            public void setCacheFiles(String cacheList) {
0554:                this .setCacheFiles(this .generateSet(cacheList));
0555:            }
0556:
0557:            /**
0558:             * Sets the caches files. If cache files have been already specified it
0559:             * adds to the existing set of files. It also sanitizes the paths. Tries
0560:             * to resolve the path, if the path given is relative instead of absolute.
0561:             *
0562:             * @param files  the set of fully qualified paths to the cache files.
0563:             *
0564:             */
0565:            public void setCacheFiles(Set files) {
0566:                //use the existing set if present
0567:                if (mCacheFiles == null) {
0568:                    mCacheFiles = new HashSet();
0569:                }
0570:
0571:                //traverse through each file in the set, and
0572:                //sanitize path along the way.
0573:                for (Iterator it = files.iterator(); it.hasNext();) {
0574:                    mCacheFiles.add(this .sanitizePath((String) it.next()));
0575:                }
0576:            }
0577:
0578:            /**
0579:             * Sets the clustering option.
0580:             *
0581:             * @param value  the value to set.
0582:             */
0583:            public void setClusteringTechnique(String value) {
0584:                mClusterer = value;
0585:            }
0586:
0587:            /**
0588:             * Sets the DAX that has to be worked on by the planner.
0589:             *
0590:             * @param dax  the path to the DAX file.
0591:             */
0592:            public void setDAX(String dax) {
0593:                dax = sanitizePath(dax);
0594:                mDAXFile = dax;
0595:            }
0596:
0597:            /**
0598:             * Sets the names of the execution sites where the concrete workflow can
0599:             * be run.
0600:             *
0601:             * @param siteList  comma separated list of sites.
0602:             */
0603:            public void setExecutionSites(String siteList) {
0604:
0605:                mvExecPools = this .generateSet(siteList);
0606:            }
0607:
0608:            /**
0609:             * Sets the names of the execution sites where the concrete workflow can
0610:             * be run.
0611:             *
0612:             * @param sites  <code>Collection</code> of execution site names.
0613:             */
0614:            public void setExecutionSites(Collection sites) {
0615:                mvExecPools = new HashSet(sites);
0616:            }
0617:
0618:            /**
0619:             * Sets the force option for the planner.
0620:             *
0621:             * @param force  boolean value.
0622:             */
0623:            public void setForce(boolean force) {
0624:                mForce = force;
0625:            }
0626:
0627:            /**
0628:             * Sets the cleanup option for the planner.
0629:             *
0630:             * @param cleanup  boolean value.
0631:             */
0632:            public void setCleanup(boolean cleanup) {
0633:                mCleanup = cleanup;
0634:            }
0635:
0636:            /**
0637:             * Sets the help option for the planner.
0638:             *
0639:             * @param help boolean value.
0640:             */
0641:            public void setHelp(boolean help) {
0642:                mDisplayHelp = help;
0643:            }
0644:
0645:            /**
0646:             * Sets the logging level for logging of messages.
0647:             *
0648:             * @param level the logging level.
0649:             */
0650:            public void setLoggingLevel(String level) {
0651:                mLoggingLevel = (level != null && level.length() > 0) ?
0652:                //the value that was passed by the user
0653:                new Integer(level).intValue()
0654:                        :
0655:                        //by default not setting it to 0,
0656:                        //but to 1, as --verbose is an optional
0657:                        //argument
0658:                        1;
0659:            }
0660:
0661:            /**
0662:             * Sets the megadag generation option
0663:             *
0664:             * @param mode the mode.
0665:             */
0666:            public void setMegaDAGMode(String mode) {
0667:                this .mMegadag = mode;
0668:            }
0669:
0670:            /**
0671:             * Sets the PDAX that has to be worked on by the planner.
0672:             *
0673:             * @param pdax  the path to the PDAX file.
0674:             */
0675:            public void setPDAX(String pdax) {
0676:                pdax = sanitizePath(pdax);
0677:                mPDAXFile = pdax;
0678:            }
0679:
0680:            /**
0681:             * Sets the output site specified by the user.
0682:             *
0683:             * @param site the output site.
0684:             */
0685:            public void setOutputSite(String site) {
0686:                mOutputPool = site;
0687:            }
0688:
0689:            /**
0690:             * Sets the random directory in which the jobs are run.
0691:             *
0692:             * @param dir  the basename of the random directory.
0693:             */
0694:            public void setRandomDir(String dir) {
0695:                //setting the genRandomDir option to true also
0696:                mGenRandomDir = true;
0697:                mRandomDirName = dir;
0698:                if (dir != null && dir.length() > 0)
0699:                    //set the flag to denote that optional arg was given
0700:                    setOptionalArg(true);
0701:            }
0702:
0703:            /**
0704:             * Returns whether to submit the workflow or not.
0705:             *
0706:             * @param submit boolean indicating whether to submit or not.
0707:             */
0708:            public void setSubmitToScheduler(boolean submit) {
0709:                mSubmit = submit;
0710:            }
0711:
0712:            /**
0713:             * Sets the path to the directory where the submit files are to be
0714:             * generated.
0715:             *
0716:             * @param dir the path to the directory.
0717:             */
0718:            public void setSubmitDirectory(String dir) {
0719:                this .setSubmitDirectory(dir, null);
0720:            }
0721:
0722:            /**
0723:             * Sets the path to the directory where the submit files are to be
0724:             * generated.
0725:             *
0726:             * @param dir the path to the directory.
0727:             */
0728:            public void setSubmitDirectory(File dir) {
0729:                this .setSubmitDirectory(dir.getAbsolutePath(), null);
0730:            }
0731:
0732:            /**
0733:             * Sets the path to the directory where the submit files are to be
0734:             * generated.
0735:             *
0736:             * @param base       the path to the base directory.
0737:             * @param relative   the directory relative to the base where submit files are generated.
0738:             */
0739:            public void setSubmitDirectory(String base, String relative) {
0740:                base = sanitizePath(base);
0741:                /*
0742:                mSubmitFileDir = ( relative == null )?
0743:                                 new File( base ).getAbsolutePath():
0744:                                 new File( base, relative ).getAbsolutePath();
0745:                 */
0746:                mRelativeDir = relative;
0747:                mBaseDir = base;
0748:            }
0749:
0750:            /**
0751:             * Sets the path to the directory where the submit files are to be
0752:             * generated.
0753:             *
0754:             * @param relative   the directory relative to the base where submit files are generated.
0755:             */
0756:            public void setRelativeSubmitDirectory(String relative) {
0757:                mRelativeDir = relative;
0758:            }
0759:
0760:            /**
0761:             * Sets the VDS properties specifed by the user at the command line.
0762:             *
0763:             * @param properties  List of <code>NameValue</code> objects.
0764:             */
0765:            public void setVDSProperties(List properties) {
0766:                mVDSProps = properties;
0767:            }
0768:
0769:            /**
0770:             * Set the VO Group to which the user belongs
0771:             *
0772:             * @param group  the VOGroup
0773:             */
0774:            public void setVOGroup(String group) {
0775:                mVOGroup = group;
0776:            }
0777:
0778:            /**
0779:             * Returns the textual description of all the options that were set for
0780:             * the planner.
0781:             *
0782:             * @return the textual description.
0783:             */
0784:            public String toString() {
0785:                String st = "\n" + "\n Concrete Planner Options"
0786:                        + "\n Base Submit Directory "
0787:                        + mBaseDir
0788:                        + "\n SubmitFile Directory "
0789:                        + this .getSubmitDirectory()
0790:                        + "\n Basename Prefix      "
0791:                        + mBasenamePrefix
0792:                        + "\n Abstract Dag File    "
0793:                        + mDAXFile
0794:                        + "\n Partition File       "
0795:                        + mPDAXFile
0796:                        + "\n Execution Pools      "
0797:                        + this .setToString(mvExecPools, ",")
0798:                        + "\n Cache Files          "
0799:                        + this .setToString(mCacheFiles, ",")
0800:                        + "\n Output Pool          "
0801:                        + mOutputPool
0802:                        + "\n Submit to CondorG    "
0803:                        + mSubmit
0804:                        + "\n Display Help         "
0805:                        + mDisplayHelp
0806:                        + "\n Logging Level        "
0807:                        + mLoggingLevel
0808:                        + "\n Force Option         "
0809:                        + mForce
0810:                        + "\n Cleanup within wf    "
0811:                        + mCleanup
0812:                        + "\n Create Random Direct "
0813:                        + mGenRandomDir
0814:                        + "\n Random Direct Name   "
0815:                        + mRandomDirName
0816:                        + "\n Authenticate         "
0817:                        + mAuthenticate
0818:                        + "\n Clustering Technique "
0819:                        + mClusterer
0820:                        + "\n Monitor Workflow     "
0821:                        + mMonitor
0822:                        + "\n VO Group             "
0823:                        + mVOGroup
0824:                        + "\n VDS Properties       " + mVDSProps;
0825:                return st;
0826:            }
0827:
0828:            /**
0829:             * Generates the argument string corresponding to these options that can
0830:             * be used to invoke Pegasus. During its generation it ignores the
0831:             * dax and pdax options as they are specified elsewhere.
0832:             *
0833:             * @return all the options in a String separated by whitespace.
0834:             */
0835:            public String toOptions() {
0836:                StringBuffer sb = new StringBuffer();
0837:
0838:                //the submit file dir
0839:                //        if( mSubmitFileDir != null){ sb.append(" --dir ").append(mSubmitFileDir);}
0840:                //confirm how this plays in deferred planning. not clear. Karan Oct 31 2007
0841:                sb.append(" --dir ").append(this .getBaseSubmitDirectory());
0842:                if (mRelativeDir != null) {
0843:                    sb.append(" --relative-dir ").append(
0844:                            this .getRelativeSubmitDirectory());
0845:                }
0846:
0847:                //the basename prefix
0848:                if (mBasenamePrefix != null) {
0849:                    sb.append(" --basename ").append(mBasenamePrefix);
0850:                }
0851:
0852:                if (!mvExecPools.isEmpty()) {
0853:                    sb.append(" --sites ");
0854:                    //generate the comma separated string
0855:                    //for the execution pools
0856:                    sb.append(setToString(mvExecPools, ","));
0857:                }
0858:
0859:                //cache files
0860:                if (!mCacheFiles.isEmpty()) {
0861:                    sb.append(" --cache ")
0862:                            .append(setToString(mCacheFiles, ","));
0863:                }
0864:
0865:                //collapse option
0866:                if (mClusterer != null) {
0867:                    sb.append(" --cluster ").append(mClusterer);
0868:                }
0869:
0870:                //specify the output pool
0871:                if (mOutputPool != null) {
0872:                    sb.append(" --output ").append(mOutputPool);
0873:                }
0874:
0875:                //the condor submit option
0876:                if (mSubmit) {
0877:                    sb.append(" --run ");
0878:                }
0879:
0880:                //the force option
0881:                if (mForce) {
0882:                    sb.append(" --force ");
0883:                }
0884:
0885:                //the cleanup option
0886:                if (!mCleanup) {
0887:                    sb.append(" --nocleanup ");
0888:                }
0889:
0890:                //the verbose option
0891:                for (int i = 0; i < getLoggingLevel(); i++)
0892:                    sb.append(" --verbose ");
0893:
0894:                //the monitor option
0895:                if (mMonitor) {
0896:                    sb.append(" --monitor ");
0897:                }
0898:
0899:                //the deferred run option
0900:                if (mDeferredRun) {
0901:                    sb.append(" --deferred ");
0902:                }
0903:
0904:                //the random directory
0905:                if (mGenRandomDir) {
0906:                    //an optional argument
0907:                    sb.append(" --randomdir");
0908:                    if (this .getRandomDir() == null) {
0909:                        //no argument to be given
0910:                        sb.append(" ");
0911:                    } else {
0912:                        //add the optional argument
0913:                        sb.append("=").append(getRandomDir());
0914:                    }
0915:                }
0916:
0917:                //the authenticate option
0918:                if (mAuthenticate) {
0919:                    sb.append(" --authenticate");
0920:                }
0921:
0922:                //specify the megadag option if set
0923:                if (mMegadag != null) {
0924:                    sb.append(" --megadag ").append(mMegadag);
0925:                }
0926:
0927:                //specify the vogroup
0928:                sb.append(" --group ").append(mVOGroup);
0929:
0930:                //help option
0931:                if (mDisplayHelp) {
0932:                    sb.append(" --help ");
0933:                }
0934:
0935:                return sb.toString();
0936:            }
0937:
0938:            /**
0939:             * Converts the vds properties that need to be passed to the jvm as an
0940:             * option.
0941:             *
0942:             * @return the jvm options as String.
0943:             */
0944:            public String toJVMOptions() {
0945:                StringBuffer sb = new StringBuffer();
0946:
0947:                Iterator it = (mVDSProps == null) ? null : mVDSProps.iterator();
0948:
0949:                if (it != null) {
0950:                    while (it.hasNext()) {
0951:                        NameValue nv = (NameValue) it.next();
0952:                        sb.append(" -D").append(nv.getKey()).append("=")
0953:                                .append(nv.getValue());
0954:                    }
0955:                }
0956:
0957:                return sb.toString();
0958:            }
0959:
0960:            /**
0961:             * Clones a Set.
0962:             *
0963:             * @param s Set
0964:             *
0965:             * @return  the cloned set as a HashSet
0966:             */
0967:            private Set cloneSet(Set s) {
0968:                java.util.Iterator it = s.iterator();
0969:                Set newSet = new java.util.HashSet();
0970:
0971:                while (it.hasNext()) {
0972:                    newSet.add(it.next());
0973:                }
0974:
0975:                return newSet;
0976:            }
0977:
0978:            /**
0979:             * Returns a new copy of the Object. The clone does not clone the internal
0980:             * VDS properties at the moment.
0981:             *
0982:             * @return the cloned copy.
0983:             */
0984:            public Object clone() {
0985:                PlannerOptions pOpt = null;
0986:
0987:                try {
0988:                    pOpt = (PlannerOptions) super .clone();
0989:                } catch (CloneNotSupportedException e) {
0990:                    //somewhere in the hierarch chain clone is not implemented
0991:                    mLogger.log("Clone not implemented in the base class of "
0992:                            + this .getClass().getName(),
0993:                            LogManager.WARNING_MESSAGE_LEVEL);
0994:                    //try calling the constructor directly
0995:                    pOpt = new PlannerOptions();
0996:                }
0997:                //        pOpt.mSubmitFileDir  = this.mSubmitFileDir;
0998:                pOpt.mBaseDir = this .mBaseDir;
0999:                pOpt.mRelativeDir = this .mRelativeDir;
1000:                pOpt.mDAXFile = this .mDAXFile;
1001:                pOpt.mPDAXFile = this .mPDAXFile;
1002:                pOpt.mvExecPools = cloneSet(this .mvExecPools);
1003:                pOpt.mCacheFiles = cloneSet(this .mCacheFiles);
1004:                pOpt.mOutputPool = this .mOutputPool;
1005:                pOpt.mDisplayHelp = this .mDisplayHelp;
1006:                pOpt.mLoggingLevel = this .mLoggingLevel;
1007:                pOpt.mForce = this .mForce;
1008:                pOpt.mCleanup = this .mCleanup;
1009:                pOpt.mSubmit = this .mSubmit;
1010:                pOpt.mGenRandomDir = this .mGenRandomDir;
1011:                pOpt.mOptArg = this .mOptArg;
1012:                pOpt.mMonitor = this .mMonitor;
1013:                pOpt.mRandomDirName = this .mRandomDirName;
1014:                pOpt.mAuthenticate = this .mAuthenticate;
1015:                pOpt.mClusterer = this .mClusterer;
1016:                pOpt.mBasenamePrefix = this .mBasenamePrefix;
1017:                pOpt.mVOGroup = this .mVOGroup;
1018:                pOpt.mDeferredRun = this .mDeferredRun;
1019:                pOpt.mDate = (Date) this .mDate.clone();
1020:                pOpt.mPartitioningType = this .mPartitioningType;
1021:                //Note not cloning the vdsProps
1022:                pOpt.mVDSProps = null;
1023:                return pOpt;
1024:            }
1025:
1026:            /**
1027:             * Generates a Set by parsing a comma separated string.
1028:             *
1029:             * @param str   the comma separted String.
1030:             *
1031:             * @return Set containing the parsed values, in case of a null string
1032:             *             an empty set is returned.
1033:             */
1034:            private Set generateSet(String str) {
1035:                Set s = new HashSet();
1036:
1037:                //check for null
1038:                if (s == null) {
1039:                    return s;
1040:                }
1041:
1042:                for (StringTokenizer st = new StringTokenizer(str, ","); st
1043:                        .hasMoreElements();) {
1044:                    s.add(st.nextToken().trim());
1045:                }
1046:
1047:                return s;
1048:            }
1049:
1050:            /**
1051:             * A small utility method that santizes the url, converting it from
1052:             * relative to absolute. In case the path is relative, it uses the
1053:             * System property user.dir to get the current working directory, from
1054:             * where the planner is being run.
1055:             *
1056:             * @param path the absolute or the relative path.
1057:             *
1058:             * @return the absolute path.
1059:             */
1060:            private String sanitizePath(String path) {
1061:                if (path == null) {
1062:                    return null;
1063:                }
1064:                String absPath;
1065:                char separator = File.separatorChar;
1066:
1067:                absPath = (path.indexOf(separator) == 0) ?
1068:                //absolute path given already
1069:                path
1070:                        :
1071:                        //get the current working dir
1072:                        System.getProperty("user.dir")
1073:                                + separator
1074:                                + ((path.indexOf('.') == 0) ? //path starts with a . ?
1075:                                ((path.indexOf(separator) == 1) ? //path starts with a ./ ?
1076:                                path.substring(2)
1077:                                        : (path.length() > 1 && path.charAt(1) == '.') ? //path starts with .. ?
1078:                                        path
1079:                                                : //keep path as it is
1080:                                                path.substring(path
1081:                                                        .indexOf('.') + 1))
1082:                                        : path);
1083:
1084:                //remove trailing separator if any
1085:                absPath = (absPath.lastIndexOf(separator) == absPath.length() - 1) ? absPath
1086:                        .substring(0, absPath.length() - 1)
1087:                        : absPath;
1088:
1089:                return absPath;
1090:            }
1091:
1092:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.