Пример #1
0
        /// <exception cref="System.Exception"></exception>
        /// <exception cref="Sharpen.ExecutionException"></exception>
        /// <exception cref="Apache.Http.Conn.ConnectionPoolTimeoutException"></exception>
        protected internal virtual HttpClientConnection LeaseConnection(Future <CPoolEntry
                                                                                > future, long timeout, TimeUnit tunit)
        {
            CPoolEntry entry;

            try
            {
                entry = future.Get(timeout, tunit);
                if (entry == null || future.IsCancelled())
                {
                    throw new Exception();
                }
                Asserts.Check(entry.GetConnection() != null, "Pool entry with no connection");
                if (this.log.IsDebugEnabled())
                {
                    this.log.Debug("Connection leased: " + Format(entry) + FormatStats(entry.GetRoute
                                                                                           ()));
                }
                return(CPoolProxy.NewProxy(entry));
            }
            catch (TimeoutException)
            {
                throw new ConnectionPoolTimeoutException("Timeout waiting for connection from pool"
                                                         );
            }
        }
Пример #2
0
 internal void Update()
 {
     Log.V(Log.TagQuery, "%s: update() called.", this);
     if (GetView() == null)
     {
         throw new InvalidOperationException("Cannot start LiveQuery when view is null");
     }
     if (runningState.Get() == false)
     {
         Log.D(Log.TagQuery, "%s: update() called, but running state == false.  Ignoring."
               , this);
         return;
     }
     if (queryFuture != null && !queryFuture.IsCancelled() && !queryFuture.IsDone())
     {
         // There is a already a query in flight, so leave it alone except to schedule something
         // to run update() again once it finishes.
         Log.D(Log.TagQuery, "%s: already a query in flight, scheduling call to update() once it's done"
               , this);
         if (rerunUpdateFuture != null && !rerunUpdateFuture.IsCancelled() && !rerunUpdateFuture
             .IsDone())
         {
             bool cancelResult = rerunUpdateFuture.Cancel(true);
             Log.D(Log.TagQuery, "%s: cancelled %s result: %s", this, rerunUpdateFuture, cancelResult
                   );
         }
         rerunUpdateFuture = RerunUpdateAfterQueryFinishes(queryFuture);
         Log.D(Log.TagQuery, "%s: created new rerunUpdateFuture: %s", this, rerunUpdateFuture
               );
         return;
     }
     // No query in flight, so kick one off
     queryFuture = RunAsyncInternal(new _QueryCompleteListener_281(this));
     Log.D(Log.TagQuery, "%s: update() created queryFuture: %s", this, queryFuture);
 }