コード例 #1
0
    public void run() {
      __log.debug("Starting process definition reaper thread.");
      long pollingTime = 10000;
      try {
        while (true) {
          Thread.sleep(pollingTime);
          if (!_mngmtLock.writeLock().tryLock(100L, TimeUnit.MILLISECONDS)) continue;
          try {
            __log.debug("Kicking reaper, OProcess instances: " + OProcess.instanceCount);
            // Copying the runnning process list to avoid synchronization
            // problems and a potential mess if a policy modifies the list
            List<BpelProcess> candidates = new ArrayList<BpelProcess>(_registeredProcesses);
            CollectionsX.remove_if(
                candidates,
                new MemberOfFunction<BpelProcess>() {
                  public boolean isMember(BpelProcess o) {
                    return !o.hintIsHydrated();
                  }
                });

            // And the happy winners are...
            List<BpelProcess> ripped = _dehydrationPolicy.markForDehydration(candidates);
            // Bye bye
            for (BpelProcess process : ripped) {
              __log.debug("Dehydrating process " + process.getPID());
              process.dehydrate();
            }
          } finally {
            _mngmtLock.writeLock().unlock();
          }
        }
      } catch (InterruptedException e) {
        __log.debug(e);
      }
    }
コード例 #2
0
  @SuppressWarnings("unchecked")
  public Future invoke(Message request, boolean immediate) {
    if (request == null) {
      String errmsg = "Must pass non-null message to invoke()!";
      __log.fatal(errmsg);
      throw new NullPointerException(errmsg);
    }

    _dao.setRequest(((MessageImpl) request)._dao);
    _dao.setStatus(MessageExchange.Status.REQUEST.toString());

    if (!processInterceptors(this, InterceptorInvoker.__onBpelServerInvoked)) return null;

    BpelProcess target = _process;

    if (__log.isDebugEnabled()) __log.debug("invoke() EPR= " + _epr + " ==> " + target);

    if (target == null) {
      if (__log.isWarnEnabled()) __log.warn(__msgs.msgUnknownEPR("" + _epr));

      setCorrelationStatus(MyRoleMessageExchange.CorrelationStatus.UKNOWN_ENDPOINT);
      setFailure(MessageExchange.FailureType.UNKNOWN_ENDPOINT, null, null);
      return null;
    } else {
      // Schedule a new job for invocation
      JobDetails we = new JobDetails();
      we.setType(JobType.INVOKE_INTERNAL);
      we.setInMem(target.isInMemory());
      we.setProcessId(target.getPID());
      we.setMexId(getDAO().getMessageExchangeId());

      if (getOperation().getOutput() != null) {
        ResponseCallback callback = new ResponseCallback();
        _waitingCallbacks.put(getClientId(), callback);
      }

      setStatus(Status.ASYNC);
      Replayer replayer = Replayer.replayer.get();
      if (replayer == null) {
        if (immediate) _engine.onScheduledJob(we);
        else if (target.isInMemory()) _engine._contexts.scheduler.scheduleVolatileJob(true, we);
        else _engine._contexts.scheduler.schedulePersistedJob(we, null);
      } else {
        replayer.scheduler.schedulePersistedJob(we, null);
      }
      return new ResponseFuture(getClientId());
    }
  }
コード例 #3
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.
    try {
      _mngmtLock.writeLock().lockInterruptibly();
    } catch (InterruptedException ie) {
      __log.debug("register(...) interrupted.", ie);
      throw new BpelEngineException(__msgs.msgOperationInterrupted());
    }

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

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

      BpelProcess process = createBpelProcess(conf);
      process._classLoader = Thread.currentThread().getContextClassLoader();

      _engine.registerProcess(process);
      _registeredProcesses.add(process);
      if (!isLazyHydratable(process)) {
        process.hydrate();
      } else {
        _engine.setProcessSize(process.getPID(), false);
      }

      __log.info(__msgs.msgProcessRegistered(conf.getProcessId()));

    } catch (Exception ex) {
      __log.error(ex);
      throw new BpelEngineException(ex);
    } finally {
      _mngmtLock.writeLock().unlock();
    }
  }