Source Code Cross Referenced for MdsQuery.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » poolinfo » 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.poolinfo 
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 at $PEGASUS_HOME/GTPL or
004:         * http://www.globus.org/toolkit/download/license.html.
005:         * This notice must appear in redistributions of this file
006:         * with or without modification.
007:         *
008:         * Redistributions of this Software, with or without modification, must reproduce
009:         * the GTPL in:
010:         * (1) the Software, or
011:         * (2) the Documentation or
012:         * some other similar material which is provided with the Software (if any).
013:         *
014:         * Copyright 1999-2004
015:         * University of Chicago and The University of Southern California.
016:         * All rights reserved.
017:         */package org.griphyn.cPlanner.poolinfo;
018:
019:        import java.util.ArrayList;
020:        import java.util.Enumeration;
021:        import java.util.Hashtable;
022:        import java.util.Iterator;
023:        import java.util.StringTokenizer;
024:        import javax.naming.Context;
025:        import javax.naming.NamingEnumeration;
026:        import javax.naming.NamingException;
027:        import javax.naming.directory.Attribute;
028:        import javax.naming.directory.Attributes;
029:        import javax.naming.directory.SearchResult;
030:        import javax.naming.ldap.InitialLdapContext;
031:        import javax.naming.ldap.LdapContext;
032:
033:        import org.griphyn.cPlanner.classes.PoolConfig;
034:        import org.griphyn.cPlanner.classes.GridFTPServer;
035:        import org.griphyn.cPlanner.classes.GridFTPBandwidth;
036:        import org.griphyn.cPlanner.classes.SiteInfo;
037:        import org.griphyn.cPlanner.classes.JobManager;
038:        import org.griphyn.cPlanner.classes.LRC;
039:        import org.griphyn.cPlanner.classes.Profile;
040:        import org.griphyn.cPlanner.classes.WorkDir;
041:
042:        /**
043:         * This Class queries the GT2 based Monitoring and Discovery Service (MDS)
044:         * and stores the remote sites information into a single data class.
045:         *
046:         * @author Gaurang Mehta gmehta@isi.edu
047:         * @author Karan Vahi vahi@isi.edu
048:         *
049:         * @version $Revision: 50 $
050:         */
051:        public class MdsQuery {
052:
053:            private String mdshost; //holds the hostname for MDS
054:            private int mdsport; //holds the port number for MDS
055:            private String mdsbaseDN; //holds the baseDN for the GRIS/GIIS
056:            private String DEFAULT_CTX = "com.sun.jndi.ldap.LdapCtxFactory";
057:            private Hashtable env; //Hashtable holding connection setting to the MDS
058:            // private GvdsPoolConfig poolconfig = new GvdsPoolConfig();
059:
060:            private static final int Gvds_Pool_Id = 0;
061:            private static final int Gvds_Pool_Universe = 1;
062:            private static final int Gvds_Pool_WorkDir = 2;
063:            private static final int Gvds_Pool_Lrc = 3;
064:            private static final int Gvds_Pool_Gridlaunch = 4;
065:            private static final int Gvds_Pool_Storage = 5;
066:            private static final int Gvds_Pool_Profile = 6;
067:
068:            private static final int Mds_Computer_Total_Free_NodeCount = 7;
069:            private static final int Mds_Computer_Total_NodeCount = 8;
070:            private static final int Mds_Gram_Job_Queue_MaxCount = 9;
071:            private static final int Mds_Gram_Job_Queue_MaxCpuTime = 10;
072:            private static final int Mds_Gram_Job_Queue_MaxRunningJobs = 11;
073:            private static final int Mds_Gram_Job_Queue_MaxJobsInQueue = 12;
074:            private static final int Mds_Memory_Ram_Total_SizeMB = 13;
075:            private static final int Mds_Memory_Ram_FreeSizeMB = 14;
076:            private static final int Mds_Service_Gram_SchedulerType = 15;
077:            private static final int Mds_Computer_Isa = 16;
078:            private static final int Mds_Os_Name = 17;
079:
080:            private static final int Mds_Subnetid = 18;
081:
082:            /*
083:             * TODO:sk to add constants which represent the attributes in the
084:             * MDS objectclass=gridftp-pair-bandwidth-info
085:             */
086:            private static final int Host_Subnet_Id = 19;
087:            private static final int Dest_Subnet_Id = 20;
088:            private static final int Avg_Bandwidth_range1 = 21;
089:            private static final int Avg_Bandwidth_range2 = 22;
090:            private static final int Avg_Bandwidth_range3 = 23;
091:            private static final int Avg_Bandwidth_range4 = 24;
092:            private static final int Avg_Bandwidth = 25;
093:            private static final int Max_Bandwidth = 26;
094:            private static final int Min_Bandwidth = 27;
095:
096:            private ArrayList m_identifiers = new ArrayList(28);
097:
098:            // private SearchControls constraints;
099:
100:            /**
101:             * C'tor for the class.
102:             */
103:            public MdsQuery() {
104:
105:            }
106:
107:            /**
108:             * Valid C'tor for the class to create a MdsQuery object.
109:             * Sets the SECURITY_ATHENTICATION with simple authentication.
110:             * Sets the PROVIDER_URL to the MDS host and port.
111:             * Sets the INTITIAL CONTEXT FACTORY.
112:             *
113:             * @param host  the hostname of the machine on which a GRIS or GIIS is running.
114:             * @param port  the Port number on which a GRIS or GIIS is running.
115:             */
116:            public MdsQuery(String host, int port) {
117:                mdshost = host;
118:                mdsport = port;
119:                mdsbaseDN = new String();
120:
121:                env = new Hashtable();
122:                env.put(Context.PROVIDER_URL, "ldap://" + mdshost + ":"
123:                        + mdsport);
124:                env.put(Context.INITIAL_CONTEXT_FACTORY, DEFAULT_CTX);
125:                env.put(Context.SECURITY_AUTHENTICATION, "simple");
126:
127:                m_identifiers.add("Gvds-Pool-Id");
128:                m_identifiers.add("Gvds-Pool-Universe");
129:                m_identifiers.add("Gvds-Pool-WorkDir");
130:                m_identifiers.add("Gvds-Pool-Lrc");
131:                m_identifiers.add("Gvds-Pool-GridLaunch");
132:                m_identifiers.add("Gvds-Pool-Storage");
133:                m_identifiers.add("Gvds-Pool-Profile");
134:                m_identifiers.add("Mds-Computer-Total-Free-nodeCount");
135:                m_identifiers.add("Mds-Computer-Total-nodeCount");
136:                m_identifiers.add("Mds-Gram-Job-Queue-maxcount");
137:                m_identifiers.add("Mds-Gram-Job-Queue-maxcputime");
138:                m_identifiers.add("Mds-Gram-Job-Queue-maxrunningjobs");
139:                m_identifiers.add("Mds-Gram-Job-Queue-maxjobsinqueue");
140:                m_identifiers.add("Mds-Memory-Ram-Total-sizeMB");
141:                m_identifiers.add("Mds-Memory-Ram-sizeMB");
142:                m_identifiers.add("Mds-Service-Gram-schedulertype");
143:                m_identifiers.add("Mds-Computer-isa");
144:                m_identifiers.add("Mds-Os-name");
145:                m_identifiers.add("Mds-Net-netaddr");
146:
147:                /**
148:                 * sk added the attributes here as well in the same order as they are defined
149:                 * before as this is like a hash
150:                 */
151:                m_identifiers.add("Host-Subnet-Id");
152:                m_identifiers.add("Dest-Subnet-Id");
153:                m_identifiers.add("Avg-Bandwidth-range1");
154:                m_identifiers.add("Avg-Bandwidth-range2");
155:                m_identifiers.add("Avg-Bandwidth-range3");
156:                m_identifiers.add("Avg-Bandwidth-range4");
157:                m_identifiers.add("Avg-Bandwidth");
158:                m_identifiers.add("Max-Bandwidth");
159:                m_identifiers.add("Min-Bandwidth");
160:
161:                // constraints = new SearchControls();
162:                // constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
163:            }
164:
165:            /**
166:             * Enables a user to set new or overide existing connection settings to the MDS.
167:             *
168:             * @param index Holds the index string for the connection environment.
169:             * @param value Holds the value corresponding to the index fro the connnection environment.
170:             */
171:            public void setLdapConnectionEnv(String index, String value) {
172:                env.put(index, value);
173:            }
174:
175:            public void setLdapSearchConstraints() {
176:
177:            }
178:
179:            /**
180:             * Create and return a MDS LdapContext.
181:             *
182:             * @return LdapContext
183:             */
184:
185:            public LdapContext connectMds() throws NamingException {
186:                LdapContext mdsctx = new InitialLdapContext(env, null);
187:                return mdsctx;
188:            }
189:
190:            /**
191:             * Still Thinking how to eable this option.
192:             */
193:            public NamingEnumeration searchMDS(LdapContext mdsctx,
194:                    String baseDN, String filter) {
195:
196:                NamingEnumeration results = null;
197:                return results;
198:
199:            }
200:
201:            public PoolConfig StoreGvdsMdsInfo(NamingEnumeration results,
202:                    String baseDN, PoolConfig poolconfig)
203:                    throws NamingException, Exception {
204:
205:                SiteInfo poolinfo = null;
206:
207:                String jburl = null;
208:                mdsbaseDN = baseDN;
209:                if (results == null) {
210:                    return null;
211:                }
212:
213:                String dn;
214:                String attribute;
215:                Attributes attrs;
216:                Attribute at;
217:                SearchResult si;
218:
219:                while (results.hasMoreElements()) {
220:                    si = (SearchResult) results.next();
221:                    attrs = si.getAttributes();
222:
223:                    if (si.getName().trim().length() == 0) {
224:                        dn = baseDN;
225:                    } else {
226:                        dn = si.getName() + ", " + baseDN;
227:                    }
228:                    //      System.out.println("dn: " + dn);
229:                    if (dn.startsWith("Gvds-Vo-name")
230:                            || dn.startsWith("Gvds-Software-deployment")) {
231:                        poolinfo = new SiteInfo();
232:
233:                        for (NamingEnumeration ae = attrs.getAll(); ae
234:                                .hasMoreElements();) {
235:                            at = (Attribute) ae.next();
236:
237:                            attribute = at.getID();
238:
239:                            Enumeration vals = at.getAll();
240:
241:                            while (vals.hasMoreElements()) {
242:                                int switchkey = m_identifiers
243:                                        .indexOf(attribute);
244:                                switch (switchkey) {
245:                                //Setup pool id
246:                                case 0:
247:                                    String poolHandle = new String(
248:                                            (String) vals.nextElement());
249:                                    if (poolconfig.getSites().containsKey(
250:                                            poolHandle)) {
251:                                        java.util.Date date = new java.util.Date();
252:                                        poolconfig.add(poolHandle + "-"
253:                                                + date.getTime(), poolinfo);
254:                                    } else {
255:                                        poolconfig.add(poolHandle, poolinfo);
256:                                    }
257:
258:                                    // poolconfig.setPoolConfig((String) vals.nextElement(),poolinfo);
259:                                    break;
260:
261:                                //Setup pool universe's info
262:                                case 1:
263:                                    StringTokenizer st = new StringTokenizer(
264:                                            (String) vals.nextElement(), "@");
265:                                    String universe = st.nextToken();
266:                                    String url = st.nextToken();
267:                                    String globus_version = st.nextToken();
268:
269:                                    JobManager jobmanagerinfo = new JobManager();
270:
271:                                    //setting the universe,globus version and the url mappings
272:                                    jobmanagerinfo.setInfo(JobManager.URL, url);
273:                                    jobmanagerinfo.setInfo(JobManager.UNIVERSE,
274:                                            universe);
275:                                    jobmanagerinfo.setInfo(
276:                                            JobManager.GLOBUS_VERSION,
277:                                            globus_version);
278:                                    poolinfo.setInfo(SiteInfo.JOBMANAGER,
279:                                            jobmanagerinfo);
280:                                    break;
281:
282:                                //Setup the pool workdir info
283:                                case 2:
284:                                    WorkDir workdir = new WorkDir();
285:                                    st = new StringTokenizer((String) vals
286:                                            .nextElement(), "@");
287:
288:                                    String path = null;
289:                                    String totalsize = null;
290:                                    String freesize = null;
291:
292:                                    if (st.countTokens() == 1) {
293:                                        path = st.nextToken();
294:                                    } else {
295:                                        path = st.nextToken();
296:                                        totalsize = st.nextToken();
297:                                        freesize = st.nextToken();
298:
299:                                    }
300:                                    workdir.setInfo(WorkDir.WORKDIR, path);
301:                                    workdir.setInfo(WorkDir.TOTAL_SIZE,
302:                                            totalsize);
303:                                    workdir
304:                                            .setInfo(WorkDir.FREE_SIZE,
305:                                                    freesize);
306:                                    poolinfo.setInfo(SiteInfo.WORKDIR, workdir);
307:                                    break;
308:
309:                                //Setup the pool LRC info
310:                                case 3:
311:                                    LRC lrc = new LRC((String) vals
312:                                            .nextElement());
313:                                    poolinfo.setInfo(SiteInfo.LRC, lrc);
314:                                    break;
315:
316:                                //Setup the pool GridLaunch Info
317:                                case 4:
318:                                    poolinfo.setInfo(SiteInfo.GRIDLAUNCH,
319:                                            (String) vals.nextElement());
320:                                    break;
321:
322:                                //Setup the pool Storage info
323:                                case 5:
324:                                    GridFTPServer gftp = new GridFTPServer();
325:                                    st = new StringTokenizer((String) vals
326:                                            .nextElement(), "@");
327:
328:                                    String gftp_url = null;
329:                                    String gftp_globus_version = null;
330:                                    String storage_totalsize = null;
331:                                    String storage_freesize = null;
332:                                    if (st.countTokens() == 2) {
333:                                        gftp_url = st.nextToken();
334:                                        gftp_globus_version = st.nextToken();
335:                                    } else {
336:                                        gftp_url = st.nextToken();
337:                                        gftp_globus_version = st.nextToken();
338:                                        storage_totalsize = st.nextToken();
339:                                        storage_freesize = st.nextToken();
340:                                    }
341:                                    StringTokenizer stt = new StringTokenizer(
342:                                            gftp_url, "/");
343:                                    String gridftpurl = stt.nextToken() + "//"
344:                                            + stt.nextToken();
345:                                    String storagedir = "";
346:                                    while (stt.hasMoreTokens()) {
347:                                        storagedir += "/" + stt.nextToken();
348:                                    }
349:                                    gftp.setInfo(GridFTPServer.GRIDFTP_URL,
350:                                            gridftpurl);
351:                                    gftp.setInfo(GridFTPServer.STORAGE_DIR,
352:                                            storagedir);
353:                                    gftp.setInfo(GridFTPServer.TOTAL_SIZE,
354:                                            storage_totalsize);
355:                                    gftp.setInfo(GridFTPServer.FREE_SIZE,
356:                                            storage_freesize);
357:                                    gftp.setInfo(GridFTPServer.GLOBUS_VERSION,
358:                                            gftp_globus_version);
359:                                    poolinfo.setInfo(SiteInfo.GRIDFTP, gftp);
360:                                    break;
361:
362:                                //Setup the pool Profile Info
363:                                case 6:
364:                                    st = new StringTokenizer((String) vals
365:                                            .nextElement(), "@");
366:                                    String namespace = st.nextToken();
367:                                    String key = st.nextToken();
368:                                    String value = st.nextToken();
369:                                    Profile profile = new Profile(namespace,
370:                                            key, value);
371:                                    poolinfo.setInfo(SiteInfo.PROFILE, profile);
372:                                    break;
373:
374:                                default:
375:                                    vals.nextElement();
376:                                }
377:                            }
378:                        }
379:                    } else if (dn.startsWith("Mds-Job-Queue-name")
380:                            || dn
381:                                    .startsWith("Mds-Software-deployment=jobmanager")) {
382:
383:                        StringTokenizer dnst = new StringTokenizer(dn, ",");
384:                        if (dn.startsWith("Mds-Job-Queue-name")) {
385:                            dnst.nextToken();
386:                        }
387:                        String jbmanager = dnst.nextToken();
388:                        String jbhost = dnst.nextToken();
389:                        jburl = jbhost.substring(jbhost.indexOf("=") + 1)
390:                                + "/"
391:                                + jbmanager
392:                                        .substring(jbmanager.indexOf("=") + 1);
393:
394:                        ArrayList jobmanagers = null;
395:                        JobManager jobmanager = null;
396:                        for (Iterator i = poolconfig.getSites().values()
397:                                .iterator(); i.hasNext();) {
398:                            poolinfo = (SiteInfo) i.next();
399:                            if ((jobmanagers = (ArrayList) poolinfo
400:                                    .getInfo(SiteInfo.JOBMANAGER)) != null) {
401:                                if (!jobmanagers.isEmpty()) {
402:                                    for (Iterator j = jobmanagers.iterator(); j
403:                                            .hasNext();) {
404:
405:                                        jobmanager = (JobManager) j.next();
406:                                        if (jobmanager.getInfo(JobManager.URL)
407:                                                .equalsIgnoreCase(jburl)) {
408:                                            for (NamingEnumeration ae = attrs
409:                                                    .getAll(); ae
410:                                                    .hasMoreElements();) {
411:                                                at = (Attribute) ae.next();
412:                                                attribute = at.getID();
413:                                                Enumeration vals = at.getAll();
414:                                                while (vals.hasMoreElements()) {
415:                                                    int switchkey = m_identifiers
416:                                                            .indexOf(attribute);
417:                                                    switch (switchkey) {
418:                                                    //Setup other jobmanager Related Information.
419:                                                    case 7:
420:                                                        jobmanager
421:                                                                .setInfo(
422:                                                                        JobManager.IDLE_NODES,
423:                                                                        (String) vals
424:                                                                                .nextElement());
425:                                                        break;
426:
427:                                                    case 8:
428:                                                        jobmanager
429:                                                                .setInfo(
430:                                                                        JobManager.TOTAL_NODES,
431:                                                                        (String) vals
432:                                                                                .nextElement());
433:                                                        break;
434:
435:                                                    case 9:
436:                                                        jobmanager
437:                                                                .setInfo(
438:                                                                        JobManager.MAX_COUNT,
439:                                                                        (String) vals
440:                                                                                .nextElement());
441:                                                        break;
442:
443:                                                    case 10:
444:                                                        jobmanager
445:                                                                .setInfo(
446:                                                                        JobManager.MAX_CPU_TIME,
447:                                                                        (String) vals
448:                                                                                .nextElement());
449:                                                        break;
450:
451:                                                    case 11:
452:                                                        jobmanager
453:                                                                .setInfo(
454:                                                                        JobManager.RUNNING_JOBS,
455:                                                                        (String) vals
456:                                                                                .nextElement());
457:                                                        break;
458:
459:                                                    case 12:
460:                                                        jobmanager
461:                                                                .setInfo(
462:                                                                        JobManager.JOBS_IN_QUEUE,
463:                                                                        (String) vals
464:                                                                                .nextElement());
465:                                                        break;
466:
467:                                                    case 13:
468:                                                        jobmanager
469:                                                                .setInfo(
470:                                                                        JobManager.TOTAL_MEM,
471:                                                                        (String) vals
472:                                                                                .nextElement());
473:                                                        break;
474:
475:                                                    case 14:
476:                                                        jobmanager
477:                                                                .setInfo(
478:                                                                        JobManager.FREE_MEM,
479:                                                                        (String) vals
480:                                                                                .nextElement());
481:                                                        break;
482:
483:                                                    case 15:
484:                                                        jobmanager
485:                                                                .setInfo(
486:                                                                        JobManager.JOBMANAGER_TYPE,
487:                                                                        (String) vals
488:                                                                                .nextElement());
489:                                                        break;
490:
491:                                                    case 16:
492:                                                        jobmanager
493:                                                                .setInfo(
494:                                                                        JobManager.ARCH_TYPE,
495:                                                                        (String) vals
496:                                                                                .nextElement());
497:                                                        break;
498:
499:                                                    case 17:
500:                                                        jobmanager
501:                                                                .setInfo(
502:                                                                        JobManager.OS_TYPE,
503:                                                                        (String) vals
504:                                                                                .nextElement());
505:                                                        break;
506:
507:                                                    default:
508:                                                        vals.nextElement();
509:
510:                                                    }
511:                                                }
512:                                            }
513:                                        }
514:
515:                                    } //for loop
516:                                }
517:                            }
518:                        }
519:                    }
520:
521:                    /*
522:                     * sk added a case where the dn starts with 'Dest-Subnet-Id'
523:                     * to gather destination bandwidth information for each gridftp server
524:                     */
525:
526:                    else if (dn.startsWith("Dest-Subnet-Id")) {
527:
528:                        GridFTPBandwidth gridftp_bandwidth = new GridFTPBandwidth();
529:                        String dest_subnet_id = null;
530:                        boolean flag = false; //flag to check if any elements occur
531:
532:                        StringTokenizer dnst = new StringTokenizer(dn, ",");
533:                        if (dn.startsWith("Dest-Subnet-Id")) {
534:                            dnst.nextToken();
535:                        }
536:
537:                        String gridhost = dnst.nextToken();
538:                        String hosturl = gridhost.substring(gridhost
539:                                .indexOf("=") + 1);
540:
541:                        ArrayList gridftpservers = null;
542:                        GridFTPServer gridftpserver = null;
543:                        for (Iterator i = poolconfig.getSites().values()
544:                                .iterator(); i.hasNext();) {
545:                            poolinfo = (SiteInfo) i.next();
546:                            if ((gridftpservers = (ArrayList) poolinfo
547:                                    .getInfo(SiteInfo.GRIDFTP)) != null) {
548:                                if (!gridftpservers.isEmpty()) {
549:                                    for (Iterator j = gridftpservers.iterator(); j
550:                                            .hasNext();) {
551:                                        gridftpserver = (GridFTPServer) j
552:                                                .next();
553:
554:                                        /**
555:                                         * calculate the gridftpserver url in the form smarty.isi.edu
556:                                         */
557:                                        String url = gridftpserver.getInfo(0);
558:                                        String halfurl = url.substring(url
559:                                                .indexOf("/") + 2);
560:                                        String finalurl = halfurl.substring(0,
561:                                                halfurl.indexOf("/"));
562:                                        //System.out.println("In url="+hosturl +" grid url="+finalurl);
563:                                        //if (finalurl.equalsIgnoreCase(hosturl))
564:                                        //means that the particular gridftpserver object has been found among the elements of the arraylist maintained in
565:                                        //the poolinfo class
566:                                        {
567:                                            flag = true;
568:
569:                                            //System.out.println("Url has matched "+hosturl);
570:                                            for (NamingEnumeration ae = attrs
571:                                                    .getAll(); ae
572:                                                    .hasMoreElements();) { //ae iterates over the attributes
573:                                                at = (Attribute) ae.next(); //get each attribute
574:                                                attribute = at.getID();
575:                                                Enumeration vals = at.getAll(); //get all the values of that attribute !
576:
577:                                                while (vals.hasMoreElements()) {
578:                                                    //form a GridFTPBandwidth object and then
579:                                                    // call gridftpserver.setGridFtpBandwidthInfo(dest_subnet_id, object);
580:
581:                                                    boolean intflag = false;
582:                                                    int switchkey = m_identifiers
583:                                                            .indexOf(attribute);
584:                                                    switch (switchkey) {
585:                                                    /**
586:                                                     * populate the gridftp_bandwidth object with the attributes
587:                                                     * and then store this object in the hashmap maintained in the gridftpserver object
588:                                                     */
589:
590:                                                    //Host-Subnet-Id
591:                                                    case 19:
592:
593:                                                        //neednt store this information
594:                                                        vals.nextElement();
595:                                                        break;
596:                                                    //Dest-Subnet-Id
597:                                                    case 20:
598:                                                        dest_subnet_id = (String) vals
599:                                                                .nextElement();
600:                                                        gridftp_bandwidth
601:                                                                .setInfo(
602:                                                                        GridFTPBandwidth.DEST_ID,
603:                                                                        dest_subnet_id);
604:                                                        break;
605:                                                    //Avg-Bandwidth-range1
606:                                                    case 21:
607:                                                        gridftp_bandwidth
608:                                                                .setInfo(
609:                                                                        GridFTPBandwidth.AVG_BW_RANGE1,
610:                                                                        (String) vals
611:                                                                                .nextElement());
612:                                                        break;
613:                                                    //Avg-Bandwidth-range2
614:                                                    case 22:
615:                                                        gridftp_bandwidth
616:                                                                .setInfo(
617:                                                                        GridFTPBandwidth.AVG_BW_RANGE2,
618:                                                                        (String) vals
619:                                                                                .nextElement());
620:                                                        break;
621:                                                    //Avg-Bandwidth-range3
622:                                                    case 23:
623:                                                        gridftp_bandwidth
624:                                                                .setInfo(
625:                                                                        GridFTPBandwidth.AVG_BW_RANGE3,
626:                                                                        (String) vals
627:                                                                                .nextElement());
628:                                                        break;
629:                                                    //Avg-Bandwidth-range4
630:                                                    case 24:
631:                                                        gridftp_bandwidth
632:                                                                .setInfo(
633:                                                                        GridFTPBandwidth.AVG_BW_RANGE4,
634:                                                                        (String) vals
635:                                                                                .nextElement());
636:                                                        break;
637:                                                    //Avg-Bandwidth
638:                                                    case 25:
639:                                                        gridftp_bandwidth
640:                                                                .setInfo(
641:                                                                        GridFTPBandwidth.AVG_BW,
642:                                                                        (String) vals
643:                                                                                .nextElement());
644:                                                        break;
645:                                                    //Max-Bandwidth
646:                                                    case 26:
647:                                                        gridftp_bandwidth
648:                                                                .setInfo(
649:                                                                        GridFTPBandwidth.MAX_BW,
650:                                                                        (String) vals
651:                                                                                .nextElement());
652:                                                        break;
653:                                                    //Min-Bandwidth
654:                                                    case 27:
655:                                                        gridftp_bandwidth
656:                                                                .setInfo(
657:                                                                        GridFTPBandwidth.MIN_BW,
658:                                                                        (String) vals
659:                                                                                .nextElement());
660:                                                        break;
661:                                                    default:
662:                                                        intflag = true;
663:                                                        break;
664:                                                    }
665:                                                    if (intflag) {
666:                                                        break;
667:                                                    }
668:                                                } //end of While
669:
670:                                                //now add the gridftp_bandwidth object in the hash maintained in the GvdsPoolGridFtp object
671:                                                /*
672:                                                                         if(flag)
673:                                                                         {
674:                                                 gridftpserver.setInfo(dest_subnet_id,gridftp_bandwidth);
675:                                                                         }*/
676:                                            }
677:
678:                                        } //end of if matching the appropriate gridftpserver
679:                                    } //for loop
680:                                }
681:                            }
682:                        }
683:                        if (flag) {
684:                            gridftpserver
685:                                    .setGridFTPBandwidthInfo(gridftp_bandwidth); //set the gridftp_bandwidth object in GvdsPoolGridFtp class
686:                        }
687:                    }
688:
689:                }
690:                return poolconfig;
691:            }
692:
693:            /**
694:             * Displays the result on stdout instead of putting it in data classes.
695:             *
696:             * @param results Takes a NamingEnumeration returned by the MDS search
697:             * @param baseDN Takes the baseDN provided to the MDS search.
698:             *
699:             */
700:            public void displayResults(NamingEnumeration results, String baseDN)
701:                    throws NamingException {
702:                mdsbaseDN = baseDN;
703:                if (results == null) {
704:                    return;
705:                }
706:
707:                String dn;
708:                String attribute;
709:                Attributes attrs;
710:                Attribute at;
711:                SearchResult si;
712:
713:                while (results.hasMoreElements()) {
714:                    si = (SearchResult) results.next();
715:                    attrs = si.getAttributes();
716:
717:                    if (si.getName().trim().length() == 0) {
718:                        dn = baseDN;
719:                    } else {
720:                        dn = si.getName() + ", " + baseDN;
721:                    }
722:                    System.out.println("dn: " + dn);
723:
724:                    for (NamingEnumeration ae = attrs.getAll(); ae
725:                            .hasMoreElements();) {
726:                        at = (Attribute) ae.next();
727:
728:                        attribute = at.getID();
729:
730:                        Enumeration vals = at.getAll();
731:                        while (vals.hasMoreElements()) {
732:                            System.out.println(attribute + ": "
733:                                    + vals.nextElement());
734:                        }
735:                    }
736:                    System.out.println();
737:                }
738:            }
739:
740:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.