Merge pull request #3255 from eclipse/jetty-10.0.x-2095-remove_fcgi_multiplex

Fixes #2095 - Remove FastCGI multiplexing.
This commit is contained in:
Simone Bordet 2019-01-15 11:02:00 +01:00 committed by GitHub
commit 1eb6339a6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 39 deletions

View File

@ -18,14 +18,12 @@
package org.eclipse.jetty.fcgi.client.http; package org.eclipse.jetty.fcgi.client.http;
import java.io.IOException;
import java.util.Map; import java.util.Map;
import org.eclipse.jetty.client.AbstractConnectorHttpClientTransport; import org.eclipse.jetty.client.AbstractConnectorHttpClientTransport;
import org.eclipse.jetty.client.DuplexConnectionPool; import org.eclipse.jetty.client.DuplexConnectionPool;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpDestination; import org.eclipse.jetty.client.HttpDestination;
import org.eclipse.jetty.client.MultiplexConnectionPool;
import org.eclipse.jetty.client.Origin; import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.api.Connection; import org.eclipse.jetty.client.api.Connection;
import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Request;
@ -40,35 +38,25 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
@ManagedObject("The FastCGI/1.0 client transport") @ManagedObject("The FastCGI/1.0 client transport")
public class HttpClientTransportOverFCGI extends AbstractConnectorHttpClientTransport public class HttpClientTransportOverFCGI extends AbstractConnectorHttpClientTransport
{ {
private final boolean multiplexed;
private final String scriptRoot; private final String scriptRoot;
public HttpClientTransportOverFCGI(String scriptRoot) public HttpClientTransportOverFCGI(String scriptRoot)
{ {
this( Math.max( 1, ProcessorUtils.availableProcessors() / 2), false, scriptRoot); this(Math.max(1, ProcessorUtils.availableProcessors() / 2), scriptRoot);
} }
public HttpClientTransportOverFCGI(int selectors, boolean multiplexed, String scriptRoot) public HttpClientTransportOverFCGI(int selectors, String scriptRoot)
{ {
super(selectors); super(selectors);
this.multiplexed = multiplexed;
this.scriptRoot = scriptRoot; this.scriptRoot = scriptRoot;
setConnectionPoolFactory(destination -> setConnectionPoolFactory(destination ->
{ {
HttpClient httpClient = getHttpClient(); HttpClient httpClient = getHttpClient();
int maxConnections = httpClient.getMaxConnectionsPerDestination(); int maxConnections = httpClient.getMaxConnectionsPerDestination();
return isMultiplexed() ? return new DuplexConnectionPool(destination, maxConnections, destination);
new MultiplexConnectionPool(destination, maxConnections, destination, httpClient.getMaxRequestsQueuedPerDestination()) :
new DuplexConnectionPool(destination, maxConnections, destination);
}); });
} }
@ManagedAttribute(value = "Whether connections are multiplexed", readonly = true)
public boolean isMultiplexed()
{
return multiplexed;
}
@ManagedAttribute(value = "The scripts root directory", readonly = true) @ManagedAttribute(value = "The scripts root directory", readonly = true)
public String getScriptRoot() public String getScriptRoot()
{ {
@ -78,12 +66,11 @@ public class HttpClientTransportOverFCGI extends AbstractConnectorHttpClientTran
@Override @Override
public HttpDestination newHttpDestination(Origin origin) public HttpDestination newHttpDestination(Origin origin)
{ {
return isMultiplexed() ? new MultiplexHttpDestinationOverFCGI(getHttpClient(), origin) return new HttpDestinationOverFCGI(getHttpClient(), origin);
: new HttpDestinationOverFCGI(getHttpClient(), origin);
} }
@Override @Override
public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map<String, Object> context) throws IOException public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map<String, Object> context)
{ {
HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY); HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -96,7 +83,7 @@ public class HttpClientTransportOverFCGI extends AbstractConnectorHttpClientTran
protected HttpConnectionOverFCGI newHttpConnection(EndPoint endPoint, HttpDestination destination, Promise<Connection> promise) protected HttpConnectionOverFCGI newHttpConnection(EndPoint endPoint, HttpDestination destination, Promise<Connection> promise)
{ {
return new HttpConnectionOverFCGI(endPoint, destination, promise, isMultiplexed()); return new HttpConnectionOverFCGI(endPoint, destination, promise);
} }
protected void customize(Request request, HttpFields fastCGIHeaders) protected void customize(Request request, HttpFields fastCGIHeaders)

View File

@ -64,18 +64,16 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec
private final AtomicBoolean closed = new AtomicBoolean(); private final AtomicBoolean closed = new AtomicBoolean();
private final HttpDestination destination; private final HttpDestination destination;
private final Promise<Connection> promise; private final Promise<Connection> promise;
private final boolean multiplexed;
private final Flusher flusher; private final Flusher flusher;
private final Delegate delegate; private final Delegate delegate;
private final ClientParser parser; private final ClientParser parser;
private ByteBuffer buffer; private ByteBuffer buffer;
public HttpConnectionOverFCGI(EndPoint endPoint, HttpDestination destination, Promise<Connection> promise, boolean multiplexed) public HttpConnectionOverFCGI(EndPoint endPoint, HttpDestination destination, Promise<Connection> promise)
{ {
super(endPoint, destination.getHttpClient().getExecutor()); super(endPoint, destination.getHttpClient().getExecutor());
this.destination = destination; this.destination = destination;
this.promise = promise; this.promise = promise;
this.multiplexed = multiplexed;
this.flusher = new Flusher(endPoint); this.flusher = new Flusher(endPoint);
this.delegate = new Delegate(destination); this.delegate = new Delegate(destination);
this.parser = new ClientParser(new ResponseListener()); this.parser = new ClientParser(new ResponseListener());
@ -201,8 +199,6 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec
{ {
long idleTimeout = getEndPoint().getIdleTimeout(); long idleTimeout = getEndPoint().getIdleTimeout();
boolean close = delegate.onIdleTimeout(idleTimeout); boolean close = delegate.onIdleTimeout(idleTimeout);
if (multiplexed)
close &= isFillInterested();
if (close) if (close)
close(new TimeoutException("Idle timeout " + idleTimeout + " ms")); close(new TimeoutException("Idle timeout " + idleTimeout + " ms"));
return false; return false;
@ -257,8 +253,6 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec
protected boolean closeByHTTP(HttpFields fields) protected boolean closeByHTTP(HttpFields fields)
{ {
if (multiplexed)
return false;
if (!fields.contains(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE.asString())) if (!fields.contains(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE.asString()))
return false; return false;
close(); close();

View File

@ -245,7 +245,7 @@ public class FastCGIProxyServlet extends AsyncProxyServlet.Transparent
{ {
private ProxyHttpClientTransportOverFCGI(int selectors, String scriptRoot) private ProxyHttpClientTransportOverFCGI(int selectors, String scriptRoot)
{ {
super(selectors, false, scriptRoot); super(selectors, scriptRoot);
} }
@Override @Override

View File

@ -18,8 +18,6 @@
package org.eclipse.jetty.fcgi.server; package org.eclipse.jetty.fcgi.server;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
@ -40,6 +38,8 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import static org.hamcrest.MatcherAssert.assertThat;
public abstract class AbstractHttpClientServerTest public abstract class AbstractHttpClientServerTest
{ {
private LeakTrackingByteBufferPool serverBufferPool; private LeakTrackingByteBufferPool serverBufferPool;
@ -67,7 +67,7 @@ public abstract class AbstractHttpClientServerTest
QueuedThreadPool executor = new QueuedThreadPool(); QueuedThreadPool executor = new QueuedThreadPool();
executor.setName(executor.getName() + "-client"); executor.setName(executor.getName() + "-client");
HttpClientTransport transport = new HttpClientTransportOverFCGI(1, false, ""); HttpClientTransport transport = new HttpClientTransportOverFCGI(1, "");
transport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination) transport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination)
{ {
@Override @Override

View File

@ -18,8 +18,6 @@
package org.eclipse.jetty.http.client; package org.eclipse.jetty.http.client;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -49,6 +47,8 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource; import org.junit.jupiter.params.provider.ArgumentsSource;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class HttpChannelAssociationTest extends AbstractTest<TransportScenario> public class HttpChannelAssociationTest extends AbstractTest<TransportScenario>
{ {
@Override @Override
@ -173,12 +173,12 @@ public class HttpChannelAssociationTest extends AbstractTest<TransportScenario>
} }
case FCGI: case FCGI:
{ {
return new HttpClientTransportOverFCGI(1, false, "") return new HttpClientTransportOverFCGI(1, "")
{ {
@Override @Override
protected HttpConnectionOverFCGI newHttpConnection(EndPoint endPoint, HttpDestination destination, Promise<Connection> promise) protected HttpConnectionOverFCGI newHttpConnection(EndPoint endPoint, HttpDestination destination, Promise<Connection> promise)
{ {
return new HttpConnectionOverFCGI(endPoint, destination, promise, isMultiplexed()) return new HttpConnectionOverFCGI(endPoint, destination, promise)
{ {
@Override @Override
protected HttpChannelOverFCGI newHttpChannel(Request request) protected HttpChannelOverFCGI newHttpChannel(Request request)

View File

@ -18,9 +18,6 @@
package org.eclipse.jetty.http.client; package org.eclipse.jetty.http.client;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException; import java.io.IOException;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -68,6 +65,9 @@ import org.hamcrest.Matchers;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource; import org.junit.jupiter.params.provider.ArgumentsSource;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class HttpClientLoadTest extends AbstractTest<HttpClientLoadTest.LoadTransportScenario> public class HttpClientLoadTest extends AbstractTest<HttpClientLoadTest.LoadTransportScenario>
{ {
private final Logger logger = Log.getLogger(HttpClientLoadTest.class); private final Logger logger = Log.getLogger(HttpClientLoadTest.class);
@ -402,7 +402,7 @@ public class HttpClientLoadTest extends AbstractTest<HttpClientLoadTest.LoadTran
} }
case FCGI: case FCGI:
{ {
HttpClientTransport clientTransport = new HttpClientTransportOverFCGI(1, false, ""); HttpClientTransport clientTransport = new HttpClientTransportOverFCGI(1, "");
clientTransport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination) clientTransport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination(), destination)
{ {
@Override @Override

View File

@ -195,7 +195,7 @@ public class TransportScenario
} }
case FCGI: case FCGI:
{ {
return new HttpClientTransportOverFCGI(1, false, ""); return new HttpClientTransportOverFCGI(1, "");
} }
case UNIX_SOCKET: case UNIX_SOCKET:
{ {