コード例 #1
0
ファイル: ConnectionState.cs プロジェクト: yepuv1/curator.net
        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);
            }
        }
コード例 #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);
        }
コード例 #3
0
ファイル: ConnectionState.cs プロジェクト: yepuv1/curator.net
		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);
			}
		}