1 | package simulator.workload.reader.archive.swf; |
---|
2 | |
---|
3 | import org.qcg.broker.schemas.jobdesc.ComputingResourceBaseTypeChoice; |
---|
4 | import org.qcg.broker.schemas.jobdesc.ComputingResourceType; |
---|
5 | import org.qcg.broker.schemas.jobdesc.ComputingResourceBaseTypeChoiceItem; |
---|
6 | import org.qcg.broker.schemas.jobdesc.ComputingResourceParameterType; |
---|
7 | import org.qcg.broker.schemas.jobdesc.ExecutionTimeType; |
---|
8 | import org.qcg.broker.schemas.jobdesc.ParameterTypeChoice; |
---|
9 | import org.qcg.broker.schemas.jobdesc.ParameterTypeChoiceItem; |
---|
10 | import org.qcg.broker.schemas.jobdesc.ResourceRequirementsType; |
---|
11 | import org.qcg.broker.schemas.jobdesc.Value; |
---|
12 | import org.qcg.broker.schemas.jobdesc.RequirementsType; |
---|
13 | import org.qcg.broker.schemas.jobdesc.types.ComputingParameterName; |
---|
14 | import org.qcg.broker.schemas.jobdesc.Task; |
---|
15 | import java.io.IOException; |
---|
16 | |
---|
17 | import org.apache.commons.logging.Log; |
---|
18 | import org.apache.commons.logging.LogFactory; |
---|
19 | import org.exolab.castor.types.Duration; |
---|
20 | |
---|
21 | import simulator.workload.reader.archive.GrmsWAJobReader; |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | /** |
---|
26 | * |
---|
27 | * @author Marcin Krystek |
---|
28 | * |
---|
29 | */ |
---|
30 | public class Grms3SWFJobReader extends GrmsWAJobReader { |
---|
31 | |
---|
32 | private Log log = LogFactory.getLog(Grms3SWFJobReader.class); |
---|
33 | |
---|
34 | protected String currntJobID; |
---|
35 | |
---|
36 | public Grms3SWFJobReader(String fileName) throws NullPointerException, |
---|
37 | IOException { |
---|
38 | super(fileName); |
---|
39 | this.waParser.loadHeader(); |
---|
40 | } |
---|
41 | |
---|
42 | public Grms3SWFJobReader(SWFParser parser) { |
---|
43 | super(parser); |
---|
44 | } |
---|
45 | |
---|
46 | protected Task createTask(String[] data) { |
---|
47 | RequirementsType requirements = null; |
---|
48 | ResourceRequirementsType taskReq = null; |
---|
49 | ComputingResourceType compResource = null; |
---|
50 | ComputingResourceBaseTypeChoice choice = null; |
---|
51 | ComputingResourceBaseTypeChoiceItem crItem = null; |
---|
52 | ComputingResourceParameterType param = null; |
---|
53 | |
---|
54 | Task task = null; |
---|
55 | long value = -1; |
---|
56 | |
---|
57 | task = new Task(); |
---|
58 | requirements = new RequirementsType(); |
---|
59 | taskReq = new ResourceRequirementsType(); |
---|
60 | compResource = new ComputingResourceType(); |
---|
61 | choice = new ComputingResourceBaseTypeChoice(); |
---|
62 | |
---|
63 | compResource.setComputingResourceBaseTypeChoice(choice); |
---|
64 | taskReq.addComputingResource(compResource); |
---|
65 | requirements.setResourceRequirements(taskReq); |
---|
66 | task.setRequirements(requirements); |
---|
67 | |
---|
68 | for(int i = 0; i < SWFFields.DATA_FIELDS.length; i++){ |
---|
69 | try { |
---|
70 | |
---|
71 | value = Long.parseLong(data[SWFFields.DATA_FIELDS[i]]); |
---|
72 | |
---|
73 | switch(SWFFields.DATA_FIELDS[i]){ |
---|
74 | case SWFFields.DATA_NUMBER_OF_ALLOCATED_PROCESSORS: |
---|
75 | if(value <= 0){ |
---|
76 | if(log.isWarnEnabled()) |
---|
77 | log.warn("Task "+data[0] + " is omited. Number of allocated processors should be grather then 0."); |
---|
78 | return null; |
---|
79 | } |
---|
80 | break; |
---|
81 | case SWFFields.DATA_REQUESTED_NUMBER_OF_PROCESSORS: |
---|
82 | if(value <= 0){ |
---|
83 | if(log.isWarnEnabled()) |
---|
84 | log.warn("Task "+data[0] + " is omited. Number of requested processors should be grather then 0."); |
---|
85 | return null; |
---|
86 | } |
---|
87 | break; |
---|
88 | case SWFFields.DATA_RUN_TIME: |
---|
89 | if(value <= 0){ |
---|
90 | if(log.isWarnEnabled()) |
---|
91 | log.warn("Task "+data[0] + " is omited. Task runtime should be grather then 0."); |
---|
92 | return null; |
---|
93 | } |
---|
94 | break; |
---|
95 | } |
---|
96 | |
---|
97 | if (value == -1) continue; |
---|
98 | |
---|
99 | } catch (NumberFormatException e) { |
---|
100 | if(SWFFields.DATA_FIELDS[i] != SWFFields.DATA_JOB_NUMBER && |
---|
101 | SWFFields.DATA_FIELDS[i] != SWFFields.DATA_PRECEDING_JOB_NUMBER) |
---|
102 | continue; |
---|
103 | } |
---|
104 | |
---|
105 | switch(SWFFields.DATA_FIELDS[i]){ |
---|
106 | case SWFFields.DATA_JOB_NUMBER: |
---|
107 | currntJobID = data[SWFFields.DATA_FIELDS[i]]; |
---|
108 | String tab[] = this.waParser.getIDMapping(currntJobID); |
---|
109 | task.setTaskId(tab[1]); |
---|
110 | break; |
---|
111 | |
---|
112 | case SWFFields.DATA_SUBMIT_TIME: |
---|
113 | /* |
---|
114 | * This is information for simulator not for task description. |
---|
115 | * See WorkloadLoader for details. |
---|
116 | */ |
---|
117 | break; |
---|
118 | |
---|
119 | case SWFFields.DATA_WAIT_TIME: |
---|
120 | break; |
---|
121 | |
---|
122 | case SWFFields.DATA_RUN_TIME: |
---|
123 | /* |
---|
124 | * This is information for simulator not for task description. |
---|
125 | * See WorkloadLoader for details. |
---|
126 | */ |
---|
127 | break; |
---|
128 | |
---|
129 | case SWFFields.DATA_NUMBER_OF_ALLOCATED_PROCESSORS: |
---|
130 | /* |
---|
131 | * This is information for simulator not for task description. |
---|
132 | * See WorkloadLoader for details. |
---|
133 | */ |
---|
134 | break; |
---|
135 | |
---|
136 | case SWFFields.DATA_AVERAGE_CPU_TIME_USED: |
---|
137 | break; |
---|
138 | |
---|
139 | case SWFFields.DATA_USED_MEMORY: |
---|
140 | /* |
---|
141 | * This is information for simulator not for task description. |
---|
142 | * See WorkloadLoader for details. |
---|
143 | */ |
---|
144 | break; |
---|
145 | |
---|
146 | case SWFFields.DATA_REQUESTED_NUMBER_OF_PROCESSORS: |
---|
147 | |
---|
148 | crItem = new ComputingResourceBaseTypeChoiceItem(); |
---|
149 | param = new ComputingResourceParameterType(); |
---|
150 | |
---|
151 | param.setName(ComputingParameterName.CPUCOUNT); |
---|
152 | { |
---|
153 | ParameterTypeChoice tpChoice = new ParameterTypeChoice(); |
---|
154 | ParameterTypeChoiceItem item = new ParameterTypeChoiceItem(); |
---|
155 | Value paramValue = new Value(); |
---|
156 | |
---|
157 | paramValue.setContent(Long.valueOf(value).doubleValue()); |
---|
158 | item.setValue(paramValue); |
---|
159 | tpChoice.addParameterTypeChoiceItem(item); |
---|
160 | param.setParameterTypeChoice(tpChoice); |
---|
161 | } |
---|
162 | crItem.setHostParameter(param); |
---|
163 | choice.addComputingResourceBaseTypeChoiceItem(crItem); |
---|
164 | |
---|
165 | break; |
---|
166 | |
---|
167 | case SWFFields.DATA_REQUESTED_TIME: |
---|
168 | ExecutionTimeType executionTime = new ExecutionTimeType(); |
---|
169 | |
---|
170 | // requested time is expressed in swf file in seconds |
---|
171 | // multiply value * 1000 to get milliseconds |
---|
172 | Duration d = new Duration(value * 1000); |
---|
173 | |
---|
174 | executionTime.setExecutionDuration(d); |
---|
175 | task.setExecutionTime(executionTime); |
---|
176 | break; |
---|
177 | |
---|
178 | case SWFFields.DATA_REQUESTED_MEMORY: |
---|
179 | crItem = new ComputingResourceBaseTypeChoiceItem(); |
---|
180 | param = new ComputingResourceParameterType(); |
---|
181 | |
---|
182 | param.setName(ComputingParameterName.MEMORY); |
---|
183 | { |
---|
184 | ParameterTypeChoice tpChoice = new ParameterTypeChoice(); |
---|
185 | ParameterTypeChoiceItem item = new ParameterTypeChoiceItem(); |
---|
186 | Value paramValue = new Value(); |
---|
187 | |
---|
188 | paramValue.setContent(Long.valueOf(value).doubleValue()); |
---|
189 | item.setValue(paramValue); |
---|
190 | tpChoice.addParameterTypeChoiceItem(item); |
---|
191 | param.setParameterTypeChoice(tpChoice); |
---|
192 | } |
---|
193 | |
---|
194 | crItem.setHostParameter(param); |
---|
195 | choice.addComputingResourceBaseTypeChoiceItem(crItem); |
---|
196 | |
---|
197 | break; |
---|
198 | |
---|
199 | case SWFFields.DATA_STATUS: |
---|
200 | break; |
---|
201 | |
---|
202 | case SWFFields.DATA_USER_ID: |
---|
203 | break; |
---|
204 | |
---|
205 | case SWFFields.DATA_GROUP_ID: |
---|
206 | break; |
---|
207 | |
---|
208 | case SWFFields.DATA_EXECUTABLE_NUMBER: |
---|
209 | break; |
---|
210 | |
---|
211 | case SWFFields.DATA_QUEUE_NUMBER: |
---|
212 | break; |
---|
213 | |
---|
214 | case SWFFields.DATA_PARTITION_NUMBER: |
---|
215 | break; |
---|
216 | |
---|
217 | case SWFFields.DATA_PRECEDING_JOB_NUMBER: |
---|
218 | break; |
---|
219 | |
---|
220 | case SWFFields.DATA_THINK_TIME_FROM_PRECEDING_JOB: |
---|
221 | break; |
---|
222 | } |
---|
223 | } |
---|
224 | |
---|
225 | return task; |
---|
226 | } |
---|
227 | |
---|
228 | } |
---|