Changeset 1207 for DCWoRMS/branches/coolemall/src/simulator/workload
- Timestamp:
- 11/26/13 11:56:07 (11 years ago)
- Location:
- DCWoRMS/branches/coolemall/src/simulator/workload
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/simulator/workload/WorkloadLoader.java
r1170 r1207 17 17 import javax.xml.xpath.XPathExpressionException; 18 18 19 import org.apache.commons.io.FilenameUtils; 19 20 import org.apache.commons.logging.Log; 20 21 import org.apache.commons.logging.LogFactory; … … 32 33 import simulator.workload.reader.archive.swf.SWFFields; 33 34 import simulator.workload.reader.xmlJob.XMLJobReader; 35 import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 34 36 import dcworms.schedframe.scheduling.utils.JobDescription; 35 37 import dcworms.schedframe.scheduling.utils.TaskDescription; … … 56 58 57 59 protected Map<String, JobDescription> jobsMap; 58 protected Map<String, JobDescription> applicationProfilesMap; 59 60 public WorkloadLoader(XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlReader, WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader){ 60 61 protected String appProfilesFolder; 62 protected Map<String, ApplicationProfileDescription> applicationProfiles; 63 64 public WorkloadLoader(XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlReader, WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader, String appProfilesFolder){ 61 65 if(swfReader == null){ 62 66 throw new RuntimeException("Swf reader is required to build proper tasks."); … … 67 71 this.generatedTasksCnt = 0; 68 72 this.jobsMap = new TreeMap<String, JobDescription>(); 69 this.applicationProfilesMap = new TreeMap<String, JobDescription>(); 73 this.appProfilesFolder = appProfilesFolder; 74 this.applicationProfiles = new TreeMap<String, ApplicationProfileDescription>(); 70 75 try { 71 76 this.xsltTransformation = new XsltTransformations(); … … 187 192 188 193 // determine which reader should be used 189 String jobDesc = null; 190 JobDescription job = null; 191 194 String xmlJob = null; 195 JobDescription jobDesc = null; 196 197 for(String key: waReader.getParser().getAppProfilesLocation().keySet()){ 198 String xmlApp = loadApplicationProfile(waReader.getParser().getAppProfilesLocation().get(key)); 199 xmlApp = this.xsltTransformation.extendJobDescription(xmlApp); 200 ApplicationProfileDescription app = this.xsltTransformation.getApplicationProfileDescription(xmlApp); 201 this.applicationProfiles.put(key, app); 202 } 203 192 204 if(this.xmlJobReader != null){ // use xml job reader. Xml job require xslt transformation 193 while(( jobDesc= this.xmlJobReader.readRaw()) != null){194 jobDesc = this.xsltTransformation.extendJobDescription(jobDesc);195 job = createJobDescription(jobDesc, puSpeed);196 if(job != null)197 this.jobsMap.put(job .getJobId(), job);205 while((xmlJob = this.xmlJobReader.readRaw()) != null){ 206 xmlJob = this.xsltTransformation.extendJobDescription(xmlJob); 207 jobDesc = createJobDescription(xmlJob, puSpeed); 208 if(jobDesc != null) 209 this.jobsMap.put(jobDesc.getJobId(), jobDesc); 198 210 } 199 211 } else { // use swf job reader. Job created by this reader does not require xslt transformation 200 212 201 for(String key: waReader.getParser().getAppMapping().keySet()){ 202 jobDesc = loadApplicationProfile(waReader.getParser().getAppMapping().get(key)); 203 jobDesc = this.xsltTransformation.extendJobDescription(jobDesc); 204 205 try { 206 job = this.xsltTransformation.splitJobToTasks(jobDesc); 207 } catch (Exception e) { 208 throw new IOException(e.getMessage()); 209 } 210 211 this.applicationProfilesMap.put(key, job); 212 } 213 214 while((jobDesc = this.waReader.readRaw()) != null){ 213 while((xmlJob = this.waReader.readRaw()) != null){ 215 214 QcgWAJobReader qcgReader = (QcgWAJobReader)waReader; 216 if(!applicationProfilesMap.isEmpty()) 217 jobDesc = qcgReader.mergeSwfAndXmlProfile(applicationProfilesMap, jobDesc); 218 job = createJobDescription(jobDesc, puSpeed); 219 /*if(job!= null && !applicationProfilesMap.isEmpty()){ 220 for(int i = 0; i < job.getDescription().getTaskCount(); i++){ 221 try { 222 JobDescription xmlJobDescription = applicationProfilesMap.get(job.getDescription().getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 223 if(xmlJobDescription != null){ 224 for(int j = 0; j < xmlJobDescription.size(); j++){ 225 Task patternTask = xmlJobDescription.getDescription().getTask(j); 226 if(patternTask != null){ 227 ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile(); 228 job.getDescription().getTask(j).getExecution().setResourceConsumptionProfile(rcp); 229 } 230 } 231 } 232 } catch (Exception e){ 233 continue; 234 } 235 } 236 } 237 */ 238 if(job != null) 239 this.jobsMap.put(job.getJobId(), job); 215 if(!applicationProfiles.isEmpty()) 216 xmlJob = qcgReader.mergeSwfAndAppProfile(applicationProfiles, xmlJob); 217 jobDesc = createJobDescription(xmlJob, puSpeed); 218 if(jobDesc != null) 219 this.jobsMap.put(jobDesc.getJobId(), jobDesc); 240 220 } 241 221 } … … 302 282 } 303 283 304 public String loadApplicationProfile(String fileName) throws IOException{284 public String loadApplicationProfile(String pathToAppProfile) throws IOException{ 305 285 306 286 BufferedReader reader = null; 307 287 StringBuffer buffer = new StringBuffer(); 308 288 309 try { 310 reader = new BufferedReader(new FileReader(fileName)); 289 String localPathToAppProfile; 290 291 if(appProfilesFolder != null) { 292 String folderName = FilenameUtils.getFullPath(appProfilesFolder); 293 String fileName = FilenameUtils.getName(pathToAppProfile); 294 localPathToAppProfile = folderName + fileName; 295 } else { 296 localPathToAppProfile = pathToAppProfile; 297 } 298 try { 299 reader = new BufferedReader(new FileReader(localPathToAppProfile )); 311 300 String line = null; 312 301 -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/AbstractWAParser.java
r1144 r1207 33 33 protected HashMap<String, String> reverseIdMapping; // key - xmlJobId_xmlTaskId, value - swf job id 34 34 protected HashMap<String, Long> jobIndex; 35 protected HashMap<String, String> app Mapping;35 protected HashMap<String, String> appProfilesLocation; 36 36 protected String fields[]; 37 37 protected int fieldsNo; … … 46 46 this.reverseIdMapping = new HashMap<String, String>(); 47 47 this.jobIndex = new HashMap<String, Long>(); 48 this.app Mapping= new HashMap<String, String>();48 this.appProfilesLocation = new HashMap<String, String>(); 49 49 this.headerLoaded = false; 50 50 this.buildIndex = true; 51 51 this.fieldsNo = 18; 52 52 53 } 53 54 … … 152 153 String appId = valueData[0]; 153 154 String pathToAppProfile = valueData[1]; 154 app Mapping.put(appId, pathToAppProfile);155 appProfilesLocation.put(appId, pathToAppProfile); 155 156 continue; 156 157 } … … 296 297 297 298 298 public Map<String, String> getApp Mapping() {299 return app Mapping;299 public Map<String, String> getAppProfilesLocation() { 300 return appProfilesLocation; 300 301 } 301 302 -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/QcgWAJobReader.java
r1163 r1207 15 15 16 16 import simulator.workload.reader.archive.swf.SWFFields; 17 18 import org.qcg.broker.schemas.jobdesc.FileType; 17 19 import org.qcg.broker.schemas.jobdesc.ResourceConsumptionProfileType; 18 20 import org.qcg.broker.schemas.jobdesc.Task; 19 21 import org.qcg.broker.schemas.jobdesc.Workflow; 20 22 21 import dcworms.schedframe.scheduling.utils. JobDescription;23 import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 22 24 23 25 /** … … 116 118 } 117 119 118 public String mergeSwfAnd XmlProfile(Map<String, JobDescription> applicationProfilesMap, String swfJobDesc) throws IOException{120 public String mergeSwfAndAppProfile(Map<String, ApplicationProfileDescription> applicationProfiles, String swfJobDesc) throws IOException{ 119 121 120 122 StringReader reader = new StringReader(swfJobDesc); … … 132 134 for(int i = 0; i < job.getTaskCount(); i++){ 133 135 try { 134 JobDescription xmlJobDescription = applicationProfilesMap.get(job.getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 135 if(xmlJobDescription != null){ 136 for(int j = 0; j < xmlJobDescription.size(); j++){ 137 Task patternTask = xmlJobDescription.getDescription().getTask(j); 138 if(patternTask != null){ 139 ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile(); 140 job.getTask(j).getExecution().setResourceConsumptionProfile(rcp); 141 } 136 ApplicationProfileDescription appProfileDescription = applicationProfiles.get(job.getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 137 if(appProfileDescription != null){ 138 Task patternTask = appProfileDescription.getDescription(); 139 if(patternTask != null){ 140 ResourceConsumptionProfileType[] rcp = patternTask.getExecution().getResourceConsumptionProfile(); 141 job.getTask(i).getExecution().setResourceConsumptionProfile(rcp); 142 FileType script = new FileType(); 143 script.setName(patternTask.getId()); 144 job.getTask(i).getExecution().addStdin(script); 142 145 } 143 146 } -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/WAParser.java
r1144 r1207 45 45 public int getType(); 46 46 47 public Map<String, String> getApp Mapping();47 public Map<String, String> getAppProfilesLocation(); 48 48 } -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/swf/QcgSWFJobReader.java
r1202 r1207 221 221 222 222 case SWFFields.DATA_EXECUTABLE_NUMBER: 223 String pathToAppProfile = waParser.getApp Mapping().get(String.valueOf(value));223 String pathToAppProfile = waParser.getAppProfilesLocation().get(String.valueOf(value)); 224 224 String appName = null; 225 225 if(pathToAppProfile == null){
Note: See TracChangeset
for help on using the changeset viewer.