Source Code Cross Referenced for Windward.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » common » catalog » 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.common.catalog.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:         */
015:        package org.griphyn.common.catalog.replica;
016:
017:        import org.griphyn.common.catalog.ReplicaCatalog;
018:        import org.griphyn.common.catalog.ReplicaCatalogEntry;
019:
020:        import org.griphyn.cPlanner.common.LogManager;
021:
022:        import edu.isi.ikcap.workflows.dc.DataCharacterization;
023:        import edu.isi.ikcap.workflows.dc.DataCharacterizationFactory;
024:
025:        import edu.isi.ikcap.workflows.dc.classes.DataSourceLocationObject;
026:
027:        import edu.isi.ikcap.workflows.util.FactoryException;
028:
029:        import java.util.List;
030:        import java.util.LinkedList;
031:        import java.util.Iterator;
032:        import java.util.Map;
033:        import java.util.HashMap;
034:        import java.util.Set;
035:        import java.util.HashSet;
036:        import java.util.Collection;
037:        import java.util.Properties;
038:
039:        /**
040:         * An implementation of the Replica Catalog interface that talks to Windward
041:         * Data Characterization Catalog.
042:         *
043:         * @author Karan Vahi
044:         * @version $Revision: 439 $
045:         */
046:        public class Windward implements  ReplicaCatalog {
047:
048:            /**
049:             * The property that designates which data characterization catalog impl to pick up.
050:             */
051:            public static final String DATA_CHARACTERIZATION_IMPL_PROPERTY = "windward";
052:
053:            /**
054:             * The availability time attribute key, that designates how soon the data
055:             * will be available.
056:             */
057:            public static final String DATA_AVAILABILITY_KEY = "data_availability";
058:
059:            /**
060:             * The handle to the Data Characterization Catalog.
061:             */
062:            private DataCharacterization mDCharCatalog;
063:
064:            /**
065:             * The handle to the log manager.
066:             */
067:            protected LogManager mLogger;
068:
069:            /**
070:             * Converts a DataSourceLocationObject to ReplicaCatalogEntry.
071:             *
072:             *
073:             * @param ds  the DataSourceLocation to be converted.
074:             *
075:             * @return ReplicaCatalogEntry
076:             */
077:            public static ReplicaCatalogEntry convertToRCE(
078:                    DataSourceLocationObject ds) {
079:                ReplicaCatalogEntry rce = new ReplicaCatalogEntry();
080:                rce.setPFN(ds.getLocation());
081:                rce.setResourceHandle(ds.getSite());
082:                rce.addAttribute(DATA_AVAILABILITY_KEY, ds
083:                        .getAvailabilityTime());
084:
085:                //other attributes to converted later on.
086:
087:                return rce;
088:            }
089:
090:            /**
091:             * The default constructor.
092:             */
093:            public Windward() {
094:            }
095:
096:            /**
097:             * Removes everything. The SR DC API does not support removes or deletes.
098:             * Always returns 0.
099:             *
100:             * @return the number of removed entries.
101:             */
102:            public int clear() {
103:                return 0;
104:            }
105:
106:            /**
107:             * Explicitely free resources before the garbage collection hits.
108:             *
109:             *
110:             */
111:            public void close() {
112:
113:                mDCharCatalog.close();
114:                mDCharCatalog = null;
115:            }
116:
117:            /**
118:             * Establishes a link between the implementation and the thing the
119:             * implementation is build upon.
120:             *
121:             * @param props contains all necessary data to establish the link.
122:             * @return true if connected now, or false to indicate a failure.
123:             */
124:            public boolean connect(Properties props) {
125:                boolean connect = true;
126:                //figure out how to specify via properties
127:                try {
128:                    String implementor = props
129:                            .getProperty(this .DATA_CHARACTERIZATION_IMPL_PROPERTY);
130:                    mDCharCatalog = DataCharacterizationFactory.loadInstance(
131:                            implementor, props);
132:                } catch (FactoryException e) {
133:                    connect = false;
134:                    mLogger.log(
135:                            "Unable to connect to Data Characterization Catalog "
136:                                    + e.convertException(),
137:                            LogManager.DEBUG_MESSAGE_LEVEL);
138:                }
139:
140:                return connect;
141:
142:            }
143:
144:            /**
145:             * Deletes all PFN entries for a given LFN from the replica catalog where
146:             * the PFN attribute is found, and matches exactly the object value.
147:             * The SR DC API does not support removes or deletes. Always returns 0.
148:             *
149:             * @param lfn is the logical filename to look for.
150:             * @param name is the PFN attribute name to look for.
151:             * @param value is an exact match of the attribute value to match.
152:             * @return the number of removed entries.
153:             */
154:            public int delete(String lfn, String name, Object value) {
155:                return 0;
156:            }
157:
158:            /**
159:             * Deletes a very specific mapping from the replica catalog.
160:             * The SR DC API does not support removes or deletes.
161:             * Always returns 0.
162:             *
163:             * @param lfn is the logical filename in the tuple.
164:             * @param tuple is a description of the PFN and its attributes.
165:             * @return the number of removed entries, either 0 or 1.
166:             */
167:            public int delete(String lfn, ReplicaCatalogEntry tuple) {
168:                return 0;
169:            }
170:
171:            /**
172:             * Deletes multiple mappings into the replica catalog.
173:             * The SR DC API does not support removes or deletes.
174:             * Always returns 0.
175:             *
176:             * @param x is a map from logical filename string to list of replica
177:             *   catalog entries.
178:             * @param matchAttributes whether mapping should be deleted only if all
179:             *   attributes match.
180:             *
181:             * @return the number of deletions.
182:             *
183:             */
184:            public int delete(Map x, boolean matchAttributes) {
185:                return 0;
186:            }
187:
188:            /**
189:             * Deletes a specific mapping from the replica catalog.
190:             * The SR DC API does not support removes or deletes.
191:             * Always returns 0.
192:             *
193:             * @param lfn is the logical filename in the tuple.
194:             * @param pfn is the physical filename in the tuple.
195:             *
196:             * @return the number of removed entries.
197:             */
198:            public int delete(String lfn, String pfn) {
199:                return 0;
200:            }
201:
202:            /**
203:             * Deletes all PFN entries for a given LFN from the replica catalog where
204:             * the resource handle is found. The SR DC API does not support removes or deletes.
205:             * Always returns 0.
206:             *
207:             * @param lfn is the logical filename to look for.
208:             * @param handle is the resource handle
209:             *
210:             * @return the number of entries removed.
211:             */
212:            public int deleteByResource(String lfn, String handle) {
213:                return 0;
214:            }
215:
216:            /**
217:             * Inserts a new mapping into the replica catalog.
218:             *
219:             * @param lfn is the logical filename under which to book the entry.
220:             * @param pfn is the physical filename associated with it.
221:             * @param handle is a resource handle where the PFN resides.
222:             * @return number of insertions, should always be 1. On failure, throw
223:             *   an exception, don't use zero.
224:             *
225:             */
226:            public int insert(String lfn, String pfn, String handle) {
227:                DataSourceLocationObject ds = new DataSourceLocationObject();
228:                ds.setDataObjectID(lfn);
229:                ds.setLocation(pfn);
230:                ds.setSite(handle);
231:
232:                return mDCharCatalog.registerDataObject(ds) ? 1 : 0;
233:            }
234:
235:            /**
236:             * Inserts a new mapping into the replica catalog.
237:             * For the time being only the pfn and site attribute are registered.
238:             *
239:             * @param lfn is the logical filename under which to book the entry.
240:             * @param tuple is the physical filename and associated PFN attributes.
241:             *
242:             * @return number of insertions, should always be 1. On failure, throw
243:             *   an exception, don't use zero.
244:             */
245:            public int insert(String lfn, ReplicaCatalogEntry tuple) {
246:
247:                //for the time being only populating the pfn and site attribute
248:                DataSourceLocationObject ds = new DataSourceLocationObject();
249:                ds.setDataObjectID(lfn);
250:                ds.setLocation(tuple.getPFN());
251:                ds.setSite(tuple.getResourceHandle());
252:
253:                return mDCharCatalog.registerDataObject(ds) ? 1 : 0;
254:            }
255:
256:            /**
257:             * Inserts multiple mappings into the replica catalog.
258:             * For the time being only the pfn and site attribute are registered for
259:             * each entry.
260:             *
261:             * @param x is a map from logical filename string to list of replica
262:             *   catalog entries.
263:             *
264:             * @return the number of insertions.
265:             *
266:             */
267:            public int insert(Map x) {
268:                int result = 0;
269:                //traverse through the entries and insert one by one
270:                for (Iterator it = x.entrySet().iterator(); it.hasNext();) {
271:                    Map.Entry entry = (Map.Entry) it.next();
272:                    String lfn = (String) entry.getKey();
273:
274:                    //traverse through rce's for each lfn
275:                    for (Iterator rceIt = ((List) entry.getValue()).iterator(); rceIt
276:                            .hasNext();) {
277:                        ReplicaCatalogEntry rce = (ReplicaCatalogEntry) rceIt
278:                                .next();
279:                        result += this .insert(lfn, rce);
280:                    }
281:
282:                }
283:                return result;
284:            }
285:
286:            /**
287:             * Predicate to check, if the connection with the catalog's
288:             * implementation is still active.
289:             *
290:             * @return true, if the implementation is disassociated, false otherwise.
291:             */
292:            public boolean isClosed() {
293:                return mDCharCatalog == null;
294:            }
295:
296:            /**
297:             * Lists a subset of all logical filenames in the catalog.
298:             *
299:             * @param constraint is a constraint for the logical filename only. It
300:             *   is a string that has some meaning to the implementing system. This
301:             *   can be a SQL wildcard for queries, or a regular expression for
302:             *   Java-based memory collections.
303:             *
304:             * @return A set of logical filenames that match. The set may be empty
305:             *
306:             * @throws UnsupportedOperationException
307:             *
308:             */
309:            public Set list(String constraint) {
310:                throw new UnsupportedOperationException(
311:                        "Unsupported operation list( String )");
312:            }
313:
314:            /**
315:             * Lists all logical filenames in the catalog.
316:             *
317:             * @return A set of all logical filenames known to the catalog.
318:             *
319:             *
320:             * @throws UnsupportedOperationException
321:             */
322:            public Set list() {
323:                throw new UnsupportedOperationException(
324:                        "Unsupported operation list( String )");
325:            }
326:
327:            /**
328:             * Retrieves the entry for a given filename and resource handle from the
329:             * replica catalog.
330:             *
331:             * @param lfn is the logical filename to obtain information for.
332:             * @param handle is the resource handle to obtain entries for.
333:             *
334:             * @return the (first) matching physical filename, or <code>null</code>
335:             *   if no match was found.
336:             */
337:            public String lookup(String lfn, String handle) {
338:                String result = null;
339:
340:                Collection l = mDCharCatalog
341:                        .findDataObjectLocationsAndAccessAttributes(lfn);
342:
343:                //sanity check
344:                if (l == null) {
345:                    return result;
346:                }
347:
348:                for (Iterator it = l.iterator(); it.hasNext();) {
349:                    DataSourceLocationObject ds = (DataSourceLocationObject) it
350:                            .next();
351:                    if ((result = ds.getSite()).equals(handle)) {
352:                        return result;
353:                    }
354:                }
355:
356:                return null;
357:            }
358:
359:            /**
360:             * Retrieves all entries for a given LFN from the replica catalog.
361:             * For the time being only the pfn and site attribute are retrieved for
362:             * the lfn.
363:             *
364:             * @param lfn is the logical filename to obtain information for.
365:             *
366:             * @return a collection of replica catalog entries
367:             */
368:            public Collection lookup(String lfn) {
369:                Collection result = new LinkedList();
370:
371:                Collection l = mDCharCatalog
372:                        .findDataObjectLocationsAndAccessAttributes(lfn);
373:
374:                //sanity check
375:                if (l == null) {
376:                    return result;
377:                }
378:
379:                for (Iterator it = l.iterator(); it.hasNext();) {
380:                    DataSourceLocationObject ds = (DataSourceLocationObject) it
381:                            .next();
382:                    result.add(convertToRCE(ds));
383:                }
384:
385:                return result;
386:            }
387:
388:            /**
389:             * Retrieves multiple entries for a given logical filename, up to the
390:             * complete catalog. For the time being only the pfn and site attribute are
391:             * retrieved for the lfn.
392:             *
393:             * @param lfns is a set of logical filename strings to look up.
394:             * @param handle is the resource handle, restricting the LFNs.
395:             *
396:             * @return a map indexed by the LFN. Each value is a collection of
397:             *   replica catalog entries (all attributes).
398:             */
399:            public Map lookup(Set lfns, String handle) {
400:                Map result = new HashMap();
401:
402:                Map m = mDCharCatalog
403:                        .findDataObjectLocationsAndAccessAttributes(lfns);
404:
405:                //iterate through the entries and match for handle
406:                for (Iterator it = m.entrySet().iterator(); it.hasNext();) {
407:                    Map.Entry entry = (Map.Entry) it.next();
408:                    String lfn = (String) entry.getKey();
409:                    List rces = new LinkedList();
410:
411:                    //traverse through all the DataSourceLocationObjects for lfn
412:                    List l = (List) entry.getValue();
413:                    //sanity check
414:                    if (l == null) {
415:                        continue;
416:                    }
417:
418:                    for (Iterator dit = l.iterator(); dit.hasNext();) {
419:                        DataSourceLocationObject ds = (DataSourceLocationObject) dit
420:                                .next();
421:                        if (ds.getSite().equals(handle)) {
422:                            //add to the rces list
423:                            rces.add(convertToRCE(ds));
424:                        }
425:                    }
426:
427:                    //populate the entry for lfn into result
428:                    //Do we checks for empty rce list ???
429:                    result.put(lfn, rces);
430:                }
431:
432:                return result;
433:            }
434:
435:            /**
436:             * Retrieves multiple entries for a given logical filename, up to the
437:             * complete catalog.
438:             *
439:             * @param constraints is mapping of keys 'lfn', 'pfn', or any attribute
440:             *   name, e.g. the resource handle 'site', to a string that has some
441:             *   meaning to the implementing system. This can be a SQL wildcard for
442:             *   queries, or a regular expression for Java-based memory collections.
443:             *   Unknown keys are ignored. Using an empty map requests the complete
444:             *   catalog.
445:             *
446:             * @return a map indexed by the LFN. Each value is a collection of
447:             *   replica catalog entries.
448:             *
449:             * @throws new UnsupportedOperationException( "Unsupported operation list( String )" );
450:             */
451:            public Map lookup(Map constraints) {
452:                throw new UnsupportedOperationException(
453:                        "Unsupported operation lookup( Map )");
454:            }
455:
456:            /**
457:             * Retrieves multiple entries for a given logical filename, up to the
458:             * complete catalog. For the time being only the pfn and site attribute are
459:             * retrieved for the lfn.
460:             *
461:             * @param lfns is a set of logical filename strings to look up.
462:             *
463:             * @return a map indexed by the LFN. Each value is a collection of
464:             *   replica catalog entries for the LFN.
465:             */
466:            public Map lookup(Set lfns) {
467:                Map result = new HashMap();
468:
469:                Map m = mDCharCatalog
470:                        .findDataObjectLocationsAndAccessAttributes(lfns);
471:
472:                //iterate through the entries and match for handle
473:                for (Iterator it = m.entrySet().iterator(); it.hasNext();) {
474:                    Map.Entry entry = (Map.Entry) it.next();
475:                    String lfn = (String) entry.getKey();
476:                    List rces = new LinkedList();
477:
478:                    //traverse through all the DataSourceLocationObjects for lfn
479:                    List l = (List) entry.getValue();
480:                    //sanity check
481:                    if (l == null) {
482:                        continue;
483:                    }
484:
485:                    for (Iterator dit = l.iterator(); dit.hasNext();) {
486:                        DataSourceLocationObject ds = (DataSourceLocationObject) dit
487:                                .next();
488:                        //add to the rces list
489:                        rces.add(convertToRCE(ds));
490:                    }
491:
492:                    //populate the entry for lfn into result
493:                    //Do we checks for empty rce list ???
494:                    result.put(lfn, rces);
495:                }
496:
497:                return result;
498:
499:            }
500:
501:            /**
502:             * Retrieves all entries for a given LFN from the replica catalog.
503:             *
504:             * @param lfn is the logical filename to obtain information for.
505:             *
506:             * @return a set of PFN strings
507:             *
508:             */
509:            public Set lookupNoAttributes(String lfn) {
510:                Set result = new HashSet();
511:
512:                for (Iterator it = this .lookup(lfn).iterator(); it.hasNext();) {
513:                    ReplicaCatalogEntry rce = (ReplicaCatalogEntry) it.next();
514:                    result.add(rce.getPFN());
515:                }
516:
517:                return result;
518:            }
519:
520:            /**
521:             * Retrieves multiple entries for a given logical filename, up to the
522:             * complete catalog.
523:             *
524:             * @param lfns is a set of logical filename strings to look up.
525:             *
526:             * @return a map indexed by the LFN. Each value is a set of PFN strings.
527:             */
528:            public Map lookupNoAttributes(Set lfns) {
529:                Map result = new HashMap();
530:
531:                for (Iterator it = this .lookup(lfns).entrySet().iterator(); it
532:                        .hasNext();) {
533:                    Map.Entry entry = (Map.Entry) it.next();
534:                    String lfn = (String) entry.getKey();
535:                    Set pfns = new HashSet();
536:                    //traverse through the rce's and put only pfn's
537:                    for (Iterator rceIt = ((Collection) entry.getValue())
538:                            .iterator(); rceIt.hasNext();) {
539:                        ReplicaCatalogEntry rce = (ReplicaCatalogEntry) rceIt
540:                                .next();
541:                        pfns.add(rce.getPFN());
542:                    }
543:
544:                    //populate the entry for lfn into result
545:                    //Do we checks for empty rce list ???
546:                    result.put(lfn, pfns);
547:
548:                }
549:                return result;
550:            }
551:
552:            /**
553:             * Retrieves multiple entries for a given logical filename, up to the
554:             * complete catalog.
555:             *
556:             * @param lfns is a set of logical filename strings to look up.
557:             * @param handle is the resource handle, restricting the LFNs.
558:             *
559:             * @return a map indexed by the LFN. Each value is a set of physical
560:             *   filenames.
561:             */
562:            public Map lookupNoAttributes(Set lfns, String handle) {
563:                Map result = new HashMap();
564:
565:                for (Iterator it = this .lookup(lfns, handle).entrySet()
566:                        .iterator(); it.hasNext();) {
567:                    Map.Entry entry = (Map.Entry) it.next();
568:                    String lfn = (String) entry.getKey();
569:                    Set pfns = new HashSet();
570:                    //traverse through the rce's and put only pfn's
571:                    for (Iterator rceIt = ((Collection) entry.getValue())
572:                            .iterator(); rceIt.hasNext();) {
573:                        ReplicaCatalogEntry rce = (ReplicaCatalogEntry) rceIt
574:                                .next();
575:                        pfns.add(rce.getPFN());
576:                    }
577:
578:                    //populate the entry for lfn into result
579:                    //Do we checks for empty rce list ???
580:                    result.put(lfn, pfns);
581:
582:                }
583:                return result;
584:
585:            }
586:
587:            /**
588:             * Removes all mappings for an LFN from the replica catalog.
589:             *
590:             * @param lfn is the logical filename to remove all mappings for.
591:             * @return the number of removed entries.
592:             */
593:            public int remove(String lfn) {
594:                return 0;
595:            }
596:
597:            /**
598:             * Removes all mappings for a set of LFNs.
599:             * The SR DC API does not support removes or deletes. Always returns 0.
600:             *
601:             * @param lfns is a set of logical filename to remove all mappings for.
602:             *
603:             * @return the number of removed entries.
604:             *
605:             */
606:            public int remove(Set lfns) {
607:                return 0;
608:            }
609:
610:            /**
611:             * Removes all entries from the replica catalog where the PFN attribute
612:             * is found, and matches exactly the object value.
613:             *
614:             * The SR DC API does not support removes or deletes. Always returns 0.
615:             *
616:             * @param name is the PFN attribute name to look for.
617:             * @param value is an exact match of the attribute value to match.
618:             *
619:             * @return the number of removed entries.
620:             *
621:             */
622:            public int removeByAttribute(String name, Object value) {
623:                return 0;
624:            }
625:
626:            /**
627:             * Removes all entries associated with a particular resource handle.
628:             *
629:             *
630:             * The SR DC API does not support removes or deletes. Always returns 0.
631:             *
632:             * @param handle is the site handle to remove all entries for.
633:             *
634:             * @return the number of removed entries.
635:             */
636:            public int removeByAttribute(String handle) {
637:                return 0;
638:            }
639:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.