/** Construct the ExertionSorter */ public ExertionSorter(Exertion topLevelJob) throws ContextException, SortingException { dag = new DAG(); projectMap = new HashMap(); contextIdsMap = new HashMap<String, String>(); revContextIdsMap = new HashMap<String, String>(); this.topLevelJob = topLevelJob; addVertex(this.topLevelJob); try { getMapping(this.topLevelJob); checkParentCycle(this.topLevelJob); List sortedProjects = new ArrayList(); for (Iterator i = TopologicalSorter.sort(dag).iterator(); i.hasNext(); ) { String id = (String) i.next(); sortedProjects.add(projectMap.get(id)); } this.sortedProjects = Collections.unmodifiableList(sortedProjects); reorderJob(this.topLevelJob, this.sortedProjects); } catch (CycleDetectedException ce) { throw new SortingException(ce.getMessage()); } }
/** * Find the dependencies that result from the pipes specified between tasks * * @param topXrt * @throws CycleDetectedException * @throws SortingException */ private void getMapping(Exertion topXrt) throws CycleDetectedException, ContextException, SortingException { for (Iterator i = topXrt.getMograms().iterator(); i.hasNext(); ) { Exertion project = (Exertion) i.next(); String id = project.getId().toString(); String topId = topXrt.getId().toString(); dag.addEdge(id, topId); Map<String, Map<String, String>> metaCtx = project.getDataContext().getMetacontext(); Map<String, String> ctxMapping = metaCtx.get("cid"); if (ctxMapping != null) { for (Map.Entry<String, String> mapping : ctxMapping.entrySet()) { if (mapping.getValue() != null && mapping.getValue().length() > 0) { String dependencyId = revContextIdsMap.get(mapping.getValue()); logger.debug("Map: " + mapping.getKey() + " to " + dependencyId); if (dag.getVertex(dependencyId) != null) { dag.addEdge(id, dependencyId); } } } } if (project instanceof Job) { getMapping(project); } } }
private void printRecord(Uuid id, Store type) throws RemoteException, MonitorException { Exertion xrt = null; if (selectedDataStorer >= 0) { xrt = ((MonitorUIManagement) dataStorers[selectedDataStorer].service) .getMonitorableExertion(id, NetworkShell.getPrincipal()); } else { xrt = ((MonitorUIManagement) dataStorerMap.get(id).service) .getMonitorableExertion(id, NetworkShell.getPrincipal()); } out.println("--------- STORAGE RECORD # " + selectedRecord + " ---------"); out.println(((ServiceExertion) xrt).describe()); }