01: /*
02: * This file or a portion of this file is licensed under the terms of
03: * the Globus Toolkit Public License, found in file GTPL, or at
04: * http://www.globus.org/toolkit/download/license.html. This notice must
05: * appear in redistributions of this file, with or without modification.
06: *
07: * Redistributions of this Software, with or without modification, must
08: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
09: * some other similar material which is provided with the Software (if
10: * any).
11: *
12: * Copyright 1999-2004 University of Chicago and The University of
13: * Southern California. All rights reserved.
14: */
15: package org.griphyn.cPlanner.poolinfo;
16:
17: import org.griphyn.cPlanner.classes.SiteInfo;
18:
19: import org.griphyn.cPlanner.common.PegasusProperties;
20: import org.griphyn.cPlanner.common.LogManager;
21:
22: import org.griphyn.cPlanner.namespace.Condor;
23:
24: import java.util.List;
25: import java.util.Iterator;
26:
27: /**
28: * A Test program that shows how to load a Site Catalog, and query for all sites.
29: * The configuration is picked from the Properties. The following properties
30: * need to be set
31: * <pre>
32: * pegasus.catalog.site Text|XML
33: * pegasus.catalog.site.file path to the site catalog.
34: * </pre>
35: *
36: * @author Karan Vahi
37: * @version $Revision: 50 $
38: */
39:
40: public class TestSiteCatalog {
41:
42: /**
43: * The main program.
44: */
45: public static void main(String[] args) {
46: PoolInfoProvider catalog = null;
47: LogManager logger = LogManager.getInstance();
48:
49: /* load the catalog using the factory */
50: try {
51: catalog = SiteFactory.loadInstance(PegasusProperties
52: .nonSingletonInstance(), false);
53: } catch (SiteFactoryException e) {
54: logger.log(e.convertException(),
55: LogManager.FATAL_MESSAGE_LEVEL);
56: System.exit(2);
57: }
58:
59: /* query for the sites, and print them out */
60: List siteIDs = catalog.getPools();
61:
62: for (Iterator it = catalog.getPools().iterator(); it.hasNext();) {
63: String siteID = (String) it.next();
64: SiteInfo site = catalog.getPoolEntry(siteID,
65: Condor.VANILLA_UNIVERSE);
66: //System.out.println( site.toXML() ); //for XML output
67: System.out.println(site.toMultiLine()); //for multiline text output
68: }
69:
70: }
71: }
|