Beispiel #1
0
  /**
   * 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);
      }
    }
  }
Beispiel #2
0
  /** 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());
    }
  }
Beispiel #3
0
  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());
  }
Beispiel #4
0
  /**
   * Add the job and all inner exertions as vertexes
   *
   * @param topXrt
   * @throws SortingException
   */
  private void addVertex(Exertion topXrt) throws ContextException, SortingException {

    String id = topXrt.getId().toString();
    dag.addVertex(id);
    projectMap.put(id, topXrt);
    contextIdsMap.put(id, topXrt.getDataContext().getId().toString());
    revContextIdsMap.put(topXrt.getDataContext().getId().toString(), id);

    for (Iterator i = topXrt.getMograms().iterator(); i.hasNext(); ) {
      Exertion project = (Exertion) i.next();

      id = project.getId().toString();

      if (dag.getVertex(id) != null) {
        throw new SortingException(
            "Exertion '"
                + project.getName()
                + "'("
                + id
                + ") is duplicated in the job: '"
                + topXrt.getName()
                + "' ("
                + topXrt.getId()
                + ")");
      }

      dag.addVertex(id);
      projectMap.put(id, project);
      contextIdsMap.put(id, project.getDataContext().getId().toString());
      revContextIdsMap.put(project.getDataContext().getId().toString(), id);

      if (project instanceof Job) {
        addVertex(project);
      }
    }
  }
Beispiel #5
0
  private void printRecords(Store type) throws RemoteException, MonitorException {
    if (dataStorers == null || dataStorers.length == 0) {
      findStorers();
    }
    Map<Uuid, ObjectInfo> all;
    if (selectedDataStorer >= 0) {
      out.println(
          "From Data Storage: "
              + AttributesUtil.getProviderName(dataStorers[selectedDataStorer].attributeSets)
              + " at: "
              + AttributesUtil.getHostName(dataStorers[selectedDataStorer].attributeSets));
      //			all = ((StorageManagement) dataStorers[selectedDataStorer].service)
      //					.getMonitorableExertionInfo(type,
      //							NetworkShell.getPrincipal());

      Context cxt = null;
      try {
        store("test-only");
        out.println("XXXXXXXXXXXXX service item: " + dataStorers[selectedDataStorer]);
        out.println(
            "XXXXXXXXXXXXX service: " + (DatabaseStorer) dataStorers[selectedDataStorer].service);
        out.println(
            "XXXXXXXXXXXXX interfaces: "
                + Arrays.toString(
                    dataStorers[selectedDataStorer].service.getClass().getInterfaces()));
        out.println(
            "XXXXXXXXXXXXX name: "
                + ((Provider) dataStorers[selectedDataStorer].service).getProviderName());
        try {
          cxt =
              ((DatabaseStorer) dataStorers[selectedDataStorer].service)
                  .contextList(SdbUtil.getListContext(Store.object));
        } catch (MalformedURLException e) {
          e.printStackTrace();
        }
        out.println("XXXXXXXXXXXXX context: " + cxt);
        try {
          store("test-only");
          List<String> records = list(Store.object);
          out.println("XXXXXXXXXXXXX records; " + records);
        } catch (ExertionException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (SignatureException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        out.println(cxt.getValue(DatabaseStorer.store_content_list));
        //			} catch (ExertionException e) {
        //				e.printStackTrace();
        //			} catch (SignatureException e) {
        //				e.printStackTrace();
      } catch (ContextException e) {
        e.printStackTrace();
      }

    } else {
      Map<Uuid, ObjectInfo> ri = null;
      all = new HashMap<Uuid, ObjectInfo>();
      for (int i = 0; i < dataStorers.length; i++) {
        out.println(
            "From Data Storage "
                + AttributesUtil.getProviderName(dataStorers[i].attributeSets)
                + " at: "
                + AttributesUtil.getHostName(dataStorers[i].attributeSets));

        DatabaseStorer emx = (DatabaseStorer) dataStorers[i].service;
        //				ri = emx.getMonitorableExertionInfo(type,
        //						NetworkShell.getPrincipal());
        if (ri != null && ri.size() > 0) {
          all.putAll(ri);
        }
        // populate exertion/EMX map
        dataStorerMap.clear();
        for (ObjectInfo ei : ri.values()) {
          dataStorerMap.put(ei.uuid, dataStorers[i]);
        }
      }
    }
    //		if (all.size() == 0) {
    //			out.println("No monitored exertions at this time.");
    //			return;
    //		}
    //		recordInfos = new RecordInfo[all.size()];
    //		all.values().toArray(recordInfos);
    //		printRecordInfos(recordInfos);
  }