Source Code Cross Referenced for TCMap.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) 


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.cPlanner.classes;
017:
018:        import org.griphyn.cPlanner.common.LogManager;
019:        import org.griphyn.common.catalog.TransformationCatalogEntry;
020:
021:        import java.util.ArrayList;
022:        import java.util.HashMap;
023:        import java.util.HashSet;
024:        import java.util.Iterator;
025:        import java.util.List;
026:        import java.util.Map;
027:        import java.util.Set;
028:
029:        /**
030:         * This is a data class to store the TCMAP for a particular dag.
031:         * This data class is populated and maintained in the TCMapper and is queried
032:         * from the Interpool Engine and site selectors.
033:         *
034:         *  The TCMAP is a hashmap which maps an lfn to a Map which contains keys as
035:         * siteids and values as  List of TransformationCatalogEntry objects
036:         *
037:         * TCMAP= lfn1 ---> MAP1
038:         *        lfn2 ---> MAP2
039:         *
040:         *
041:         * MAP1 = site1 ---> List1
042:         *        site2 ---> List2
043:         *
044:         * List1 = TCE1
045:         *         TCE2
046:         *         TCEn
047:         *
048:         *
049:         * @author Gaurang Mehta
050:         * @version $Revision: 50 $
051:         */
052:        public class TCMap {
053:
054:            /**
055:             * The TCMap for a dag is stored in this HashMap.
056:             */
057:            private Map mTCMap;
058:
059:            private LogManager mLogger;
060:
061:            /**
062:             * Default constructor. Initializes the tcmap to 10 lfns.
063:             */
064:            public TCMap() {
065:                mLogger = LogManager.getInstance();
066:                mTCMap = new HashMap(10);
067:            }
068:
069:            /**
070:             * Returns a HashMap of sites as keys and a List of TransformationCatalogEntry object as values.
071:             * @param fqlfn String The fully qualified logical transformation name for which you want the map.
072:             * @return Map Returns <B>NULL</B> if the transformation does not exist in the map.
073:             * @see org.griphyn.common.catalog.TransformationCatalogEntry
074:             */
075:            public Map getSiteMap(String fqlfn) {
076:                return mTCMap.containsKey(fqlfn) ? (Map) mTCMap.get(fqlfn)
077:                        : null;
078:            }
079:
080:            /**
081:             * This method allows to associate a site map with a particular logical transformation
082:             * @param fqlfn String The transformation for which the sitemap is to be stored
083:             * @param sitemap Map The sitemap that is to be stored. It is a hashmap with key
084:             *                     as the siteid and value as a list of TranformationCatalogEntry objects
085:             * @return boolean
086:             * @see org.griphyn.common.catalog.TransformationCatalogEntry
087:             */
088:            public boolean setSiteMap(String fqlfn, Map sitemap) {
089:                mTCMap.put(fqlfn, sitemap);
090:                return true;
091:            }
092:
093:            /**
094:             * Returns a List of siteid's that are valid for a particular lfn.
095:             * @param fqlfn String
096:             * @return List
097:             */
098:            public List getSiteList(String fqlfn) {
099:                List results = null;
100:                if (mTCMap.containsKey(fqlfn)) {
101:                    return new ArrayList(((Map) mTCMap.get(fqlfn)).keySet());
102:                }
103:                return results;
104:            }
105:
106:            /**
107:             * Returns a list of siteid's that are valid for a particular lfn and
108:             * among a list of input sites
109:             * @param fqlfn The logical name of the transformation
110:             * @param sites The list of siteids
111:             * @return the list of siteids which are valid.
112:             */
113:            public List getSiteList(String fqlfn, List sites) {
114:                List results = new ArrayList();
115:                if (mTCMap.containsKey(fqlfn)) {
116:                    for (Iterator i = ((Map) mTCMap.get(fqlfn)).keySet()
117:                            .iterator(); i.hasNext();) {
118:                        String site = (String) i.next();
119:                        if (sites.contains(site)) {
120:                            results.add(site);
121:                        }
122:                    }
123:                }
124:                return results.isEmpty() ? null : results;
125:            }
126:
127:            /**
128:             * This method returns a list of TransformationCatalogEntry objects
129:             * for a given transformation and siteid
130:             * @param fqlfn String The fully qualified logical name of the transformation
131:             * @param siteid String The siteid for which the Entries are required
132:             * @return List returns NULL if no entries exist.
133:             */
134:            public List getSiteTCEntries(String fqlfn, String siteid) {
135:                Map sitemap = null;
136:                List tcentries = null;
137:                if (mTCMap.containsKey(fqlfn)) {
138:                    sitemap = (Map) mTCMap.get(fqlfn);
139:                    if (sitemap.containsKey(siteid)) {
140:                        tcentries = (List) sitemap.get(siteid);
141:                    } else {
142:                        mLogger.log("The TCMap does not contain the site \""
143:                                + siteid + "\" for the transformation \""
144:                                + fqlfn + "\"", LogManager.DEBUG_MESSAGE_LEVEL);
145:                    }
146:                } else {
147:                    mLogger.log(
148:                            "The TCMap does not contain the transformation \""
149:                                    + fqlfn + "\"",
150:                            LogManager.DEBUG_MESSAGE_LEVEL);
151:                }
152:                return tcentries;
153:            }
154:
155:            /**
156:             * Retrieves all the entries matching a particular lfn for the sites
157:             * passed.
158:             *
159:             * @param fqlfn   the fully qualified logical name
160:             * @param sites the list of siteID's for which the entries are required.
161:             *
162:             * @return a map indexed by site names. Each value is a collection of
163:             * <code>TransformationCatalogEntry</code> objects. Returns null in case
164:             * of no entry being found.
165:             */
166:            public Map getSitesTCEntries(String fqlfn, List sites) {
167:                Map m = this .getSiteMap(fqlfn);
168:                Set siteIDS = new HashSet(sites);
169:                String site = null;
170:                if (m == null) {
171:                    return null;
172:                }
173:
174:                Map result = new HashMap(siteIDS.size());
175:                for (Iterator it = m.keySet().iterator(); it.hasNext();) {
176:                    site = (String) it.next();
177:                    if (siteIDS.contains(site)) {
178:                        result.put(site, m.get(site));
179:                    }
180:                }
181:
182:                //returning NULL only to maintain semantics
183:                //for rest of mapper operations. Gaurang
184:                //should change to return empty map
185:                return result.isEmpty() ? null : result;
186:            }
187:
188:            /**
189:             * This method allows to add a TransformationCatalogEntry object in the map
190:             * to a particular transformation for a particular site
191:             * @param fqlfn String The fully qualified logical transformation
192:             * @param siteid String The site for which the TransformationCatalogEntry is valid
193:             * @param entry TransformationCatalogEntry The Transformation CatalogEntry object to be added.
194:             * @return boolean
195:             */
196:            public boolean setSiteTCEntries(String fqlfn, String siteid,
197:                    TransformationCatalogEntry entry) {
198:                Map sitemap = null;
199:                List tcentries = null;
200:                if (mTCMap.containsKey(fqlfn)) {
201:                    sitemap = (Map) mTCMap.get(fqlfn);
202:                } else {
203:                    sitemap = new HashMap(10);
204:                    setSiteMap(fqlfn, sitemap);
205:                }
206:                if (sitemap.containsKey(siteid)) {
207:                    tcentries = (List) sitemap.get(siteid);
208:                } else {
209:                    tcentries = new ArrayList(10);
210:                    sitemap.put(siteid, tcentries);
211:                }
212:                tcentries.add(entry);
213:                return true;
214:            }
215:
216:            /**
217:             * Returns the textual description of the contents of the object
218:             * @return String
219:             */
220:            public String toString() {
221:                StringBuffer sb = new StringBuffer();
222:                for (Iterator i = mTCMap.keySet().iterator(); i.hasNext();) {
223:                    sb.append(toString((String) i.next()));
224:                }
225:                return sb.toString();
226:            }
227:
228:            /**
229:             * Returns a textual description of the object.
230:             * @param lfn String
231:             * @return the textual description.
232:             */
233:            public String toString(String lfn) {
234:                StringBuffer sb = new StringBuffer();
235:                sb.append("LFN = " + lfn + "\n");
236:                sb.append("\tSite map\n");
237:                Map sitemap = (Map) mTCMap.get(lfn);
238:                for (Iterator j = sitemap.keySet().iterator(); j.hasNext();) {
239:                    String site = (String) j.next();
240:                    sb.append("\t\tSite=" + site + "\n");
241:                    List tc = (List) sitemap.get(site);
242:                    for (Iterator k = tc.iterator(); k.hasNext();) {
243:                        TransformationCatalogEntry tcentry = (TransformationCatalogEntry) k
244:                                .next();
245:                        sb.append("\t\t\tPfn="
246:                                + tcentry.getPhysicalTransformation() + "\n");
247:                        sb.append("\t\t\tPfn site=" + tcentry.getResourceId()
248:                                + "\n");
249:
250:                    }
251:                }
252:                return sb.toString();
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.