Ejemplo n.º 1
0
        private void CheckTimeouts()
        {
            double minTimeout = Math.Min(sessionTimeout.TotalMilliseconds, connectionTimeout.TotalMilliseconds);
            double elapsed    = TimeSpan.FromTicks(System.DateTime.Now.Ticks).TotalMilliseconds - connectionStart.TotalMilliseconds;

            if (elapsed >= minTimeout)
            {
                if (zooKeeper.HasNewConnectionString())
                {
                    HandleNewConnectionString();
                }
                else
                {
                    double maxTimeout = Math.Max(sessionTimeout.TotalMilliseconds, connectionTimeout.TotalMilliseconds);
                    if (elapsed > maxTimeout)
                    {
//						if ( !bool.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES) )
//						{
                        log.Warn(String.Format("Connection attempt unsuccessful after ({0}) (greater than max timeout of ({1})). Resetting connection and trying again with a new connection.", elapsed, maxTimeout));
//						}
                        Reset();
                    }
                    else
                    {
                        KeeperException.ConnectionLossException connectionLossException = new CuratorConnectionLossException();
//						if ( !bool.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES) )
//						{
                        log.Error(String.Format("Connection timed out for connection string ({0}) and timeout ({1}) / elapsed ({2})", zooKeeper.GetConnectionString(), connectionTimeout, elapsed), connectionLossException);
//						}
                        tracer.AddCount("connections-timed-out", 1);
                        throw connectionLossException;
                    }
                }
            }
        }
Ejemplo n.º 2
0
		private  void CheckTimeouts() 
		{
			double minTimeout = Math.Min(sessionTimeout.TotalMilliseconds, connectionTimeout.TotalMilliseconds);
			double elapsed = TimeSpan.FromTicks(System.DateTime.Now.Ticks).TotalMilliseconds - connectionStart.TotalMilliseconds;
			if ( elapsed >= minTimeout )
			{
				if ( zooKeeper.HasNewConnectionString() )
				{
					HandleNewConnectionString();
				}
				else
				{
					double maxTimeout = Math.Max(sessionTimeout.TotalMilliseconds, connectionTimeout.TotalMilliseconds);
					if ( elapsed > maxTimeout )
					{
//						if ( !bool.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES) )
//						{
							log.Warn(String.Format("Connection attempt unsuccessful after ({0}) (greater than max timeout of ({1})). Resetting connection and trying again with a new connection.", elapsed, maxTimeout));
//						}
						Reset();
					}
					else
					{
						KeeperException.ConnectionLossException connectionLossException = new CuratorConnectionLossException();
//						if ( !bool.getBoolean(DebugUtils.PROPERTY_DONT_LOG_CONNECTION_ISSUES) )
//						{
							log.Error(String.Format("Connection timed out for connection string ({0}) and timeout ({1}) / elapsed ({2})", zooKeeper.GetConnectionString(), connectionTimeout, elapsed), connectionLossException);
//						}
						tracer.AddCount("connections-timed-out", 1);
						throw connectionLossException;
					}
				}
			}
		}