예제 #1
0
        public override Task process(WatchedEvent @event)
        {
            if (LOG_EVENTS)
            {
                log.Debug("ConnectState watcher: " + @event);
            }

            if (@event.get_Type() == Watcher.Event.EventType.None)
            {
                bool wasConnected   = _isConnected.get();
                bool newIsConnected = checkState(@event.getState(), wasConnected);
                if (newIsConnected != wasConnected)
                {
                    _isConnected.set(newIsConnected);
                    Volatile.Write(ref connectionStartMs, CurrentMillis);
                }
            }

            foreach (Watcher parentWatcher in parentWatchers)
            {
                TimeTrace timeTrace = new TimeTrace("connection-state-parent-process", tracer.Get());
                parentWatcher.process(@event);
                timeTrace.commit();
            }
            return(Task.FromResult <object>(null));
        }
예제 #2
0
        /**
         * This method blocks until the connection to ZK succeeds. Use with caution. The block
         * will timeout after the connection timeout (as passed to the constructor) has elapsed
         *
         * @return true if the connection succeeded, false if not
         * @throws InterruptedException interrupted while waiting
         */
        public bool blockUntilConnectedOrTimedOut()
        {
            if (!started.get())
            {
                throw new InvalidOperationException("Client is not started");
            }

            log.Debug("blockUntilConnectedOrTimedOut() start");
            TimeTrace trace = startTracer("blockUntilConnectedOrTimedOut");

            internalBlockUntilConnectedOrTimedOut();

            trace.commit();

            bool localIsConnected = state.isConnected();

            log.Debug("blockUntilConnectedOrTimedOut() end. isConnected: " + localIsConnected);

            return(localIsConnected);
        }
예제 #3
0
        public override Task process(WatchedEvent @event)
        {
            if (LOG_EVENTS)
            {
                log.Debug("ConnectState watcher: " + @event);
            }

            if ( @event.get_Type() == Watcher.Event.EventType.None )
            {
                bool wasConnected = _isConnected.get();
                bool newIsConnected = checkState(@event.getState(), wasConnected);
                if ( newIsConnected != wasConnected )
                {
                    _isConnected.set(newIsConnected);
                    Volatile.Write(ref connectionStartMs, CurrentMillis);
                }
            }

            foreach ( Watcher parentWatcher in parentWatchers )
            {
                TimeTrace timeTrace = new TimeTrace("connection-state-parent-process", tracer.Get());
                parentWatcher.process(@event);
                timeTrace.commit();
            }
            return Task.FromResult<object>(null);
        }