Source Code Cross Referenced for RM.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » engine » cleanup » 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.engine.cleanup 
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.engine.cleanup;
015:
016:        import org.griphyn.cPlanner.classes.SubInfo;
017:        import org.griphyn.cPlanner.classes.PlannerOptions;
018:        import org.griphyn.cPlanner.classes.PegasusFile;
019:        import org.griphyn.cPlanner.classes.SiteInfo;
020:
021:        import org.griphyn.cPlanner.common.PegasusProperties;
022:
023:        import org.griphyn.cPlanner.namespace.Condor;
024:
025:        import org.griphyn.cPlanner.poolinfo.PoolInfoProvider;
026:        import org.griphyn.cPlanner.poolinfo.SiteFactory;
027:        import org.griphyn.cPlanner.poolinfo.SiteFactoryException;
028:
029:        import org.griphyn.common.catalog.TransformationCatalog;
030:        import org.griphyn.common.catalog.TransformationCatalogEntry;
031:
032:        import org.griphyn.common.catalog.transformation.TransformationFactory;
033:        import org.griphyn.common.catalog.transformation.TransformationFactoryException;
034:
035:        import org.griphyn.common.classes.TCType;
036:
037:        import java.util.List;
038:        import java.util.Iterator;
039:        import java.util.HashSet;
040:
041:        /**
042:         * Use's RM to do removal of the files on the remote sites.
043:         *
044:         * @author Karan Vahi
045:         * @version $Revision: 50 $
046:         */
047:        public class RM implements  Implementation {
048:
049:            /**
050:             * The default logical name to rm executable.
051:             */
052:            public static final String DEFAULT_RM_LOGICAL_NAME = "rm";
053:
054:            /**
055:             * The default path to rm executable.
056:             */
057:            public static final String DEFAULT_RM_LOCATION = "/bin/rm";
058:
059:            /**
060:             * The default priority key associated with the cleanup jobs.
061:             */
062:            public static final String DEFAULT_PRIORITY_KEY = "1000";
063:
064:            /**
065:             * The handle to the transformation catalog.
066:             */
067:            protected TransformationCatalog mTCHandle;
068:
069:            /**
070:             * Handle to the site catalog.
071:             */
072:            protected PoolInfoProvider mSiteHandle;
073:
074:            /**
075:             * The handle to the properties passed to Pegasus.
076:             */
077:            private PegasusProperties mProps;
078:
079:            /**
080:             * Creates a new instance of InPlace
081:             *
082:             * @param properties  the properties passed to the planner.
083:             * @param options     the options passed to the planner.
084:             *
085:             */
086:            public RM(PegasusProperties properties, PlannerOptions options) {
087:                mProps = properties;
088:
089:                /* load the site catalog using the factory */
090:                try {
091:                    mSiteHandle = SiteFactory.loadInstance(properties, false);
092:                } catch (SiteFactoryException e) {
093:                    throw new RuntimeException("Unable to load Site Catalog "
094:                            + e.convertException(), e);
095:                }
096:
097:                /* load the transformation catalog using the factory */
098:                try {
099:                    mTCHandle = TransformationFactory.loadInstance(properties);
100:                } catch (TransformationFactoryException e) {
101:                    throw new RuntimeException(
102:                            "Unable to load Transformation Catalog "
103:                                    + e.convertException(), e);
104:                }
105:
106:            }
107:
108:            /**
109:             * Creates a cleanup job that removes the files from remote working directory.
110:             * This will eventually make way to it's own interface.
111:             *
112:             * @param id         the identifier to be assigned to the job.
113:             * @param files      the list of <code>PegasusFile</code> that need to be
114:             *                   cleaned up.
115:             * @param job        the primary compute job with which this cleanup job is associated.
116:             *
117:             * @return the cleanup job.
118:             */
119:            public SubInfo createCleanupJob(String id, List files, SubInfo job) {
120:
121:                //we want to run the clnjob in the same directory
122:                //as the compute job. So we clone.
123:                SubInfo cJob = (SubInfo) job.clone();
124:                cJob.setJobType(SubInfo.CLEANUP_JOB);
125:                cJob.setName(id);
126:                cJob.setSiteHandle(job.getSiteHandle());
127:
128:                //inconsistency between job name and logical name for now
129:                cJob.setTXVersion(null);
130:                cJob.setTXName("rm");
131:                cJob.setTXNamespace(null);
132:                cJob.setLogicalID(id);
133:
134:                //the compute job of the VDS supernode is this job itself
135:                cJob.setVDSSuperNode(job.getID());
136:
137:                //set the list of files as input files
138:                //to change function signature to reflect a set only.
139:                cJob.setInputFiles(new HashSet(files));
140:
141:                //set the path to the rm executable
142:                TransformationCatalogEntry entry = this .getTCEntry(job
143:                        .getSiteHandle());
144:                cJob.setRemoteExecutable(entry.getPhysicalTransformation());
145:
146:                //set the arguments for the cleanup job
147:                StringBuffer arguments = new StringBuffer();
148:                for (Iterator it = files.iterator(); it.hasNext();) {
149:                    PegasusFile file = (PegasusFile) it.next();
150:                    arguments.append(" ").append(file.getLFN());
151:                }
152:                cJob.setArguments(arguments.toString());
153:
154:                //the cleanup job is a clone of compute
155:                //need to reset the profiles first
156:                cJob.resetProfiles();
157:
158:                //the profile information from the pool catalog needs to be
159:                //assimilated into the job.
160:                cJob.updateProfiles(mSiteHandle.getPoolProfile(job
161:                        .getSiteHandle()));
162:
163:                //the profile information from the transformation
164:                //catalog needs to be assimilated into the job
165:                //overriding the one from pool catalog.
166:                cJob.updateProfiles(entry);
167:
168:                //the profile information from the properties file
169:                //is assimilated overidding the one from transformation
170:                //catalog.
171:                cJob.updateProfiles(mProps);
172:
173:                //let us put some priority for the cleaunup jobs
174:                cJob.condorVariables.construct(Condor.PRIORITY_KEY,
175:                        DEFAULT_PRIORITY_KEY);
176:
177:                return cJob;
178:            }
179:
180:            /**
181:             * Returns the TCEntry object for the rm executable on a grid site.
182:             *
183:             * @param site the site corresponding to which the entry is required.
184:             *
185:             * @return  the TransformationCatalogEntry corresponding to the site.
186:             */
187:            protected TransformationCatalogEntry getTCEntry(String site) {
188:                List tcentries = null;
189:                TransformationCatalogEntry entry = null;
190:                try {
191:                    tcentries = mTCHandle.getTCEntries(null,
192:                            DEFAULT_RM_LOGICAL_NAME, null, site,
193:                            TCType.INSTALLED);
194:                } catch (Exception e) { /* empty catch */
195:                }
196:
197:                //see if any record is returned or not
198:                entry = (tcentries == null) ? defaultTCEntry()
199:                        : (TransformationCatalogEntry) tcentries.get(0);
200:
201:                return entry;
202:
203:            }
204:
205:            /**
206:             * Returns a default TransformationCatalogEntry object for the rm executable.
207:             *
208:             * @return default <code>TransformationCatalogEntry</code>
209:             */
210:            private static TransformationCatalogEntry defaultTCEntry() {
211:                TransformationCatalogEntry entry = new TransformationCatalogEntry(
212:                        null, DEFAULT_RM_LOGICAL_NAME, null);
213:                entry.setPhysicalTransformation(DEFAULT_RM_LOCATION);
214:
215:                return entry;
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.