ManagedClientConnectionImpl( final ClientConnectionManager manager, final ClientConnectionOperator operator, final HttpPoolEntry entry) { super(); if (manager == null) { throw new IllegalArgumentException("Connection manager may not be null"); } if (operator == null) { throw new IllegalArgumentException("Connection operator may not be null"); } if (entry == null) { throw new IllegalArgumentException("HTTP pool entry may not be null"); } this.manager = manager; this.operator = operator; this.poolEntry = entry; this.reusable = false; this.duration = Long.MAX_VALUE; }
/** * @since 4.1 */ public ConnPoolByRoute( final ClientConnectionOperator operator, final ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, final TimeUnit connTTLTimeUnit) { super(); if (operator == null) { throw new IllegalArgumentException("Connection operator may not be null"); } if (connPerRoute == null) { throw new IllegalArgumentException("Connections per route may not be null"); } this.poolLock = super.poolLock; this.leasedConnections = super.leasedConnections; this.operator = operator; this.connPerRoute = connPerRoute; this.maxTotalConnections = maxTotalConnections; this.freeConnections = createFreeConnQueue(); this.waitingThreads = createWaitingThreadQueue(); this.routeToPool = createRouteToPoolMap(); this.connTTL = connTTL; this.connTTLTimeUnit = connTTLTimeUnit; }
/** * Creates a new pool entry. * This method assumes that the new connection will be handed * out immediately. * * @param rospl the route-specific pool for which to create the entry * @param op the operator for creating a connection * * @return the new pool entry for a new connection */ protected BasicPoolEntry createEntry(RouteSpecificPool rospl, ClientConnectionOperator op) { if (log.isDebugEnabled()) { log.debug("Creating new connection [" + rospl.getRoute() + "]"); } // the entry will create the connection when needed BasicPoolEntry entry = new BasicPoolEntry(op, rospl.getRoute(), connTTL, connTTLTimeUnit); poolLock.lock(); try { rospl.createdEntry(entry); numConnections++; leasedConnections.add(entry); } finally { poolLock.unlock(); } return entry; }
/** * @since 4.1 */ public ConnPoolByRoute( final ClientConnectionOperator operator, final ConnPerRoute connPerRoute, final int maxTotalConnections, final long connTTL, final TimeUnit connTTLTimeUnit) { super(); Args.notNull(operator, "Connection operator"); Args.notNull(connPerRoute, "Connections per route"); this.poolLock = super.poolLock; this.leasedConnections = super.leasedConnections; this.operator = operator; this.connPerRoute = connPerRoute; this.maxTotalConnections = maxTotalConnections; this.freeConnections = createFreeConnQueue(); this.waitingThreads = createWaitingThreadQueue(); this.routeToPool = createRouteToPoolMap(); this.connTTL = connTTL; this.connTTLTimeUnit = connTTLTimeUnit; }
/** * Creates a new pool entry. * This method assumes that the new connection will be handed * out immediately. * * @param rospl the route-specific pool for which to create the entry * @param op the operator for creating a connection * * @return the new pool entry for a new connection */ protected BasicPoolEntry createEntry(final RouteSpecificPool rospl, final ClientConnectionOperator op) { if (log.isDebugEnabled()) { log.debug("Creating new connection [" + rospl.getRoute() + "]"); } // the entry will create the connection when needed final BasicPoolEntry entry = new BasicPoolEntry(op, rospl.getRoute(), connTTL, connTTLTimeUnit); poolLock.lock(); try { rospl.createdEntry(entry); numConnections++; leasedConnections.add(entry); } finally { poolLock.unlock(); } return entry; }
/** * Creates a new pool entry. * This method assumes that the new connection will be handed * out immediately. * * @param rospl the route-specific pool for which to create the entry * @param op the operator for creating a connection * * @return the new pool entry for a new connection */ protected BasicPoolEntry createEntry(RouteSpecificPool rospl, ClientConnectionOperator op) { if (log.isDebugEnabled()) { log.debug("Creating new connection [" + rospl.getRoute() + "]"); } // the entry will create the connection when needed BasicPoolEntry entry = new BasicPoolEntry(op, rospl.getRoute()); poolLock.lock(); try { rospl.createdEntry(entry); numConnections++; leasedConnections.add(entry); } finally { poolLock.unlock(); } return entry; }
/** * Creates a new connection pool, managed by route. * * @since 4.1 */ public ConnPoolByRoute( final ClientConnectionOperator operator, final ConnPerRoute connPerRoute, int maxTotalConnections) { this(operator, connPerRoute, maxTotalConnections, -1, TimeUnit.MILLISECONDS); }
public BasicPoolEntry(ClientConnectionOperator op, HttpRoute route, ReferenceQueue<Object> queue) { super(op, route); if (route == null) { throw new IllegalArgumentException("HTTP route may not be null"); } this.created = System.currentTimeMillis(); this.validUntil = Long.MAX_VALUE; this.expiry = this.validUntil; }
/** * Creates a new pool entry with a specified maximum lifetime. * * @param op the connection operator * @param route the planned route for the connection * @param connTTL maximum lifetime of this entry, <=0 implies "infinity" * @param timeunit TimeUnit of connTTL * * @since 4.1 */ public BasicPoolEntry(ClientConnectionOperator op, HttpRoute route, long connTTL, TimeUnit timeunit) { super(op, route); if (route == null) { throw new IllegalArgumentException("HTTP route may not be null"); } this.created = System.currentTimeMillis(); if (connTTL > 0) { this.validUntil = this.created + timeunit.toMillis(connTTL); } else { this.validUntil = Long.MAX_VALUE; } this.expiry = this.validUntil; }
/** * Creates a new pool entry. * * @param connOperator the Connection Operator for this entry * @param route the planned route for the connection, * or <code>null</code> */ protected AbstractPoolEntry(ClientConnectionOperator connOperator, HttpRoute route) { super(); if (connOperator == null) { throw new IllegalArgumentException("Connection operator may not be null"); } this.connOperator = connOperator; this.connection = connOperator.createConnection(); this.route = route; this.tracker = null; }
public HttpConnPool(final Log log, final ClientConnectionOperator connOperator, final int defaultMaxPerRoute, final int maxTotal, final long timeToLive, final TimeUnit tunit) { super(new InternalConnFactory(connOperator), defaultMaxPerRoute, maxTotal); this.log = log; this.timeToLive = timeToLive; this.tunit = tunit; }
ManagedClientConnectionImpl( final ClientConnectionManager manager, final ClientConnectionOperator operator, final HttpPoolEntry entry) { super(); Args.notNull(manager, "Connection manager"); Args.notNull(operator, "Connection operator"); Args.notNull(entry, "HTTP pool entry"); this.manager = manager; this.operator = operator; this.poolEntry = entry; this.reusable = false; this.duration = Long.MAX_VALUE; }
/** * Creates a new connection pool, managed by route. * * @since 4.1 */ public ConnPoolByRoute( final ClientConnectionOperator operator, final ConnPerRoute connPerRoute, final int maxTotalConnections) { this(operator, connPerRoute, maxTotalConnections, -1, TimeUnit.MILLISECONDS); }
/** * Creates a new connection pool, managed by route. * * @deprecated (4.1) use {@link ConnPoolByRoute#ConnPoolByRoute(ClientConnectionOperator, ConnPerRoute, int)} */ @Deprecated public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params) { this(operator, ConnManagerParams.getMaxConnectionsPerRoute(params), ConnManagerParams.getMaxTotalConnections(params)); }
public BasicPoolEntry(final ClientConnectionOperator op, final HttpRoute route, final ReferenceQueue<Object> queue) { super(op, route); Args.notNull(route, "HTTP route"); this.created = System.currentTimeMillis(); this.validUntil = Long.MAX_VALUE; this.expiry = this.validUntil; }
/** * Creates a new pool entry with a specified maximum lifetime. * * @param op the connection operator * @param route the planned route for the connection * @param connTTL maximum lifetime of this entry, <=0 implies "infinity" * @param timeunit TimeUnit of connTTL * * @since 4.1 */ public BasicPoolEntry(final ClientConnectionOperator op, final HttpRoute route, final long connTTL, final TimeUnit timeunit) { super(op, route); Args.notNull(route, "HTTP route"); this.created = System.currentTimeMillis(); if (connTTL > 0) { this.validUntil = this.created + timeunit.toMillis(connTTL); } else { this.validUntil = Long.MAX_VALUE; } this.expiry = this.validUntil; }
/** * Creates a new pool entry. * * @param connOperator the Connection Operator for this entry * @param route the planned route for the connection, * or {@code null} */ protected AbstractPoolEntry(final ClientConnectionOperator connOperator, final HttpRoute route) { super(); Args.notNull(connOperator, "Connection operator"); this.connOperator = connOperator; this.connection = connOperator.createConnection(); this.route = route; this.tracker = null; }
/** * Creates a new connection pool, managed by route. */ public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params) { super(); if (operator == null) { throw new IllegalArgumentException("Connection operator may not be null"); } this.operator = operator; this.params = params; freeConnections = createFreeConnQueue(); waitingThreads = createWaitingThreadQueue(); routeToPool = createRouteToPoolMap(); }
/** * @deprecated do not use */ @Deprecated public BasicPoolEntry(ClientConnectionOperator op, HttpRoute route, ReferenceQueue<Object> queue) { super(op, route); if (route == null) { throw new IllegalArgumentException("HTTP route may not be null"); } }
/** * Creates a new pool entry. * * @param op the connection operator * @param route the planned route for the connection */ public BasicPoolEntry(ClientConnectionOperator op, HttpRoute route) { super(op, route); if (route == null) { throw new IllegalArgumentException("HTTP route may not be null"); } }
@Override protected BasicPoolEntry createEntry(RouteSpecificPool rospl, ClientConnectionOperator op) { createEntryCounter.increment(); Stopwatch stopWatch = creationTimer.start(); try { return super.createEntry(rospl, op); } finally { stopWatch.stop(); } }
protected ClientConnectionOperator createConnectionOperator(final SchemeRegistry schreg) { return new DefaultClientConnectionOperator(schreg); }
/** * Creates a new connection pool, managed by route. * * @deprecated (4.1) use {@link ConnPoolByRoute#ConnPoolByRoute(ClientConnectionOperator, ConnPerRoute, int)} */ public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params) { this(operator, ConnManagerParams.getMaxConnectionsPerRoute(params), ConnManagerParams.getMaxTotalConnections(params)); }
public static void main(String[] args) throws Exception { HttpHost target = new HttpHost("jakarta.apache.org", 80, "http"); // some general setup // Register the "http" protocol scheme, it is required // by the default operator to look up socket factories. SchemeRegistry supportedSchemes = new SchemeRegistry(); SocketFactory sf = PlainSocketFactory.getSocketFactory(); supportedSchemes.register(new Scheme("http", sf, 80)); // Prepare parameters. // Since this example doesn't use the full core framework, // only few parameters are actually required. HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setUseExpectContinue(params, false); // one operator can be used for many connections ClientConnectionOperator scop = new DefaultClientConnectionOperator(supportedSchemes); HttpRequest req = new BasicHttpRequest("OPTIONS", "*", HttpVersion.HTTP_1_1); req.addHeader("Host", target.getHostName()); HttpContext ctx = new BasicHttpContext(); OperatedClientConnection conn = scop.createConnection(); try { System.out.println("opening connection to " + target); scop.openConnection(conn, target, null, ctx, params); System.out.println("sending request"); conn.sendRequestHeader(req); // there is no request entity conn.flush(); System.out.println("receiving response header"); HttpResponse rsp = conn.receiveResponseHeader(); System.out.println("----------------------------------------"); System.out.println(rsp.getStatusLine()); Header[] headers = rsp.getAllHeaders(); for (int i = 0; i < headers.length; i++) { System.out.println(headers[i]); } System.out.println("----------------------------------------"); } finally { System.out.println("closing connection"); conn.close(); } }
/** * Overriden to use {@link JMeterClientConnectionOperator} and fix SNI issue * @see "https://bz.apache.org/bugzilla/show_bug.cgi?id=57935" * @see org.apache.http.impl.conn.PoolingClientConnectionManager#createConnectionOperator(org.apache.http.conn.scheme.SchemeRegistry) */ @Override protected ClientConnectionOperator createConnectionOperator( SchemeRegistry schreg) { return new JMeterClientConnectionOperator(schreg); }
InternalConnFactory(final ClientConnectionOperator connOperator) { this.connOperator = connOperator; }
public ElegantPool(ClientConnectionOperator paramClientConnectionOperator, HttpParams paramHttpParams) { super(paramHttpParams); }
@Override protected ClientConnectionOperator createConnectionOperator(final SchemeRegistry sr) { return new MyClientConnectionOperator(sr); }
@Override protected ClientConnectionOperator createConnectionOperator(final SchemeRegistry registry) { return new MyClientConnectionOperator(registry); }
public NamedConnectionPool(String name, ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit) { super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit); initMonitors(name); }
public NamedConnectionPool(String name, ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections) { super(operator, connPerRoute, maxTotalConnections); initMonitors(name); }
public NamedConnectionPool(String name, ClientConnectionOperator operator, HttpParams params) { super(operator, params); initMonitors(name); }
NamedConnectionPool(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit) { super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit); }
NamedConnectionPool(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections) { super(operator, connPerRoute, maxTotalConnections); }
NamedConnectionPool(ClientConnectionOperator operator, HttpParams params) { super(operator, params); }
private CougarConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit) { super(operator, connPerRoute, maxTotalConnections, connTTL, connTTLTimeUnit); }
public static void main(String[] args) throws Exception { HttpHost target = new HttpHost("jakarta.apache.org", 80, "http"); // some general setup // Register the "http" protocol scheme, it is required // by the default operator to look up socket factories. SchemeRegistry supportedSchemes = new SchemeRegistry(); supportedSchemes.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); // Prepare parameters. // Since this example doesn't use the full core framework, // only few parameters are actually required. HttpParams params = new SyncBasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setUseExpectContinue(params, false); // one operator can be used for many connections ClientConnectionOperator scop = new DefaultClientConnectionOperator(supportedSchemes); HttpRequest req = new BasicHttpRequest("OPTIONS", "*", HttpVersion.HTTP_1_1); req.addHeader("Host", target.getHostName()); HttpContext ctx = new BasicHttpContext(); OperatedClientConnection conn = scop.createConnection(); try { System.out.println("opening connection to " + target); scop.openConnection(conn, target, null, ctx, params); System.out.println("sending request"); conn.sendRequestHeader(req); // there is no request entity conn.flush(); System.out.println("receiving response header"); HttpResponse rsp = conn.receiveResponseHeader(); System.out.println("----------------------------------------"); System.out.println(rsp.getStatusLine()); Header[] headers = rsp.getAllHeaders(); for (int i = 0; i < headers.length; i++) { System.out.println(headers[i]); } System.out.println("----------------------------------------"); } finally { System.out.println("closing connection"); conn.close(); } }