Exemplo n.º 1
0
        public override void addObserver(ServiceObserverPrx observer, Ice.Current current)
        {
            List<string> activeServices = new List<string>();

            //
            // Null observers and duplicate registrations are ignored
            //

            _m.Lock();
            try
            {
            if(observer != null)
            {
                try
                {
                    _observers.Add(observer, true);
                }
                catch(ArgumentException)
                {
                    return;
                }

                if(_traceServiceObserver >= 1)
                {
                    _logger.trace("IceBox.ServiceObserver",
                                  "Added service observer " + _communicator.proxyToString(observer));
                }

                foreach(ServiceInfo info in _services)
                {
                    if(info.status == ServiceStatus.Started)
                    {
                        activeServices.Add(info.name);
                    }
                }
            }
            }
            finally
            {
            _m.Unlock();
            }

            if(activeServices.Count > 0)
            {
            observer.servicesStarted_async(new AMIServicesStartedCallback(this, observer),
                                           activeServices.ToArray());
            }
        }
Exemplo n.º 2
0
 private void observerRemoved(ServiceObserverPrx observer, System.Exception ex)
 {
     if (_traceServiceObserver >= 1)
     {
         //
         // CommunicatorDestroyedException may occur during shutdown. The observer notification has
         // been sent, but the communicator was destroyed before the reply was received. We do not
         // log a message for this exception.
         //
         if (!(ex is CommunicatorDestroyedException))
         {
             _logger.trace("IceBox.ServiceObserver",
                           $"Removed service observer {observer}\nafter catching {ex}");
         }
     }
 }
Exemplo n.º 3
0
        public override void addObserver(ServiceObserverPrx observer, Ice.Current current)
        {
            List <string> activeServices = new List <string>();

            //
            // Null observers and duplicate registrations are ignored
            //

            _m.Lock();
            try
            {
                if (observer != null)
                {
                    try
                    {
                        _observers.Add(observer, true);
                    }
                    catch (ArgumentException)
                    {
                        return;
                    }

                    if (_traceServiceObserver >= 1)
                    {
                        _logger.trace("IceBox.ServiceObserver",
                                      "Added service observer " + _communicator.proxyToString(observer));
                    }

                    foreach (ServiceInfo info in _services)
                    {
                        if (info.status == ServiceStatus.Started)
                        {
                            activeServices.Add(info.name);
                        }
                    }
                }
            }
            finally
            {
                _m.Unlock();
            }

            if (activeServices.Count > 0)
            {
                observer.begin_servicesStarted(activeServices.ToArray(), this.observerCompleted, null);
            }
        }
Exemplo n.º 4
0
 private void observerRemoved(ServiceObserverPrx observer, Exception ex)
 {
     if (_traceServiceObserver >= 1)
     {
         //
         // CommunicatorDestroyedException may occur during shutdown. The observer notification has
         // been sent, but the communicator was destroyed before the reply was received. We do not
         // log a message for this exception.
         //
         if (!(ex is Ice.CommunicatorDestroyedException))
         {
             _logger.trace("IceBox.ServiceObserver",
                           "Removed service observer " + _communicator.proxyToString(observer)
                           + "\nafter catching " + ex.ToString());
         }
     }
 }
Exemplo n.º 5
0
 observerCompleted(ServiceObserverPrx observer, Task t)
 {
     try
     {
         t.Wait();
     }
     catch (AggregateException ae)
     {
         lock (this)
         {
             if (_observers.Remove(observer))
             {
                 observerRemoved(observer, ae.InnerException);
             }
         }
     }
 }
Exemplo n.º 6
0
 observerCompleted(Ice.AsyncResult result)
 {
     try
     {
         result.throwLocalException();
     }
     catch (Ice.LocalException ex)
     {
         lock (this)
         {
             ServiceObserverPrx observer = ServiceObserverPrxHelper.uncheckedCast(result.getProxy());
             if (_observers.Remove(observer))
             {
                 observerRemoved(observer, ex);
             }
         }
     }
 }
Exemplo n.º 7
0
        public override void addObserver(ServiceObserverPrx observer, Ice.Current current)
        {
            List <string> activeServices = new List <string>();

            //
            // Null observers and duplicate registrations are ignored
            //
            lock (this)
            {
                if (observer != null)
                {
                    try
                    {
                        _observers.Add(observer, true);
                    }
                    catch (ArgumentException)
                    {
                        return;
                    }

                    if (_traceServiceObserver >= 1)
                    {
                        _logger.trace("IceBox.ServiceObserver",
                                      "Added service observer " + _communicator.proxyToString(observer));
                    }

                    foreach (ServiceInfo info in _services)
                    {
                        if (info.status == ServiceStatus.Started)
                        {
                            activeServices.Add(info.name);
                        }
                    }
                }
            }

            if (activeServices.Count > 0)
            {
                observer.servicesStartedAsync(activeServices.ToArray()).ContinueWith((t) => observerCompleted(observer, t),
                                                                                     TaskScheduler.Current);
            }
        }
Exemplo n.º 8
0
 public AMIServicesStartedCallback(ServiceManagerI serviceManager, ServiceObserverPrx observer)
 {
     _serviceManager = serviceManager;
     _observer = observer;
 }
Exemplo n.º 9
0
 private void removeObserver(ServiceObserverPrx observer, Ice.Exception ex)
 {
     _m.Lock();
     try
     {
     if(_observers.Remove(observer))
     {
         observerRemoved(observer, ex);
     }
     }
     finally
     {
     _m.Unlock();
     }
 }
Exemplo n.º 10
0
 private void observerRemoved(ServiceObserverPrx observer, System.Exception ex)
 {
     if(_traceServiceObserver >= 1)
     {
     //
     // CommunicatorDestroyedException may occur during shutdown. The observer notification has
     // been sent, but the communicator was destroyed before the reply was received. We do not
     // log a message for this exception.
     //
     if(!(ex is Ice.CommunicatorDestroyedException))
     {
         _logger.trace("IceBox.ServiceObserver",
                       "Removed service observer " + _communicator.proxyToString(observer)
                       + "\nafter catching " + ex.ToString());
     }
     }
 }
Exemplo n.º 11
0
 private void observerCompleted(ServiceObserverPrx observer, Task t)
 {
     try
     {
     t.Wait();
     }
     catch(AggregateException ae)
     {
     lock(this)
     {
         if(_observers.Remove(observer))
         {
             observerRemoved(observer, ae.InnerException);
         }
     }
     }
 }