internal virtual CPoolEntry Detach() { CPoolEntry local = this.poolEntry; this.poolEntry = null; return(local); }
/// <exception cref="System.IO.IOException"></exception> public virtual void Close() { CPoolEntry local = this.poolEntry; if (local != null) { local.CloseConnection(); } }
/// <exception cref="System.IO.IOException"></exception> public virtual void Shutdown() { CPoolEntry local = this.poolEntry; if (local != null) { local.ShutdownConnection(); } }
internal virtual HttpClientConnection GetConnection() { CPoolEntry local = this.poolEntry; if (local == null) { return(null); } return(local.GetConnection()); }
public static CPoolEntry GetPoolEntry(HttpClientConnection proxy) { CPoolEntry entry = GetHandler(proxy).GetPoolEntry(); if (entry == null) { throw new ConnectionShutdownException(); } return(entry); }
/// <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(); } }
public virtual bool IsOpen() { CPoolEntry local = this.poolEntry; if (local != null) { return(!local.IsClosed()); } else { return(false); } }
/// <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); }
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()); }
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 ())); } } } }
/// <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); }
internal CPoolProxy(CPoolEntry entry) : base() { this.poolEntry = entry; }
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))); }