summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/src/IceBox/ServiceManagerI.cpp80
-rw-r--r--cpp/src/IceBox/ServiceManagerI.h4
-rw-r--r--cs/src/IceBox/ServiceManagerI.cs156
-rw-r--r--cs/src/IceGrid/Makefile2
-rw-r--r--java/src/IceBox/ServiceManagerI.java423
5 files changed, 314 insertions, 351 deletions
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp
index 88ee6a99ed4..7b5c92c9161 100644
--- a/cpp/src/IceBox/ServiceManagerI.cpp
+++ b/cpp/src/IceBox/ServiceManagerI.cpp
@@ -144,7 +144,9 @@ IceBox::ServiceManagerI::startService(const string& name, const Current&)
{
vector<string> services;
services.push_back(name);
- servicesStarted(services);
+ set<ServiceObserverPrx> observers = _observers;
+ lock.release();
+ servicesStarted(services, observers);
}
return;
@@ -195,7 +197,9 @@ IceBox::ServiceManagerI::stopService(const string& name, const Current&)
{
vector<string> services;
services.push_back(name);
- servicesStopped(services);
+ set<ServiceObserverPrx> observers = _observers;
+ lock.release();
+ servicesStopped(services, observers);
}
return;
@@ -234,21 +238,9 @@ IceBox::ServiceManagerI::addObserver(const ServiceObserverPrx& observer, const I
if(activeServices.size() > 0)
{
- try
- {
- observer->servicesStarted_async(new AMICallback<AMI_ServiceObserver_servicesStarted>(this, observer),
- activeServices);
- }
- catch(const std::exception& ex)
- {
- _observers.erase(observer);
- observerRemoved(observer, ex);
- }
- catch(...)
- {
- _observers.erase(observer);
- throw;
- }
+ lock.release();
+ observer->servicesStarted_async(new AMICallback<AMI_ServiceObserver_servicesStarted>(this, observer),
+ activeServices);
}
}
}
@@ -759,8 +751,6 @@ IceBox::ServiceManagerI::stopAll()
}
}
- servicesStopped(stoppedServices);
-
for(p = _services.rbegin(); p != _services.rend(); ++p)
{
ServiceInfo& info = *p;
@@ -851,57 +841,45 @@ IceBox::ServiceManagerI::stopAll()
}
_services.clear();
+
+ set<ServiceObserverPrx> observers = _observers;
+ lock.release();
+ servicesStopped(stoppedServices, observers);
}
void
-IceBox::ServiceManagerI::servicesStarted(const vector<string>& services)
+IceBox::ServiceManagerI::servicesStarted(const vector<string>& services, const set<ServiceObserverPrx>& observers)
{
+ //
+ // Must be called with 'this' unlocked
+ //
+
if(services.size() > 0)
{
- //
- // Must be called with 'this' locked
- //
- for(set<ServiceObserverPrx>::iterator p = _observers.begin(); p != _observers.end(); ++p)
+ for(set<ServiceObserverPrx>::const_iterator p = observers.begin(); p != observers.end(); ++p)
{
ServiceObserverPrx observer = *p;
-
- try
- {
- observer->servicesStarted_async(new AMICallback<AMI_ServiceObserver_servicesStarted>(this, observer),
- services);
- }
- catch(const std::exception& ex)
- {
- _observers.erase(p);
- observerRemoved(observer, ex);
- }
+ observer->servicesStarted_async(new AMICallback<AMI_ServiceObserver_servicesStarted>(this, observer),
+ services);
}
}
}
void
-IceBox::ServiceManagerI::servicesStopped(const vector<string>& services)
+IceBox::ServiceManagerI::servicesStopped(const vector<string>& services, const set<ServiceObserverPrx>& observers)
{
+ //
+ // Must be called with 'this' unlocked
+ //
+
if(services.size() > 0)
{
- //
- // Must be called with 'this' locked
- //
- for(set<ServiceObserverPrx>::iterator p = _observers.begin(); p != _observers.end(); ++p)
+ for(set<ServiceObserverPrx>::const_iterator p = observers.begin(); p != observers.end(); ++p)
{
ServiceObserverPrx observer = *p;
-
- try
- {
- observer->servicesStopped_async(new AMICallback<AMI_ServiceObserver_servicesStopped>(this, observer),
- services);
- }
- catch(const std::exception& ex)
- {
- _observers.erase(p);
- observerRemoved(observer, ex);
- }
+ observer->servicesStopped_async(new AMICallback<AMI_ServiceObserver_servicesStopped>(this, observer),
+ services);
}
}
}
diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h
index 2b9d7213c80..e4131a82bb0 100644
--- a/cpp/src/IceBox/ServiceManagerI.h
+++ b/cpp/src/IceBox/ServiceManagerI.h
@@ -59,8 +59,8 @@ private:
void start(const std::string&, const std::string&, const ::Ice::StringSeq&);
void stopAll();
- void servicesStarted(const std::vector<std::string>&);
- void servicesStopped(const std::vector<std::string>&);
+ void servicesStarted(const std::vector<std::string>&, const std::set<ServiceObserverPrx>&);
+ void servicesStopped(const std::vector<std::string>&, const std::set<ServiceObserverPrx>&);
void observerRemoved(const ServiceObserverPrx&, const std::exception&);
::Ice::CommunicatorPtr _communicator;
diff --git a/cs/src/IceBox/ServiceManagerI.cs b/cs/src/IceBox/ServiceManagerI.cs
index e30f8c22d9c..d913049affe 100644
--- a/cs/src/IceBox/ServiceManagerI.cs
+++ b/cs/src/IceBox/ServiceManagerI.cs
@@ -91,17 +91,25 @@ class ServiceManagerI : ServiceManagerDisp_
public override void
startService(string name, Ice.Current current)
{
+ bool found = false;
+ Dictionary<ServiceObserverPrx, bool> observers = null;
+
lock(this)
{
//
// Search would be more efficient if services were contained in
// a map, but order is required for shutdown.
//
- for(int i = 0; i < _services.Count; ++i)
+
+ int i = 0;
+
+ while(!found && i < _services.Count)
{
- ServiceInfo info = (ServiceInfo)_services[i];
+ ServiceInfo info = _services[i];
if(info.name.Equals(name))
{
+ found = true;
+
if(info.active)
{
throw new AlreadyStartedException();
@@ -113,42 +121,54 @@ class ServiceManagerI : ServiceManagerDisp_
: info.communicator, info.args);
info.active = true;
_services[i] = info;
+ observers = new Dictionary<ServiceObserverPrx, bool>(_observers);
}
catch(Exception e)
{
_logger.warning("ServiceManager: exception in start for service " + info.name + "\n" +
e.ToString());
}
-
- if(info.active)
- {
- List<string> services = new List<string>();
- services.Add(name);
- servicesStarted(services);
- }
-
- return;
}
+ ++i;
}
-
+ }
+
+
+ if(!found)
+ {
throw new NoSuchServiceException();
}
+
+ if(observers != null)
+ {
+ List<string> services = new List<string>();
+ services.Add(name);
+ servicesStarted(services, observers.Keys);
+ }
}
public override void
stopService(string name, Ice.Current current)
{
+ bool found = false;
+ Dictionary<ServiceObserverPrx, bool> observers = null;
+
lock(this)
{
//
// Search would be more efficient if services were contained in
// a map, but order is required for shutdown.
//
- for(int i = 0; i < _services.Count; ++i)
+ int i = 0;
+
+ while(!found && i < _services.Count)
{
- ServiceInfo info = (ServiceInfo)_services[i];
+ ServiceInfo info = _services[i];
+
if(info.name.Equals(name))
{
+ found = true;
+
if(!info.active)
{
throw new AlreadyStoppedException();
@@ -159,31 +179,36 @@ class ServiceManagerI : ServiceManagerDisp_
info.service.stop();
info.active = false;
_services[i] = info;
+ observers = new Dictionary<ServiceObserverPrx, bool>(_observers);
}
catch(Exception e)
{
_logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
e.ToString());
}
-
- if(!info.active)
- {
- List<string> services = new List<string>();
- services.Add(name);
- servicesStopped(services);
- }
-
- return;
}
+ ++i;
}
+ }
+ if(!found)
+ {
throw new NoSuchServiceException();
}
+
+ if(observers != null)
+ {
+ List<string> services = new List<string>();
+ services.Add(name);
+ servicesStarted(services, observers.Keys);
+ }
}
public override void
addObserver(ServiceObserverPrx observer, Ice.Current current)
{
+ List<string> activeServices = new List<string>();
+
//
// Null observers and duplicate registrations are ignored
//
@@ -207,8 +232,6 @@ class ServiceManagerI : ServiceManagerDisp_
"Added service observer: " + Ice.Application.communicator().proxyToString(observer));
}
- List<string> activeServices = new List<string>();
-
foreach(ServiceInfo info in _services)
{
if(info.active)
@@ -216,23 +239,14 @@ class ServiceManagerI : ServiceManagerDisp_
activeServices.Add(info.name);
}
}
-
- if(activeServices.Count > 0)
- {
- try
- {
- observer.servicesStarted_async(new AMIServicesStartedCallback(this, observer),
- activeServices.ToArray());
- }
- catch(System.Exception ex)
- {
- _observers.Remove(observer);
- observerRemoved(observer, ex);
- throw;
- }
- }
}
}
+
+ if(activeServices.Count > 0)
+ {
+ observer.servicesStarted_async(new AMIServicesStartedCallback(this, observer),
+ activeServices.ToArray());
+ }
}
public override void
@@ -707,10 +721,11 @@ class ServiceManagerI : ServiceManagerDisp_
private void
stopAll()
{
+ List<string> stoppedServices = new List<string>();
+ Dictionary<ServiceObserverPrx, bool> observers = null;
+
lock(this)
{
- List<string> stoppedServices = new List<string>();
-
//
// First, for each service, we call stop on the service and flush its database environment to
// the disk. Services are stopped in the reverse order of which they were started.
@@ -773,78 +788,47 @@ class ServiceManagerI : ServiceManagerDisp_
}
}
- servicesStopped(stoppedServices);
-
_services.Clear();
+ observers = new Dictionary<ServiceObserverPrx, bool>(_observers);
}
+
+ servicesStopped(stoppedServices, observers.Keys);
}
private void
- servicesStarted(List<String> services)
+ servicesStarted(List<String> services, Dictionary<ServiceObserverPrx, bool>.KeyCollection observers)
{
//
- // Must be called with 'this' locked
+ // Must be called with 'this' unlocked
//
if(services.Count > 0)
{
string[] servicesArray = services.ToArray();
- List<ServiceObserverPrx> deadObservers = new List<ServiceObserverPrx>();
-
-
- foreach(ServiceObserverPrx observer in _observers.Keys)
+
+ foreach(ServiceObserverPrx observer in observers)
{
AMI_ServiceObserver_servicesStarted cb = new AMIServicesStartedCallback(this, observer);
-
- try
- {
- observer.servicesStarted_async(cb, servicesArray);
- }
- catch(System.Exception ex)
- {
- deadObservers.Add(observer);
- observerRemoved(observer, ex);
- }
- }
-
- foreach(ServiceObserverPrx observer in deadObservers)
- {
- _observers.Remove(observer);
+ observer.servicesStarted_async(cb, servicesArray);
}
}
}
private void
- servicesStopped(List<string> services)
+ servicesStopped(List<string> services, Dictionary<ServiceObserverPrx, bool>.KeyCollection observers)
{
//
- // Must be called with 'this' locked
+ // Must be called with 'this' unlocked
//
if(services.Count > 0)
{
string[] servicesArray = services.ToArray();
- List<ServiceObserverPrx> deadObservers = new List<ServiceObserverPrx>();
-
-
- foreach(ServiceObserverPrx observer in _observers.Keys)
+
+ foreach(ServiceObserverPrx observer in observers)
{
AMI_ServiceObserver_servicesStopped cb = new AMIServicesStoppedCallback(this, observer);
-
- try
- {
- observer.servicesStopped_async(cb, servicesArray);
- }
- catch(System.Exception ex)
- {
- deadObservers.Add(observer);
- observerRemoved(observer, ex);
- }
- }
-
- foreach(ServiceObserverPrx observer in deadObservers)
- {
- _observers.Remove(observer);
+ observer.servicesStopped_async(cb, servicesArray);
}
}
}
diff --git a/cs/src/IceGrid/Makefile b/cs/src/IceGrid/Makefile
index 71e1877b826..8dd038fb126 100644
--- a/cs/src/IceGrid/Makefile
+++ b/cs/src/IceGrid/Makefile
@@ -31,7 +31,7 @@ GDIR = generated
include $(top_srcdir)/config/Make.rules.cs
-MCSFLAGS := $(MCSFLAGS) -target:library -out:$(TARGETS) -unsafe
+MCSFLAGS := $(MCSFLAGS) -target:library -out:$(TARGETS) -unsafe -warnaserror-
MCSFLAGS := $(MCSFLAGS) -keyfile:$(top_srcdir)/config/IcecsKey.snk
SLICE2CSFLAGS := $(SLICE2CSFLAGS) --ice -I$(slicedir)
diff --git a/java/src/IceBox/ServiceManagerI.java b/java/src/IceBox/ServiceManagerI.java
index 471e5aebaac..ff930bf77f4 100644
--- a/java/src/IceBox/ServiceManagerI.java
+++ b/java/src/IceBox/ServiceManagerI.java
@@ -30,159 +30,175 @@ public class ServiceManagerI extends _ServiceManagerDisp
return SliceChecksums.checksums;
}
- synchronized public void
+ public void
startService(String name, Ice.Current current)
throws AlreadyStartedException, NoSuchServiceException
{
- //
- // Search would be more efficient if services were contained in
- // a map, but order is required for shutdown.
- //
- java.util.Iterator p = _services.iterator();
- while(p.hasNext())
+
+ boolean found = false;
+ java.util.Set<ServiceObserverPrx> observers = null;
+
+ synchronized(this)
{
- ServiceInfo info = (ServiceInfo)p.next();
- if(info.name.equals(name))
+ //
+ // Search would be more efficient if services were contained in
+ // a map, but order is required for shutdown.
+ //
+ java.util.Iterator<ServiceInfo> p = _services.iterator();
+ while(p.hasNext() && !found)
{
- if(info.active)
+ ServiceInfo info = p.next();
+ if(info.name.equals(name))
{
- throw new AlreadyStartedException();
- }
+ found = true;
- try
- {
- info.service.start(name, info.communicator == null ? _server.communicator() : info.communicator,
- info.args);
- info.active = true;
- }
- catch(java.lang.Exception e)
- {
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- e.printStackTrace(pw);
- pw.flush();
- _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
- sw.toString());
- }
+ if(info.active)
+ {
+ throw new AlreadyStartedException();
+ }
- if(info.active)
- {
- java.util.List<String> services = new java.util.Vector<String>();
- services.add(name);
- servicesStarted(services);
+ try
+ {
+ info.service.start(name, info.communicator == null ? _server.communicator() : info.communicator,
+ info.args);
+ info.active = true;
+ observers = (java.util.Set<ServiceObserverPrx>)_observers.clone();
+ }
+ catch(java.lang.Exception e)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ e.printStackTrace(pw);
+ pw.flush();
+ _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
+ sw.toString());
+ }
}
-
- return;
}
}
+
+ if(!found)
+ {
+ throw new NoSuchServiceException();
+ }
- throw new NoSuchServiceException();
+ if(observers != null)
+ {
+ java.util.List<String> services = new java.util.Vector<String>();
+ services.add(name);
+ servicesStarted(services, observers);
+ }
}
synchronized public void
stopService(String name, Ice.Current current)
throws AlreadyStoppedException, NoSuchServiceException
{
- //
- // Search would be more efficient if services were contained in
- // a map, but order is required for shutdown.
- //
- java.util.Iterator p = _services.iterator();
- while(p.hasNext())
+ boolean found = false;
+ java.util.Set<ServiceObserverPrx> observers = null;
+
+ synchronized(this)
{
- ServiceInfo info = (ServiceInfo)p.next();
- if(info.name.equals(name))
+ //
+ // Search would be more efficient if services were contained in
+ // a map, but order is required for shutdown.
+ //
+ java.util.Iterator<ServiceInfo> p = _services.iterator();
+ while(p.hasNext() && !found)
{
- if(!info.active)
- {
- throw new AlreadyStoppedException();
- }
-
- try
- {
- info.service.stop();
- info.active = false;
- }
- catch(java.lang.Exception e)
+ ServiceInfo info = p.next();
+ if(info.name.equals(name))
{
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- e.printStackTrace(pw);
- pw.flush();
- _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
- sw.toString());
- }
-
- if(!info.active)
- {
- java.util.List<String> services = new java.util.Vector<String>();
- services.add(name);
- servicesStopped(services);
+ found = true;
+
+ if(!info.active)
+ {
+ throw new AlreadyStoppedException();
+ }
+
+ try
+ {
+ info.service.stop();
+ info.active = false;
+ observers = (java.util.Set<ServiceObserverPrx>)_observers.clone();
+ }
+ catch(java.lang.Exception e)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ e.printStackTrace(pw);
+ pw.flush();
+ _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
+ sw.toString());
+ }
}
-
- return;
}
}
- throw new NoSuchServiceException();
+ if(!found)
+ {
+ throw new NoSuchServiceException();
+ }
+
+ if(observers != null)
+ {
+ java.util.List<String> services = new java.util.Vector<String>();
+ services.add(name);
+ servicesStopped(services, observers);
+ }
}
- public synchronized void
+ public void
addObserver(final ServiceObserverPrx observer, Ice.Current current)
{
+ java.util.List<String> activeServices = new java.util.LinkedList<String>();
+
//
// Null observers and duplicate registrations are ignored
//
- if(observer != null && _observers.add(observer))
+ synchronized(this)
{
- if(_traceServiceObserver >= 1)
+ if(observer != null && _observers.add(observer))
{
- _logger.trace("IceBox.ServiceObserver",
- "Added service observer: " + _server.communicator().proxyToString(observer));
- }
-
- java.util.List<String> activeServices = new java.util.LinkedList<String>();
-
- for(ServiceInfo info: _services)
- {
- if(info.active)
+ if(_traceServiceObserver >= 1)
{
- activeServices.add(info.name);
- }
- }
-
- if(activeServices.size() > 0)
- {
- AMI_ServiceObserver_servicesStarted cb = new AMI_ServiceObserver_servicesStarted()
- {
- public void ice_response()
- {
- // ok, success
- }
-
- public void ice_exception(Ice.LocalException ex)
- {
- //
- // Drop this observer
- //
- removeObserver(observer, ex);
- }
- };
+ _logger.trace("IceBox.ServiceObserver",
+ "Added service observer: " + _server.communicator().proxyToString(observer));
+ }
-
- try
- {
- observer.servicesStarted_async(cb, activeServices.toArray(new String[0]));
- }
- catch(RuntimeException ex)
+
+ for(ServiceInfo info: _services)
{
- _observers.remove(observer);
- observerRemoved(observer, ex);
- throw ex;
+ if(info.active)
+ {
+ activeServices.add(info.name);
+ }
}
+
}
}
+
+ if(activeServices.size() > 0)
+ {
+ AMI_ServiceObserver_servicesStarted cb = new AMI_ServiceObserver_servicesStarted()
+ {
+ public void ice_response()
+ {
+ // ok, success
+ }
+
+ public void ice_exception(Ice.LocalException ex)
+ {
+ //
+ // Drop this observer
+ //
+ removeObserver(observer, ex);
+ }
+ };
+
+ observer.servicesStarted_async(cb, activeServices.toArray(new String[0]));
+ }
}
@@ -645,107 +661,110 @@ public class ServiceManagerI extends _ServiceManagerDisp
}
}
- synchronized private void
+ private void
stopAll()
{
java.util.List<String> stoppedServices = new java.util.Vector<String>();
+ java.util.Set<ServiceObserverPrx> observers = null;
- //
- // First, for each service, we call stop on the service and flush its database environment to
- // the disk. Services are stopped in the reverse order of the order they were started.
- //
- java.util.ListIterator p = _services.listIterator(_services.size());
- while(p.hasPrevious())
+
+ synchronized(this)
{
- ServiceInfo info = (ServiceInfo)p.previous();
- if(info.active)
+ //
+ // First, for each service, we call stop on the service and flush its database environment to
+ // the disk. Services are stopped in the reverse order of the order they were started.
+ //
+ java.util.ListIterator p = _services.listIterator(_services.size());
+ while(p.hasPrevious())
{
- try
- {
- info.service.stop();
- info.active = false;
- stoppedServices.add(info.name);
- }
- catch(java.lang.Exception e)
+ ServiceInfo info = (ServiceInfo)p.previous();
+ if(info.active)
{
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- e.printStackTrace(pw);
- pw.flush();
- _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
- sw.toString());
+ try
+ {
+ info.service.stop();
+ info.active = false;
+ stoppedServices.add(info.name);
+ }
+ catch(java.lang.Exception e)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ e.printStackTrace(pw);
+ pw.flush();
+ _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
+ sw.toString());
+ }
}
- }
- if(info.communicator != null)
- {
- try
- {
- _server.communicator().removeAdminFacet("IceBox.Service." + info.name + ".Properties");
- }
- catch(Ice.LocalException e)
+ if(info.communicator != null)
{
- // Ignored
- }
+ try
+ {
+ _server.communicator().removeAdminFacet("IceBox.Service." + info.name + ".Properties");
+ }
+ catch(Ice.LocalException e)
+ {
+ // Ignored
+ }
- try
- {
- info.communicator.shutdown();
- info.communicator.waitForShutdown();
- }
- catch(Ice.CommunicatorDestroyedException e)
- {
- //
- // Ignore, the service might have already destroyed
- // the communicator for its own reasons.
- //
- }
- catch(java.lang.Exception e)
- {
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- e.printStackTrace(pw);
- pw.flush();
- _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
- sw.toString());
- }
+ try
+ {
+ info.communicator.shutdown();
+ info.communicator.waitForShutdown();
+ }
+ catch(Ice.CommunicatorDestroyedException e)
+ {
+ //
+ // Ignore, the service might have already destroyed
+ // the communicator for its own reasons.
+ //
+ }
+ catch(java.lang.Exception e)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ e.printStackTrace(pw);
+ pw.flush();
+ _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
+ sw.toString());
+ }
- try
- {
- info.communicator.destroy();
- }
- catch(java.lang.Exception e)
- {
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- e.printStackTrace(pw);
- pw.flush();
- _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
- sw.toString());
+ try
+ {
+ info.communicator.destroy();
+ }
+ catch(java.lang.Exception e)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ e.printStackTrace(pw);
+ pw.flush();
+ _logger.warning("ServiceManager: exception in stop for service " + info.name + "\n" +
+ sw.toString());
+ }
}
}
- }
- servicesStopped(stoppedServices);
+ _services.clear();
+ observers = (java.util.Set<ServiceObserverPrx>)_observers.clone();
+ }
- _services.clear();
+ servicesStopped(stoppedServices, observers);
}
private void
- servicesStarted(java.util.List<String> services)
+ servicesStarted(java.util.List<String> services, java.util.Set<ServiceObserverPrx> observers)
{
- assert Thread.holdsLock(this);
+ assert !Thread.holdsLock(this);
if(services.size() > 0)
{
String[] servicesArray = services.toArray(new String[0]);
- java.util.Iterator<ServiceObserverPrx> p = _observers.iterator();
- while(p.hasNext())
+ for(final ServiceObserverPrx observer: observers)
{
- final ServiceObserverPrx observer = p.next();
-
AMI_ServiceObserver_servicesStarted cb = new AMI_ServiceObserver_servicesStarted()
{
public void ice_response()
@@ -762,33 +781,22 @@ public class ServiceManagerI extends _ServiceManagerDisp
}
};
- try
- {
- observer.servicesStarted_async(cb, servicesArray);
- }
- catch(RuntimeException ex)
- {
- p.remove();
- observerRemoved(observer, ex);
- }
+ observer.servicesStarted_async(cb, servicesArray);
}
}
}
private void
- servicesStopped(java.util.List<String> services)
+ servicesStopped(java.util.List<String> services, java.util.Set<ServiceObserverPrx> observers)
{
- assert Thread.holdsLock(this);
+ assert !Thread.holdsLock(this);
if(services.size() > 0)
{
String[] servicesArray = services.toArray(new String[0]);
- java.util.Iterator<ServiceObserverPrx> p = _observers.iterator();
- while(p.hasNext())
+ for(final ServiceObserverPrx observer: observers)
{
- final ServiceObserverPrx observer = p.next();
-
AMI_ServiceObserver_servicesStopped cb = new AMI_ServiceObserver_servicesStopped()
{
public void ice_response()
@@ -805,19 +813,12 @@ public class ServiceManagerI extends _ServiceManagerDisp
}
};
- try
- {
- observer.servicesStopped_async(cb, servicesArray);
- }
- catch(RuntimeException ex)
- {
- p.remove();
- observerRemoved(observer, ex);
- }
+ observer.servicesStopped_async(cb, servicesArray);
}
}
}
+
private synchronized void
removeObserver(ServiceObserverPrx observer, Ice.LocalException ex)
{
@@ -874,6 +875,6 @@ public class ServiceManagerI extends _ServiceManagerDisp
private String[] _argv; // Filtered server argument vector
private java.util.List<ServiceInfo> _services = new java.util.LinkedList<ServiceInfo>();
- java.util.Set<ServiceObserverPrx> _observers = new java.util.HashSet<ServiceObserverPrx>();
+ java.util.HashSet<ServiceObserverPrx> _observers = new java.util.HashSet<ServiceObserverPrx>();
int _traceServiceObserver = 0;
}