示例#1
0
    private boolean scan() {
      boolean has = false;
      Set<Integer> tSet = this.ftList.keySet();
      for (Iterator<Integer> it = tSet.iterator(); it.hasNext(); ) {
        Integer id = (Integer) it.next();
        CustomedTransition ct = ftList.get(id);
        if (ct.isVisited() || ct.isInvalid()) continue;
        if (ct.getDeadLine() > 0) {
          Timestamp current = new Timestamp(System.currentTimeMillis());
          Log.getLogger(Config.FLOW).debug(ct.getDeadLine() + ":" + ct.getId());
          long howlong = (current.getTime() - parentProcess.startTime.getTime()) / 1000 / 60;
          Log.getLogger(Config.FLOW).debug("流程运行时间:" + howlong);
          if (howlong >= ct.getDeadLine()) {

            parentProcess.scheduler.addAction(Action.timeoutAction(null, ct));
            String info = "[Transition" + ct.getId() + "(" + ct.getInfo() + ")]发生超时异常";
            String pid = "" + parentProcess.id;
            ExceptionModel.insertNewException(pid, info);
            has = true;
            try {
              Thread.sleep(10000);
            } catch (InterruptedException e) {
              Log.getLogger("system").fatal("thread sleep error", e);
            }
            CustomedPlace p = ct.getBackPlace();
            ct.setInvalid(true);
            ct.setVisited(true);
            if (p != null) {
              parentProcess.tokenArrivePlace(
                  p.getId(), new ForwardToken(p.getId(), ForwardToken.EXCEPTION));
            }
          }
        }
      }
      return has;
    }