ServiceController Enhancement
jdoble Jun 13, 2005 2:48 PMMy company has developed a network management appliance using JBoss as an underlying framework. Up to now, we haven't had any need to modify the JBoss code itself, but we recently ran into a issue that can easily be resolved with a minor modification to org.jboss.system.ServiceController.java.
Given that our product is an appliance, we have had to write additional Operations, Administration and Maintenance (OAM) services (e.g. system monitoring & automatic recovery, backup & restore, etc.) which typically require individual services, or groups of services to be stopped and/or started. We have been invoking the stop and start JMX operations in ServiceController.java to request the individual stop/start operations, so that ServiceController's cached service states are kept up to date, and so that any services that are listening to ServiceControllers notifications are informed when other services are started or stopped.
The problem we currently have is that the start method not only starts the requested service, but then proceeds to start any services that depend an the requested service, which will then start any services that depend on those services and so on. This is a problem for us because there are times when we need to start a service, do some work, then start the dependent services.
The solution we are proposing is this:
Modify the start method in ServiceController.java to have the following signature:
public synchronized void start(ObjectName serviceName, Boolean startDependents)
and modify the code which starts dependent services to look like the following:
if (startDependents.booleanValue()) { // Those that depend on me are waiting for my start, recursively start them log.debug("Starting dependent components for: " + serviceName + " dependent components: " + ctx.dependsOnMe); ArrayList tmp = new ArrayList(ctx.dependsOnMe); for (int n = 0; n < tmp.size(); n++) { // marcf fixme circular dependencies? ServiceContext ctx2 = (ServiceContext) tmp.get(n); start(ctx2.objectName); } tmp.clear(); }
In order to ensure that existing clients of ServiceController do not need to be modified, add the following method:
public synchronized void start(ObjectName serviceName) throws Exception { start(serviceName, Boolean.TRUE); }
Both of the start methods would need to be tagged as JMX operations, so that they clients can invoke them via the JMX server.
I am happy to make this change (if approved/allowed/etc.). I am new to the JBoss contributor process, so I will likely have a few questions about how best to proceed. I am hoping that this forum was the right place to start. If not, please advise.