コード例 #1
0
    public void run() {
      __log.debug("Starting process definition reaper thread.");
      long pollingTime = 10000;
      try {
        while (true) {
          Thread.sleep(pollingTime);
          // Copying the runnning process list to avoid synchronizatMessageExchangeInterion
          // problems and a potential mess if a policy modifies the list
          List<ODEProcess> candidates = new ArrayList<ODEProcess>(_registeredProcesses.values());
          CollectionsX.remove_if(
              candidates,
              new MemberOfFunction<ODEProcess>() {
                public boolean isMember(ODEProcess o) {
                  return !o.hintIsHydrated();
                }
              });

          // And the happy winners are...
          List<ODEProcess> ripped = _dehydrationPolicy.markForDehydration(candidates);
          // Bye bye
          for (ODEProcess process : ripped) {
            __log.debug("Dehydrating process " + process.getPID());
            process.dehydrate();
          }
        }
      } catch (InterruptedException e) {
        __log.info(e);
      }
    }
コード例 #2
0
  public void unregister(QName pid) throws BpelEngineException {
    if (__log.isTraceEnabled()) __log.trace("unregister: " + pid);

    try {
      ODEProcess p = _registeredProcesses.remove(pid);
      if (p == null) return;

      // TODO Looks like there are some possible bugs here, if a new version of a process gets
      // deployed, the service will be removed.
      p.deactivate();

      // Remove the process from any services that might reference it.
      // However, don't remove the service itself from the map.
      for (List<ODEProcess> processes : _serviceMap.values()) {
        __log.debug(
            "removing process " + pid + "; handle " + p + "; exists " + processes.contains(p));
        processes.remove(p);
      }

      __log.info(__msgs.msgProcessUnregistered(pid));

    } catch (Exception ex) {
      __log.error(__msgs.msgProcessUnregisterFailed(pid), ex);
      throw new BpelEngineException(ex);
    }
  }
コード例 #3
0
  public ProcessModel getProcessModel(QName processId) {
    ODEProcess process = _registeredProcesses.get(processId);

    if (process == null) return null;

    return process.getProcessModel();
  }
コード例 #4
0
  MessageExchangeDAO getInMemMexDAO(String mexId) {
    for (ODEProcess p : _registeredProcesses.values()) {
      MessageExchangeDAO mexDao = p.getInMemMexDAO(mexId);
      if (mexDao != null) return mexDao;
    }

    return null;
  }
コード例 #5
0
  public void onScheduledJob(final JobInfo jobInfo) throws JobProcessorException {
    try {
      final WorkEvent we = new WorkEvent(jobInfo.jobDetail);
      ODEProcess process = _registeredProcesses.get(we.getProcessId());
      if (process == null) {
        // If the process is not active, it means that we should not be
        // doing any work on its behalf, therefore we will reschedule the
        // events for some time in the future (1 minute).

        // 31-05-2010
        // According to the bpel server logic, we won't find a process with matching
        // process id in future for this type of case where we can't find the process at
        // first job invocation. Because all the processes(both hydrated and dehydrated) are there
        // in _registeredProcesses Map. And even we deploy a new version of the process, it's
        // QName will be different because of the versioning.
        // So I am removing scheduling part.
        // TODO: Let's revert the logic if an issue occurred because of this.
        _contexts.execTransaction(
            new Callable<Void>() {
              public Void call() throws Exception {
                _contexts.scheduler.jobCompleted(jobInfo.jobName);
                // Date future = new Date(System.currentTimeMillis() + (60 * 1000));
                // __log.info(__msgs.msgReschedulingJobForInactiveProcess(we.getProcessId(),
                // jobInfo.jobName, future));
                // _contexts.scheduler.schedulePersistedJob(we.getDetail(), future);
                return null;
              }
            });
        return;
      }

      if (we.getType().equals(WorkEvent.Type.INVOKE_CHECK)) {
        if (__log.isDebugEnabled())
          __log.debug("handleWorkEvent: InvokeCheck event for mexid " + we.getMexId());

        PartnerRoleMessageExchange mex =
            (PartnerRoleMessageExchange) getMessageExchange(we.getMexId());
        if (mex.getStatus() == MessageExchange.Status.ASYNC
            || mex.getStatus() == MessageExchange.Status.ACK) {
          String msg =
              "Dangling invocation (mexId=" + we.getMexId() + "), forcing it into a failed state.";
          if (__log.isDebugEnabled()) __log.debug(msg);
          mex.replyWithFailure(MessageExchange.FailureType.COMMUNICATION_ERROR, msg, null);
        }
        return;
      }

      process.handleWorkEvent(jobInfo);
    } catch (Exception ex) {
      throw new JobProcessorException(ex, jobInfo.jobDetail.get("inmem") == null);
    }
  }
コード例 #6
0
  public void register(ProcessConf conf) {
    if (conf == null)
      throw new NullPointerException("must specify non-null process configuration.");

    __log.debug("register: " + conf.getProcessId());

    // Ok, IO out of the way, we will mod the server state, so need to get a
    // lock.

    // If the process is already active, do nothing.
    if (_registeredProcesses.containsKey(conf.getProcessId())) {
      __log.debug(
          "skipping doRegister" + conf.getProcessId() + ") -- process is already registered");
      return;
    }

    __log.debug("Registering process " + conf.getProcessId() + " with server.");

    ODEProcess process = new ODEProcess(this, conf, null, _myRoleMexCache);

    for (Endpoint e : process.getServiceNames()) {
      __log.debug("Register process: serviceId=" + e + ", process=" + process);
      // Get the list of processes associated with the given service
      List<ODEProcess> processes = _serviceMap.get(e.serviceName);
      if (processes == null) {
        // Create an empty list, if no processes were associated
        _serviceMap.put(e.serviceName, processes = new ArrayList<ODEProcess>());
      }
      // Remove any older version of the process from the list
      for (int i = 0; i < processes.size(); i++) {
        ODEProcess cachedVersion = processes.get(i);
        __log.debug(
            "cached version "
                + cachedVersion.getPID()
                + " vs registering version "
                + process.getPID());
        if (cachedVersion.getProcessType().equals(process.getProcessType())) {
          processes.remove(cachedVersion);
        }
      }
      // Add the given process to the list associated with the given service
      processes.add(process);
    }

    process.activate(_contexts);

    _registeredProcesses.put(process.getPID(), process);
    if (_dehydrationPolicy == null) process.hydrate();

    __log.info(__msgs.msgProcessRegistered(conf.getProcessId()));
  }
コード例 #7
0
  /**
   * Return a simple type of MEX for a given process target
   *
   * @param process
   * @param istyle
   * @param targetService
   * @param operation
   * @param clientKey
   * @return
   */
  private MyRoleMessageExchange createNewMyRoleMex(
      ODEProcess process,
      final InvocationStyle istyle,
      final QName targetService,
      final String operation,
      final String clientKey) {
    if (istyle == InvocationStyle.RELIABLE || istyle == InvocationStyle.TRANSACTED)
      assertTransaction();
    else assertNoTransaction();

    return process.createNewMyRoleMex(istyle, targetService, operation);
  }
コード例 #8
0
  /*
   * Calculate the invocation style of the target(s) associated with the given service
   * If more than one target exists, then take the intersection of their individual styles.
   *
   * (non-Javadoc)
   * @see org.apache.ode.bpel.iapi.BpelServer#getSupportedInvocationStyle(javax.xml.namespace.QName)
   */
  public Set<InvocationStyle> getSupportedInvocationStyle(QName serviceId) {

    List<ODEProcess> processes = route(serviceId, null);
    if (processes == null || processes.size() == 0)
      throw new BpelEngineException("No such service: " + serviceId);

    // Compute the intersection of the styles of all providing processes
    Set<InvocationStyle> istyles = new HashSet<InvocationStyle>();
    for (ODEProcess process : processes) {
      Set<InvocationStyle> pistyles = process.getSupportedInvocationStyle(serviceId);
      if (istyles.isEmpty()) {
        istyles.addAll(pistyles);
      } else {
        for (InvocationStyle istyle : istyles) {
          if (!pistyles.contains(istyle)) {
            istyles.remove(istyle);
          }
        }
      }
    }
    return istyles;
  }