- Timestamp:
- 02/26/13 08:41:50 (12 years ago)
- Location:
- DCWoRMS/branches/coolemall
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/simulator/workload/WorkloadLoader.java
r801 r883 2 2 3 3 import org.qcg.broker.schemas.jobdesc.QcgJob; 4 import org.qcg.broker.schemas.jobdesc.ResourceConsumptionProfileType; 5 import org.qcg.broker.schemas.jobdesc.Task; 4 6 5 7 import java.io.IOException; … … 27 29 28 30 31 import schedframe.scheduling.tasks.Job; 29 32 import simulator.utils.XsltTransformations; 30 33 import simulator.workload.exceptons.NoSuchCommentException; 31 34 import simulator.workload.reader.archive.AbstractWAParser; 35 import simulator.workload.reader.archive.QcgWAJobReader; 32 36 import simulator.workload.reader.archive.WAFields; 33 37 import simulator.workload.reader.archive.WAReader; … … 58 62 59 63 protected Map<String, JobDescription> jobGridletsMap; 60 64 protected Map<String, JobDescription> jobProfilesMap; 65 61 66 public WorkloadLoader(XMLJobReader<QcgJob> xmlReader, WAReader<QcgJob> swfReader){ 62 67 if(swfReader == null){ 63 throw new RuntimeException("Swf reader is required to build proper gridlerts.");68 throw new RuntimeException("Swf reader is required to build proper tasks."); 64 69 } 65 70 this.xmlJobReader = xmlReader; … … 68 73 this.generatedTasksCnt = 0; 69 74 this.jobGridletsMap = new TreeMap<String, JobDescription>(); 75 this.jobProfilesMap = new TreeMap<String, JobDescription>(); 70 76 try { 71 77 this.xsltTransformation = new XsltTransformations(); … … 90 96 if(jobDescription.size() == 0){ 91 97 if(log.isWarnEnabled()) 92 log.warn("Omit ing job gridletcreation for job "+jobDescription.getDescription().getAppId()+". This job contains no tasks.");98 log.warn("Omitting tasks creation for job "+jobDescription.getDescription().getAppId()+". This job contains no tasks."); 93 99 return null; 94 100 } … … 103 109 104 110 String waTaskDesc[] = localWAParser.readTask(jobId, taskDesc.getTaskId()); 111 112 try{ 113 Integer.parseInt(taskDesc.getTaskId()); 114 } catch (NumberFormatException e){ 115 return jobDescription; 116 } 105 117 if(waTaskDesc != null) { 106 118 … … 125 137 timeValue = timeValue * puSpeed * allocProcesors; 126 138 taskDesc.setTaskLength(timeValue); 139 140 //if(taskDesc.getDescription().getExecution()!= n 127 141 128 142 } else if(parserType == 1){ … … 177 191 while((jobDesc = this.xmlJobReader.readRaw()) != null){ 178 192 jobDesc = this.xsltTransformation.extendJobDescription(jobDesc); 193 int prevJobCnt = generatedJobsCnt; 179 194 job = createJobDescription(jobDesc, puSpeed); 180 if(job != null )195 if(job != null && prevJobCnt != generatedJobsCnt) 181 196 this.jobGridletsMap.put(job.getJobId(), job); 197 else if (prevJobCnt == generatedJobsCnt){ 198 Task taskPattern = job.getDescription().getTask(0); 199 this.jobProfilesMap.put(taskPattern.getTaskId(), job); 200 } 182 201 } 183 202 } else { // use swf job reader. Job created by this reader does not require xslt transformation … … 188 207 } 189 208 } 209 210 if(generatedJobsCnt == 0){ 211 while((jobDesc = this.waReader.readRaw()) != null){ 212 QcgWAJobReader qcgReader = (QcgWAJobReader)waReader; 213 jobDesc = qcgReader.mergeSwfAndXmlProfile(jobProfilesMap, jobDesc); 214 job = createJobDescription(jobDesc, puSpeed); 215 if(job != null) 216 this.jobGridletsMap.put(job.getJobId(), job); 217 } 218 } 190 219 191 220 this.localWAParser.close(); … … 249 278 return simStartTimeDefined; 250 279 } 280 281 protected JobDescription createJobDescription(String jobDesc, long puSpeed, Map<String, JobDescription> jobProfilesMap) throws IOException{ 282 283 JobDescription jobDescription = null; 284 try { 285 jobDescription = this.xsltTransformation.splitJobToTasks(jobDesc); 286 } catch (Exception e) { 287 throw new IOException(e.getMessage()); 288 } 289 290 // look for any 291 292 if(jobDescription.size() == 0){ 293 if(log.isWarnEnabled()) 294 log.warn("Omitting tasks creation for job "+jobDescription.getDescription().getAppId()+". This job contains no tasks."); 295 return null; 296 } 297 298 String jobId = jobDescription.getJobId(); 299 int parserType = localWAParser.getType(); 300 301 for(int i = 0; i < jobDescription.size(); i++){ 302 TaskDescription taskDesc = jobDescription.get(i); 303 304 String waTaskDesc[] = localWAParser.readTask(jobId, taskDesc.getTaskId()); 305 306 if(waTaskDesc != null) { 307 308 if(parserType == 0){ 309 310 taskDesc.setUserDn(waTaskDesc[SWFFields.DATA_USER_ID]); 311 312 long timeValue = Long.parseLong(waTaskDesc[SWFFields.DATA_SUBMIT_TIME]); 313 taskDesc.setSubmissionTime(timeValue); 314 315 long waitTime = Long.parseLong(waTaskDesc[SWFFields.DATA_WAIT_TIME]); 316 taskDesc.setWorkloadLogWaitTime(waitTime); 317 318 timeValue = Long.parseLong(waTaskDesc[SWFFields.DATA_RUN_TIME]); 319 if(timeValue <= 0) 320 return null; 321 322 long allocProcesors = Long.parseLong(waTaskDesc[SWFFields.DATA_NUMBER_OF_ALLOCATED_PROCESSORS]); 323 if(allocProcesors <= 0) 324 return null; 325 326 timeValue = timeValue * puSpeed * allocProcesors; 327 taskDesc.setTaskLength(timeValue); 328 329 } else if(parserType == 1){ 330 331 taskDesc.setUserDn(waTaskDesc[GWFFields.DATA_USER_ID]); 332 333 long timeValue = Long.parseLong(waTaskDesc[GWFFields.DATA_SUBMIT_TIME]); 334 taskDesc.setSubmissionTime(timeValue); 335 336 long waitTime = Long.parseLong(waTaskDesc[GWFFields.DATA_WAIT_TIME]); 337 taskDesc.setWorkloadLogWaitTime(waitTime); 338 339 timeValue = Long.parseLong(waTaskDesc[GWFFields.DATA_RUN_TIME]); 340 if(timeValue <= 0) 341 return null; 342 343 long allocProcesors = Long.parseLong(waTaskDesc[GWFFields.DATA_NPROCS]); 344 if(allocProcesors <= 0) 345 return null; 346 347 timeValue = timeValue * puSpeed * allocProcesors; 348 taskDesc.setTaskLength(timeValue); 349 } 350 } 351 /*JobDescription xmlJobDescription = jobProfilesMap.get(taskDesc.getDescription().getExecution().getExecutable().getApplication().getName()); 352 if(xmlJobDescription != null){ 353 Task patternTask = xmlJobDescription.getDescription().getTask(0); 354 if(patternTask != null){ 355 ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile(); 356 taskDesc.getDescription().getExecution().setResourceConsumptionProfile(rcp); 357 } 358 }*/ 359 this.generatedTasksCnt++; 360 361 } 362 this.generatedJobsCnt++; 363 364 return jobDescription; 365 } 251 366 252 367 }
Note: See TracChangeset
for help on using the changeset viewer.