Source Code Cross Referenced for HeftBag.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 org.griphyn.cPlanner.partitioner.graph.Bag;
020:
021:        /**
022:         * A data class that implements the Bag interface and stores the extra information
023:         * that is required by the HEFT algorithm for each node.
024:         *
025:         * @author Karan Vahi
026:         * @version $Revision: 298 $
027:         */
028:        public class HeftBag implements  Bag {
029:
030:            /**
031:             * Array storing the names of the attributes that are stored with the
032:             * site.
033:             */
034:            public static final String HEFTINFO[] = { "avg-compute-time",
035:                    "downward-rank", "upward-rank", "start-time", "end-time",
036:                    "scheduled-site" };
037:
038:            /**
039:             * The constant to be passed to the accessor functions to get or set the
040:             * average compute time for the node.
041:             */
042:            public static final Integer AVG_COMPUTE_TIME = new Integer(0);
043:
044:            /**
045:             * The constant to be passed to the accessor functions to get or set the
046:             * downward rank for a node.
047:             */
048:            public static final Integer DOWNWARD_RANK = new Integer(1);
049:
050:            /**
051:             * The constant to be passed to the accessor functions to get or set the
052:             * upward rank for a node.
053:             */
054:            public static final Integer UPWARD_RANK = new Integer(2);
055:
056:            /**
057:             * The constant to be passed to the accessor functions to get or set the
058:             * actual start time for a job.
059:             */
060:            public static final Integer ACTUAL_START_TIME = new Integer(3);
061:
062:            /**
063:             * The constant to be passed to the accessor functions to get or set the
064:             * actual end time for a job.
065:             */
066:            public static final Integer ACTUAL_FINISH_TIME = new Integer(4);
067:
068:            /**
069:             * The site where the job is scheduled.
070:             */
071:            public static final Integer SCHEDULED_SITE = new Integer(5);
072:
073:            /**
074:             * The average compute time for a node.
075:             */
076:            private float mAvgComputeTime;
077:
078:            /**
079:             * The downward rank for a node.
080:             */
081:            private float mDownwardRank;
082:
083:            /**
084:             * The upward rank for a node.
085:             */
086:            private float mUpwardRank;
087:
088:            /**
089:             * The estimated start time for a job.
090:             */
091:            private long mStartTime;
092:
093:            /**
094:             * The estimated end time for a job.
095:             */
096:            private long mEndTime;
097:
098:            /**
099:             * The site where a job is scheduled to run.
100:             */
101:            private String mScheduledSite;
102:
103:            /**
104:             * The default constructor.
105:             */
106:            public HeftBag() {
107:                mAvgComputeTime = 0;
108:                mDownwardRank = 0;
109:                mUpwardRank = 0;
110:                mStartTime = 0;
111:                mEndTime = 0;
112:                mScheduledSite = "";
113:            }
114:
115:            /**
116:             * Adds an object to the underlying bag corresponding to a particular key.
117:             *
118:             * @param key the key with which the value has to be associated.
119:             * @param value the value to be associated with the key.
120:             *
121:             * @return boolean indicating if insertion was successful.
122:             *
123:             */
124:            public boolean add(Object key, Object value) {
125:                boolean result = true;
126:
127:                int k = getIntValue(key);
128:
129:                float fv = 0;
130:                long lv = 0;
131:
132:                //short cut for scheduled site
133:                if (k == this .SCHEDULED_SITE) {
134:                    mScheduledSite = (String) value;
135:                    return result;
136:                }
137:
138:                //parse the value correctly
139:                switch (k) {
140:                case 0:
141:                case 1:
142:                case 2:
143:                    fv = ((Float) value).floatValue();
144:                    break;
145:                case 3:
146:                case 4:
147:                    lv = ((Long) value).longValue();
148:                    break;
149:                default:
150:                }
151:
152:                switch (k) {
153:                case 0:
154:                    this .mAvgComputeTime = fv;
155:                    break;
156:
157:                case 1:
158:                    this .mDownwardRank = fv;
159:                    break;
160:
161:                case 2:
162:                    this .mUpwardRank = fv;
163:                    break;
164:
165:                case 3:
166:                    this .mStartTime = lv;
167:                    break;
168:
169:                case 4:
170:                    this .mEndTime = lv;
171:                    break;
172:
173:                default:
174:                    result = false;
175:                }
176:
177:                return result;
178:
179:            }
180:
181:            /**
182:             * Returns true if the namespace contains a mapping for the specified key.
183:             *
184:             * @param key The key that you want to search for in the bag.
185:             *
186:             * @return boolean
187:             */
188:            public boolean containsKey(Object key) {
189:
190:                int k = -1;
191:                try {
192:                    k = ((Integer) key).intValue();
193:                } catch (Exception e) {
194:                }
195:
196:                return (k >= this .AVG_COMPUTE_TIME.intValue() && k <= this .UPWARD_RANK
197:                        .intValue());
198:            }
199:
200:            /**
201:             * Returns an objects corresponding to the key passed.
202:             *
203:             * @param key the key corresponding to which the objects need to be
204:             *            returned.
205:             *
206:             * @return the object that is found corresponding to the key or null.
207:             */
208:            public Object get(Object key) {
209:
210:                int k = getIntValue(key);
211:
212:                switch (k) {
213:                case 0:
214:                    return this .mAvgComputeTime;
215:
216:                case 1:
217:                    return this .mDownwardRank;
218:
219:                case 2:
220:                    return this .mUpwardRank;
221:
222:                case 3:
223:                    return this .mStartTime;
224:
225:                case 4:
226:                    return this .mEndTime;
227:
228:                case 5:
229:                    return this .mScheduledSite;
230:
231:                default:
232:                    throw new RuntimeException(
233:                            " Wrong Heft key. Please use one of the predefined key types "
234:                                    + key);
235:                }
236:            }
237:
238:            /**
239:             * A convenience method to get the intValue for the object passed.
240:             *
241:             * @param key   the key to be converted
242:             *
243:             * @return the int value if object an integer, else -1
244:             */
245:            private int getIntValue(Object key) {
246:
247:                int k = -1;
248:                try {
249:                    k = ((Integer) key).intValue();
250:                } catch (Exception e) {
251:                }
252:
253:                return k;
254:
255:            }
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.