Пример #1
0
  public void setProperty(final QName pid, final QName propName, final String value) {
    if (__log.isDebugEnabled()) __log.debug("Setting property " + propName + " on process " + pid);

    ProcessConfImpl pconf = _processes.get(pid);
    if (pconf == null) {
      String msg = __msgs.msgProcessNotFound(pid);
      __log.info(msg);
      throw new ContextException(msg);
    }

    final DeploymentUnitDir dudir = pconf.getDeploymentUnit();
    exec(
        new ProcessStoreImpl.Callable<Object>() {
          public Object call(ConfStoreConnection conn) {
            DeploymentUnitDAO dudao = conn.getDeploymentUnit(dudir.getName());
            if (dudao == null) return null;
            ProcessConfDAO proc = dudao.getProcess(pid);
            if (proc == null) return null;
            proc.setProperty(propName, value);
            return null;
          }
        });

    fireEvent(new ProcessStoreEvent(ProcessStoreEvent.Type.PROPERTY_CHANGED, pid, dudir.getName()));
  }
Пример #2
0
  /** Load all the deployment units out of the store. Called on start-up. */
  public void loadAll() {
    final ArrayList<ProcessConfImpl> loaded = new ArrayList<ProcessConfImpl>();
    exec(
        new Callable<Object>() {
          public Object call(ConfStoreConnection conn) {
            Collection<DeploymentUnitDAO> dus = conn.getDeploymentUnits();
            for (DeploymentUnitDAO du : dus)
              try {
                loaded.addAll(load(du));
              } catch (Exception ex) {
                __log.error("Error loading DU from store: " + du.getName(), ex);
              }
            return null;
          }
        });

    // Dispatch DISABLED, RETIRED and ACTIVE events in that order
    Collections.sort(
        loaded,
        new Comparator<ProcessConf>() {
          public int compare(ProcessConf o1, ProcessConf o2) {
            return stateValue(o1.getState()) - stateValue(o2.getState());
          }

          int stateValue(ProcessState state) {
            if (ProcessState.DISABLED.equals(state)) return 0;
            if (ProcessState.RETIRED.equals(state)) return 1;
            if (ProcessState.ACTIVE.equals(state)) return 2;
            throw new IllegalStateException("Unexpected process state: " + state);
          }
        });
    for (ProcessConfImpl p : loaded) {
      try {
        fireStateChange(p.getProcessId(), p.getState(), p.getDeploymentUnit().getName());
      } catch (Exception except) {
        __log.error(
            "Error while activating process: pid="
                + p.getProcessId()
                + " package="
                + p.getDeploymentUnit().getName(),
            except);
      }
    }
  }
Пример #3
0
  public Collection<QName> undeploy(final String duName) {
    try {
      exec(
          new Callable<Collection<QName>>() {
            public Collection<QName> call(ConfStoreConnection conn) {
              DeploymentUnitDAO dudao = conn.getDeploymentUnit(duName);
              if (dudao != null) dudao.delete();
              return null;
            }
          });
    } catch (Exception ex) {
      __log.error(
          "Error synchronizing with data store; " + duName + " may be reappear after restart!");
    }

    Collection<QName> undeployed = Collections.emptyList();
    DeploymentUnitDir du;
    _rw.writeLock().lock();
    try {
      du = _deploymentUnits.remove(duName);
      if (du != null) {
        undeployed = toPids(du.getProcessNames(), du.getVersion());
      }

      for (QName pn : undeployed) {
        fireEvent(new ProcessStoreEvent(ProcessStoreEvent.Type.UNDEPLOYED, pn, du.getName()));
        __log.info(__msgs.msgProcessUndeployed(pn));
      }

      _processes.keySet().removeAll(undeployed);
    } finally {
      _rw.writeLock().unlock();
    }

    return undeployed;
  }