예제 #1
0
        public void close()
        {
            log.Debug("Closing");
            if (state.CompareAndSet(CuratorFrameworkState.STARTED, CuratorFrameworkState.STOPPED))
            {
                listeners.forEach(listener =>
                {
                    ICuratorEvent @event = new CuratorEventImpl(this, CuratorEventType.CLOSING, 0, null, null, null, null, null, null, null, null);
                    try
                    {
                        listener.eventReceived(this, @event);
                    }
                    catch (Exception e)
                    {
                        ThreadUtils.checkInterrupted(e);
                        log.Error("Exception while sending Closing event", e);
                    }
                    return(null);
                });

                if (executorService != null)
                {
                    executorService.Dispose();
                }

                listeners.clear();
                unhandledErrorListeners.clear();
                connectionStateManager.Dispose();
                client.Dispose();
                namespaceWatcherMap.Dispose();
            }
        }
예제 #2
0
 public void Dispose()
 {
     if (state.CompareAndSet(STARTED, CLOSED) == STARTED)
     {
         service.Dispose();
         listeners.clear();
     }
 }