Source Code Cross Referenced for Site.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » selector » site » heft » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » pegasus 2.1.0 » org.griphyn.cPlanner.selector.site.heft 
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.selector.site.heft;
018:
019:        import java.util.List;
020:        import java.util.LinkedList;
021:        import java.util.ListIterator;
022:
023:        /**
024:         * A data class that models a site as a collection of processors.
025:         * The number of processors can only be specified in the constructor.
026:         *
027:         * @author Karan Vahi
028:         * @version $Revision: 297 $
029:         */
030:        public class Site {
031:
032:            /**
033:             * The number of processors making up a site.
034:             */
035:            private int mNumProcessors;
036:
037:            /**
038:             * A list of processors making up the site.
039:             */
040:            private List mProcessors;
041:
042:            /**
043:             * The index to the processor that is to be used for scheduling a job.
044:             */
045:            private int mCurrentProcessorIndex;
046:
047:            /**
048:             * The logical name assigned to the site.
049:             */
050:            private String mName;
051:
052:            /**
053:             * The default constructor.
054:             *
055:             * @param name  the name to be assigned to the site.
056:             */
057:            public Site(String name) {
058:                mName = name;
059:                mNumProcessors = 0;
060:                mProcessors = new LinkedList();
061:                mCurrentProcessorIndex = 0;
062:            }
063:
064:            /**
065:             * The overloaded constructor.
066:             *
067:             * @param name  the name to be assigned to the site.
068:             * @param  num   the number of processors.
069:             */
070:            public Site(String name, int num) {
071:                mName = name;
072:                mNumProcessors = num;
073:                mCurrentProcessorIndex = -1;
074:                mProcessors = new LinkedList();
075:            }
076:
077:            /**
078:             * Returns the earliest time the site is available for scheduling
079:             * a job.  It is non insertion based scheduling policy.
080:             *
081:             * @param start     the time at which to start the search.
082:             *
083:             * @return long
084:             */
085:            public long getAvailableTime(long start) {
086:                int num = 0;
087:
088:                //each processor is checked for start of list
089:                long result = Long.MAX_VALUE;
090:                long current;
091:                ListIterator it;
092:                for (it = mProcessors.listIterator(); it.hasNext(); num++) {
093:                    Processor p = (Processor) it.next();
094:                    current = p.getAvailableTime(start);
095:                    if (current < result) {
096:                        //tentatively schedule a job on the processor
097:                        result = current;
098:                        mCurrentProcessorIndex = num;
099:                    }
100:                }
101:
102:                if (result > start && num < mNumProcessors) {
103:                    //tentatively schedule a job to an unused processor as yet.
104:                    result = start;
105:                    mCurrentProcessorIndex = num++;
106:                    //if using a normal iterator
107:                    //could use addLast() method
108:                    it.add(new Processor());
109:
110:                }
111:
112:                //sanity check
113:                if (result == Long.MAX_VALUE) {
114:                    throw new RuntimeException("Unable to scheduled to site");
115:                }
116:
117:                return result;
118:            }
119:
120:            /**
121:             * Schedules a job to the site.
122:             *
123:             * @param start    the start time of the job.
124:             * @param end      the end time for the job
125:             */
126:            public void scheduleJob(long start, long end) {
127:                //sanity check
128:                if (mCurrentProcessorIndex == -1) {
129:                    throw new RuntimeException(
130:                            "Invalid State. The job needs to be tentatively scheduled first!");
131:                }
132:
133:                Processor p = (Processor) mProcessors
134:                        .get(mCurrentProcessorIndex);
135:                p.scheduleJob(start, end);
136:
137:                //reset the index
138:                mCurrentProcessorIndex = -1;
139:            }
140:
141:            /**
142:             * Returns the name of the site.
143:             *
144:             * @return name of the site.
145:             */
146:            public String getName() {
147:                return mName;
148:            }
149:
150:            /**
151:             * Returns the number of available processors.
152:             *
153:             * @return number of available processors.
154:             */
155:            public int getAvailableProcessors() {
156:                return this.mNumProcessors;
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.