geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r216256 - in /geronimo/trunk/modules: deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/ deploy-tool/src/java/org/apache/geronimo/deployment/cli/
Date Wed, 13 Jul 2005 21:16:57 GMT
Author: ammulder
Date: Wed Jul 13 14:16:54 2005
New Revision: 216256

URL: http://svn.apache.org/viewcvs?rev=216256&view=rev
Log:
Show more fine-grained deployment status
Better handling for stop and undeploy when modules aren't running

Modified:
    geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
    geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
    geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
    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/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

Modified: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java?rev=216256&r1=216255&r2=216256&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
(original)
+++ geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
Wed Jul 13 14:16:54 2005
@@ -62,6 +62,10 @@
         moduleIDs.add(moduleID);
     }
 
+    protected synchronized int getModuleCount() {
+        return moduleIDs.size();
+    }
+
     public synchronized TargetModuleID[] getResultTargetModuleIDs() {
         return (TargetModuleID[]) moduleIDs.toArray(new TargetModuleID[moduleIDs.size()]);
     }
@@ -113,6 +117,10 @@
         sendEvent(message, StateType.COMPLETED);
     }
 
+    protected final void updateStatus(String message) {
+        sendEvent(message, state);
+    }
+
     protected void doFail(Exception e) {
         if (e instanceof InternalKernelException) {
             e = (Exception)((InternalKernelException)e).getCause();
@@ -155,6 +163,13 @@
         for (int i = 0; i < toNotify.length; i++) {
             toNotify[i].handleProgressEvent(event);
         }
+    }
+
+    protected static String clean(String value) {
+        if(value.startsWith("\"") && value.endsWith("\"")) {
+            return value.substring(1, value.length()-1);
+        }
+        return value;
     }
 
     private static class Status implements DeploymentStatus {

Modified: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java?rev=216256&r1=216255&r2=216256&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
(original)
+++ geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
Wed Jul 13 14:16:54 2005
@@ -18,12 +18,16 @@
 package org.apache.geronimo.deployment.plugin.local;
 
 import java.net.URI;
+import java.util.Map;
+import java.util.HashMap;
 
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.management.ObjectName;
 
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.InternalKernelException;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
@@ -49,11 +53,25 @@
 
                 URI moduleID = URI.create(module.getModuleID());
                 ObjectName configName = Configuration.getConfigurationObjectName(moduleID);
-                kernel.stopGBean(configName);
+                try {
+                    kernel.stopGBean(configName);
+                } catch (GBeanNotFoundException e) {
+                    if(clean(e.getGBeanName().getKeyProperty("name")).equals(moduleID.toString()))
{
+                        updateStatus("Module "+moduleID+" is not running.");
+                        continue;
+                    } else {
+                        System.out.println("Unmatched name '"+clean(e.getGBeanName().getKeyProperty("name"))+"'");
+                        throw e;
+                    }
+                }
                 configurationManager.unload(moduleID);
                 addModule(module);
             }
-            complete("Completed");
+            if(getModuleCount() < modules.length) {
+                fail("Some modules could not be stopped");
+            } else {
+                complete("Completed");
+            }
         } catch (Exception e) {
             doFail(e);
         }

Modified: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java?rev=216256&r1=216255&r2=216256&view=diff
==============================================================================
--- geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
(original)
+++ geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/UndeployCommand.java
Wed Jul 13 14:16:54 2005
@@ -30,6 +30,7 @@
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 
 /**
  * @version $Rev$ $Date$
@@ -54,8 +55,18 @@
                 URI moduleID = URI.create(module.getModuleID());
                 try {
                     ObjectName configName = Configuration.getConfigurationObjectName(moduleID);
-                    kernel.stopGBean(configName);
+                    try {
+                        kernel.stopGBean(configName);
+                        updateStatus("Module "+moduleID+" stopped.");
+                    } catch (GBeanNotFoundException e) {
+                        if(clean(e.getGBeanName().getKeyProperty("name")).equals(moduleID.toString()))
{
+                            // the module is not running
+                        } else {
+                            throw e;
+                        }
+                    }
                     configurationManager.unload(moduleID);
+                    updateStatus("Module "+moduleID+" unloaded.");
                 } catch (InternalKernelException e) {
                     // this is cause by the kernel being already shutdown
                 } catch (NoSuchConfigException e) {
@@ -67,11 +78,14 @@
                     ObjectName storeName = target.getObjectName();
                     URI configID = URI.create(module.getModuleID());
                     kernel.invoke(storeName, "uninstall", new Object[]{configID}, UNINSTALL_SIG);
+                    updateStatus("Module "+moduleID+" uninstalled.");
+                    addModule(module);
                 } catch (NoSuchConfigException e) {
                     // module was already undeployed - just continue
                 }
-
-                addModule(module);
+            }
+            if(getModuleCount() < modules.length) {
+                updateStatus("Some of the modules to undeploy were not previously deployed.
 This is not treated as an error.");
             }
             complete("Completed");
         } catch (Exception e) {

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?rev=216256&r1=216255&r2=216256&view=diff
==============================================================================
--- 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 Jul 13 14:16:54 2005
@@ -20,6 +20,8 @@
 import org.apache.geronimo.common.DeploymentException;
 
 import javax.enterprise.deploy.spi.status.ProgressObject;
+import javax.enterprise.deploy.spi.status.ProgressListener;
+import javax.enterprise.deploy.spi.status.ProgressEvent;
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.DeploymentManager;
@@ -79,6 +81,16 @@
      * @param po a <code>ProgressObject</code> value
      */
     protected static void waitForProgress(PrintWriter out, ProgressObject po) {
+        po.addProgressListener(new ProgressListener() {
+            String last = null;
+            public void handleProgressEvent(ProgressEvent event) {
+                String msg = event.getDeploymentStatus().getMessage();
+                if(last != null && !last.equals(msg)) {
+                    System.out.println(DeployUtils.reformat(last,8,72)); //todo: use the
same writer as DeployTool
+                }
+                last = msg;
+            }
+        });
         while(po.getDeploymentStatus().isRunning()) {
             try {
                 Thread.sleep(100);
@@ -144,7 +156,7 @@
             }
         }
         if(list.isEmpty()) {
-            throw new DeploymentException(name+" does not appear to be a module name or a
TargetModuleID.  For a TargetModuleID, specify it as TargetName|ModuleName");
+            throw new DeploymentException(name+" does not appear to be a TargetModuleID or
the name of a module available on the selected server.  For a TargetModuleID, specify it as
TargetName|ModuleName");
         }
         return list;
     }

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?rev=216256&r1=216255&r2=216256&view=diff
==============================================================================
--- 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 Jul 13 14:16:54 2005
@@ -148,13 +148,13 @@
         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()
: ""));
+            out.println(DeployUtils.reformat(getAction()+" "+result.getModuleID()+(multipleTargets
? " to "+result.getTarget().getName() : ""), 4, 72));
         }
 
         // 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());
+            throw new DeploymentException("Operation failed: "+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?rev=216256&r1=216255&r2=216256&view=diff
==============================================================================
--- 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 Jul 13 14:16:54 2005
@@ -118,7 +118,7 @@
             out.println("Redeployed "+id.getModuleID()+(multiple ? " on "+id.getTarget().getName()
: ""));
         }
         if(po.getDeploymentStatus().isFailed()) {
-            throw new DeploymentException("Deployment failed, Server reports: "+po.getDeploymentStatus().getMessage());
+            throw new DeploymentException("Operation failed: "+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?rev=216256&r1=216255&r2=216256&view=diff
==============================================================================
--- 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 Jul 13 14:16:54 2005
@@ -74,10 +74,10 @@
         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()
: ""));
+            out.println(DeployUtils.reformat(getAction()+" "+id.getModuleID()+(multiple ?
" on "+id.getTarget().getName() : ""),4, 72));
         }
         if(po.getDeploymentStatus().isFailed()) {
-            throw new DeploymentException("Deployment failed, Server reports: "+po.getDeploymentStatus().getMessage());
+            throw new DeploymentException("Operation failed: "+po.getDeploymentStatus().getMessage());
         }
     }
 



Mime
View raw message