geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r160279 - in geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli: AbstractCommand.java CommandDeploy.java CommandDistribute.java CommandRedeploy.java CommandStart.java CommandStop.java CommandUndeploy.java
Date Wed, 06 Apr 2005 10:14:21 GMT
Author: gdamour
Date: Wed Apr  6 03:14:19 2005
New Revision: 160279

URL: http://svn.apache.org/viewcvs?view=rev&rev=160279
Log:
GERONIMO-587 submitted by Toby Cabot

In some specific cases, Deployer returned 0 even if the command was not 
successfully executed.

Modified:
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDeploy.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStart.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStop.java
    geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java?view=diff&r1=160278&r2=160279
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
Wed Apr  6 03:14:19 2005
@@ -69,19 +69,24 @@
         return false;
     }
 
-    protected static TargetModuleID[] waitForProgress(PrintWriter out, ProgressObject po)
{
+    /**
+     * Busy-waits until the provided <code>ProgressObject</code>
+     * indicates that it's no longer running.
+     *
+     * @param out a <code>PrintWriter</code> value, only used in case
+     * of an <code>InterruptedException</code> to output the stack
+     * trace.
+     * @param po a <code>ProgressObject</code> value
+     */
+    protected static void waitForProgress(PrintWriter out, ProgressObject po) {
         while(po.getDeploymentStatus().isRunning()) {
             try {
                 Thread.sleep(100);
             } catch (InterruptedException e) {
-                e.printStackTrace();
+                e.printStackTrace(out);
             }
         }
-        if(po.getDeploymentStatus().isFailed()) {
-            out.println("Deployment failed");
-            out.println("  Server reports: "+po.getDeploymentStatus().getMessage());
-        }
-        return po.getResultTargetModuleIDs();
+        return;
     }
 
     protected static boolean isMultipleTargets(TargetModuleID[] ids) {

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDeploy.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDeploy.java?view=diff&r1=160278&r2=160279
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDeploy.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDeploy.java
Wed Apr  6 03:14:19 2005
@@ -51,8 +51,9 @@
     }
 
     protected ProgressObject runCommand(DeploymentManager mgr, PrintWriter out, Target[]
tlist, File module, File plan) {
-        TargetModuleID[] modules = waitForProgress(out, mgr.distribute(tlist, module, plan));
-        return mgr.start(modules);
+        ProgressObject po = mgr.distribute(tlist, module, plan);
+        waitForProgress(out, po);
+        return mgr.start(po.getResultTargetModuleIDs());
     }
 
     public void execute(PrintWriter out, ServerConnection connection, String[] args) throws
DeploymentException {

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java?view=diff&r1=160278&r2=160279
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
Wed Apr  6 03:14:19 2005
@@ -131,18 +131,30 @@
         final DeploymentManager mgr = connection.getDeploymentManager();
         TargetModuleID[] results;
         boolean multipleTargets;
+        ProgressObject po;
         if(targets.size() > 0) {
             Target[] tlist = identifyTargets(targets, mgr);
             multipleTargets = tlist.length > 1;
-            results = waitForProgress(out, runCommand(mgr, out, tlist, module, plan));
+            po = runCommand(mgr, out, tlist, module, plan);
+            waitForProgress(out, po);
         } else {
             final Target[] tlist = mgr.getTargets();
             multipleTargets = tlist.length > 1;
-            results = waitForProgress(out, runCommand(mgr, out, tlist, module, plan));
+            po = runCommand(mgr, out, tlist, module, plan);
+            waitForProgress(out, po);
         }
+
+        // print the results that succeeded
+        results = po.getResultTargetModuleIDs();
         for (int i = 0; i < results.length; i++) {
             TargetModuleID result = results[i];
             out.println(getAction()+" "+result.getModuleID()+(multipleTargets ? " to "+result.getTarget().getName()
: ""));
+        }
+
+        // if any results failed then throw so that we'll return non-0
+        // to the operating system
+        if(po.getDeploymentStatus().isFailed()) {
+            throw new DeploymentException("Deployment failed, Server reports: "+po.getDeploymentStatus().getMessage());
         }
     }
 

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java?view=diff&r1=160278&r2=160279
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
Wed Apr  6 03:14:19 2005
@@ -27,6 +27,7 @@
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.exceptions.TargetException;
+import javax.enterprise.deploy.spi.status.ProgressObject;
 
 /**
  * The CLI deployer logic to redeploy.
@@ -109,10 +110,15 @@
         }
         TargetModuleID[] ids = (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
         boolean multiple = isMultipleTargets(ids);
-        TargetModuleID[] done = waitForProgress(out, mgr.redeploy(ids, module, plan));
+        ProgressObject po = mgr.redeploy(ids, module, plan);
+        waitForProgress(out, po);
+        TargetModuleID[] done = po.getResultTargetModuleIDs();
         for(int i = 0; i < done.length; i++) {
             TargetModuleID id = done[i];
             out.println("Redeployed "+id.getModuleID()+(multiple ? " on "+id.getTarget().getName()
: ""));
+        }
+        if(po.getDeploymentStatus().isFailed()) {
+            throw new DeploymentException("Deployment failed, Server reports: "+po.getDeploymentStatus().getMessage());
         }
     }
 }

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStart.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStart.java?view=diff&r1=160278&r2=160279
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStart.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStart.java
Wed Apr  6 03:14:19 2005
@@ -26,6 +26,7 @@
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.exceptions.TargetException;
+import javax.enterprise.deploy.spi.status.ProgressObject;
 
 /**
  * The CLI deployer logic to start.
@@ -69,15 +70,21 @@
         }
         TargetModuleID[] ids = (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
         boolean multiple = isMultipleTargets(ids);
-        TargetModuleID[] done = runCommand(out, mgr, ids);
+        ProgressObject po = runCommand(out, mgr, ids);
+        TargetModuleID[] done = po.getResultTargetModuleIDs();
         for(int i = 0; i < done.length; i++) {
             TargetModuleID id = done[i];
             out.println(getAction()+" "+id.getModuleID()+(multiple ? " on "+id.getTarget().getName()
: ""));
         }
+        if(po.getDeploymentStatus().isFailed()) {
+            throw new DeploymentException("Deployment failed, Server reports: "+po.getDeploymentStatus().getMessage());
+        }
     }
 
-    protected TargetModuleID[] runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[]
ids) {
-        return waitForProgress(out, mgr.start(ids));
+    protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[]
ids) {
+        ProgressObject po = mgr.start(ids);
+        waitForProgress(out, po);
+        return po;
     }
 
     protected String getAction() {

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStop.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStop.java?view=diff&r1=160278&r2=160279
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStop.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandStop.java
Wed Apr  6 03:14:19 2005
@@ -17,9 +17,12 @@
 
 package org.apache.geronimo.deployment.cli;
 
+import org.apache.geronimo.common.DeploymentException;
+
 import java.io.PrintWriter;
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.status.ProgressObject;
 
 /**
  * The CLI deployer logic to stop.
@@ -39,8 +42,10 @@
                 "start next time the server is started.");
     }
 
-    protected TargetModuleID[] runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[]
ids) {
-        return waitForProgress(out, mgr.stop(ids));
+    protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[]
ids) {
+        ProgressObject po = mgr.stop(ids);
+        waitForProgress(out, po);
+        return po;
     }
 
     protected String getAction() {

Modified: geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java?view=diff&r1=160278&r2=160279
==============================================================================
--- geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java
(original)
+++ geronimo/trunk/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java
Wed Apr  6 03:14:19 2005
@@ -20,6 +20,8 @@
 import java.io.PrintWriter;
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+import org.apache.geronimo.common.DeploymentException;
 
 /**
  * the CLI deployer logic to undeploy.
@@ -36,8 +38,10 @@
                 "all be undeployed.");
     }
 
-    protected TargetModuleID[] runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[]
ids) {
-        return waitForProgress(out, mgr.undeploy(ids));
+    protected ProgressObject runCommand(PrintWriter out, DeploymentManager mgr, TargetModuleID[]
ids) {
+        ProgressObject po = mgr.undeploy(ids);
+        waitForProgress(out, po);
+        return po;
     }
 
     protected String getAction() {



Mime
View raw message