Source Code Cross Referenced for Local.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » selector » replica » 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.selector.replica 
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.selector.replica;
015:
016:        import org.griphyn.cPlanner.classes.ReplicaLocation;
017:
018:        import org.griphyn.cPlanner.selector.ReplicaSelector;
019:
020:        import org.griphyn.cPlanner.common.LogManager;
021:        import org.griphyn.cPlanner.common.PegasusProperties;
022:        import org.griphyn.cPlanner.common.PegRandom;
023:
024:        import org.griphyn.common.catalog.ReplicaCatalogEntry;
025:
026:        import java.util.ArrayList;
027:        import java.util.Iterator;
028:        import java.util.Vector;
029:
030:        /**
031:         * This replica selector only prefers replicas from the local host and that
032:         * start with a file: URL scheme. It is useful, when you want to stagin
033:         * files to a remote site from your submit host using the Condor file transfer
034:         * mechanism.
035:         *
036:         * <p>
037:         * In order to use the replica selector implemented by this class,
038:         * <pre>
039:         *        - the property pegasus.selector.replica must be set to value Local
040:         * </pre>
041:         *
042:         *
043:         * @see org.griphyn.cPlanner.transfer.implementation.Condor
044:         *
045:         * @author Karan Vahi
046:         * @version $Revision: 408 $
047:         */
048:        public class Local implements  ReplicaSelector {
049:
050:            /**
051:             * A short description of the replica selector.
052:             */
053:            private static String mDescription = "Local from submit host";
054:
055:            /**
056:             * The scheme name for file url.
057:             */
058:            protected static final String FILE_URL_SCHEME = "file:";
059:
060:            /**
061:             * The handle to the logging object that is used to log the various debug
062:             * messages.
063:             */
064:            protected LogManager mLogger;
065:
066:            /**
067:             * The properties object containing the properties passed to the planner.
068:             */
069:            protected PegasusProperties mProps;
070:
071:            /**
072:             * The overloaded constructor, that is called by load method.
073:             *
074:             * @param properties the <code>PegasusProperties</code> object containing all
075:             *                   the properties required by Pegasus.
076:             *
077:             *
078:             */
079:            public Local(PegasusProperties properties) {
080:                mProps = properties;
081:                mLogger = LogManager.getInstance();
082:            }
083:
084:            /**
085:             * Selects a random replica from all the replica's that have their
086:             * site handle set to local and the pfn's start with a file url scheme.
087:             *
088:             * @param rl         the <code>ReplicaLocation</code> object containing all
089:             *                   the pfn's associated with that LFN.
090:             * @param preferredSite the preffered site for picking up the replicas.
091:             *
092:             * @return <code>ReplicaCatalogEntry</code> corresponding to the location selected.
093:             *
094:             * @see org.griphyn.cPlanner.classes.ReplicaLocation
095:             */
096:            public ReplicaCatalogEntry selectReplica(ReplicaLocation rl,
097:                    String preferredSite) {
098:
099:                ReplicaCatalogEntry rce;
100:                ArrayList prefPFNs = new ArrayList();
101:                int locSelected;
102:                String site = null;
103:
104:                //        mLogger.log("Selecting a pfn for lfn " + lfn + "\n amongst" + locations ,
105:                //                    LogManager.DEBUG_MESSAGE_LEVEL);
106:
107:                for (Iterator it = rl.pfnIterator(); it.hasNext();) {
108:                    rce = (ReplicaCatalogEntry) it.next();
109:                    site = rce.getResourceHandle();
110:
111:                    if (site == null) {
112:                        //skip to next replica
113:                        continue;
114:                    }
115:
116:                    //check if has pool attribute as local, and at same time
117:                    //start with a file url scheme
118:                    if (site.equals("local")
119:                            && rce.getPFN().startsWith(FILE_URL_SCHEME)) {
120:                        prefPFNs.add(rce);
121:                    }
122:                }
123:
124:                if (prefPFNs.isEmpty()) {
125:                    //select a random location from
126:                    //all the matching locations
127:                    //in all likelihood all the urls were file urls and none
128:                    //were associated with the preference pool.
129:                    throw new RuntimeException(
130:                            "Unable to select any location on local site from "
131:                                    + "the list passed for lfn " + rl.getLFN());
132:
133:                } else {
134:                    //select a random location
135:                    //amongst the locations
136:                    //on the preference pool
137:                    int length = prefPFNs.size();
138:                    //System.out.println("No of locations found at pool " + prefPool + " are " + length);
139:                    locSelected = PegRandom.getInteger(length - 1);
140:                    rce = (ReplicaCatalogEntry) prefPFNs.get(locSelected);
141:
142:                }
143:
144:                return rce;
145:
146:            }
147:
148:            /**
149:             * This chooses a location amongst all the locations returned by the
150:             * Replica Mechanism. If a location is found with re/pool attribute same
151:             * as the preference pool, it is taken. This returns all the locations which
152:             * match to the preference pool. This function is called to determine if a
153:             * file does exist on the output pool or not beforehand. We need all the
154:             * location to ensure that we are able to make a match if it so exists.
155:             * Else a random location is selected and returned
156:             *
157:             * @param rl         the <code>ReplicaLocation</code> object containing all
158:             *                   the pfn's associated with that LFN.
159:             * @param preferredSite the preffered site for picking up the replicas.
160:             *
161:             * @return <code>ReplicaLocation</code> corresponding to the replicas selected.
162:             *
163:             * @see org.griphyn.cPlanner.classes.ReplicaLocation
164:             */
165:            public ReplicaLocation selectReplicas(ReplicaLocation rl,
166:                    String preferredSite) {
167:
168:                String lfn = rl.getLFN();
169:                ReplicaLocation result = new ReplicaLocation();
170:                result.setLFN(rl.getLFN());
171:
172:                ReplicaCatalogEntry rce;
173:                String site;
174:                int noOfLocs = 0;
175:
176:                for (Iterator it = rl.pfnIterator(); it.hasNext();) {
177:                    noOfLocs++;
178:                    rce = (ReplicaCatalogEntry) it.next();
179:                    site = rce.getResourceHandle();
180:
181:                    if (site != null && site.equals(preferredSite)) {
182:                        result.addPFN(rce);
183:                    } else if (site == null) {
184:                        mLogger.log(
185:                                " pool attribute not specified for the location objects"
186:                                        + " in the Replica Catalog",
187:                                LogManager.WARNING_MESSAGE_LEVEL);
188:                    }
189:                }
190:
191:                if (result.getPFNCount() == 0) {
192:                    //means we have to choose a random location between 0 and (noOfLocs -1)
193:                    int locSelected = PegRandom.getInteger(noOfLocs - 1);
194:                    rce = (ReplicaCatalogEntry) rl.getPFN(locSelected);
195:                    result.addPFN(rce);
196:                }
197:                return result;
198:
199:            }
200:
201:            /**
202:             * Returns a short description of the replica selector.
203:             *
204:             * @return string corresponding to the description.
205:             */
206:            public String description() {
207:                return mDescription;
208:            }
209:
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.