/** 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); } } }
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; }