示例#1
0
  /**
   * Run a single paragraph.
   *
   * @param paragraphId ID of paragraph
   */
  public void run(String paragraphId) {
    Paragraph p = getParagraph(paragraphId);

    if (p.isBlankParagraph()) {
      logger.info("skip to run blank paragraph. {}", p.getId());
      return;
    }

    p.setListener(jobListenerFactory.getParagraphJobListener(this));
    String requiredReplName = p.getRequiredReplName();
    Interpreter intp = factory.getInterpreter(p.getUser(), getId(), requiredReplName);

    if (intp == null) {
      String intpExceptionMsg =
          p.getJobName() + "'s Interpreter " + requiredReplName + " not found";
      InterpreterException intpException = new InterpreterException(intpExceptionMsg);
      InterpreterResult intpResult =
          new InterpreterResult(InterpreterResult.Code.ERROR, intpException.getMessage());
      p.setReturn(intpResult, intpException);
      p.setStatus(Job.Status.ERROR);
      throw intpException;
    }
    if (p.getConfig().get("enabled") == null || (Boolean) p.getConfig().get("enabled")) {
      p.setAuthenticationInfo(p.getAuthenticationInfo());
      intp.getScheduler().submit(p);
    }
  }
示例#2
0
 /**
  * Run a single paragraph.
  *
  * @param paragraphId
  */
 public void run(String paragraphId) {
   Paragraph p = getParagraph(paragraphId);
   p.setNoteReplLoader(replLoader);
   p.setListener(jobListenerFactory.getParagraphJobListener(this));
   Interpreter intp = replLoader.get(p.getRequiredReplName());
   if (intp == null) {
     throw new InterpreterException("Interpreter " + p.getRequiredReplName() + " not found");
   }
   intp.getScheduler().submit(p);
 }
示例#3
0
 /**
  * Run all paragraphs sequentially.
  *
  * @param jobListener
  */
 public void runAll() {
   synchronized (paragraphs) {
     for (Paragraph p : paragraphs) {
       p.setNoteReplLoader(replLoader);
       p.setListener(jobListenerFactory.getParagraphJobListener(this));
       Interpreter intp = replLoader.get(p.getRequiredReplName());
       intp.getScheduler().submit(p);
     }
   }
 }
示例#4
0
 @Override
 protected boolean jobAbort() {
   Interpreter repl = getRepl(getRequiredReplName());
   Job job = repl.getScheduler().removeFromWaitingQueue(getId());
   if (job != null) {
     job.setStatus(Status.ABORT);
   } else {
     repl.cancel(getInterpreterContext());
   }
   return true;
 }
  @Override
  protected boolean jobAbort() {
    Interpreter repl = getRepl(getRequiredReplName());
    if (repl == null) {
      // when interpreters are already destroyed
      return true;
    }

    Scheduler scheduler = repl.getScheduler();
    if (scheduler == null) {
      return true;
    }

    Job job = scheduler.removeFromWaitingQueue(getId());
    if (job != null) {
      job.setStatus(Status.ABORT);
    } else {
      repl.cancel(getInterpreterContext());
    }
    return true;
  }