Changeset 883 for DCWoRMS/branches/coolemall/src/simulator/workload
- Timestamp:
- 02/26/13 08:41:50 (12 years ago)
- Location:
- DCWoRMS/branches/coolemall
- Files:
-
- 6 edited
- 2 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 } -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/AbstractWAParser.java
r477 r883 32 32 protected HashMap<String, String> reverseIdMapping; // key - xmlJobId_xmlTaskId, value - swf job id 33 33 protected HashMap<String, Long> jobIndex; 34 protected HashMap<String, String> appMapping; 34 35 protected String fields[]; 35 36 protected int fieldsNo; … … 44 45 this.reverseIdMapping = new HashMap<String, String>(); 45 46 this.jobIndex = new HashMap<String, Long>(); 47 this.appMapping = new HashMap<String, String>(); 46 48 this.headerLoaded = false; 47 49 this.buildIndex = true; … … 144 146 } else if(label.equals(WAFields.COMMENT_IDMAPPING)){ 145 147 loadIDMapping(); 148 continue; 149 } else if(label.equals(WAFields.COMMENT_APPLICATION)){ 150 String [] valueData = value.split(" "); 151 String appId = valueData[0]; 152 String appName = valueData[1]; 153 appMapping.put(appId, appName); 146 154 continue; 147 155 } … … 285 293 return null; 286 294 } 295 296 297 public String getAppMapping(String appId) { 298 String appName = appMapping.get(appId); 299 return appName; 300 } 301 287 302 } -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/QcgWAJobReader.java
r477 r883 2 2 3 3 import java.io.IOException; 4 import java.io.StringReader; 4 5 import java.io.StringWriter; 5 6 import java.io.Writer; 7 import java.util.Map; 6 8 7 9 import org.exolab.castor.xml.MarshalException; 8 10 import org.exolab.castor.xml.Marshaller; 9 11 import org.exolab.castor.xml.ResolverException; 12 import org.exolab.castor.xml.Unmarshaller; 10 13 import org.exolab.castor.xml.ValidationException; 11 14 import org.exolab.castor.xml.XMLContext; … … 13 16 import simulator.workload.reader.archive.swf.SWFFields; 14 17 import org.qcg.broker.schemas.jobdesc.QcgJob; 18 import org.qcg.broker.schemas.jobdesc.ResourceConsumptionProfileType; 15 19 import org.qcg.broker.schemas.jobdesc.Task; 20 21 import dcworms.schedframe.scheduling.utils.JobDescription; 16 22 17 23 /** … … 25 31 protected String currntJobID; 26 32 protected Marshaller marshaller; 33 34 protected Unmarshaller unmarshaller; 27 35 28 36 public QcgWAJobReader(String fileName) throws NullPointerException, … … 42 50 context.addPackage("org.qcg.broker.schemas.jobdesc.QcgJob"); 43 51 this.marshaller = context.createMarshaller(); 52 unmarshaller = context.createUnmarshaller(); 44 53 } catch (ResolverException e) { 45 54 e.printStackTrace(); 46 55 this.marshaller = null; 56 unmarshaller = null; 47 57 } 48 58 } … … 100 110 } 101 111 112 public String mergeSwfAndXmlProfile( Map<String, JobDescription> jobProfilesMap, String swfJobDesc) throws IOException{ 113 114 StringReader reader = new StringReader(swfJobDesc); 115 QcgJob job = null; 116 try { 117 job = (QcgJob)unmarshaller.unmarshal(reader); 118 } catch (MarshalException e) { 119 // TODO Auto-generated catch block 120 e.printStackTrace(); 121 } catch (ValidationException e) { 122 // TODO Auto-generated catch block 123 e.printStackTrace(); 124 } 125 126 JobDescription xmlJobDescription = jobProfilesMap.get(job.getTask(0).getExecution().getExecutable().getApplication().getName()); 127 if(xmlJobDescription != null){ 128 Task patternTask = xmlJobDescription.getDescription().getTask(0); 129 if(patternTask != null){ 130 ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile(); 131 job.getTask(0).getExecution().setResourceConsumptionProfile(rcp); 132 } 133 } 134 135 Writer w = new StringWriter(); 136 try { 137 this.marshaller.setWriter(w); 138 this.marshaller.marshal(job); 139 } catch (MarshalException e) { 140 new IOException(e.getMessage()); 141 } catch (ValidationException e) { 142 new IOException(e.getMessage()); 143 } 144 return w.toString(); 145 } 102 146 } -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/WAParser.java
r477 r883 43 43 44 44 public int getType(); 45 46 public String getAppMapping(String appId); 45 47 } -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/swf/QcgSWFJobReader.java
r477 r883 1 1 package simulator.workload.reader.archive.swf; 2 2 3 import org.qcg.broker.schemas.jobdesc.Application; 3 4 import org.qcg.broker.schemas.jobdesc.ComputingResourceBaseTypeChoice; 4 5 import org.qcg.broker.schemas.jobdesc.ComputingResourceType; 5 6 import org.qcg.broker.schemas.jobdesc.ComputingResourceBaseTypeChoiceItem; 6 7 import org.qcg.broker.schemas.jobdesc.ComputingResourceParameterType; 8 import org.qcg.broker.schemas.jobdesc.Executable; 7 9 import org.qcg.broker.schemas.jobdesc.ExecutionTimeType; 10 import org.qcg.broker.schemas.jobdesc.ExecutionType; 8 11 import org.qcg.broker.schemas.jobdesc.ParameterTypeChoice; 9 12 import org.qcg.broker.schemas.jobdesc.ParameterTypeChoiceItem; … … 13 16 import org.qcg.broker.schemas.jobdesc.types.ComputingParameterName; 14 17 import org.qcg.broker.schemas.jobdesc.Task; 18 15 19 import java.io.IOException; 16 20 … … 20 24 21 25 import simulator.workload.reader.archive.QcgWAJobReader; 26 import test.workloadandapp.AppTypeGenerator; 22 27 23 28 … … 34 39 protected String currntJobID; 35 40 41 protected AppTypeGenerator appTypeGen; 42 36 43 public QcgSWFJobReader(String fileName) throws NullPointerException, 37 44 IOException { 38 45 super(fileName); 39 46 this.waParser.loadHeader(); 47 this.appTypeGen = new AppTypeGenerator(); 40 48 } 41 49 … … 75 83 if(value <= 0){ 76 84 if(log.isWarnEnabled()) 77 log.warn("Task "+data[0] + " is omit ed. Number of allocated processors should be grather then 0.");85 log.warn("Task "+data[0] + " is omitted. Number of allocated processors should be greater than 0."); 78 86 return null; 79 87 } … … 82 90 if(value <= 0){ 83 91 if(log.isWarnEnabled()) 84 log.warn("Task "+data[0] + " is omit ed. Number of requested processors should be grather then 0.");92 log.warn("Task "+data[0] + " is omitted. Number of requested processors should be greater than 0."); 85 93 return null; 86 94 } … … 89 97 if(value <= 0){ 90 98 if(log.isWarnEnabled()) 91 log.warn("Task "+data[0] + " is omit ed. Task runtime should be grather then 0.");99 log.warn("Task "+data[0] + " is omitted. Task runtime should be greater than 0."); 92 100 return null; 93 101 } … … 95 103 } 96 104 97 if (value == -1 ) continue;105 if (value == -1 && i != SWFFields.DATA_EXECUTABLE_NUMBER) continue; 98 106 99 107 } catch (NumberFormatException e) { … … 207 215 208 216 case SWFFields.DATA_EXECUTABLE_NUMBER: 217 String appName = waParser.getAppMapping(String.valueOf(value)); 218 if(appName == null){ 219 if(value != -1){ 220 appName = String.valueOf(value); 221 } else { 222 appName = appTypeGen.randomAppType(); 223 } 224 } 225 ExecutionType execType = new ExecutionType(); 226 Executable executable = new Executable(); 227 Application application = new Application(); 228 application.setName(appName); 229 executable.setApplication(application); 230 execType.setExecutable(executable); 231 task.setExecution(execType); 209 232 break; 210 233 -
DCWoRMS/branches/coolemall/src/simulator/workload/writer/swf/QcgSWFJobWriter.java
r477 r883 13 13 import org.qcg.broker.schemas.jobdesc.Task; 14 14 import org.qcg.broker.schemas.jobdesc.wrapper.TaskRequirements; 15 import org.qcg.broker.schemas.jobdesc.wrapper.impl.TaskRequirementsImpl;15 import test.jobschema.DCWoRMSTaskRequirementsImpl; 16 16 17 17 /** … … 37 37 String idMapping; 38 38 String taskId; 39 TaskRequirements taskReqWrapper = new TaskRequirementsImpl();39 TaskRequirements taskReqWrapper = new DCWoRMSTaskRequirementsImpl(); 40 40 41 41 for(int i = 0; i < job.getTaskCount(); i++){
Note: See TracChangeset
for help on using the changeset viewer.