Exemplo n.º 1
0
        public void Process(WatchedEvent @event)
        {
            if (LOG_EVENTS)
            {
                log.Debug("ConnectState watcher: " + @event);
            }

            foreach (IWatcher parentWatcher in parentWatchers)
            {
                TimeTrace timeTrace = new TimeTrace("connection-state-parent-process", tracer);
                parentWatcher.Process(@event);
                timeTrace.Commit();
            }

            bool wasConnected = isConnected;
            //Interlocked.Exchange(ref wasConnected,isConnected);
            bool newIsConnected = wasConnected;

            if (@event.Type == EventType.None)
            {
                newIsConnected = CheckState(@event.State, wasConnected);
            }

            if (newIsConnected != wasConnected)
            {
                isConnected = newIsConnected;
                //Interlocked.Exchange(ref isConnected, newIsConnected);

                connectionStart = TimeSpan.FromTicks(System.DateTime.Now.Ticks);
            }
        }
Exemplo n.º 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()
        {
            Contract.Ensures(started, "\"Client is not started\"");
            //Preconditions.checkState(started, "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);
        }
Exemplo n.º 3
0
		public void Process(WatchedEvent @event)
		{
			if ( LOG_EVENTS )
			{
				log.Debug("ConnectState watcher: " + @event);
			}

			foreach ( IWatcher parentWatcher in parentWatchers )
			{
				TimeTrace timeTrace = new TimeTrace("connection-state-parent-process", tracer);
				parentWatcher.Process(@event);
				timeTrace.Commit();
			}

			bool wasConnected = isConnected ;
			//Interlocked.Exchange(ref wasConnected,isConnected);
			bool newIsConnected = wasConnected;
			if ( @event.Type == EventType.None )
			{
				newIsConnected = CheckState(@event.State, wasConnected);
			}

			if ( newIsConnected != wasConnected )
			{
				isConnected = newIsConnected;
				//Interlocked.Exchange(ref isConnected, newIsConnected);

				connectionStart = TimeSpan.FromTicks(System.DateTime.Now.Ticks);
			}
		}