Пример #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
 /**
  * Insert paragraph in given index.
  *
  * @param index index of paragraphs
  */
 public Paragraph insertParagraph(int index, AuthenticationInfo authenticationInfo) {
   Paragraph p = new Paragraph(this, this, factory);
   p.setAuthenticationInfo(authenticationInfo);
   setParagraphMagic(p, index);
   synchronized (paragraphs) {
     paragraphs.add(index, p);
   }
   if (noteEventListener != null) {
     noteEventListener.onParagraphCreate(p);
   }
   return p;
 }
Пример #3
0
 /** Run all paragraphs sequentially. */
 public synchronized void runAll() {
   String cronExecutingUser = (String) getConfig().get("cronExecutingUser");
   if (null == cronExecutingUser) {
     cronExecutingUser = "******";
   }
   for (Paragraph p : getParagraphs()) {
     if (!p.isEnabled()) {
       continue;
     }
     AuthenticationInfo authenticationInfo = new AuthenticationInfo();
     authenticationInfo.setUser(cronExecutingUser);
     p.setAuthenticationInfo(authenticationInfo);
     run(p.getId());
   }
 }