You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by am...@apache.org on 2003/11/22 21:08:55 UTC
cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/server JmxProgressObject.java JmxServerConnection.java
ammulder 2003/11/22 12:08:55
Modified: . maven.xml
modules/core/src/java/org/apache/geronimo/console/cli/controller
ProgressMonitor.java
modules/core/src/java/org/apache/geronimo/enterprise/deploy/server
JmxProgressObject.java JmxServerConnection.java
Log:
ProgressObject is now hooked up to the remote server (though the remoting
still exhibits some strange behavior). Play with it by distributing an
EJB JAR with the command-line deployer.
ProgressObject and DeploymentStatus are now fully implemented.
Revision Changes Path
1.45 +2 -2 incubator-geronimo/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/maven.xml,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- maven.xml 17 Nov 2003 10:57:39 -0000 1.44
+++ maven.xml 22 Nov 2003 20:08:54 -0000 1.45
@@ -536,7 +536,7 @@
<property environment="env"/>
<java classname="org.apache.geronimo.kernel.Main"
fork="true"
- maxmemory="128m"
+ maxmemory="256m"
failonerror="true"
dir="${run.dir}">
1.2 +21 -6 incubator-geronimo/modules/core/src/java/org/apache/geronimo/console/cli/controller/ProgressMonitor.java
Index: ProgressMonitor.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/console/cli/controller/ProgressMonitor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProgressMonitor.java 19 Oct 2003 01:56:14 -0000 1.1
+++ ProgressMonitor.java 22 Nov 2003 20:08:54 -0000 1.2
@@ -69,22 +69,21 @@
*/
public class ProgressMonitor extends TextController implements ProgressListener {
private ProgressObject progress;
+ private boolean started = false;
public ProgressMonitor(DeploymentContext context, ProgressObject progress) {
super(context);
this.progress = progress;
+ progress.addProgressListener(this);
}
public void execute() {
- println("Monitoring the progress of a "+progress.getDeploymentStatus().getCommand()+" operation.");
- println("This operation can"+(progress.isCancelSupported() ? "" : "not")+" be canceled");
- println("This operation can"+(progress.isStopSupported() ? "" : "not")+" be stopped");
initialize(); //todo: allow cancel/stop
}
private synchronized void initialize() {
if(!progress.getDeploymentStatus().isRunning()) {
- println("--"+progress.getDeploymentStatus().getMessage());
+ message("--"+progress.getDeploymentStatus().getMessage());
printCompletion();
return;
} else {
@@ -92,14 +91,30 @@
wait();
} catch(InterruptedException e) {
}
+ printCompletion();
}
}
public synchronized void handleProgressEvent(ProgressEvent event) {
- println("--"+event.getDeploymentStatus().getMessage());
+ message("--"+event.getDeploymentStatus().getMessage());
if(!event.getDeploymentStatus().isRunning()) {
notifyAll();
}
+ }
+
+ private void printBanner() {
+ newScreen("Progress Monitor");
+ println("Monitoring the progress of a "+progress.getDeploymentStatus().getCommand()+" operation.");
+ println("This operation can"+(progress.isCancelSupported() ? "" : "not")+" be canceled");
+ println("This operation can"+(progress.isStopSupported() ? "" : "not")+" be stopped");
+ }
+
+ private void message(String message) {
+ if(!started) {
+ printBanner();
+ started = true;
+ }
+ println(message);
}
private void printCompletion() {
1.3 +63 -21 incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/server/JmxProgressObject.java
Index: JmxProgressObject.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/server/JmxProgressObject.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JmxProgressObject.java 17 Nov 2003 20:31:07 -0000 1.2
+++ JmxProgressObject.java 22 Nov 2003 20:08:54 -0000 1.3
@@ -58,6 +58,11 @@
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.List;
+import java.rmi.server.RemoteObject;
+import java.rmi.Remote;
+import java.io.Serializable;
import javax.enterprise.deploy.spi.status.ProgressObject;
import javax.enterprise.deploy.spi.status.DeploymentStatus;
import javax.enterprise.deploy.spi.status.ClientConfiguration;
@@ -93,16 +98,17 @@
private final static ObjectName CONTROLLER = JMXUtil.getObjectName("geronimo.deployment:role=DeploymentController");
private int jobID;
private MBeanServer server;
- private JobDeploymentStatus status = new JobDeploymentStatus();
+ private JobDeploymentStatus status;
private EventListenerList listenerList = new EventListenerList();
private NotificationListener listener;
-//todo: this class is just a beginning
- public JmxProgressObject(int jobID, MBeanServer server) {
+
+ public JmxProgressObject(int jobID, MBeanServer server, CommandType command) {
+ status = new JobDeploymentStatus(command);
this.jobID = jobID;
this.server = server;
try {
server.addNotificationListener(CONTROLLER, listener = new PONotificationListener(),
- new PONotificationFilter(),null);
+ new PONotificationFilter(jobID),null);
server.invoke(CONTROLLER, "startDeploymentJob", new Object[]{new Integer(jobID)}, new String[]{Integer.TYPE.toString()});
} catch(InstanceNotFoundException e) {
throw new RuntimeException("ProgressObject unable to register with server");
@@ -129,7 +135,7 @@
* @return a list of TargetModuleIDs.
*/
public TargetModuleID[] getResultTargetModuleIDs() {
- return new TargetModuleID[0]; //todo: how can we generate this list?
+ return status.getCompletedModules();
}
/**
@@ -221,7 +227,12 @@
// Lazily create the event:
if (event == null)
event = new ProgressEvent(this, tmid, status);
- ((ProgressListener)listeners[i+1]).handleProgressEvent(event);
+ try {
+ ((ProgressListener)listeners[i+1]).handleProgressEvent(event);
+ } catch(Throwable t) {
+ log.error("Exception caught from event listener; removing listener.", t);
+ removeProgressListener((ProgressListener)listeners[i+1]);
+ }
}
}
}
@@ -230,9 +241,12 @@
private JobDeploymentStatus parent;
private String message;
private StateType stateType;
+ private CommandType command;
+ private ActionType action = ActionType.EXECUTE;
public TMDeploymentStatus(JobDeploymentStatus parent) {
this.parent = parent;
+ command = parent.getCommand();
}
/**
@@ -254,7 +268,7 @@
* @return the CommandType Object
*/
public CommandType getCommand() {
- return null;
+ return command;
}
/**
@@ -263,7 +277,7 @@
* @return the ActionType Object
*/
public ActionType getAction() {
- return null;
+ return action;
}
/**
@@ -286,7 +300,7 @@
* @return <tt>true</tt> if this command has completed successfully
*/
public boolean isCompleted() {
- return false;
+ return stateType == StateType.COMPLETED;
}
/**
@@ -295,7 +309,7 @@
* @return <tt>true</tt> if this command has failed
*/
public boolean isFailed() {
- return false;
+ return stateType == StateType.FAILED;
}
/**
@@ -304,7 +318,7 @@
* @return <tt>true</tt> if this command is still running
*/
public boolean isRunning() {
- return false;
+ return stateType == StateType.RUNNING;
}
}
@@ -313,6 +327,12 @@
private Map tms = new HashMap();
private StateType stateType = StateType.RUNNING;
private boolean failed = false;
+ private CommandType command;
+ private ActionType action = ActionType.EXECUTE;
+
+ public JobDeploymentStatus(CommandType command) {
+ this.command = command;
+ }
public TMDeploymentStatus getTargetModule(TargetModuleID id) {
TMDeploymentStatus tm = (TMDeploymentStatus)tms.get(id);
@@ -324,7 +344,7 @@
}
public TMDeploymentStatus closeTargetModule(TargetModuleID id, boolean success, String message) {
- TMDeploymentStatus tm = (TMDeploymentStatus)tms.get(id);
+ TMDeploymentStatus tm = getTargetModule(id);
if(tm != null) {
tm.setMessage(message);
tm.setStateType(success ? StateType.COMPLETED : StateType.FAILED);
@@ -346,6 +366,18 @@
return tm;
}
+ public TargetModuleID[] getCompletedModules() {
+ List list = new ArrayList();
+ for(Iterator it = tms.keySet().iterator(); it.hasNext();) {
+ TargetModuleID id = (TargetModuleID)it.next();
+ TMDeploymentStatus status = (TMDeploymentStatus)tms.get(id);
+ if(status.isCompleted()) {
+ list.add(id);
+ }
+ }
+ return (TargetModuleID[])list.toArray(new TargetModuleID[list.size()]);
+ }
+
/**
* Retrieve the StateType value.
*
@@ -361,7 +393,7 @@
* @return the CommandType Object
*/
public CommandType getCommand() {
- return null;
+ return command;
}
/**
@@ -370,7 +402,7 @@
* @return the ActionType Object
*/
public ActionType getAction() {
- return null;
+ return action;
}
/**
@@ -392,7 +424,7 @@
* @return <tt>true</tt> if this command has completed successfully
*/
public boolean isCompleted() {
- return false;
+ return stateType == StateType.COMPLETED;
}
/**
@@ -401,7 +433,7 @@
* @return <tt>true</tt> if this command has failed
*/
public boolean isFailed() {
- return false;
+ return stateType == StateType.FAILED;
}
/**
@@ -410,11 +442,11 @@
* @return <tt>true</tt> if this command is still running
*/
public boolean isRunning() {
- return false;
+ return stateType == StateType.RUNNING;
}
}
- private class PONotificationListener implements NotificationListener {
+ private class PONotificationListener extends RemoteObject implements NotificationListener, Remote {
/**
* Called when a notification occurs.
*
@@ -449,7 +481,13 @@
}
}
- private static class PONotificationFilter implements NotificationFilter {
+ private static class PONotificationFilter implements NotificationFilter, Serializable {
+ private int jobID;
+
+ public PONotificationFilter(int jobID) {
+ this.jobID = jobID;
+ }
+
/**
* Invoked before sending the <code>Notification</code> to the listener.
*
@@ -457,9 +495,13 @@
*
*/
public boolean isNotificationEnabled(Notification notification) {
- return notification.getType().equals(DeploymentNotification.DEPLOYMENT_COMPLETED) ||
+ boolean result = notification.getType().equals(DeploymentNotification.DEPLOYMENT_COMPLETED) ||
notification.getType().equals(DeploymentNotification.DEPLOYMENT_FAILED) ||
notification.getType().equals(DeploymentNotification.DEPLOYMENT_UPDATE);
+ if(result) {
+ result = ((DeploymentNotification)notification).getDeploymentID() == jobID;
+ }
+ return result;
}
}
}
1.5 +9 -8 incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/server/JmxServerConnection.java
Index: JmxServerConnection.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/server/JmxServerConnection.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JmxServerConnection.java 17 Nov 2003 20:31:07 -0000 1.4
+++ JmxServerConnection.java 22 Nov 2003 20:08:54 -0000 1.5
@@ -14,6 +14,7 @@
import javax.enterprise.deploy.spi.TargetModuleID;
import javax.enterprise.deploy.spi.exceptions.TargetException;
import javax.enterprise.deploy.shared.ModuleType;
+import javax.enterprise.deploy.shared.CommandType;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.commons.logging.Log;
@@ -110,7 +111,7 @@
if(result instanceof Exception) {
throw (Exception)result;
} else {
- return new JmxProgressObject(((Integer)result).intValue(), server);
+ return new JmxProgressObject(((Integer)result).intValue(), server, CommandType.DISTRIBUTE);
}
} catch(UndeclaredThrowableException e) {
throw new RemoteException("Server request failed", e.getCause());
@@ -132,7 +133,7 @@
if(result instanceof Exception) {
throw (Exception)result;
} else {
- return new JmxProgressObject(((Integer)result).intValue(), server);
+ return new JmxProgressObject(((Integer)result).intValue(), server, CommandType.DISTRIBUTE);
}
} catch(UndeclaredThrowableException e) {
throw new RemoteException("Server request failed", e.getCause());
@@ -157,7 +158,7 @@
if(result instanceof Exception) {
throw (Exception)result;
} else {
- return new JmxProgressObject(((Integer)result).intValue(), server);
+ return new JmxProgressObject(((Integer)result).intValue(), server, CommandType.REDEPLOY);
}
} catch(UndeclaredThrowableException e) {
throw new RemoteException("Server request failed", e.getCause());
@@ -174,7 +175,7 @@
if(result instanceof Exception) {
throw (Exception)result;
} else {
- return new JmxProgressObject(((Integer)result).intValue(), server);
+ return new JmxProgressObject(((Integer)result).intValue(), server, CommandType.REDEPLOY);
}
} catch(UndeclaredThrowableException e) {
throw new RemoteException("Server request failed", e.getCause());
@@ -190,7 +191,7 @@
if(result instanceof Exception) {
throw (Exception)result;
} else {
- return new JmxProgressObject(((Integer)result).intValue(), server);
+ return new JmxProgressObject(((Integer)result).intValue(), server, CommandType.START);
}
} catch(UndeclaredThrowableException e) {
throw new RemoteException("Server request failed", e.getCause());
@@ -206,7 +207,7 @@
if(result instanceof Exception) {
throw (Exception)result;
} else {
- return new JmxProgressObject(((Integer)result).intValue(), server);
+ return new JmxProgressObject(((Integer)result).intValue(), server, CommandType.STOP);
}
} catch(UndeclaredThrowableException e) {
throw new RemoteException("Server request failed", e.getCause());
@@ -222,7 +223,7 @@
if(result instanceof Exception) {
throw (Exception)result;
} else {
- return new JmxProgressObject(((Integer)result).intValue(), server);
+ return new JmxProgressObject(((Integer)result).intValue(), server, CommandType.UNDEPLOY);
}
} catch(UndeclaredThrowableException e) {
throw new RemoteException("Server request failed", e.getCause());