Author: mszefler
Date: Mon Aug 14 13:13:51 2006
New Revision: 431428
URL: http://svn.apache.org/viewvc?rev=431428&view=rev
Log:
Rollback of deployed processes in case of failure.
Modified:
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEngineException.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Messages.java
Modified:
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java?rev=431428&r1=431427&r2=431428&view=diff
==============================================================================
---
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
(original)
+++
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
Mon Aug 14 13:13:51 2006
@@ -154,7 +154,6 @@
void setDeployURI(URI dduri);
-
void setCompiledProcess(byte[] cbp);
byte[] getCompiledProcess();
Modified:
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEngineException.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEngineException.java?rev=431428&r1=431427&r2=431428&view=diff
==============================================================================
---
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEngineException.java
(original)
+++
incubator/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/BpelEngineException.java
Mon Aug 14 13:13:51 2006
@@ -24,16 +24,18 @@
*/
public class BpelEngineException extends RuntimeException {
- public BpelEngineException(String msg, Exception e) {
- super(msg,e);
- }
+ private static final long serialVersionUID = 1L;
- public BpelEngineException(Exception ex) {
- super(ex);
- }
+ public BpelEngineException(String msg, Throwable e) {
+ super(msg, e);
+ }
- public BpelEngineException(String string) {
- super(string);
- }
+ public BpelEngineException(Throwable ex) {
+ super(ex);
+ }
+
+ public BpelEngineException(String string) {
+ super(string);
+ }
}
Modified:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java?rev=431428&r1=431427&r2=431428&view=diff
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
(original)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
Mon Aug 14 13:13:51 2006
@@ -555,8 +555,13 @@
* Deploys a process.
*/
public Collection<QName> deploy(File deploymentUnitDirectory) {
+
+ __log.info(__msgs.msgDeployStarting(deploymentUnitDirectory));
+
DeploymentUnitImpl du = new
DeploymentUnitImpl(deploymentUnitDirectory);
+ ArrayList<QName> deployed = new ArrayList<QName> ();
+ BpelEngineException failed = null;
// Going trough each process declared in the dd
for (TDeployment.Process processDD :
du.getDeploymentDescriptor().getDeploy().getProcessList()) {
OProcess oprocess = du.getProcesses().get(processDD.getName());
@@ -568,13 +573,31 @@
deploy(processDD.getName(), du, oprocess, du.getDocRegistry()
.getDefinitions(), processDD);
+ deployed.add(processDD.getName());
} catch (Throwable e) {
- __log.error("Process deployment failed!", e);
- // TODO: we need to got back and undeploy the processes that
were deployed.
+ String errmsg = __msgs.msgDeployFailed(processDD.getName(),
deploymentUnitDirectory);
+ __log.error(errmsg, e);
+
+ failed = new BpelEngineException(errmsg,e);
+ break;
}
}
- return du.getProcesses().keySet();
+ // Roll back succesfull deployments if we failed.
+ if (failed != null) {
+ if (!deployed.isEmpty()) {
+ __log.error(__msgs.msgDeployRollback(deploymentUnitDirectory));
+ for (QName pid : deployed) {
+ try {
+ undeploy(pid);
+ } catch (Throwable t) {
+ __log.fatal("Unexpect error undeploying process " +
pid, t);
+ }
+ }
+ }
+ throw failed;
+ } else
+ return du.getProcesses().keySet();
}
private void deploy(final QName processId, final DeploymentUnitImpl du,
final OProcess oprocess,
Modified:
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Messages.java
URL:
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Messages.java?rev=431428&r1=431427&r2=431428&view=diff
==============================================================================
---
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Messages.java
(original)
+++
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Messages.java
Mon Aug 14 13:13:51 2006
@@ -21,6 +21,8 @@
import org.apache.ode.utils.msg.MessageBundle;
import javax.xml.namespace.QName;
+
+import java.io.File;
import java.net.URI;
import java.util.Date;
@@ -167,4 +169,16 @@
aliasDescription, reason);
}
+ public String msgDeployStarting(File deploymentUnitDirectory) {
+ return format("Starting deployment of processes from directory \"{0}\".
", deploymentUnitDirectory);
+ }
+
+ public String msgDeployFailed(QName name, File deploymentUnitDirectory) {
+ return format("Deployment of process \"{0}\" from \"{1}\" failed.",
name,deploymentUnitDirectory);
+ }
+
+ public String msgDeployRollback(File deploymentUnitDirectory) {
+ return format("Deployment of processes from \"{0}\" failed, rolling
back. ", deploymentUnitDirectory);
+ }
+
}