Ignore:
Timestamp:
02/26/13 08:41:50 (12 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/branches/coolemall
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/simulator/workload/WorkloadLoader.java

    r801 r883  
    22 
    33import org.qcg.broker.schemas.jobdesc.QcgJob; 
     4import org.qcg.broker.schemas.jobdesc.ResourceConsumptionProfileType; 
     5import org.qcg.broker.schemas.jobdesc.Task; 
    46 
    57import java.io.IOException; 
     
    2729 
    2830 
     31import schedframe.scheduling.tasks.Job; 
    2932import simulator.utils.XsltTransformations; 
    3033import simulator.workload.exceptons.NoSuchCommentException; 
    3134import simulator.workload.reader.archive.AbstractWAParser; 
     35import simulator.workload.reader.archive.QcgWAJobReader; 
    3236import simulator.workload.reader.archive.WAFields; 
    3337import simulator.workload.reader.archive.WAReader; 
     
    5862         
    5963        protected Map<String, JobDescription> jobGridletsMap; 
    60          
     64        protected Map<String, JobDescription> jobProfilesMap; 
     65 
    6166        public WorkloadLoader(XMLJobReader<QcgJob> xmlReader, WAReader<QcgJob> swfReader){ 
    6267                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."); 
    6469                } 
    6570                this.xmlJobReader = xmlReader; 
     
    6873                this.generatedTasksCnt = 0; 
    6974                this.jobGridletsMap = new TreeMap<String, JobDescription>(); 
     75                this.jobProfilesMap = new TreeMap<String, JobDescription>(); 
    7076                try { 
    7177                        this.xsltTransformation = new XsltTransformations(); 
     
    9096                if(jobDescription.size() == 0){ 
    9197                        if(log.isWarnEnabled()) 
    92                                 log.warn("Omiting job gridlet creation 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."); 
    9399                        return null; 
    94100                } 
     
    103109                         
    104110                        String waTaskDesc[] = localWAParser.readTask(jobId, taskDesc.getTaskId()); 
     111                         
     112                        try{ 
     113                                Integer.parseInt(taskDesc.getTaskId()); 
     114                        } catch (NumberFormatException e){ 
     115                                return jobDescription; 
     116                        } 
    105117                        if(waTaskDesc != null) { 
    106118                                 
     
    125137                                        timeValue = timeValue * puSpeed * allocProcesors; 
    126138                                        taskDesc.setTaskLength(timeValue); 
     139                                         
     140                                        //if(taskDesc.getDescription().getExecution()!= n 
    127141 
    128142                                } else if(parserType == 1){ 
     
    177191                        while((jobDesc = this.xmlJobReader.readRaw()) != null){ 
    178192                                jobDesc = this.xsltTransformation.extendJobDescription(jobDesc); 
     193                                int prevJobCnt = generatedJobsCnt; 
    179194                                job = createJobDescription(jobDesc, puSpeed); 
    180                                 if(job != null) 
     195                                if(job != null && prevJobCnt != generatedJobsCnt) 
    181196                                        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                                } 
    182201                        } 
    183202                } else {                                                // use swf job reader. Job created by this reader does not require xslt transformation 
     
    188207                        } 
    189208                } 
     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                } 
    190219 
    191220                this.localWAParser.close(); 
     
    249278                return simStartTimeDefined; 
    250279        } 
     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        } 
    251366         
    252367} 
Note: See TracChangeset for help on using the changeset viewer.