Пример #1
0
  private String configureService(CoasterChannel channel, Task task)
      throws InterruptedException, ProtocolException, IOException {
    String configId = checkConfigured(channel, task);
    if (configId == null) {
      try {
        ServiceConfigurationCommand scc = new ServiceConfigurationCommand(task);
        byte[] reply = scc.execute(channel);
        configId = new String(reply);

        Object rt = task.getService(0).getAttribute("resource-tracker");
        if (rt != null) {
          if (rt instanceof CoasterResourceTracker) {
            LocalService ls = (LocalService) channel.getService();
            ls.addResourceTracker(channel, task.getService(0), (CoasterResourceTracker) rt);
          } else {
            logger.warn(
                "Invalid resource tracker specified: "
                    + rt.getClass()
                    + " does not implement "
                    + CoasterResourceTracker.class);
          }
        }
        setConfigured(channel, task, configId);
      } catch (Exception e) {
        e.printStackTrace();
        task.setStatus(new StatusImpl(Status.FAILED, "Failed to configure coaster service", e));
      }
    }
    return configId;
  }
Пример #2
0
 public void statusChanged(Status s, String out, String err) {
   Task t = getTask();
   if (out != null) {
     t.setStdOutput(out);
   }
   if (err != null) {
     t.setStdError(err);
   }
   t.setStatus(s);
 }
Пример #3
0
 public void submit(Task task)
     throws IllegalSpecException, InvalidSecurityContextException, InvalidServiceContactException,
         TaskSubmissionException {
   checkAndSetTask(task);
   validateTaskSettings();
   task.setStatus(Status.SUBMITTING);
   try {
     CoasterChannel channel = getChannel(task);
     String configId = configureService(channel, task);
     submitJob(channel, task, configId);
   } catch (Exception e) {
     throw new TaskSubmissionException("Could not submit job", e);
   }
 }
Пример #4
0
  public void statusChanged(StatusEvent e) {
    Task t = (Task) e.getSource();
    try {
      if (logger.isDebugEnabled()) {
        logger.debug("Got task status change for " + t.getIdentity());
      }
      LinkedList cluster = null;
      synchronized (tasks) {
        cluster = (LinkedList) tasks.get(t);
      }

      if (cluster == null) {
        super.statusChanged(e);
      } else {
        if (logger.isDebugEnabled()) {
          logger.debug("Got cluster status change for " + t.getIdentity());
        }

        Status clusterMemberStatus = e.getStatus();
        if (clusterMemberStatus.getStatusCode() == Status.FAILED) {
          clusterMemberStatus = new StatusImpl(Status.COMPLETED);
        }
        Iterator i = cluster.iterator();
        while (i.hasNext()) {
          Object[] h = (Object[]) i.next();
          Task ct = (Task) h[0];
          StatusEvent nse = new StatusEvent(ct, clusterMemberStatus);
          ct.setStatus(clusterMemberStatus);
          fireJobStatusChangeEvent(nse);
        }
        if (e.getStatus().isTerminal()) {
          if (logger.isInfoEnabled()) {
            logger.info("Removing cluster " + t.getIdentity());
          }
          synchronized (tasks) {
            tasks.remove(t);
          }
        }
      }
    } catch (Exception ex) {
      failTask(t, ex.getMessage(), ex);
    }
  }