Ignore:
Timestamp:
02/26/13 08:41:50 (12 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/branches/coolemall
Files:
6 edited
2 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} 
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/AbstractWAParser.java

    r477 r883  
    3232        protected HashMap<String, String> reverseIdMapping; // key - xmlJobId_xmlTaskId, value - swf job id 
    3333        protected HashMap<String, Long> jobIndex; 
     34        protected HashMap<String, String> appMapping; 
    3435        protected String fields[]; 
    3536        protected int fieldsNo; 
     
    4445                this.reverseIdMapping = new HashMap<String, String>(); 
    4546                this.jobIndex = new HashMap<String, Long>(); 
     47                this.appMapping = new HashMap<String, String>(); 
    4648                this.headerLoaded = false; 
    4749                this.buildIndex = true; 
     
    144146                        } else if(label.equals(WAFields.COMMENT_IDMAPPING)){ 
    145147                                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); 
    146154                                continue; 
    147155                        } 
     
    285293                return null; 
    286294        } 
     295         
     296         
     297        public String getAppMapping(String appId) { 
     298                String appName = appMapping.get(appId); 
     299                return appName; 
     300        } 
     301         
    287302} 
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/QcgWAJobReader.java

    r477 r883  
    22 
    33import java.io.IOException; 
     4import java.io.StringReader; 
    45import java.io.StringWriter; 
    56import java.io.Writer; 
     7import java.util.Map; 
    68 
    79import org.exolab.castor.xml.MarshalException; 
    810import org.exolab.castor.xml.Marshaller; 
    911import org.exolab.castor.xml.ResolverException; 
     12import org.exolab.castor.xml.Unmarshaller; 
    1013import org.exolab.castor.xml.ValidationException; 
    1114import org.exolab.castor.xml.XMLContext; 
     
    1316import simulator.workload.reader.archive.swf.SWFFields; 
    1417import org.qcg.broker.schemas.jobdesc.QcgJob; 
     18import org.qcg.broker.schemas.jobdesc.ResourceConsumptionProfileType; 
    1519import org.qcg.broker.schemas.jobdesc.Task; 
     20 
     21import dcworms.schedframe.scheduling.utils.JobDescription; 
    1622 
    1723/** 
     
    2531        protected String currntJobID; 
    2632        protected Marshaller marshaller; 
     33         
     34        protected Unmarshaller unmarshaller; 
    2735         
    2836        public QcgWAJobReader(String fileName) throws NullPointerException, 
     
    4250                        context.addPackage("org.qcg.broker.schemas.jobdesc.QcgJob"); 
    4351                        this.marshaller = context.createMarshaller(); 
     52                        unmarshaller = context.createUnmarshaller(); 
    4453                } catch (ResolverException e) { 
    4554                        e.printStackTrace(); 
    4655                        this.marshaller = null; 
     56                        unmarshaller = null; 
    4757                } 
    4858        } 
     
    100110        } 
    101111 
     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        } 
    102146} 
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/WAParser.java

    r477 r883  
    4343         
    4444        public int getType(); 
     45         
     46        public String getAppMapping(String appId); 
    4547} 
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/swf/QcgSWFJobReader.java

    r477 r883  
    11package simulator.workload.reader.archive.swf; 
    22 
     3import org.qcg.broker.schemas.jobdesc.Application; 
    34import org.qcg.broker.schemas.jobdesc.ComputingResourceBaseTypeChoice; 
    45import org.qcg.broker.schemas.jobdesc.ComputingResourceType; 
    56import org.qcg.broker.schemas.jobdesc.ComputingResourceBaseTypeChoiceItem; 
    67import org.qcg.broker.schemas.jobdesc.ComputingResourceParameterType; 
     8import org.qcg.broker.schemas.jobdesc.Executable; 
    79import org.qcg.broker.schemas.jobdesc.ExecutionTimeType; 
     10import org.qcg.broker.schemas.jobdesc.ExecutionType; 
    811import org.qcg.broker.schemas.jobdesc.ParameterTypeChoice; 
    912import org.qcg.broker.schemas.jobdesc.ParameterTypeChoiceItem; 
     
    1316import org.qcg.broker.schemas.jobdesc.types.ComputingParameterName; 
    1417import org.qcg.broker.schemas.jobdesc.Task; 
     18 
    1519import java.io.IOException; 
    1620 
     
    2024 
    2125import simulator.workload.reader.archive.QcgWAJobReader; 
     26import test.workloadandapp.AppTypeGenerator; 
    2227 
    2328 
     
    3439        protected String currntJobID; 
    3540         
     41        protected AppTypeGenerator appTypeGen; 
     42         
    3643        public QcgSWFJobReader(String fileName) throws NullPointerException, 
    3744                        IOException { 
    3845                super(fileName); 
    3946                this.waParser.loadHeader(); 
     47                this.appTypeGen = new AppTypeGenerator(); 
    4048        } 
    4149         
     
    7583                                                if(value <= 0){ 
    7684                                                        if(log.isWarnEnabled()) 
    77                                                                 log.warn("Task "+data[0] + " is omited. 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."); 
    7886                                                        return null; 
    7987                                                } 
     
    8290                                                if(value <= 0){ 
    8391                                                        if(log.isWarnEnabled()) 
    84                                                                 log.warn("Task "+data[0] + " is omited. 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."); 
    8593                                                        return null; 
    8694                                                } 
     
    8997                                                if(value <= 0){ 
    9098                                                        if(log.isWarnEnabled()) 
    91                                                                 log.warn("Task "+data[0] + " is omited. Task runtime should be grather then 0."); 
     99                                                                log.warn("Task "+data[0] + " is omitted. Task runtime should be greater than 0."); 
    92100                                                        return null; 
    93101                                                } 
     
    95103                                } 
    96104                                 
    97                                 if (value == -1) continue; 
     105                                if (value == -1 && i != SWFFields.DATA_EXECUTABLE_NUMBER) continue; 
    98106                                 
    99107                        } catch (NumberFormatException e) { 
     
    207215                                         
    208216                                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); 
    209232                                        break; 
    210233                                         
  • DCWoRMS/branches/coolemall/src/simulator/workload/writer/swf/QcgSWFJobWriter.java

    r477 r883  
    1313import org.qcg.broker.schemas.jobdesc.Task; 
    1414import org.qcg.broker.schemas.jobdesc.wrapper.TaskRequirements; 
    15 import org.qcg.broker.schemas.jobdesc.wrapper.impl.TaskRequirementsImpl; 
     15import test.jobschema.DCWoRMSTaskRequirementsImpl; 
    1616 
    1717/** 
     
    3737                String idMapping; 
    3838                String taskId; 
    39                 TaskRequirements taskReqWrapper = new TaskRequirementsImpl(); 
     39                TaskRequirements taskReqWrapper = new DCWoRMSTaskRequirementsImpl(); 
    4040                 
    4141                for(int i = 0; i < job.getTaskCount(); i++){ 
Note: See TracChangeset for help on using the changeset viewer.