[1226] | 1 | package test; |
---|
| 2 | |
---|
| 3 | import java.util.Map; |
---|
| 4 | import java.util.TreeMap; |
---|
| 5 | |
---|
| 6 | import javax.xml.parsers.ParserConfigurationException; |
---|
| 7 | import javax.xml.xpath.XPathExpressionException; |
---|
| 8 | |
---|
| 9 | import org.joda.time.DateTime; |
---|
| 10 | |
---|
| 11 | import schedframe.scheduling.tasks.Task; |
---|
| 12 | import simulator.utils.XsltTransformations; |
---|
| 13 | import dcworms.schedframe.scheduling.utils.JobDescription; |
---|
| 14 | import dcworms.schedframe.scheduling.utils.TaskDescription; |
---|
| 15 | |
---|
| 16 | public class ApplicationRepository { |
---|
| 17 | public static Map<String, JobDescription> applicationProfilesMap = new TreeMap<String, JobDescription>(); |
---|
| 18 | public static Map<String, org.qcg.broker.schemas.resreqs.Task> applicationProfilesMapNew = new TreeMap<String, org.qcg.broker.schemas.resreqs.Task>(); |
---|
| 19 | |
---|
| 20 | protected static XsltTransformations xsltTransformer; |
---|
| 21 | |
---|
| 22 | static { |
---|
| 23 | try { |
---|
| 24 | xsltTransformer = new XsltTransformations(); |
---|
| 25 | } catch (XPathExpressionException e) { |
---|
| 26 | // TODO Auto-generated catch block |
---|
| 27 | e.printStackTrace(); |
---|
| 28 | } catch (ParserConfigurationException e) { |
---|
| 29 | // TODO Auto-generated catch block |
---|
| 30 | e.printStackTrace(); |
---|
| 31 | } |
---|
| 32 | } |
---|
| 33 | public static void transform() throws Exception{ |
---|
| 34 | for(String key: applicationProfilesMap.keySet()){ |
---|
| 35 | JobDescription jobDesc = applicationProfilesMap.get(key); |
---|
| 36 | for (TaskDescription taskDescription : jobDesc) { |
---|
| 37 | DateTime submitionTime = new DateTime(); |
---|
| 38 | String xmlResReq = xsltTransformer.taskToResourceRequirements( |
---|
| 39 | taskDescription.getDocument(), |
---|
| 40 | jobDesc.getJobId(), |
---|
| 41 | taskDescription.getUserDn(), |
---|
| 42 | submitionTime); |
---|
| 43 | |
---|
| 44 | applicationProfilesMapNew.put(key, new Task(xmlResReq).getDescription()); |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | public static void prepareApplciation(org.qcg.broker.schemas.resreqs.Task task) { |
---|
| 50 | try { |
---|
| 51 | org.qcg.broker.schemas.resreqs.Task patternTask = applicationProfilesMapNew.get(task.getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); |
---|
| 52 | if(patternTask != null){ |
---|
| 53 | org.qcg.broker.schemas.resreqs.ResourceConsumptionProfileType[] rcp = patternTask.getExecution().getResourceConsumptionProfile(); |
---|
| 54 | task.getExecution().setResourceConsumptionProfile(rcp); |
---|
| 55 | } |
---|
| 56 | } catch (Exception e){ |
---|
| 57 | |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | } |
---|