ammulder 2003/11/17 07:26:46
Modified: modules/kernel/src/java/org/apache/geronimo/kernel Main.java
modules/kernel/src/java/org/apache/geronimo/kernel/deployment
DeploymentController.java
Log:
Remove synchronization from DeploymentController
- the method to do the work is now only ever called from 1 thread, so
we don't need to synchronize to prevent overlap
- the work methods fire notifications, and it's rumored to be bad to do
that while holding the object's monitor
Fire the first update messages on a deployment job when the job is first
made runnable, instead of when the work is actually started (which
might be much later if there was a long deployment in front of it)
Take advantage of the deployment notifications to print the server startup
message at the end of the initial startup sequence
- to do this, we assume that the first run of the DeploymentScanner
will not achieve anything, so we wait for the second run. This
appears to be consistent. It would shave a couple seconds off our
startup time if we fixed that. Perhaps the scanner starts before
the relevant deployment planners?
Revision Changes Path
1.3 +48 -12
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/Main.java
Index: Main.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/Main.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Main.java 17 Nov 2003 10:57:40 -0000 1.2
+++ Main.java 17 Nov 2003 15:26:46 -0000 1.3
@@ -63,15 +63,22 @@
import java.util.List;
import java.util.Arrays;
import java.util.LinkedList;
+import java.util.HashSet;
import java.beans.PropertyEditorManager;
import javax.management.MBeanServer;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
+import javax.management.NotificationListener;
+import javax.management.Notification;
+import javax.management.NotificationFilter;
+import javax.management.InstanceNotFoundException;
+import javax.management.ListenerNotFoundException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.LogFactoryImpl;
import org.apache.geronimo.kernel.deployment.DeploymentException;
+import org.apache.geronimo.kernel.deployment.client.DeploymentNotification;
import org.apache.geronimo.kernel.jmx.JMXKernel;
/**
@@ -121,7 +128,7 @@
* Main entry point
*/
public void run() {
- long time = System.currentTimeMillis();
+ final long time = System.currentTimeMillis();
Object[] deployArgs = {bootURL};
JMXKernel kernel = null;
@@ -171,18 +178,47 @@
// start her up
log.info("Deploying Bootstrap Services from " + bootURL);
- MBeanServer mbServer = kernel.getMBeanServer();
+ final MBeanServer mbServer = kernel.getMBeanServer();
+ final ObjectName nameToDeregister = controllerName;
+ mbServer.addNotificationListener(controllerName, new
NotificationListener() {
+ private Set ids = new HashSet();
+ private int zeroCount = 0;
+ public void handleNotification(Notification
notification, Object handback) {
+ DeploymentNotification dn =
(DeploymentNotification)notification;
+
if(dn.getType().equals(DeploymentNotification.DEPLOYMENT_UPDATE)) {
+ ids.add(dn.getTargetModuleID());
+ } else {
+ ids.remove(dn.getTargetModuleID());
+ }
+ if(ids.size() == 0) {
+ ++zeroCount;
+ if(zeroCount > 1) { // todo: here we assume that
the first run of the DeploymentScanner will not do anything. We could save
several seconds if we fixed that, but for now this works.
+ // Booted... print the startup time
+ long delta = (System.currentTimeMillis() -
time) / 1000;
+ StringBuffer startMessage = new
StringBuffer(50);
+ startMessage.append("Started Server in ");
+ if(delta > 60) {
+ startMessage.append(delta /
60).append("m ");
+ }
+ startMessage.append(delta % 60).append("s");
+ log.info(startMessage);
+ try {
+
mbServer.removeNotificationListener(nameToDeregister, this);
+ } catch(InstanceNotFoundException e) {
+ log.error("Couldn't remove start
listener", e);
+ } catch(ListenerNotFoundException e) {
+ log.error("Couldn't remove start
listener", e);
+ }
+ }
+ }
+ }
+ }, new NotificationFilter() {
+ public boolean isNotificationEnabled(Notification
notification) {
+ return true;
+ }
+ }, null);
mbServer.invoke(deployerName, "deploy", deployArgs,
DEPLOY_ARG_TYPES);
- // Booted... print the startup time
- time = (System.currentTimeMillis() - time) / 1000;
- StringBuffer startMessage = new StringBuffer(50);
- startMessage.append("Started Server in ");
- if(time > 60) {
- startMessage.append(time / 60).append("m ");
- }
- startMessage.append(time % 60).append("s");
- log.info(startMessage);
} catch (Throwable e) {
log.error("Error starting Server", e);
return;
1.7 +5 -5
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/DeploymentController.java
Index: DeploymentController.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/DeploymentController.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DeploymentController.java 17 Nov 2003 10:57:40 -0000 1.6
+++ DeploymentController.java 17 Nov 2003 15:26:46 -0000 1.7
@@ -183,16 +183,13 @@
waiter.startJob(deploymentID);
}
- private synchronized void executeJob(DeploymentGoal[] job) {
+ private void executeJob(DeploymentGoal[] job) {
if(job.length == 0) {
return;
}
int id = job[0].getTargetModule().getDeploymentID();
try {
goals.addAll(Arrays.asList(job));
- for(int i=0; i<job.length; i++) {
- updateDeploymentStatus(id, "Starting deployment job.",
DeploymentNotification.DEPLOYMENT_UPDATE, job[i].getTargetModule());
- }
generatePlans();
executePlans();
for(int i=0; i<job.length; i++) {
@@ -344,6 +341,9 @@
if(job == null) {
log.error("Job should not be null", new RuntimeException());
return;
+ }
+ for(int i=0; i<job.length; i++) {
+
updateDeploymentStatus(job[i].getTargetModule().getDeploymentID(), "Starting
deployment job.", DeploymentNotification.DEPLOYMENT_UPDATE,
job[i].getTargetModule());
}
synchronized(work) {
work.addLast(job);