private Exertion register(Exertion exertion) throws Exception {
    RemoteEventListener l = (RemoteEventListener) (new ResultListener().export());
    ServiceExertion registeredExertion =
        (ServiceExertion) (sessionMonitor.register(l, exertion, LEASE_RENEWAL_PERIOD));

    MonitoringSession session = (MonitoringSession) (registeredExertion.getMonitorSession());
    logger.info("Session for the exertion =" + session);
    logger.info(
        "Lease to be renewed for duration ="
            + (session.getLease().getExpiration() - System.currentTimeMillis()));
    lrm.renewUntil(session.getLease(), Lease.ANY, null);
    return registeredExertion;
  }
Esempio n. 2
0
  /**
   * Actually rearrange the exertions in the job according to the sorting
   *
   * @param topXrt
   * @param sortedExertions
   * @throws CycleDetectedException
   * @throws ContextException
   */
  private void reorderJob(Exertion topXrt, List<Mogram> sortedExertions) {
    List<Mogram> sortedSubset = new ArrayList(sortedExertions);
    sortedSubset.retainAll(topXrt.getMograms());

    if (topXrt.getFlowType() != null && topXrt.getFlowType().equals(Strategy.Flow.AUTO)) {
      ((ServiceExertion) topXrt).setFlowType(setFlow(topXrt, sortedSubset));
      logger.info("FLOW for exertion: " + topXrt.getName() + " set to: " + topXrt.getFlowType());
    }
    List<String> exertionsBefore = new ArrayList<String>();
    for (Mogram xrt : topXrt.getMograms()) exertionsBefore.add(xrt.getName());

    List<String> exertionsAfter = new ArrayList<String>();
    for (Mogram xrt : sortedExertions) exertionsAfter.add(xrt.getName());
    if (!topXrt.getMograms().equals(sortedSubset)) {
      logger.info("Order of exertions for " + topXrt.getName() + " will be changed: ");
      logger.info("From: " + exertionsBefore);
      logger.info("To: " + exertionsAfter);
      topXrt.getMograms().removeAll(sortedSubset);
      topXrt.getMograms().addAll(sortedSubset);
    }

    for (Iterator i = topXrt.getMograms().iterator(); i.hasNext(); ) {
      Exertion xrt = (Exertion) i.next();
      if (xrt instanceof Job) {
        reorderJob(xrt, sortedExertions);
      }
    }
  }
  protected void preExecExertion(Exertion exertion) throws ExertionException {
    try {
      exertion
          .getControlContext()
          .appendTrace(provider.getProviderName() + " dispatcher: " + getClass().getName());

      ExertionSessionInfo.add((ServiceExertion) exertion);
      // Provider is expecting exertion field in Context to be set.
      xrt.getContext().setExertion(xrt);
      updateInputs(exertion);
    } catch (Exception e) {
      throw new ExertionException(e);
    }
    ((ServiceExertion) exertion).startExecTime();
    ((ServiceExertion) exertion).setStatus(RUNNING);
  }
  protected void postExecExertion(Exertion result) throws ExertionException {
    ServiceExertion sxrt = (ServiceExertion) result;
    if (sxrt instanceof NetJob)
      ((NetJob) xrt).setExertionAt(result, ((ServiceExertion) result).getIndex());
    else xrt = sxrt;
    try {
      if (sxrt.getStatus() > ERROR && sxrt.getStatus() != SUSPENDED) {
        sxrt.setStatus(DONE);
        collectOutputs(result);
      }
    } catch (Exception e) {
      throw new ExertionException(e);
    }
    if (sxrt.getStatus() != DONE) state = sxrt.getStatus();

    xrt.stopExecTime();
    dispatchers.remove(xrt.getId());
    ExertionSessionInfo.removeLease();
    dThread.stop = true;
  }
  protected void execExertion(Exertion exertion)
      throws ExertionException, SignatureException, RemoteException {
    ServiceExertion ei = (ServiceExertion) exertion;
    preExecExertion(exertion);

    logger.log(Level.INFO, "Prexec Exertion done .... noe executing exertion");
    try {
      if (ei.isTask()) execTask((NetTask) exertion);
      else throw new ExertionException("Functionality not yet supported");
    } catch (Exception ex) {
      ex.printStackTrace();
      ei.reportException(ex);
      try {
        if (ei.isTask())
          ((MonitoringSession) ((ServiceExertion) exertion).getMonitorSession())
              .changed(((NetTask) exertion).getContext(), State.FAILED);
      } catch (Exception ex0) {
        ex0.printStackTrace();
      } finally {
        ((ServiceExertion) exertion).setStatus(FAILED);
      }
    }
  }