Ejemplo n.º 1
0
        internal virtual CPoolEntry Detach()
        {
            CPoolEntry local = this.poolEntry;

            this.poolEntry = null;
            return(local);
        }
Ejemplo n.º 2
0
        /// <exception cref="System.IO.IOException"></exception>
        public virtual void Close()
        {
            CPoolEntry local = this.poolEntry;

            if (local != null)
            {
                local.CloseConnection();
            }
        }
Ejemplo n.º 3
0
        /// <exception cref="System.IO.IOException"></exception>
        public virtual void Shutdown()
        {
            CPoolEntry local = this.poolEntry;

            if (local != null)
            {
                local.ShutdownConnection();
            }
        }
Ejemplo n.º 4
0
        internal virtual HttpClientConnection GetConnection()
        {
            CPoolEntry local = this.poolEntry;

            if (local == null)
            {
                return(null);
            }
            return(local.GetConnection());
        }
Ejemplo n.º 5
0
        public static CPoolEntry GetPoolEntry(HttpClientConnection proxy)
        {
            CPoolEntry entry = GetHandler(proxy).GetPoolEntry();

            if (entry == null)
            {
                throw new ConnectionShutdownException();
            }
            return(entry);
        }
Ejemplo n.º 6
0
 /// <exception cref="System.IO.IOException"></exception>
 public virtual void RouteComplete(HttpClientConnection managedConn, HttpRoute route
                                   , HttpContext context)
 {
     Args.NotNull(managedConn, "Managed Connection");
     Args.NotNull(route, "HTTP route");
     lock (managedConn)
     {
         CPoolEntry entry = CPoolProxy.GetPoolEntry(managedConn);
         entry.MarkRouteComplete();
     }
 }
Ejemplo n.º 7
0
        public virtual bool IsOpen()
        {
            CPoolEntry local = this.poolEntry;

            if (local != null)
            {
                return(!local.IsClosed());
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
        /// <exception cref="System.IO.IOException"></exception>
        public virtual void Upgrade(HttpClientConnection managedConn, HttpRoute route, HttpContext
                                    context)
        {
            Args.NotNull(managedConn, "Managed Connection");
            Args.NotNull(route, "HTTP route");
            ManagedHttpClientConnection conn;

            lock (managedConn)
            {
                CPoolEntry entry = CPoolProxy.GetPoolEntry(managedConn);
                conn = entry.GetConnection();
            }
            this.connectionOperator.Upgrade(conn, route.GetTargetHost(), context);
        }
Ejemplo n.º 9
0
        private string Format(CPoolEntry entry)
        {
            StringBuilder buf = new StringBuilder();

            buf.Append("[id: ").Append(entry.GetId()).Append("]");
            buf.Append("[route: ").Append(entry.GetRoute()).Append("]");
            object state = entry.GetState();

            if (state != null)
            {
                buf.Append("[state: ").Append(state).Append("]");
            }
            return(buf.ToString());
        }
Ejemplo n.º 10
0
 public virtual void ReleaseConnection(HttpClientConnection managedConn, object state
                                       , long keepalive, TimeUnit tunit)
 {
     Args.NotNull(managedConn, "Managed connection");
     lock (managedConn)
     {
         CPoolEntry entry = CPoolProxy.Detach(managedConn);
         if (entry == null)
         {
             return;
         }
         ManagedHttpClientConnection conn = entry.GetConnection();
         try
         {
             if (conn.IsOpen())
             {
                 entry.SetState(state);
                 entry.UpdateExpiry(keepalive, tunit != null ? tunit : TimeUnit.Milliseconds);
                 if (this.log.IsDebugEnabled())
                 {
                     string s;
                     if (keepalive > 0)
                     {
                         s = "for " + (double)keepalive / 1000 + " seconds";
                     }
                     else
                     {
                         s = "indefinitely";
                     }
                     this.log.Debug("Connection " + Format(entry) + " can be kept alive " + s);
                 }
             }
         }
         finally
         {
             this.pool.Release(entry, conn.IsOpen() && entry.IsRouteComplete());
             if (this.log.IsDebugEnabled())
             {
                 this.log.Debug("Connection released: " + Format(entry) + FormatStats(entry.GetRoute
                                                                                          ()));
             }
         }
     }
 }
Ejemplo n.º 11
0
        /// <exception cref="System.IO.IOException"></exception>
        public virtual void Connect(HttpClientConnection managedConn, HttpRoute route, int
                                    connectTimeout, HttpContext context)
        {
            Args.NotNull(managedConn, "Managed Connection");
            Args.NotNull(route, "HTTP route");
            ManagedHttpClientConnection conn;

            lock (managedConn)
            {
                CPoolEntry entry = CPoolProxy.GetPoolEntry(managedConn);
                conn = entry.GetConnection();
            }
            HttpHost host;

            if (route.GetProxyHost() != null)
            {
                host = route.GetProxyHost();
            }
            else
            {
                host = route.GetTargetHost();
            }
            IPEndPoint   localAddress = route.GetLocalSocketAddress();
            SocketConfig socketConfig = this.configData.GetSocketConfig(host);

            if (socketConfig == null)
            {
                socketConfig = this.configData.GetDefaultSocketConfig();
            }
            if (socketConfig == null)
            {
                socketConfig = SocketConfig.Default;
            }
            this.connectionOperator.Connect(conn, host, localAddress, connectTimeout, socketConfig
                                            , context);
        }
Ejemplo n.º 12
0
 internal CPoolProxy(CPoolEntry entry) : base()
 {
     this.poolEntry = entry;
 }
Ejemplo n.º 13
0
 public static HttpClientConnection NewProxy(CPoolEntry poolEntry)
 {
     return((HttpClientConnection)Proxy.NewProxyInstance(typeof(Apache.Http.Impl.Conn.CPoolProxy
                                                                ).GetClassLoader(), new Type[] { typeof(ManagedHttpClientConnection), typeof(HttpContext
                                                                                                                                             ) }, new Apache.Http.Impl.Conn.CPoolProxy(poolEntry)));
 }