Ejemplo n.º 1
0
        public void start()
        {
            log.Info("Starting");
            if (!state.CompareAndSet(CuratorFrameworkState.LATENT, CuratorFrameworkState.STARTED))
            {
                throw new InvalidOperationException("Cannot be started more than once");
            }
            try
            {
                connectionStateManager.start(); // ordering dependency - must be called before client.start()

                IConnectionStateListener listener = new ConnectedStateListener();

                this.getConnectionStateListenable().addListener(listener);

                client.start();

                executorService = ThreadUtils.newSingleThreadScheduledExecutor(GetType().FullName);
                executorService.submit(new FutureTask <object>(RunnableUtils.FromFunc(() => backgroundOperationsLoop())));
            }
            catch (Exception e)
            {
                ThreadUtils.checkInterrupted(e);
                handleBackgroundOperationException(null, e);
            }
        }
Ejemplo n.º 2
0
        public void start()
        {
            log.Info("Starting");
            if (!state.CompareAndSet(CuratorFrameworkState.LATENT, CuratorFrameworkState.STARTED))
            {
                throw new InvalidOperationException("Cannot be started more than once");
            }
            try
            {
                connectionStateManager.start(); // ordering dependency - must be called before client.start()

                IConnectionStateListener listener = new ConnectedStateListener();

                this.getConnectionStateListenable().addListener(listener);

                client.start();

                executorService = ThreadUtils.newSingleThreadScheduledExecutor(GetType().FullName);
                executorService.submit(new FutureTask<object>(RunnableUtils.FromFunc(() => backgroundOperationsLoop())));
            }
            catch ( Exception e )
            {
                ThreadUtils.checkInterrupted(e);
                handleBackgroundOperationException(null, e);
            }
        }