Rename RetainableByteBufferPool to ByteBufferPool

With issue #9166, ByteBufferPool was removed and replaced by
RetainableByteBufferPool. Since ByteBufferPool was used by
AbstractConnector, this change broke backwards compatibility with
third-party connectors such as junixsocket-jetty.

Since there's no longer any other ByteBufferPool, rename the
RetainableByteBufferPool interface, and thereby not only reinstate
compatibility with existing third-party libraries but also save a few
keystrokes.

https://github.com/eclipse/jetty.project/issues/9284

Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
This commit is contained in:
Christian Kohlschütter 2023-02-04 23:39:29 +01:00
parent 9916706b5f
commit b8ab66fd1d
235 changed files with 820 additions and 826 deletions

View File

@ -387,7 +387,7 @@ public class ClientConnectorDocs
// Wrap the "telnet" ClientConnectionFactory with the SslClientConnectionFactory. // Wrap the "telnet" ClientConnectionFactory with the SslClientConnectionFactory.
connectionFactory = new SslClientConnectionFactory(clientConnector.getSslContextFactory(), connectionFactory = new SslClientConnectionFactory(clientConnector.getSslContextFactory(),
clientConnector.getRetainableByteBufferPool(), clientConnector.getExecutor(), connectionFactory); clientConnector.getByteBufferPool(), clientConnector.getExecutor(), connectionFactory);
// We will obtain a SslConnection now. // We will obtain a SslConnection now.
CompletableFuture<SslConnection> connectionPromise = new Promise.Completable<>(); CompletableFuture<SslConnection> connectionPromise = new Promise.Completable<>();

View File

@ -52,7 +52,7 @@ public abstract class AbstractConnectorHttpClientTransport extends AbstractHttpC
{ {
HttpClient httpClient = getHttpClient(); HttpClient httpClient = getHttpClient();
connector.setBindAddress(httpClient.getBindAddress()); connector.setBindAddress(httpClient.getBindAddress());
connector.setRetainableByteBufferPool(httpClient.getRetainableByteBufferPool()); connector.setByteBufferPool(httpClient.getByteBufferPool());
connector.setConnectBlocking(httpClient.isConnectBlocking()); connector.setConnectBlocking(httpClient.isConnectBlocking());
connector.setConnectTimeout(Duration.ofMillis(httpClient.getConnectTimeout())); connector.setConnectTimeout(Duration.ofMillis(httpClient.getConnectTimeout()));
connector.setExecutor(httpClient.getExecutor()); connector.setExecutor(httpClient.getExecutor());

View File

@ -13,8 +13,8 @@
package org.eclipse.jetty.client; package org.eclipse.jetty.client;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
/** /**
* {@link ContentDecoder} for the "gzip" encoding. * {@link ContentDecoder} for the "gzip" encoding.
@ -33,9 +33,9 @@ public class GZIPContentDecoder extends org.eclipse.jetty.http.GZIPContentDecode
this(null, bufferSize); this(null, bufferSize);
} }
public GZIPContentDecoder(RetainableByteBufferPool retainableByteBufferPool, int bufferSize) public GZIPContentDecoder(ByteBufferPool byteBufferPool, int bufferSize)
{ {
super(retainableByteBufferPool, bufferSize); super(byteBufferPool, bufferSize);
} }
@Override @Override
@ -50,7 +50,7 @@ public class GZIPContentDecoder extends org.eclipse.jetty.http.GZIPContentDecode
*/ */
public static class Factory extends ContentDecoder.Factory public static class Factory extends ContentDecoder.Factory
{ {
private final RetainableByteBufferPool retainableByteBufferPool; private final ByteBufferPool byteBufferPool;
private final int bufferSize; private final int bufferSize;
public Factory() public Factory()
@ -63,22 +63,22 @@ public class GZIPContentDecoder extends org.eclipse.jetty.http.GZIPContentDecode
this(null, bufferSize); this(null, bufferSize);
} }
public Factory(RetainableByteBufferPool retainableByteBufferPool) public Factory(ByteBufferPool byteBufferPool)
{ {
this(retainableByteBufferPool, DEFAULT_BUFFER_SIZE); this(byteBufferPool, DEFAULT_BUFFER_SIZE);
} }
public Factory(RetainableByteBufferPool retainableByteBufferPool, int bufferSize) public Factory(ByteBufferPool byteBufferPool, int bufferSize)
{ {
super("gzip"); super("gzip");
this.retainableByteBufferPool = retainableByteBufferPool; this.byteBufferPool = byteBufferPool;
this.bufferSize = bufferSize; this.bufferSize = bufferSize;
} }
@Override @Override
public ContentDecoder newContentDecoder() public ContentDecoder newContentDecoder()
{ {
return new GZIPContentDecoder(retainableByteBufferPool, bufferSize); return new GZIPContentDecoder(byteBufferPool, bufferSize);
} }
} }
} }

View File

@ -49,9 +49,9 @@ import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpParser; import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory; import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory; import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.util.Fields; import org.eclipse.jetty.util.Fields;
import org.eclipse.jetty.util.Jetty; import org.eclipse.jetty.util.Jetty;
@ -199,9 +199,9 @@ public class HttpClient extends ContainerLifeCycle
int maxBucketSize = executor instanceof ThreadPool.SizedThreadPool int maxBucketSize = executor instanceof ThreadPool.SizedThreadPool
? ((ThreadPool.SizedThreadPool)executor).getMaxThreads() / 2 ? ((ThreadPool.SizedThreadPool)executor).getMaxThreads() / 2
: ProcessorUtils.availableProcessors() * 2; : ProcessorUtils.availableProcessors() * 2;
RetainableByteBufferPool retainableByteBufferPool = getRetainableByteBufferPool(); ByteBufferPool byteBufferPool = getByteBufferPool();
if (retainableByteBufferPool == null) if (byteBufferPool == null)
setRetainableByteBufferPool(new ArrayRetainableByteBufferPool(0, 2048, 65536, maxBucketSize)); setByteBufferPool(new ArrayRetainableByteBufferPool(0, 2048, 65536, maxBucketSize));
Scheduler scheduler = getScheduler(); Scheduler scheduler = getScheduler();
if (scheduler == null) if (scheduler == null)
{ {
@ -220,7 +220,7 @@ public class HttpClient extends ContainerLifeCycle
handlers.put(new ProxyAuthenticationProtocolHandler(this)); handlers.put(new ProxyAuthenticationProtocolHandler(this));
handlers.put(new UpgradeProtocolHandler()); handlers.put(new UpgradeProtocolHandler());
decoderFactories.put(new GZIPContentDecoder.Factory(retainableByteBufferPool)); decoderFactories.put(new GZIPContentDecoder.Factory(byteBufferPool));
cookieManager = newCookieManager(); cookieManager = newCookieManager();
cookieStore = cookieManager.getCookieStore(); cookieStore = cookieManager.getCookieStore();
@ -646,19 +646,19 @@ public class HttpClient extends ContainerLifeCycle
} }
/** /**
* @return the {@link RetainableByteBufferPool} of this HttpClient * @return the {@link ByteBufferPool} of this HttpClient
*/ */
public RetainableByteBufferPool getRetainableByteBufferPool() public ByteBufferPool getByteBufferPool()
{ {
return connector.getRetainableByteBufferPool(); return connector.getByteBufferPool();
} }
/** /**
* @param retainableByteBufferPool the {@link RetainableByteBufferPool} of this HttpClient * @param byteBufferPool the {@link ByteBufferPool} of this HttpClient
*/ */
public void setRetainableByteBufferPool(RetainableByteBufferPool retainableByteBufferPool) public void setByteBufferPool(ByteBufferPool byteBufferPool)
{ {
connector.setRetainableByteBufferPool(retainableByteBufferPool); connector.setByteBufferPool(byteBufferPool);
} }
/** /**
@ -1152,6 +1152,6 @@ public class HttpClient extends ContainerLifeCycle
{ {
if (sslContextFactory == null) if (sslContextFactory == null)
sslContextFactory = getSslContextFactory(); sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory); return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory);
} }
} }

View File

@ -15,7 +15,7 @@ package org.eclipse.jetty.client;
import java.io.InputStream; import java.io.InputStream;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.content.InputStreamContentSource; import org.eclipse.jetty.io.content.InputStreamContentSource;
/** /**
@ -51,7 +51,7 @@ public class InputStreamRequestContent extends InputStreamContentSource implemen
this(contentType, stream, null); this(contentType, stream, null);
} }
public InputStreamRequestContent(String contentType, InputStream stream, RetainableByteBufferPool bufferPool) public InputStreamRequestContent(String contentType, InputStream stream, ByteBufferPool bufferPool)
{ {
super(stream, bufferPool); super(stream, bufferPool);
this.contentType = contentType; this.contentType = contentType;

View File

@ -16,14 +16,14 @@ package org.eclipse.jetty.client;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.content.PathContentSource; import org.eclipse.jetty.io.content.PathContentSource;
/** /**
* <p>A {@link Request.Content} for files using JDK 7's {@code java.nio.file} APIs.</p> * <p>A {@link Request.Content} for files using JDK 7's {@code java.nio.file} APIs.</p>
* <p>It is possible to specify a buffer size used to read content from the stream, * <p>It is possible to specify a buffer size used to read content from the stream,
* by default 4096 bytes, whether the buffer should be direct or not, and a * by default 4096 bytes, whether the buffer should be direct or not, and a
* {@link RetainableByteBufferPool} from which {@code ByteBuffer}s will be acquired * {@link ByteBufferPool} from which {@code ByteBuffer}s will be acquired
* to read from the {@code Path}.</p> * to read from the {@code Path}.</p>
*/ */
public class PathRequestContent extends PathContentSource implements Request.Content public class PathRequestContent extends PathContentSource implements Request.Content
@ -51,7 +51,7 @@ public class PathRequestContent extends PathContentSource implements Request.Con
setBufferSize(bufferSize); setBufferSize(bufferSize);
} }
public PathRequestContent(String contentType, Path filePath, RetainableByteBufferPool bufferPool) throws IOException public PathRequestContent(String contentType, Path filePath, ByteBufferPool bufferPool) throws IOException
{ {
super(filePath, bufferPool); super(filePath, bufferPool);
this.contentType = contentType; this.contentType = contentType;

View File

@ -30,10 +30,10 @@ import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpParser; import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -45,7 +45,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
private final LongAdder inMessages = new LongAdder(); private final LongAdder inMessages = new LongAdder();
private final HttpParser parser; private final HttpParser parser;
private final RetainableByteBufferPool retainableByteBufferPool; private final ByteBufferPool byteBufferPool;
private RetainableByteBuffer networkBuffer; private RetainableByteBuffer networkBuffer;
private boolean shutdown; private boolean shutdown;
private boolean complete; private boolean complete;
@ -66,7 +66,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
parser.setHeaderCacheSize(httpTransport.getHeaderCacheSize()); parser.setHeaderCacheSize(httpTransport.getHeaderCacheSize());
parser.setHeaderCacheCaseSensitive(httpTransport.isHeaderCacheCaseSensitive()); parser.setHeaderCacheCaseSensitive(httpTransport.isHeaderCacheCaseSensitive());
} }
retainableByteBufferPool = httpClient.getRetainableByteBufferPool(); byteBufferPool = httpClient.getByteBufferPool();
} }
void receive() void receive()
@ -197,7 +197,7 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res
{ {
HttpClient client = getHttpDestination().getHttpClient(); HttpClient client = getHttpDestination().getHttpClient();
boolean direct = client.isUseInputDirectByteBuffers(); boolean direct = client.isUseInputDirectByteBuffers();
return retainableByteBufferPool.acquire(client.getResponseBufferSize(), direct); return byteBufferPool.acquire(client.getResponseBufferSize(), direct);
} }
private void releaseNetworkBuffer() private void releaseNetworkBuffer()

View File

@ -23,10 +23,10 @@ import org.eclipse.jetty.client.transport.HttpSender;
import org.eclipse.jetty.http.HttpGenerator; import org.eclipse.jetty.http.HttpGenerator;
import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.http.MetaData; import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.IteratingCallback; import org.eclipse.jetty.util.IteratingCallback;
@ -158,7 +158,7 @@ public class HttpSenderOverHTTP extends HttpSender
protected Action process() throws Exception protected Action process() throws Exception
{ {
HttpClient httpClient = getHttpChannel().getHttpDestination().getHttpClient(); HttpClient httpClient = getHttpChannel().getHttpDestination().getHttpClient();
RetainableByteBufferPool bufferPool = httpClient.getRetainableByteBufferPool(); ByteBufferPool bufferPool = httpClient.getByteBufferPool();
boolean useDirectByteBuffers = httpClient.isUseOutputDirectByteBuffers(); boolean useDirectByteBuffers = httpClient.isUseOutputDirectByteBuffers();
while (true) while (true)
{ {
@ -289,7 +289,7 @@ public class HttpSenderOverHTTP extends HttpSender
protected Action process() throws Exception protected Action process() throws Exception
{ {
HttpClient httpClient = getHttpChannel().getHttpDestination().getHttpClient(); HttpClient httpClient = getHttpChannel().getHttpDestination().getHttpClient();
RetainableByteBufferPool bufferPool = httpClient.getRetainableByteBufferPool(); ByteBufferPool bufferPool = httpClient.getByteBufferPool();
boolean useDirectByteBuffers = httpClient.isUseOutputDirectByteBuffers(); boolean useDirectByteBuffers = httpClient.isUseOutputDirectByteBuffers();
while (true) while (true)
{ {

View File

@ -28,8 +28,8 @@ import java.util.zip.GZIPOutputStream;
import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
@ -242,7 +242,7 @@ public class HttpClientGZIPTest extends AbstractHttpClientServerTest
} }
}); });
RetainableByteBufferPool pool = client.getRetainableByteBufferPool(); ByteBufferPool pool = client.getByteBufferPool();
assumeTrue(pool instanceof ArrayRetainableByteBufferPool); assumeTrue(pool instanceof ArrayRetainableByteBufferPool);
ArrayRetainableByteBufferPool bufferPool = (ArrayRetainableByteBufferPool)pool; ArrayRetainableByteBufferPool bufferPool = (ArrayRetainableByteBufferPool)pool;

View File

@ -45,13 +45,13 @@ import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory; import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ConnectionStatistics; import org.eclipse.jetty.io.ConnectionStatistics;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory; import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.io.ssl.SslConnection; import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.io.ssl.SslHandshakeListener; import org.eclipse.jetty.io.ssl.SslHandshakeListener;
@ -630,7 +630,7 @@ public class HttpClientTLSTest
@Override @Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{ {
return new SslConnection(connector.getRetainableByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {
@Override @Override
protected int networkFill(ByteBuffer input) throws IOException protected int networkFill(ByteBuffer input) throws IOException
@ -664,10 +664,10 @@ public class HttpClientTLSTest
{ {
if (sslContextFactory == null) if (sslContextFactory == null)
sslContextFactory = getSslContextFactory(); sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory) return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory)
{ {
@Override @Override
protected SslConnection newSslConnection(RetainableByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(ByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
{ {
return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {
@ -721,7 +721,7 @@ public class HttpClientTLSTest
@Override @Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{ {
RetainableByteBufferPool bufferPool = connector.getRetainableByteBufferPool(); ByteBufferPool bufferPool = connector.getByteBufferPool();
return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {
@Override @Override
@ -753,7 +753,7 @@ public class HttpClientTLSTest
assertThrows(Exception.class, () -> client.newRequest("localhost", connector.getLocalPort()).scheme(HttpScheme.HTTPS.asString()).send()); assertThrows(Exception.class, () -> client.newRequest("localhost", connector.getLocalPort()).scheme(HttpScheme.HTTPS.asString()).send());
ArrayRetainableByteBufferPool bufferPool = (ArrayRetainableByteBufferPool)server.getRetainableByteBufferPool(); ArrayRetainableByteBufferPool bufferPool = (ArrayRetainableByteBufferPool)server.getByteBufferPool();
Pool<RetainableByteBuffer> bucket = bufferPool.poolFor(16 * 1024 + 1, connector.getConnectionFactory(HttpConnectionFactory.class).isUseInputDirectByteBuffers()); Pool<RetainableByteBuffer> bucket = bufferPool.poolFor(16 * 1024 + 1, connector.getConnectionFactory(HttpConnectionFactory.class).isUseInputDirectByteBuffers());
assertEquals(1, bucket.size()); assertEquals(1, bucket.size());
assertEquals(1, bucket.getIdleCount()); assertEquals(1, bucket.getIdleCount());
@ -769,7 +769,7 @@ public class HttpClientTLSTest
QueuedThreadPool serverThreads = new QueuedThreadPool(); QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setName("server"); serverThreads.setName("server");
List<RetainableByteBuffer> leakedBuffers = new CopyOnWriteArrayList<>(); List<RetainableByteBuffer> leakedBuffers = new CopyOnWriteArrayList<>();
RetainableByteBufferPool bufferPool = new RetainableByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool()) ByteBufferPool bufferPool = new ByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool())
{ {
@Override @Override
public RetainableByteBuffer acquire(int size, boolean direct) public RetainableByteBuffer acquire(int size, boolean direct)
@ -798,7 +798,7 @@ public class HttpClientTLSTest
@Override @Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{ {
RetainableByteBufferPool bufferPool = connector.getRetainableByteBufferPool(); ByteBufferPool bufferPool = connector.getByteBufferPool();
return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {
@Override @Override
@ -839,7 +839,7 @@ public class HttpClientTLSTest
QueuedThreadPool serverThreads = new QueuedThreadPool(); QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setName("server"); serverThreads.setName("server");
List<RetainableByteBuffer> leakedBuffers = new CopyOnWriteArrayList<>(); List<RetainableByteBuffer> leakedBuffers = new CopyOnWriteArrayList<>();
RetainableByteBufferPool bufferPool = new RetainableByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool()) ByteBufferPool bufferPool = new ByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool())
{ {
@Override @Override
public RetainableByteBuffer acquire(int size, boolean direct) public RetainableByteBuffer acquire(int size, boolean direct)
@ -869,7 +869,7 @@ public class HttpClientTLSTest
@Override @Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{ {
RetainableByteBufferPool bufferPool = connector.getRetainableByteBufferPool(); ByteBufferPool bufferPool = connector.getByteBufferPool();
return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {
@Override @Override
@ -924,7 +924,7 @@ public class HttpClientTLSTest
QueuedThreadPool serverThreads = new QueuedThreadPool(); QueuedThreadPool serverThreads = new QueuedThreadPool();
serverThreads.setName("server"); serverThreads.setName("server");
List<RetainableByteBuffer> leakedBuffers = new CopyOnWriteArrayList<>(); List<RetainableByteBuffer> leakedBuffers = new CopyOnWriteArrayList<>();
RetainableByteBufferPool bufferPool = new RetainableByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool()) ByteBufferPool bufferPool = new ByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool())
{ {
@Override @Override
public RetainableByteBuffer acquire(int size, boolean direct) public RetainableByteBuffer acquire(int size, boolean direct)
@ -954,7 +954,7 @@ public class HttpClientTLSTest
@Override @Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{ {
RetainableByteBufferPool bufferPool = connector.getRetainableByteBufferPool(); ByteBufferPool bufferPool = connector.getByteBufferPool();
return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(bufferPool, connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {
@Override @Override
@ -1017,7 +1017,7 @@ public class HttpClientTLSTest
@Override @Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{ {
return new SslConnection(connector.getRetainableByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {
@Override @Override
protected int networkFill(ByteBuffer input) throws IOException protected int networkFill(ByteBuffer input) throws IOException
@ -1052,10 +1052,10 @@ public class HttpClientTLSTest
{ {
if (sslContextFactory == null) if (sslContextFactory == null)
sslContextFactory = getSslContextFactory(); sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory) return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory)
{ {
@Override @Override
protected SslConnection newSslConnection(RetainableByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(ByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
{ {
return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {
@ -1114,10 +1114,10 @@ public class HttpClientTLSTest
{ {
if (sslContextFactory == null) if (sslContextFactory == null)
sslContextFactory = getSslContextFactory(); sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory) return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory)
{ {
@Override @Override
protected SslConnection newSslConnection(RetainableByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(ByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
{ {
return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {
@ -1158,7 +1158,7 @@ public class HttpClientTLSTest
@Override @Override
protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(Connector connector, EndPoint endPoint, SSLEngine engine)
{ {
return new SslConnection(connector.getRetainableByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(connector.getByteBufferPool(), connector.getExecutor(), endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {
@Override @Override
protected SSLEngineResult unwrap(SSLEngine sslEngine, ByteBuffer input, ByteBuffer output) throws SSLException protected SSLEngineResult unwrap(SSLEngine sslEngine, ByteBuffer input, ByteBuffer output) throws SSLException
@ -1194,10 +1194,10 @@ public class HttpClientTLSTest
{ {
if (sslContextFactory == null) if (sslContextFactory == null)
sslContextFactory = getSslContextFactory(); sslContextFactory = getSslContextFactory();
return new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), connectionFactory) return new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), connectionFactory)
{ {
@Override @Override
protected SslConnection newSslConnection(RetainableByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine) protected SslConnection newSslConnection(ByteBufferPool bufferPool, Executor executor, EndPoint endPoint, SSLEngine engine)
{ {
return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption()) return new SslConnection(bufferPool, executor, endPoint, engine, isDirectBuffersForEncryption(), isDirectBuffersForDecryption())
{ {

View File

@ -21,8 +21,8 @@ import javax.net.ssl.SSLHandshakeException;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteArrayEndPoint; import org.eclipse.jetty.io.ByteArrayEndPoint;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslConnection; import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
@ -43,7 +43,7 @@ public class SslConnectionTest
sslContextFactory.setKeyStorePassword("storepwd"); sslContextFactory.setKeyStorePassword("storepwd");
sslContextFactory.start(); sslContextFactory.start();
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
QueuedThreadPool threadPool = new QueuedThreadPool(); QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.start(); threadPool.start();
ByteArrayEndPoint endPoint = new ByteArrayEndPoint(); ByteArrayEndPoint endPoint = new ByteArrayEndPoint();

View File

@ -283,7 +283,7 @@ public class MultiPartRequestContentTest extends AbstractHttpClientServerTest
}); });
MultiPartRequestContent multiPart = new MultiPartRequestContent(); MultiPartRequestContent multiPart = new MultiPartRequestContent();
PathRequestContent content = new PathRequestContent(contentType, tmpPath, client.getRetainableByteBufferPool()); PathRequestContent content = new PathRequestContent(contentType, tmpPath, client.getByteBufferPool());
content.setUseDirectByteBuffers(client.isUseOutputDirectByteBuffers()); content.setUseDirectByteBuffers(client.isUseOutputDirectByteBuffers());
multiPart.addPart(new MultiPart.ContentSourcePart(name, tmpPath.getFileName().toString(), null, content)); multiPart.addPart(new MultiPart.ContentSourcePart(name, tmpPath.getFileName().toString(), null, content));
multiPart.close(); multiPart.close();

View File

@ -24,9 +24,9 @@ import org.eclipse.jetty.fcgi.generator.Flusher;
import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.IdleTimeout; import org.eclipse.jetty.io.IdleTimeout;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -162,7 +162,7 @@ public class HttpChannelOverFCGI extends HttpChannel
release(); release();
} }
protected void flush(RetainableByteBufferPool.Accumulator accumulator, Callback callback) protected void flush(ByteBufferPool.Accumulator accumulator, Callback callback)
{ {
flusher.flush(accumulator, callback); flusher.flush(accumulator, callback);
} }

View File

@ -42,10 +42,10 @@ import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.Attachable; import org.eclipse.jetty.util.Attachable;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
@ -57,7 +57,7 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements IConne
{ {
private static final Logger LOG = LoggerFactory.getLogger(HttpConnectionOverFCGI.class); private static final Logger LOG = LoggerFactory.getLogger(HttpConnectionOverFCGI.class);
private final RetainableByteBufferPool networkByteBufferPool; private final ByteBufferPool networkByteBufferPool;
private final AutoLock lock = new AutoLock(); private final AutoLock lock = new AutoLock();
private final LinkedList<Integer> requests = new LinkedList<>(); private final LinkedList<Integer> requests = new LinkedList<>();
private final AtomicBoolean closed = new AtomicBoolean(); private final AtomicBoolean closed = new AtomicBoolean();
@ -81,7 +81,7 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements IConne
this.parser = new ClientParser(new ResponseListener()); this.parser = new ClientParser(new ResponseListener());
requests.addLast(0); requests.addLast(0);
HttpClient client = destination.getHttpClient(); HttpClient client = destination.getHttpClient();
this.networkByteBufferPool = client.getRetainableByteBufferPool(); this.networkByteBufferPool = client.getByteBufferPool();
} }
public HttpDestination getHttpDestination() public HttpDestination getHttpDestination()

View File

@ -29,7 +29,7 @@ import org.eclipse.jetty.fcgi.generator.ClientGenerator;
import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Jetty; import org.eclipse.jetty.util.Jetty;
import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.StringUtil;
@ -42,7 +42,7 @@ public class HttpSenderOverFCGI extends HttpSender
{ {
super(channel); super(channel);
HttpClient httpClient = channel.getHttpDestination().getHttpClient(); HttpClient httpClient = channel.getHttpDestination().getHttpClient();
this.generator = new ClientGenerator(httpClient.getRetainableByteBufferPool(), httpClient.isUseOutputDirectByteBuffers()); this.generator = new ClientGenerator(httpClient.getByteBufferPool(), httpClient.isUseOutputDirectByteBuffers());
} }
@Override @Override
@ -98,7 +98,7 @@ public class HttpSenderOverFCGI extends HttpSender
HttpClientTransportOverFCGI transport = (HttpClientTransportOverFCGI)getHttpChannel().getHttpDestination().getHttpClient().getTransport(); HttpClientTransportOverFCGI transport = (HttpClientTransportOverFCGI)getHttpChannel().getHttpDestination().getHttpClient().getTransport();
transport.customize(request, fcgiHeaders); transport.customize(request, fcgiHeaders);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
int id = getHttpChannel().getRequest(); int id = getHttpChannel().getRequest();
if (contentBuffer.hasRemaining() || lastContent) if (contentBuffer.hasRemaining() || lastContent)
{ {
@ -117,7 +117,7 @@ public class HttpSenderOverFCGI extends HttpSender
{ {
if (contentBuffer.hasRemaining() || lastContent) if (contentBuffer.hasRemaining() || lastContent)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
int request = getHttpChannel().getRequest(); int request = getHttpChannel().getRequest();
generator.generateRequestContent(accumulator, request, contentBuffer, lastContent); generator.generateRequestContent(accumulator, request, contentBuffer, lastContent);
getHttpChannel().flush(accumulator, callback); getHttpChannel().flush(accumulator, callback);

View File

@ -22,8 +22,8 @@ import java.util.List;
import org.eclipse.jetty.fcgi.FCGI; import org.eclipse.jetty.fcgi.FCGI;
import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class ClientGenerator extends Generator public class ClientGenerator extends Generator
@ -33,17 +33,17 @@ public class ClientGenerator extends Generator
// 0x7F_FF - 4 (the 4 is to make room for the name (or value) length). // 0x7F_FF - 4 (the 4 is to make room for the name (or value) length).
public static final int MAX_PARAM_LENGTH = 0x7F_FF - 4; public static final int MAX_PARAM_LENGTH = 0x7F_FF - 4;
public ClientGenerator(RetainableByteBufferPool bufferPool) public ClientGenerator(ByteBufferPool bufferPool)
{ {
this(bufferPool, true); this(bufferPool, true);
} }
public ClientGenerator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers) public ClientGenerator(ByteBufferPool bufferPool, boolean useDirectByteBuffers)
{ {
super(bufferPool, useDirectByteBuffers); super(bufferPool, useDirectByteBuffers);
} }
public void generateRequestHeaders(RetainableByteBufferPool.Accumulator accumulator, int request, HttpFields fields) public void generateRequestHeaders(ByteBufferPool.Accumulator accumulator, int request, HttpFields fields)
{ {
request &= 0xFF_FF; request &= 0xFF_FF;
@ -79,7 +79,7 @@ public class ClientGenerator extends Generator
// One FCGI_BEGIN_REQUEST + N FCGI_PARAMS + one last FCGI_PARAMS // One FCGI_BEGIN_REQUEST + N FCGI_PARAMS + one last FCGI_PARAMS
RetainableByteBuffer beginBuffer = getRetainableByteBufferPool().acquire(16, isUseDirectByteBuffers()); RetainableByteBuffer beginBuffer = getByteBufferPool().acquire(16, isUseDirectByteBuffers());
accumulator.append(beginBuffer); accumulator.append(beginBuffer);
ByteBuffer beginByteBuffer = beginBuffer.getByteBuffer(); ByteBuffer beginByteBuffer = beginBuffer.getByteBuffer();
BufferUtil.clearToFill(beginByteBuffer); BufferUtil.clearToFill(beginByteBuffer);
@ -95,7 +95,7 @@ public class ClientGenerator extends Generator
while (fieldsLength > 0) while (fieldsLength > 0)
{ {
int capacity = 8 + Math.min(maxCapacity, fieldsLength); int capacity = 8 + Math.min(maxCapacity, fieldsLength);
RetainableByteBuffer buffer = getRetainableByteBufferPool().acquire(capacity, isUseDirectByteBuffers()); RetainableByteBuffer buffer = getByteBufferPool().acquire(capacity, isUseDirectByteBuffers());
accumulator.append(buffer); accumulator.append(buffer);
ByteBuffer byteBuffer = buffer.getByteBuffer(); ByteBuffer byteBuffer = buffer.getByteBuffer();
BufferUtil.clearToFill(byteBuffer); BufferUtil.clearToFill(byteBuffer);
@ -133,7 +133,7 @@ public class ClientGenerator extends Generator
BufferUtil.flipToFlush(byteBuffer, 0); BufferUtil.flipToFlush(byteBuffer, 0);
} }
RetainableByteBuffer lastBuffer = getRetainableByteBufferPool().acquire(8, isUseDirectByteBuffers()); RetainableByteBuffer lastBuffer = getByteBufferPool().acquire(8, isUseDirectByteBuffers());
accumulator.append(lastBuffer); accumulator.append(lastBuffer);
ByteBuffer lastByteBuffer = lastBuffer.getByteBuffer(); ByteBuffer lastByteBuffer = lastBuffer.getByteBuffer();
BufferUtil.clearToFill(lastByteBuffer); BufferUtil.clearToFill(lastByteBuffer);
@ -159,7 +159,7 @@ public class ClientGenerator extends Generator
return length > 127 ? 4 : 1; return length > 127 ? 4 : 1;
} }
public void generateRequestContent(RetainableByteBufferPool.Accumulator accumulator, int request, ByteBuffer content, boolean lastContent) public void generateRequestContent(ByteBufferPool.Accumulator accumulator, int request, ByteBuffer content, boolean lastContent)
{ {
generateContent(accumulator, request, content, lastContent, FCGI.FrameType.STDIN); generateContent(accumulator, request, content, lastContent, FCGI.FrameType.STDIN);
} }

View File

@ -18,8 +18,8 @@ import java.util.ArrayDeque;
import java.util.List; import java.util.List;
import java.util.Queue; import java.util.Queue;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.IteratingCallback; import org.eclipse.jetty.util.IteratingCallback;
import org.eclipse.jetty.util.thread.AutoLock; import org.eclipse.jetty.util.thread.AutoLock;
@ -40,7 +40,7 @@ public class Flusher
this.endPoint = endPoint; this.endPoint = endPoint;
} }
public void flush(RetainableByteBufferPool.Accumulator accumulator, Callback callback) public void flush(ByteBufferPool.Accumulator accumulator, Callback callback)
{ {
offer(new Entry(accumulator, callback)); offer(new Entry(accumulator, callback));
flushCallback.iterate(); flushCallback.iterate();
@ -126,7 +126,7 @@ public class Flusher
} }
} }
private record Entry(RetainableByteBufferPool.Accumulator accumulator, Callback callback) implements Callback private record Entry(ByteBufferPool.Accumulator accumulator, Callback callback) implements Callback
{ {
@Override @Override
public void succeeded() public void succeeded()

View File

@ -16,24 +16,24 @@ package org.eclipse.jetty.fcgi.generator;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import org.eclipse.jetty.fcgi.FCGI; import org.eclipse.jetty.fcgi.FCGI;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class Generator public class Generator
{ {
public static final int MAX_CONTENT_LENGTH = 0xFF_FF; public static final int MAX_CONTENT_LENGTH = 0xFF_FF;
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private final boolean useDirectByteBuffers; private final boolean useDirectByteBuffers;
public Generator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers) public Generator(ByteBufferPool bufferPool, boolean useDirectByteBuffers)
{ {
this.bufferPool = bufferPool; this.bufferPool = bufferPool;
this.useDirectByteBuffers = useDirectByteBuffers; this.useDirectByteBuffers = useDirectByteBuffers;
} }
public RetainableByteBufferPool getRetainableByteBufferPool() public ByteBufferPool getByteBufferPool()
{ {
return bufferPool; return bufferPool;
} }
@ -43,7 +43,7 @@ public class Generator
return useDirectByteBuffers; return useDirectByteBuffers;
} }
protected void generateContent(RetainableByteBufferPool.Accumulator accumulator, int id, ByteBuffer content, boolean lastContent, FCGI.FrameType frameType) protected void generateContent(ByteBufferPool.Accumulator accumulator, int id, ByteBuffer content, boolean lastContent, FCGI.FrameType frameType)
{ {
id &= 0xFF_FF; id &= 0xFF_FF;
@ -51,7 +51,7 @@ public class Generator
while (contentLength > 0 || lastContent) while (contentLength > 0 || lastContent)
{ {
RetainableByteBuffer buffer = getRetainableByteBufferPool().acquire(8, isUseDirectByteBuffers()); RetainableByteBuffer buffer = getByteBufferPool().acquire(8, isUseDirectByteBuffers());
accumulator.append(buffer); accumulator.append(buffer);
ByteBuffer byteBuffer = buffer.getByteBuffer(); ByteBuffer byteBuffer = buffer.getByteBuffer();
BufferUtil.clearToFill(byteBuffer); BufferUtil.clearToFill(byteBuffer);

View File

@ -23,8 +23,8 @@ import org.eclipse.jetty.fcgi.FCGI;
import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class ServerGenerator extends Generator public class ServerGenerator extends Generator
@ -35,18 +35,18 @@ public class ServerGenerator extends Generator
private final boolean sendStatus200; private final boolean sendStatus200;
public ServerGenerator(RetainableByteBufferPool bufferPool) public ServerGenerator(ByteBufferPool bufferPool)
{ {
this(bufferPool, true, true); this(bufferPool, true, true);
} }
public ServerGenerator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers, boolean sendStatus200) public ServerGenerator(ByteBufferPool bufferPool, boolean useDirectByteBuffers, boolean sendStatus200)
{ {
super(bufferPool, useDirectByteBuffers); super(bufferPool, useDirectByteBuffers);
this.sendStatus200 = sendStatus200; this.sendStatus200 = sendStatus200;
} }
public void generateResponseHeaders(RetainableByteBufferPool.Accumulator accumulator, int request, int code, String reason, HttpFields fields) public void generateResponseHeaders(ByteBufferPool.Accumulator accumulator, int request, int code, String reason, HttpFields fields)
{ {
request &= 0xFF_FF; request &= 0xFF_FF;
@ -97,7 +97,7 @@ public class ServerGenerator extends Generator
generateContent(accumulator, request, byteBuffer, false, FCGI.FrameType.STDOUT); generateContent(accumulator, request, byteBuffer, false, FCGI.FrameType.STDOUT);
} }
public void generateResponseContent(RetainableByteBufferPool.Accumulator accumulator, int request, ByteBuffer content, boolean lastContent, boolean aborted) public void generateResponseContent(ByteBufferPool.Accumulator accumulator, int request, ByteBuffer content, boolean lastContent, boolean aborted)
{ {
if (aborted) if (aborted)
{ {
@ -117,7 +117,7 @@ public class ServerGenerator extends Generator
private RetainableByteBuffer generateEndRequest(int request, boolean aborted) private RetainableByteBuffer generateEndRequest(int request, boolean aborted)
{ {
request &= 0xFF_FF; request &= 0xFF_FF;
RetainableByteBuffer endRequestBuffer = getRetainableByteBufferPool().acquire(16, isUseDirectByteBuffers()); RetainableByteBuffer endRequestBuffer = getByteBufferPool().acquire(16, isUseDirectByteBuffers());
ByteBuffer byteBuffer = endRequestBuffer.getByteBuffer(); ByteBuffer byteBuffer = endRequestBuffer.getByteBuffer();
BufferUtil.clearToFill(byteBuffer); BufferUtil.clearToFill(byteBuffer);
byteBuffer.putInt(0x01_03_00_00 + request); byteBuffer.putInt(0x01_03_00_00 + request);

View File

@ -22,7 +22,7 @@ import org.eclipse.jetty.fcgi.parser.ServerParser;
import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -59,9 +59,9 @@ public class ClientGeneratorTest
String longLongValue = new String(chars); String longLongValue = new String(chars);
fields.put(new HttpField(longLongName, longLongValue)); fields.put(new HttpField(longLongName, longLongValue));
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ClientGenerator generator = new ClientGenerator(bufferPool); ClientGenerator generator = new ClientGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
int id = 13; int id = 13;
generator.generateRequestHeaders(accumulator, id, fields); generator.generateRequestHeaders(accumulator, id, fields);
@ -157,9 +157,9 @@ public class ClientGeneratorTest
{ {
ByteBuffer content = ByteBuffer.allocate(contentLength); ByteBuffer content = ByteBuffer.allocate(contentLength);
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ClientGenerator generator = new ClientGenerator(bufferPool); ClientGenerator generator = new ClientGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
int id = 13; int id = 13;
generator.generateRequestContent(accumulator, id, content, true); generator.generateRequestContent(accumulator, id, content, true);

View File

@ -23,7 +23,7 @@ import org.eclipse.jetty.fcgi.generator.ServerGenerator;
import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -44,9 +44,9 @@ public class ClientParserTest
String contentTypeValue = "text/html;charset=utf-8"; String contentTypeValue = "text/html;charset=utf-8";
fields.put(contentTypeName, contentTypeValue); fields.put(contentTypeName, contentTypeValue);
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ServerGenerator generator = new ServerGenerator(bufferPool); ServerGenerator generator = new ServerGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateResponseHeaders(accumulator, id, statusCode, statusMessage, fields); generator.generateResponseHeaders(accumulator, id, statusCode, statusMessage, fields);
// Use the fundamental theorem of arithmetic to test the results. // Use the fundamental theorem of arithmetic to test the results.
@ -108,9 +108,9 @@ public class ClientParserTest
HttpFields fields = HttpFields.build() HttpFields fields = HttpFields.build()
.put("Content-Length", "0"); .put("Content-Length", "0");
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ServerGenerator generator = new ServerGenerator(bufferPool); ServerGenerator generator = new ServerGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateResponseHeaders(accumulator, id, 200, "OK", fields); generator.generateResponseHeaders(accumulator, id, 200, "OK", fields);
generator.generateResponseContent(accumulator, id, null, true, false); generator.generateResponseContent(accumulator, id, null, true, false);
@ -158,9 +158,9 @@ public class ClientParserTest
String contentTypeValue = String.valueOf(contentLength); String contentTypeValue = String.valueOf(contentLength);
fields.put(contentTypeName, contentTypeValue); fields.put(contentTypeName, contentTypeValue);
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ServerGenerator generator = new ServerGenerator(bufferPool); ServerGenerator generator = new ServerGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateResponseHeaders(accumulator, id, code, "OK", fields); generator.generateResponseHeaders(accumulator, id, code, "OK", fields);
generator.generateResponseContent(accumulator, id, content, true, false); generator.generateResponseContent(accumulator, id, content, true, false);
@ -209,9 +209,9 @@ public class ClientParserTest
String contentTypeValue = String.valueOf(contentLength); String contentTypeValue = String.valueOf(contentLength);
fields.put(contentTypeName, contentTypeValue); fields.put(contentTypeName, contentTypeValue);
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
ServerGenerator generator = new ServerGenerator(bufferPool); ServerGenerator generator = new ServerGenerator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateResponseHeaders(accumulator, id, code, "OK", fields); generator.generateResponseHeaders(accumulator, id, code, "OK", fields);
generator.generateResponseContent(accumulator, id, content, true, false); generator.generateResponseContent(accumulator, id, content, true, false);

View File

@ -28,8 +28,8 @@ import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.http.MetaData; import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.HttpStream; import org.eclipse.jetty.server.HttpStream;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
@ -229,7 +229,7 @@ public class HttpStreamOverFCGI implements HttpStream
{ {
if (last) if (last)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generateResponseContent(accumulator, true, BufferUtil.EMPTY_BUFFER); generateResponseContent(accumulator, true, BufferUtil.EMPTY_BUFFER);
flusher.flush(accumulator, callback); flusher.flush(accumulator, callback);
} }
@ -241,7 +241,7 @@ public class HttpStreamOverFCGI implements HttpStream
} }
else else
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generateResponseContent(accumulator, last, content); generateResponseContent(accumulator, last, content);
flusher.flush(accumulator, callback); flusher.flush(accumulator, callback);
} }
@ -260,8 +260,8 @@ public class HttpStreamOverFCGI implements HttpStream
boolean shutdown = _shutdown = info.getFields().contains(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE.asString()); boolean shutdown = _shutdown = info.getFields().contains(HttpHeader.CONNECTION, HttpHeaderValue.CLOSE.asString());
RetainableByteBufferPool bufferPool = _generator.getRetainableByteBufferPool(); ByteBufferPool bufferPool = _generator.getByteBufferPool();
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
Flusher flusher = _connection.getFlusher(); Flusher flusher = _connection.getFlusher();
if (head) if (head)
{ {
@ -288,12 +288,12 @@ public class HttpStreamOverFCGI implements HttpStream
flusher.shutdown(); flusher.shutdown();
} }
private void generateResponseHeaders(RetainableByteBufferPool.Accumulator accumulator, MetaData.Response info) private void generateResponseHeaders(ByteBufferPool.Accumulator accumulator, MetaData.Response info)
{ {
_generator.generateResponseHeaders(accumulator, _id, info.getStatus(), info.getReason(), info.getFields()); _generator.generateResponseHeaders(accumulator, _id, info.getStatus(), info.getReason(), info.getFields());
} }
private void generateResponseContent(RetainableByteBufferPool.Accumulator accumulator, boolean last, ByteBuffer buffer) private void generateResponseContent(ByteBufferPool.Accumulator accumulator, boolean last, ByteBuffer buffer)
{ {
_generator.generateResponseContent(accumulator, _id, buffer, last, _aborted); _generator.generateResponseContent(accumulator, _id, buffer, last, _aborted);
} }

View File

@ -26,11 +26,11 @@ import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.ConnectionMetaData; import org.eclipse.jetty.server.ConnectionMetaData;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.HttpChannel;
@ -48,7 +48,7 @@ public class ServerFCGIConnection extends AbstractConnection implements Connecti
private final HttpChannel.Factory httpChannelFactory = new HttpChannel.DefaultFactory(); private final HttpChannel.Factory httpChannelFactory = new HttpChannel.DefaultFactory();
private final Attributes attributes = new Lazy(); private final Attributes attributes = new Lazy();
private final Connector connector; private final Connector connector;
private final RetainableByteBufferPool networkByteBufferPool; private final ByteBufferPool networkByteBufferPool;
private final boolean sendStatus200; private final boolean sendStatus200;
private final Flusher flusher; private final Flusher flusher;
private final HttpConfiguration configuration; private final HttpConfiguration configuration;
@ -63,7 +63,7 @@ public class ServerFCGIConnection extends AbstractConnection implements Connecti
{ {
super(endPoint, connector.getExecutor()); super(endPoint, connector.getExecutor());
this.connector = connector; this.connector = connector;
this.networkByteBufferPool = connector.getRetainableByteBufferPool(); this.networkByteBufferPool = connector.getByteBufferPool();
this.flusher = new Flusher(endPoint); this.flusher = new Flusher(endPoint);
this.configuration = configuration; this.configuration = configuration;
this.sendStatus200 = sendStatus200; this.sendStatus200 = sendStatus200;
@ -333,7 +333,7 @@ public class ServerFCGIConnection extends AbstractConnection implements Connecti
if (stream != null) if (stream != null)
throw new UnsupportedOperationException("FastCGI Multiplexing"); throw new UnsupportedOperationException("FastCGI Multiplexing");
HttpChannel channel = httpChannelFactory.newHttpChannel(ServerFCGIConnection.this); HttpChannel channel = httpChannelFactory.newHttpChannel(ServerFCGIConnection.this);
ServerGenerator generator = new ServerGenerator(connector.getRetainableByteBufferPool(), isUseOutputDirectByteBuffers(), sendStatus200); ServerGenerator generator = new ServerGenerator(connector.getByteBufferPool(), isUseOutputDirectByteBuffers(), sendStatus200);
stream = new HttpStreamOverFCGI(ServerFCGIConnection.this, generator, channel, request); stream = new HttpStreamOverFCGI(ServerFCGIConnection.this, generator, channel, request);
channel.setHttpStream(stream); channel.setHttpStream(stream);
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())

View File

@ -22,8 +22,8 @@ import org.eclipse.jetty.client.LeakTrackingConnectionPool;
import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI; import org.eclipse.jetty.fcgi.client.transport.HttpClientTransportOverFCGI;
import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
@ -38,8 +38,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
public abstract class AbstractHttpClientServerTest public abstract class AbstractHttpClientServerTest
{ {
private RetainableByteBufferPool serverBufferPool; private ByteBufferPool serverBufferPool;
protected RetainableByteBufferPool clientBufferPool; protected ByteBufferPool clientBufferPool;
private final AtomicLong connectionLeaks = new AtomicLong(); private final AtomicLong connectionLeaks = new AtomicLong();
protected Server server; protected Server server;
protected ServerConnector connector; protected ServerConnector connector;
@ -68,7 +68,7 @@ public abstract class AbstractHttpClientServerTest
// TODO: restore leak tracking. // TODO: restore leak tracking.
if (clientBufferPool == null) if (clientBufferPool == null)
clientBufferPool = new ArrayRetainableByteBufferPool(); clientBufferPool = new ArrayRetainableByteBufferPool();
clientConnector.setRetainableByteBufferPool(clientBufferPool); clientConnector.setByteBufferPool(clientBufferPool);
HttpClientTransport transport = new HttpClientTransportOverFCGI(clientConnector, ""); HttpClientTransport transport = new HttpClientTransportOverFCGI(clientConnector, "");
transport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination()) transport.setConnectionPoolFactory(destination -> new LeakTrackingConnectionPool(destination, client.getMaxConnectionsPerDestination())
{ {

View File

@ -20,8 +20,8 @@ import java.util.zip.DataFormatException;
import java.util.zip.Inflater; import java.util.zip.Inflater;
import java.util.zip.ZipException; import java.util.zip.ZipException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.component.Destroyable; import org.eclipse.jetty.util.component.Destroyable;
import org.eclipse.jetty.util.compression.InflaterPool; import org.eclipse.jetty.util.compression.InflaterPool;
@ -37,7 +37,7 @@ public class GZIPContentDecoder implements Destroyable
private static final long UINT_MAX = 0xFFFFFFFFL; private static final long UINT_MAX = 0xFFFFFFFFL;
private final List<RetainableByteBuffer> _inflateds = new ArrayList<>(); private final List<RetainableByteBuffer> _inflateds = new ArrayList<>();
private final RetainableByteBufferPool _pool; private final ByteBufferPool _pool;
private final int _bufferSize; private final int _bufferSize;
private InflaterPool.Entry _inflaterEntry; private InflaterPool.Entry _inflaterEntry;
private Inflater _inflater; private Inflater _inflater;
@ -57,17 +57,17 @@ public class GZIPContentDecoder implements Destroyable
this(null, bufferSize); this(null, bufferSize);
} }
public GZIPContentDecoder(RetainableByteBufferPool retainableByteBufferPool, int bufferSize) public GZIPContentDecoder(ByteBufferPool byteBufferPool, int bufferSize)
{ {
this(new InflaterPool(0, true), retainableByteBufferPool, bufferSize); this(new InflaterPool(0, true), byteBufferPool, bufferSize);
} }
public GZIPContentDecoder(InflaterPool inflaterPool, RetainableByteBufferPool retainableByteBufferPool, int bufferSize) public GZIPContentDecoder(InflaterPool inflaterPool, ByteBufferPool byteBufferPool, int bufferSize)
{ {
_inflaterEntry = inflaterPool.acquire(); _inflaterEntry = inflaterPool.acquire();
_inflater = _inflaterEntry.get(); _inflater = _inflaterEntry.get();
_bufferSize = bufferSize; _bufferSize = bufferSize;
_pool = retainableByteBufferPool != null ? retainableByteBufferPool : new RetainableByteBufferPool.NonPooling(); _pool = byteBufferPool != null ? byteBufferPool : new ByteBufferPool.NonPooling();
reset(); reset();
} }

View File

@ -30,9 +30,9 @@ import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.MimeTypes; import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.http.PreEncodedHttpField; import org.eclipse.jetty.http.PreEncodedHttpField;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Retainable; import org.eclipse.jetty.io.Retainable;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.NanoTime; import org.eclipse.jetty.util.NanoTime;
import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.StringUtil;
@ -69,16 +69,16 @@ public class CachingHttpContentFactory implements HttpContent.Factory
private final HttpContent.Factory _authority; private final HttpContent.Factory _authority;
private final ConcurrentHashMap<String, CachingHttpContent> _cache = new ConcurrentHashMap<>(); private final ConcurrentHashMap<String, CachingHttpContent> _cache = new ConcurrentHashMap<>();
private final AtomicLong _cachedSize = new AtomicLong(); private final AtomicLong _cachedSize = new AtomicLong();
private final RetainableByteBufferPool _bufferPool; private final ByteBufferPool _bufferPool;
private int _maxCachedFileSize = DEFAULT_MAX_CACHED_FILE_SIZE; private int _maxCachedFileSize = DEFAULT_MAX_CACHED_FILE_SIZE;
private int _maxCachedFiles = DEFAULT_MAX_CACHED_FILES; private int _maxCachedFiles = DEFAULT_MAX_CACHED_FILES;
private long _maxCacheSize = DEFAULT_MAX_CACHE_SIZE; private long _maxCacheSize = DEFAULT_MAX_CACHE_SIZE;
private boolean _useDirectByteBuffers = true; private boolean _useDirectByteBuffers = true;
public CachingHttpContentFactory(HttpContent.Factory authority, RetainableByteBufferPool bufferPool) public CachingHttpContentFactory(HttpContent.Factory authority, ByteBufferPool bufferPool)
{ {
_authority = authority; _authority = authority;
_bufferPool = bufferPool != null ? bufferPool : new RetainableByteBufferPool.NonPooling(); _bufferPool = bufferPool != null ? bufferPool : new ByteBufferPool.NonPooling();
} }
protected ConcurrentMap<String, CachingHttpContent> getCache() protected ConcurrentMap<String, CachingHttpContent> getCache()

View File

@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.NanoTime; import org.eclipse.jetty.util.NanoTime;
import org.eclipse.jetty.util.annotation.Name; import org.eclipse.jetty.util.annotation.Name;
import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.util.thread.Scheduler;
@ -55,11 +55,11 @@ public class ValidatingCachingHttpContentFactory extends CachingHttpContentFacto
* *
* @param authority the wrapped {@link HttpContent.Factory} to use. * @param authority the wrapped {@link HttpContent.Factory} to use.
* @param validationPeriod time between filesystem checks in ms to see if an {@link HttpContent} is still valid (-1 never validate, 0 always validate). * @param validationPeriod time between filesystem checks in ms to see if an {@link HttpContent} is still valid (-1 never validate, 0 always validate).
* @param bufferPool the {@link org.eclipse.jetty.io.RetainableByteBufferPool} to use. * @param bufferPool the {@link org.eclipse.jetty.io.ByteBufferPool} to use.
*/ */
public ValidatingCachingHttpContentFactory(@Name("authority") HttpContent.Factory authority, public ValidatingCachingHttpContentFactory(@Name("authority") HttpContent.Factory authority,
@Name("validationPeriod") long validationPeriod, @Name("validationPeriod") long validationPeriod,
@Name("bufferPool") RetainableByteBufferPool bufferPool) @Name("bufferPool") ByteBufferPool bufferPool)
{ {
this(authority, validationPeriod, bufferPool, null, -1, -1); this(authority, validationPeriod, bufferPool, null, -1, -1);
} }
@ -70,14 +70,14 @@ public class ValidatingCachingHttpContentFactory extends CachingHttpContentFacto
* *
* @param authority the wrapped {@link HttpContent.Factory} to use. * @param authority the wrapped {@link HttpContent.Factory} to use.
* @param validationPeriod time between filesystem checks in ms to see if an {@link HttpContent} is still valid (-1 never validate, 0 always validate). * @param validationPeriod time between filesystem checks in ms to see if an {@link HttpContent} is still valid (-1 never validate, 0 always validate).
* @param bufferPool the {@link org.eclipse.jetty.io.RetainableByteBufferPool} to use. * @param bufferPool the {@link org.eclipse.jetty.io.ByteBufferPool} to use.
* @param scheduler scheduler to use for the sweeper, can be null to not use sweeper. * @param scheduler scheduler to use for the sweeper, can be null to not use sweeper.
* @param sweepPeriod time between runs of the sweeper in ms (if 0 never sweep for invalid entries). * @param sweepPeriod time between runs of the sweeper in ms (if 0 never sweep for invalid entries).
* @param idleTimeout amount of time in ms an entry can be unused before evicted by the sweeper (if 0 never evict unused entries). * @param idleTimeout amount of time in ms an entry can be unused before evicted by the sweeper (if 0 never evict unused entries).
*/ */
public ValidatingCachingHttpContentFactory(@Name("authority") HttpContent.Factory authority, public ValidatingCachingHttpContentFactory(@Name("authority") HttpContent.Factory authority,
@Name("validationPeriod") long validationPeriod, @Name("validationPeriod") long validationPeriod,
@Name("byteBufferPool") RetainableByteBufferPool bufferPool, @Name("byteBufferPool") ByteBufferPool bufferPool,
@Name("scheduler") Scheduler scheduler, @Name("scheduler") Scheduler scheduler,
@Name("sweepPeriod") long sweepPeriod, @Name("sweepPeriod") long sweepPeriod,
@Name("idleTimeout") long idleTimeout) @Name("idleTimeout") long idleTimeout)

View File

@ -24,8 +24,8 @@ import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -42,12 +42,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class GZIPContentDecoderTest public class GZIPContentDecoderTest
{ {
private final AtomicInteger counter = new AtomicInteger(); private final AtomicInteger counter = new AtomicInteger();
private RetainableByteBufferPool pool; private ByteBufferPool pool;
@BeforeEach @BeforeEach
public void before() public void before()
{ {
pool = new RetainableByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool()) pool = new ByteBufferPool.Wrapper(new ArrayRetainableByteBufferPool())
{ {
@Override @Override
public RetainableByteBuffer acquire(int size, boolean direct) public RetainableByteBuffer acquire(int size, boolean direct)

View File

@ -90,7 +90,7 @@ public class HttpClientTransportOverHTTP2 extends AbstractHttpClientTransport
HttpClient httpClient = getHttpClient(); HttpClient httpClient = getHttpClient();
client.setExecutor(httpClient.getExecutor()); client.setExecutor(httpClient.getExecutor());
client.setScheduler(httpClient.getScheduler()); client.setScheduler(httpClient.getScheduler());
client.setRetainableByteBufferPool(httpClient.getRetainableByteBufferPool()); client.setByteBufferPool(httpClient.getByteBufferPool());
client.setConnectTimeout(httpClient.getConnectTimeout()); client.setConnectTimeout(httpClient.getConnectTimeout());
client.setIdleTimeout(httpClient.getIdleTimeout()); client.setIdleTimeout(httpClient.getIdleTimeout());
client.setInputBufferSize(httpClient.getResponseBufferSize()); client.setInputBufferSize(httpClient.getResponseBufferSize());

View File

@ -28,9 +28,9 @@ import org.eclipse.jetty.http2.FlowControlStrategy;
import org.eclipse.jetty.http2.api.Session; import org.eclipse.jetty.http2.api.Session;
import org.eclipse.jetty.http2.frames.Frame; import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.SettingsFrame; import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory; import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslClientConnectionFactory; import org.eclipse.jetty.io.ssl.SslClientConnectionFactory;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedAttribute;
@ -153,14 +153,14 @@ public class HTTP2Client extends ContainerLifeCycle
connector.setScheduler(scheduler); connector.setScheduler(scheduler);
} }
public RetainableByteBufferPool getRetainableByteBufferPool() public ByteBufferPool getByteBufferPool()
{ {
return connector.getRetainableByteBufferPool(); return connector.getByteBufferPool();
} }
public void setRetainableByteBufferPool(RetainableByteBufferPool bufferPool) public void setByteBufferPool(ByteBufferPool bufferPool)
{ {
connector.setRetainableByteBufferPool(bufferPool); connector.setByteBufferPool(bufferPool);
} }
public FlowControlStrategy.Factory getFlowControlStrategyFactory() public FlowControlStrategy.Factory getFlowControlStrategyFactory()
@ -435,7 +435,7 @@ public class HTTP2Client extends ContainerLifeCycle
{ {
if (isUseALPN()) if (isUseALPN())
factory = new ALPNClientConnectionFactory(getExecutor(), factory, getProtocols()); factory = new ALPNClientConnectionFactory(getExecutor(), factory, getProtocols());
factory = new SslClientConnectionFactory(sslContextFactory, getRetainableByteBufferPool(), getExecutor(), factory); factory = new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), factory);
} }
return factory; return factory;
} }

View File

@ -28,10 +28,10 @@ import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame; import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.http2.generator.Generator; import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnectionFactory; import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.thread.Scheduler; import org.eclipse.jetty.util.thread.Scheduler;
@ -48,7 +48,7 @@ public class HTTP2ClientConnectionFactory implements ClientConnectionFactory
public Connection newConnection(EndPoint endPoint, Map<String, Object> context) public Connection newConnection(EndPoint endPoint, Map<String, Object> context)
{ {
HTTP2Client client = (HTTP2Client)context.get(CLIENT_CONTEXT_KEY); HTTP2Client client = (HTTP2Client)context.get(CLIENT_CONTEXT_KEY);
RetainableByteBufferPool bufferPool = client.getRetainableByteBufferPool(); ByteBufferPool bufferPool = client.getByteBufferPool();
Executor executor = client.getExecutor(); Executor executor = client.getExecutor();
Scheduler scheduler = client.getScheduler(); Scheduler scheduler = client.getScheduler();
Session.Listener listener = (Session.Listener)context.get(SESSION_LISTENER_CONTEXT_KEY); Session.Listener listener = (Session.Listener)context.get(SESSION_LISTENER_CONTEXT_KEY);
@ -81,9 +81,9 @@ public class HTTP2ClientConnectionFactory implements ClientConnectionFactory
private final Promise<Session> promise; private final Promise<Session> promise;
private final Session.Listener listener; private final Session.Listener listener;
private HTTP2ClientConnection(HTTP2Client client, RetainableByteBufferPool retainableByteBufferPool, Executor executor, EndPoint endpoint, Parser parser, HTTP2Session session, int bufferSize, Promise<Session> promise, Session.Listener listener) private HTTP2ClientConnection(HTTP2Client client, ByteBufferPool byteBufferPool, Executor executor, EndPoint endpoint, Parser parser, HTTP2Session session, int bufferSize, Promise<Session> promise, Session.Listener listener)
{ {
super(retainableByteBufferPool, executor, endpoint, parser, session, bufferSize); super(byteBufferPool, executor, endpoint, parser, session, bufferSize);
this.client = client; this.client = client;
this.promise = promise; this.promise = promise;
this.listener = listener; this.listener = listener;

View File

@ -24,11 +24,11 @@ import org.eclipse.jetty.http2.api.Stream;
import org.eclipse.jetty.http2.frames.DataFrame; import org.eclipse.jetty.http2.frames.DataFrame;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.Retainable; import org.eclipse.jetty.io.Retainable;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.WriteFlusher; import org.eclipse.jetty.io.WriteFlusher;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
@ -47,7 +47,7 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
private final Queue<Runnable> tasks = new ArrayDeque<>(); private final Queue<Runnable> tasks = new ArrayDeque<>();
private final HTTP2Producer producer = new HTTP2Producer(); private final HTTP2Producer producer = new HTTP2Producer();
private final AtomicLong bytesIn = new AtomicLong(); private final AtomicLong bytesIn = new AtomicLong();
private final RetainableByteBufferPool retainableByteBufferPool; private final ByteBufferPool byteBufferPool;
private final Parser parser; private final Parser parser;
private final HTTP2Session session; private final HTTP2Session session;
private final int bufferSize; private final int bufferSize;
@ -55,10 +55,10 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
private boolean useInputDirectByteBuffers; private boolean useInputDirectByteBuffers;
private boolean useOutputDirectByteBuffers; private boolean useOutputDirectByteBuffers;
protected HTTP2Connection(RetainableByteBufferPool retainableByteBufferPool, Executor executor, EndPoint endPoint, Parser parser, HTTP2Session session, int bufferSize) protected HTTP2Connection(ByteBufferPool byteBufferPool, Executor executor, EndPoint endPoint, Parser parser, HTTP2Session session, int bufferSize)
{ {
super(endPoint, executor); super(endPoint, executor);
this.retainableByteBufferPool = retainableByteBufferPool; this.byteBufferPool = byteBufferPool;
this.parser = parser; this.parser = parser;
this.session = session; this.session = session;
this.bufferSize = bufferSize; this.bufferSize = bufferSize;
@ -450,7 +450,7 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
private NetworkBuffer() private NetworkBuffer()
{ {
delegate = retainableByteBufferPool.acquire(bufferSize, isUseInputDirectByteBuffers()); delegate = byteBufferPool.acquire(bufferSize, isUseInputDirectByteBuffers());
} }
public ByteBuffer getBuffer() public ByteBuffer getBuffer()

View File

@ -56,9 +56,9 @@ import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.hpack.HpackException; import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.http2.internal.HTTP2Flusher; import org.eclipse.jetty.http2.internal.HTTP2Flusher;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.CyclicTimeouts; import org.eclipse.jetty.io.CyclicTimeouts;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.WriteFlusher; import org.eclipse.jetty.io.WriteFlusher;
import org.eclipse.jetty.util.AtomicBiInteger; import org.eclipse.jetty.util.AtomicBiInteger;
import org.eclipse.jetty.util.Atomics; import org.eclipse.jetty.util.Atomics;
@ -1208,7 +1208,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements Session
return 0; return 0;
} }
public abstract boolean generate(RetainableByteBufferPool.Accumulator accumulator) throws HpackException; public abstract boolean generate(ByteBufferPool.Accumulator accumulator) throws HpackException;
public abstract long onFlushed(long bytes) throws IOException; public abstract long onFlushed(long bytes) throws IOException;
@ -1295,7 +1295,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements Session
} }
@Override @Override
public boolean generate(RetainableByteBufferPool.Accumulator accumulator) throws HpackException public boolean generate(ByteBufferPool.Accumulator accumulator) throws HpackException
{ {
frameBytes = generator.control(accumulator, frame); frameBytes = generator.control(accumulator, frame);
beforeSend(); beforeSend();
@ -1409,7 +1409,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements Session
} }
@Override @Override
public boolean generate(RetainableByteBufferPool.Accumulator accumulator) public boolean generate(ByteBufferPool.Accumulator accumulator)
{ {
int dataRemaining = getDataBytesRemaining(); int dataRemaining = getDataBytesRemaining();

View File

@ -19,8 +19,8 @@ import org.eclipse.jetty.http2.frames.DataFrame;
import org.eclipse.jetty.http2.frames.Frame; import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class DataGenerator public class DataGenerator
@ -32,12 +32,12 @@ public class DataGenerator
this.headerGenerator = headerGenerator; this.headerGenerator = headerGenerator;
} }
public int generate(RetainableByteBufferPool.Accumulator accumulator, DataFrame frame, int maxLength) public int generate(ByteBufferPool.Accumulator accumulator, DataFrame frame, int maxLength)
{ {
return generateData(accumulator, frame.getStreamId(), frame.getByteBuffer(), frame.isEndStream(), maxLength); return generateData(accumulator, frame.getStreamId(), frame.getByteBuffer(), frame.isEndStream(), maxLength);
} }
public int generateData(RetainableByteBufferPool.Accumulator accumulator, int streamId, ByteBuffer data, boolean last, int maxLength) public int generateData(ByteBufferPool.Accumulator accumulator, int streamId, ByteBuffer data, boolean last, int maxLength)
{ {
if (streamId < 0) if (streamId < 0)
throw new IllegalArgumentException("Invalid stream id: " + streamId); throw new IllegalArgumentException("Invalid stream id: " + streamId);
@ -62,7 +62,7 @@ public class DataGenerator
return Frame.HEADER_LENGTH + length; return Frame.HEADER_LENGTH + length;
} }
private void generateFrame(RetainableByteBufferPool.Accumulator accumulator, int streamId, ByteBuffer data, boolean last) private void generateFrame(ByteBufferPool.Accumulator accumulator, int streamId, ByteBuffer data, boolean last)
{ {
int length = data.remaining(); int length = data.remaining();

View File

@ -20,8 +20,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.hpack.HpackEncoder; import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.hpack.HpackException; import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public abstract class FrameGenerator public abstract class FrameGenerator
@ -33,7 +33,7 @@ public abstract class FrameGenerator
this.headerGenerator = headerGenerator; this.headerGenerator = headerGenerator;
} }
public abstract int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException; public abstract int generate(ByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException;
protected RetainableByteBuffer generateHeader(FrameType frameType, int length, int flags, int streamId) protected RetainableByteBuffer generateHeader(FrameType frameType, int length, int flags, int streamId)
{ {
@ -52,7 +52,7 @@ public abstract class FrameGenerator
protected RetainableByteBuffer encode(HpackEncoder encoder, MetaData metaData, int maxFrameSize) throws HpackException protected RetainableByteBuffer encode(HpackEncoder encoder, MetaData metaData, int maxFrameSize) throws HpackException
{ {
RetainableByteBuffer hpacked = headerGenerator.getRetainableByteBufferPool().acquire(maxFrameSize, isUseDirectByteBuffers()); RetainableByteBuffer hpacked = headerGenerator.getByteBufferPool().acquire(maxFrameSize, isUseDirectByteBuffers());
try try
{ {
ByteBuffer byteBuffer = hpacked.getByteBuffer(); ByteBuffer byteBuffer = hpacked.getByteBuffer();

View File

@ -18,27 +18,27 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.hpack.HpackEncoder; import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.hpack.HpackException; import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
public class Generator public class Generator
{ {
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private final HeaderGenerator headerGenerator; private final HeaderGenerator headerGenerator;
private final HpackEncoder hpackEncoder; private final HpackEncoder hpackEncoder;
private final FrameGenerator[] generators; private final FrameGenerator[] generators;
private final DataGenerator dataGenerator; private final DataGenerator dataGenerator;
public Generator(RetainableByteBufferPool bufferPool) public Generator(ByteBufferPool bufferPool)
{ {
this(bufferPool, 4096, 0); this(bufferPool, 4096, 0);
} }
public Generator(RetainableByteBufferPool bufferPool, int maxDynamicTableSize, int maxHeaderBlockFragment) public Generator(ByteBufferPool bufferPool, int maxDynamicTableSize, int maxHeaderBlockFragment)
{ {
this(bufferPool, true, maxDynamicTableSize, maxHeaderBlockFragment); this(bufferPool, true, maxDynamicTableSize, maxHeaderBlockFragment);
} }
public Generator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers, int maxDynamicTableSize, int maxHeaderBlockFragment) public Generator(ByteBufferPool bufferPool, boolean useDirectByteBuffers, int maxDynamicTableSize, int maxHeaderBlockFragment)
{ {
this.bufferPool = bufferPool; this.bufferPool = bufferPool;
@ -61,7 +61,7 @@ public class Generator
this.dataGenerator = new DataGenerator(headerGenerator); this.dataGenerator = new DataGenerator(headerGenerator);
} }
public RetainableByteBufferPool getRetainableByteBufferPool() public ByteBufferPool getByteBufferPool()
{ {
return bufferPool; return bufferPool;
} }
@ -81,12 +81,12 @@ public class Generator
headerGenerator.setMaxFrameSize(maxFrameSize); headerGenerator.setMaxFrameSize(maxFrameSize);
} }
public int control(RetainableByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException public int control(ByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException
{ {
return generators[frame.getType().getType()].generate(accumulator, frame); return generators[frame.getType().getType()].generate(accumulator, frame);
} }
public int data(RetainableByteBufferPool.Accumulator accumulator, DataFrame frame, int maxLength) public int data(ByteBufferPool.Accumulator accumulator, DataFrame frame, int maxLength)
{ {
return dataGenerator.generate(accumulator, frame, maxLength); return dataGenerator.generate(accumulator, frame, maxLength);
} }

View File

@ -20,8 +20,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.GoAwayFrame; import org.eclipse.jetty.http2.frames.GoAwayFrame;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class GoAwayGenerator extends FrameGenerator public class GoAwayGenerator extends FrameGenerator
@ -32,13 +32,13 @@ public class GoAwayGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{ {
GoAwayFrame goAwayFrame = (GoAwayFrame)frame; GoAwayFrame goAwayFrame = (GoAwayFrame)frame;
return generateGoAway(accumulator, goAwayFrame.getLastStreamId(), goAwayFrame.getError(), goAwayFrame.getPayload()); return generateGoAway(accumulator, goAwayFrame.getLastStreamId(), goAwayFrame.getError(), goAwayFrame.getPayload());
} }
public int generateGoAway(RetainableByteBufferPool.Accumulator accumulator, int lastStreamId, int error, byte[] payload) public int generateGoAway(ByteBufferPool.Accumulator accumulator, int lastStreamId, int error, byte[] payload)
{ {
if (lastStreamId < 0) if (lastStreamId < 0)
lastStreamId = 0; lastStreamId = 0;

View File

@ -17,28 +17,28 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.http2.frames.Frame; import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class HeaderGenerator public class HeaderGenerator
{ {
private int maxFrameSize = Frame.DEFAULT_MAX_LENGTH; private int maxFrameSize = Frame.DEFAULT_MAX_LENGTH;
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private final boolean useDirectByteBuffers; private final boolean useDirectByteBuffers;
public HeaderGenerator(RetainableByteBufferPool bufferPool) public HeaderGenerator(ByteBufferPool bufferPool)
{ {
this(bufferPool, true); this(bufferPool, true);
} }
public HeaderGenerator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers) public HeaderGenerator(ByteBufferPool bufferPool, boolean useDirectByteBuffers)
{ {
this.bufferPool = bufferPool; this.bufferPool = bufferPool;
this.useDirectByteBuffers = useDirectByteBuffers; this.useDirectByteBuffers = useDirectByteBuffers;
} }
public RetainableByteBufferPool getRetainableByteBufferPool() public ByteBufferPool getByteBufferPool()
{ {
return bufferPool; return bufferPool;
} }
@ -50,7 +50,7 @@ public class HeaderGenerator
public RetainableByteBuffer generate(FrameType frameType, int capacity, int length, int flags, int streamId) public RetainableByteBuffer generate(FrameType frameType, int capacity, int length, int flags, int streamId)
{ {
RetainableByteBuffer buffer = getRetainableByteBufferPool().acquire(capacity, isUseDirectByteBuffers()); RetainableByteBuffer buffer = getByteBufferPool().acquire(capacity, isUseDirectByteBuffers());
ByteBuffer header = buffer.getByteBuffer(); ByteBuffer header = buffer.getByteBuffer();
BufferUtil.clearToFill(header); BufferUtil.clearToFill(header);
header.put((byte)((length & 0x00_FF_00_00) >>> 16)); header.put((byte)((length & 0x00_FF_00_00) >>> 16));

View File

@ -23,8 +23,8 @@ import org.eclipse.jetty.http2.frames.PriorityFrame;
import org.eclipse.jetty.http2.hpack.HpackEncoder; import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.hpack.HpackException; import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class HeadersGenerator extends FrameGenerator public class HeadersGenerator extends FrameGenerator
@ -47,13 +47,13 @@ public class HeadersGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException public int generate(ByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException
{ {
HeadersFrame headersFrame = (HeadersFrame)frame; HeadersFrame headersFrame = (HeadersFrame)frame;
return generateHeaders(accumulator, headersFrame.getStreamId(), headersFrame.getMetaData(), headersFrame.getPriority(), headersFrame.isEndStream()); return generateHeaders(accumulator, headersFrame.getStreamId(), headersFrame.getMetaData(), headersFrame.getPriority(), headersFrame.isEndStream());
} }
public int generateHeaders(RetainableByteBufferPool.Accumulator accumulator, int streamId, MetaData metaData, PriorityFrame priority, boolean endStream) throws HpackException public int generateHeaders(ByteBufferPool.Accumulator accumulator, int streamId, MetaData metaData, PriorityFrame priority, boolean endStream) throws HpackException
{ {
if (streamId < 0) if (streamId < 0)
throw new IllegalArgumentException("Invalid stream id: " + streamId); throw new IllegalArgumentException("Invalid stream id: " + streamId);

View File

@ -14,7 +14,7 @@
package org.eclipse.jetty.http2.generator; package org.eclipse.jetty.http2.generator;
import org.eclipse.jetty.http2.frames.Frame; import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
public class NoOpGenerator extends FrameGenerator public class NoOpGenerator extends FrameGenerator
{ {
@ -24,7 +24,7 @@ public class NoOpGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{ {
return 0; return 0;
} }

View File

@ -19,8 +19,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.PingFrame; import org.eclipse.jetty.http2.frames.PingFrame;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class PingGenerator extends FrameGenerator public class PingGenerator extends FrameGenerator
@ -31,13 +31,13 @@ public class PingGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{ {
PingFrame pingFrame = (PingFrame)frame; PingFrame pingFrame = (PingFrame)frame;
return generatePing(accumulator, pingFrame.getPayload(), pingFrame.isReply()); return generatePing(accumulator, pingFrame.getPayload(), pingFrame.isReply());
} }
public int generatePing(RetainableByteBufferPool.Accumulator accumulator, byte[] payload, boolean reply) public int generatePing(ByteBufferPool.Accumulator accumulator, byte[] payload, boolean reply)
{ {
if (payload.length != PingFrame.PING_LENGTH) if (payload.length != PingFrame.PING_LENGTH)
throw new IllegalArgumentException("Invalid payload length: " + payload.length); throw new IllegalArgumentException("Invalid payload length: " + payload.length);

View File

@ -17,8 +17,8 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.http2.frames.Frame; import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.PrefaceFrame; import org.eclipse.jetty.http2.frames.PrefaceFrame;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
public class PrefaceGenerator extends FrameGenerator public class PrefaceGenerator extends FrameGenerator
{ {
@ -28,7 +28,7 @@ public class PrefaceGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{ {
accumulator.append(RetainableByteBuffer.wrap(ByteBuffer.wrap(PrefaceFrame.PREFACE_BYTES))); accumulator.append(RetainableByteBuffer.wrap(ByteBuffer.wrap(PrefaceFrame.PREFACE_BYTES)));
return PrefaceFrame.PREFACE_BYTES.length; return PrefaceFrame.PREFACE_BYTES.length;

View File

@ -19,8 +19,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.PriorityFrame; import org.eclipse.jetty.http2.frames.PriorityFrame;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class PriorityGenerator extends FrameGenerator public class PriorityGenerator extends FrameGenerator
@ -31,13 +31,13 @@ public class PriorityGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{ {
PriorityFrame priorityFrame = (PriorityFrame)frame; PriorityFrame priorityFrame = (PriorityFrame)frame;
return generatePriority(accumulator, priorityFrame.getStreamId(), priorityFrame.getParentStreamId(), priorityFrame.getWeight(), priorityFrame.isExclusive()); return generatePriority(accumulator, priorityFrame.getStreamId(), priorityFrame.getParentStreamId(), priorityFrame.getWeight(), priorityFrame.isExclusive());
} }
public int generatePriority(RetainableByteBufferPool.Accumulator accumulator, int streamId, int parentStreamId, int weight, boolean exclusive) public int generatePriority(ByteBufferPool.Accumulator accumulator, int streamId, int parentStreamId, int weight, boolean exclusive)
{ {
RetainableByteBuffer header = generateHeader(FrameType.PRIORITY, PriorityFrame.PRIORITY_LENGTH, Flags.NONE, streamId); RetainableByteBuffer header = generateHeader(FrameType.PRIORITY, PriorityFrame.PRIORITY_LENGTH, Flags.NONE, streamId);
ByteBuffer byteBuffer = header.getByteBuffer(); ByteBuffer byteBuffer = header.getByteBuffer();

View File

@ -22,8 +22,8 @@ import org.eclipse.jetty.http2.frames.PushPromiseFrame;
import org.eclipse.jetty.http2.hpack.HpackEncoder; import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.hpack.HpackException; import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class PushPromiseGenerator extends FrameGenerator public class PushPromiseGenerator extends FrameGenerator
@ -37,13 +37,13 @@ public class PushPromiseGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException public int generate(ByteBufferPool.Accumulator accumulator, Frame frame) throws HpackException
{ {
PushPromiseFrame pushPromiseFrame = (PushPromiseFrame)frame; PushPromiseFrame pushPromiseFrame = (PushPromiseFrame)frame;
return generatePushPromise(accumulator, pushPromiseFrame.getStreamId(), pushPromiseFrame.getPromisedStreamId(), pushPromiseFrame.getMetaData()); return generatePushPromise(accumulator, pushPromiseFrame.getStreamId(), pushPromiseFrame.getPromisedStreamId(), pushPromiseFrame.getMetaData());
} }
public int generatePushPromise(RetainableByteBufferPool.Accumulator accumulator, int streamId, int promisedStreamId, MetaData metaData) throws HpackException public int generatePushPromise(ByteBufferPool.Accumulator accumulator, int streamId, int promisedStreamId, MetaData metaData) throws HpackException
{ {
if (streamId < 0) if (streamId < 0)
throw new IllegalArgumentException("Invalid stream id: " + streamId); throw new IllegalArgumentException("Invalid stream id: " + streamId);

View File

@ -19,8 +19,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.ResetFrame; import org.eclipse.jetty.http2.frames.ResetFrame;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class ResetGenerator extends FrameGenerator public class ResetGenerator extends FrameGenerator
@ -31,13 +31,13 @@ public class ResetGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{ {
ResetFrame resetFrame = (ResetFrame)frame; ResetFrame resetFrame = (ResetFrame)frame;
return generateReset(accumulator, resetFrame.getStreamId(), resetFrame.getError()); return generateReset(accumulator, resetFrame.getStreamId(), resetFrame.getError());
} }
public int generateReset(RetainableByteBufferPool.Accumulator accumulator, int streamId, int error) public int generateReset(ByteBufferPool.Accumulator accumulator, int streamId, int error)
{ {
if (streamId < 0) if (streamId < 0)
throw new IllegalArgumentException("Invalid stream id: " + streamId); throw new IllegalArgumentException("Invalid stream id: " + streamId);

View File

@ -20,8 +20,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.SettingsFrame; import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class SettingsGenerator extends FrameGenerator public class SettingsGenerator extends FrameGenerator
@ -32,13 +32,13 @@ public class SettingsGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{ {
SettingsFrame settingsFrame = (SettingsFrame)frame; SettingsFrame settingsFrame = (SettingsFrame)frame;
return generateSettings(accumulator, settingsFrame.getSettings(), settingsFrame.isReply()); return generateSettings(accumulator, settingsFrame.getSettings(), settingsFrame.isReply());
} }
public int generateSettings(RetainableByteBufferPool.Accumulator accumulator, Map<Integer, Integer> settings, boolean reply) public int generateSettings(ByteBufferPool.Accumulator accumulator, Map<Integer, Integer> settings, boolean reply)
{ {
// Two bytes for the identifier, four bytes for the value. // Two bytes for the identifier, four bytes for the value.
int entryLength = 2 + 4; int entryLength = 2 + 4;

View File

@ -19,8 +19,8 @@ import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame; import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class WindowUpdateGenerator extends FrameGenerator public class WindowUpdateGenerator extends FrameGenerator
@ -31,13 +31,13 @@ public class WindowUpdateGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, Frame frame) public int generate(ByteBufferPool.Accumulator accumulator, Frame frame)
{ {
WindowUpdateFrame windowUpdateFrame = (WindowUpdateFrame)frame; WindowUpdateFrame windowUpdateFrame = (WindowUpdateFrame)frame;
return generateWindowUpdate(accumulator, windowUpdateFrame.getStreamId(), windowUpdateFrame.getWindowDelta()); return generateWindowUpdate(accumulator, windowUpdateFrame.getStreamId(), windowUpdateFrame.getWindowDelta());
} }
public int generateWindowUpdate(RetainableByteBufferPool.Accumulator accumulator, int streamId, int windowUpdate) public int generateWindowUpdate(ByteBufferPool.Accumulator accumulator, int streamId, int windowUpdate)
{ {
if (windowUpdate < 0) if (windowUpdate < 0)
throw new IllegalArgumentException("Invalid window update: " + windowUpdate); throw new IllegalArgumentException("Invalid window update: " + windowUpdate);

View File

@ -30,8 +30,8 @@ import org.eclipse.jetty.http2.HTTP2Session;
import org.eclipse.jetty.http2.HTTP2Stream; import org.eclipse.jetty.http2.HTTP2Stream;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame; import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.http2.hpack.HpackException; import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.EofException;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.IteratingCallback; import org.eclipse.jetty.util.IteratingCallback;
import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.thread.AutoLock; import org.eclipse.jetty.util.thread.AutoLock;
@ -50,7 +50,7 @@ public class HTTP2Flusher extends IteratingCallback implements Dumpable
private final Queue<HTTP2Session.Entry> pendingEntries = new ArrayDeque<>(); private final Queue<HTTP2Session.Entry> pendingEntries = new ArrayDeque<>();
private final Collection<HTTP2Session.Entry> processedEntries = new ArrayList<>(); private final Collection<HTTP2Session.Entry> processedEntries = new ArrayList<>();
private final HTTP2Session session; private final HTTP2Session session;
private final RetainableByteBufferPool.Accumulator accumulator; private final ByteBufferPool.Accumulator accumulator;
private InvocationType invocationType = InvocationType.NON_BLOCKING; private InvocationType invocationType = InvocationType.NON_BLOCKING;
private Throwable terminated; private Throwable terminated;
private HTTP2Session.Entry stalledEntry; private HTTP2Session.Entry stalledEntry;
@ -58,7 +58,7 @@ public class HTTP2Flusher extends IteratingCallback implements Dumpable
public HTTP2Flusher(HTTP2Session session) public HTTP2Flusher(HTTP2Session session)
{ {
this.session = session; this.session = session;
this.accumulator = new RetainableByteBufferPool.Accumulator(); this.accumulator = new ByteBufferPool.Accumulator();
} }
@Override @Override

View File

@ -16,19 +16,19 @@ package org.eclipse.jetty.http2.parser;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import org.eclipse.jetty.http2.frames.PriorityFrame; import org.eclipse.jetty.http2.frames.PriorityFrame;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class HeaderBlockFragments public class HeaderBlockFragments
{ {
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private PriorityFrame priorityFrame; private PriorityFrame priorityFrame;
private boolean endStream; private boolean endStream;
private int streamId; private int streamId;
private RetainableByteBuffer storage; private RetainableByteBuffer storage;
public HeaderBlockFragments(RetainableByteBufferPool bufferPool) public HeaderBlockFragments(ByteBufferPool bufferPool)
{ {
this.bufferPool = bufferPool; this.bufferPool = bufferPool;
} }

View File

@ -20,8 +20,8 @@ import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http2.ErrorCode; import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.hpack.HpackDecoder; import org.eclipse.jetty.http2.hpack.HpackDecoder;
import org.eclipse.jetty.http2.hpack.HpackException; import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -33,12 +33,12 @@ public class HeaderBlockParser
private static final Logger LOG = LoggerFactory.getLogger(HeaderBlockParser.class); private static final Logger LOG = LoggerFactory.getLogger(HeaderBlockParser.class);
private final HeaderParser headerParser; private final HeaderParser headerParser;
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private final HpackDecoder hpackDecoder; private final HpackDecoder hpackDecoder;
private final BodyParser notifier; private final BodyParser notifier;
private RetainableByteBuffer blockBuffer; private RetainableByteBuffer blockBuffer;
public HeaderBlockParser(HeaderParser headerParser, RetainableByteBufferPool bufferPool, HpackDecoder hpackDecoder, BodyParser notifier) public HeaderBlockParser(HeaderParser headerParser, ByteBufferPool bufferPool, HpackDecoder hpackDecoder, BodyParser notifier)
{ {
this.headerParser = headerParser; this.headerParser = headerParser;
this.bufferPool = bufferPool; this.bufferPool = bufferPool;

View File

@ -31,7 +31,7 @@ import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame; import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.http2.hpack.HpackDecoder; import org.eclipse.jetty.http2.hpack.HpackDecoder;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -44,7 +44,7 @@ public class Parser
{ {
private static final Logger LOG = LoggerFactory.getLogger(Parser.class); private static final Logger LOG = LoggerFactory.getLogger(Parser.class);
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private final Listener listener; private final Listener listener;
private final HeaderParser headerParser; private final HeaderParser headerParser;
private final HpackDecoder hpackDecoder; private final HpackDecoder hpackDecoder;
@ -55,12 +55,12 @@ public class Parser
private boolean continuation; private boolean continuation;
private State state = State.HEADER; private State state = State.HEADER;
public Parser(RetainableByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize) public Parser(ByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize)
{ {
this(bufferPool, listener, maxDynamicTableSize, maxHeaderSize, RateControl.NO_RATE_CONTROL); this(bufferPool, listener, maxDynamicTableSize, maxHeaderSize, RateControl.NO_RATE_CONTROL);
} }
public Parser(RetainableByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize, RateControl rateControl) public Parser(ByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize, RateControl rateControl)
{ {
this.bufferPool = bufferPool; this.bufferPool = bufferPool;
this.listener = listener; this.listener = listener;

View File

@ -19,7 +19,7 @@ import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.RateControl; import org.eclipse.jetty.http2.RateControl;
import org.eclipse.jetty.http2.frames.FrameType; import org.eclipse.jetty.http2.frames.FrameType;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -33,7 +33,7 @@ public class ServerParser extends Parser
private State state = State.PREFACE; private State state = State.PREFACE;
private boolean notifyPreface = true; private boolean notifyPreface = true;
public ServerParser(RetainableByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize, RateControl rateControl) public ServerParser(ByteBufferPool bufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize, RateControl rateControl)
{ {
super(bufferPool, listener, maxDynamicTableSize, maxHeaderSize, rateControl); super(bufferPool, listener, maxDynamicTableSize, maxHeaderSize, rateControl);
this.listener = listener; this.listener = listener;

View File

@ -30,7 +30,7 @@ import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -42,7 +42,7 @@ public class ContinuationParseTest
@Test @Test
public void testParseOneByteAtATime() throws Exception public void testParseOneByteAtATime() throws Exception
{ {
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
HeadersGenerator generator = new HeadersGenerator(new HeaderGenerator(bufferPool), new HpackEncoder()); HeadersGenerator generator = new HeadersGenerator(new HeaderGenerator(bufferPool), new HpackEncoder());
final List<HeadersFrame> frames = new ArrayList<>(); final List<HeadersFrame> frames = new ArrayList<>();
@ -71,7 +71,7 @@ public class ContinuationParseTest
.put("User-Agent", "Jetty"); .put("User-Agent", "Jetty");
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields, -1); MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields, -1);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateHeaders(accumulator, streamId, metaData, null, true); generator.generateHeaders(accumulator, streamId, metaData, null, true);
List<ByteBuffer> byteBuffers = accumulator.getByteBuffers(); List<ByteBuffer> byteBuffers = accumulator.getByteBuffers();

View File

@ -23,7 +23,7 @@ import org.eclipse.jetty.http2.generator.DataGenerator;
import org.eclipse.jetty.http2.generator.HeaderGenerator; import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -34,7 +34,7 @@ public class DataGenerateParseTest
{ {
private final byte[] smallContent = new byte[128]; private final byte[] smallContent = new byte[128];
private final byte[] largeContent = new byte[128 * 1024]; private final byte[] largeContent = new byte[128 * 1024];
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
public DataGenerateParseTest() public DataGenerateParseTest()
{ {
@ -101,7 +101,7 @@ public class DataGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
ByteBuffer slice = data.slice(); ByteBuffer slice = data.slice();
int generated = 0; int generated = 0;
while (true) while (true)
@ -141,7 +141,7 @@ public class DataGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
ByteBuffer data = ByteBuffer.wrap(largeContent); ByteBuffer data = ByteBuffer.wrap(largeContent);
ByteBuffer slice = data.slice(); ByteBuffer slice = data.slice();
int generated = 0; int generated = 0;

View File

@ -25,7 +25,7 @@ import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.lessThan;
public class FrameFloodTest public class FrameFloodTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
// Frame structure: // Frame structure:
// | Len0 | Len1 | Len2 | Type | Flags | StreamID0 |StreamID1 |StreamID2 |StreamID3 | Payload... | // | Len0 | Len1 | Len2 | Type | Flags | StreamID0 |StreamID1 |StreamID2 |StreamID3 | Payload... |

View File

@ -23,7 +23,7 @@ import org.eclipse.jetty.http2.generator.GoAwayGenerator;
import org.eclipse.jetty.http2.generator.HeaderGenerator; import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertArrayEquals;
@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
public class GoAwayGenerateParseTest public class GoAwayGenerateParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testGenerateParse() throws Exception public void testGenerateParse() throws Exception
@ -56,7 +56,7 @@ public class GoAwayGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateGoAway(accumulator, lastStreamId, error, null); generator.generateGoAway(accumulator, lastStreamId, error, null);
frames.clear(); frames.clear();
@ -100,7 +100,7 @@ public class GoAwayGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateGoAway(accumulator, lastStreamId, error, payload); generator.generateGoAway(accumulator, lastStreamId, error, payload);
frames.clear(); frames.clear();

View File

@ -29,7 +29,7 @@ import org.eclipse.jetty.http2.generator.HeadersGenerator;
import org.eclipse.jetty.http2.hpack.HpackEncoder; import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class HeadersGenerateParseTest public class HeadersGenerateParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testGenerateParse() throws Exception public void testGenerateParse() throws Exception
@ -65,7 +65,7 @@ public class HeadersGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
PriorityFrame priorityFrame = new PriorityFrame(streamId, 3 * streamId, 200, true); PriorityFrame priorityFrame = new PriorityFrame(streamId, 3 * streamId, 200, true);
generator.generateHeaders(accumulator, streamId, metaData, priorityFrame, true); generator.generateHeaders(accumulator, streamId, metaData, priorityFrame, true);
@ -124,7 +124,7 @@ public class HeadersGenerateParseTest
.put("User-Agent", "Jetty"); .put("User-Agent", "Jetty");
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields, -1); MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:8080"), "/path", HttpVersion.HTTP_2, fields, -1);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
PriorityFrame priorityFrame = new PriorityFrame(streamId, 3 * streamId, 200, true); PriorityFrame priorityFrame = new PriorityFrame(streamId, 3 * streamId, 200, true);
generator.generateHeaders(accumulator, streamId, metaData, priorityFrame, true); generator.generateHeaders(accumulator, streamId, metaData, priorityFrame, true);

View File

@ -29,7 +29,7 @@ import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.hpack.HpackException; import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class HeadersTooLargeParseTest public class HeadersTooLargeParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testProtocolErrorURITooLong() throws HpackException public void testProtocolErrorURITooLong() throws HpackException
@ -78,7 +78,7 @@ public class HeadersTooLargeParseTest
parser.init(UnaryOperator.identity()); parser.init(UnaryOperator.identity());
int streamId = 48; int streamId = 48;
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
PriorityFrame priorityFrame = new PriorityFrame(streamId, 3 * streamId, 200, true); PriorityFrame priorityFrame = new PriorityFrame(streamId, 3 * streamId, 200, true);
int len = generator.generateHeaders(accumulator, streamId, metaData, priorityFrame, true); int len = generator.generateHeaders(accumulator, streamId, metaData, priorityFrame, true);

View File

@ -20,14 +20,14 @@ import java.util.function.UnaryOperator;
import org.eclipse.jetty.http2.ErrorCode; import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
public class MaxFrameSizeParseTest public class MaxFrameSizeParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testMaxFrameSize() public void testMaxFrameSize()

View File

@ -23,7 +23,7 @@ import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.PingGenerator; import org.eclipse.jetty.http2.generator.PingGenerator;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.NanoTime; import org.eclipse.jetty.util.NanoTime;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -33,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class PingGenerateParseTest public class PingGenerateParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testGenerateParse() throws Exception public void testGenerateParse() throws Exception
@ -57,7 +57,7 @@ public class PingGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePing(accumulator, payload, true); generator.generatePing(accumulator, payload, true);
frames.clear(); frames.clear();
@ -98,7 +98,7 @@ public class PingGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePing(accumulator, payload, true); generator.generatePing(accumulator, payload, true);
frames.clear(); frames.clear();
@ -133,7 +133,7 @@ public class PingGenerateParseTest
}, 4096, 8192); }, 4096, 8192);
parser.init(UnaryOperator.identity()); parser.init(UnaryOperator.identity());
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
PingFrame ping = new PingFrame(NanoTime.now(), true); PingFrame ping = new PingFrame(NanoTime.now(), true);
generator.generate(accumulator, ping); generator.generate(accumulator, ping);

View File

@ -22,14 +22,14 @@ import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.PriorityGenerator; import org.eclipse.jetty.http2.generator.PriorityGenerator;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
public class PriorityGenerateParseTest public class PriorityGenerateParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testGenerateParse() throws Exception public void testGenerateParse() throws Exception
@ -55,7 +55,7 @@ public class PriorityGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePriority(accumulator, streamId, parentStreamId, weight, exclusive); generator.generatePriority(accumulator, streamId, parentStreamId, weight, exclusive);
frames.clear(); frames.clear();
@ -100,7 +100,7 @@ public class PriorityGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePriority(accumulator, streamId, parentStreamId, weight, exclusive); generator.generatePriority(accumulator, streamId, parentStreamId, weight, exclusive);
frames.clear(); frames.clear();

View File

@ -29,7 +29,7 @@ import org.eclipse.jetty.http2.generator.PushPromiseGenerator;
import org.eclipse.jetty.http2.hpack.HpackEncoder; import org.eclipse.jetty.http2.hpack.HpackEncoder;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class PushPromiseGenerateParseTest public class PushPromiseGenerateParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testGenerateParse() throws Exception public void testGenerateParse() throws Exception
@ -65,7 +65,7 @@ public class PushPromiseGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePushPromise(accumulator, streamId, promisedStreamId, metaData); generator.generatePushPromise(accumulator, streamId, promisedStreamId, metaData);
frames.clear(); frames.clear();
@ -118,7 +118,7 @@ public class PushPromiseGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generatePushPromise(accumulator, streamId, promisedStreamId, metaData); generator.generatePushPromise(accumulator, streamId, promisedStreamId, metaData);
frames.clear(); frames.clear();

View File

@ -22,14 +22,14 @@ import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.ResetGenerator; import org.eclipse.jetty.http2.generator.ResetGenerator;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
public class ResetGenerateParseTest public class ResetGenerateParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testGenerateParse() throws Exception public void testGenerateParse() throws Exception
@ -53,7 +53,7 @@ public class ResetGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateReset(accumulator, streamId, error); generator.generateReset(accumulator, streamId, error);
frames.clear(); frames.clear();
@ -94,7 +94,7 @@ public class ResetGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateReset(accumulator, streamId, error); generator.generateReset(accumulator, streamId, error);
frames.clear(); frames.clear();

View File

@ -27,7 +27,7 @@ import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.SettingsGenerator; import org.eclipse.jetty.http2.generator.SettingsGenerator;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class SettingsGenerateParseTest public class SettingsGenerateParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testGenerateParseNoSettings() public void testGenerateParseNoSettings()
@ -85,7 +85,7 @@ public class SettingsGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateSettings(accumulator, settings, true); generator.generateSettings(accumulator, settings, true);
frames.clear(); frames.clear();
@ -119,7 +119,7 @@ public class SettingsGenerateParseTest
Map<Integer, Integer> settings1 = new HashMap<>(); Map<Integer, Integer> settings1 = new HashMap<>();
settings1.put(13, 17); settings1.put(13, 17);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateSettings(accumulator, settings1, true); generator.generateSettings(accumulator, settings1, true);
// Modify the length of the frame to make it invalid // Modify the length of the frame to make it invalid
ByteBuffer bytes = accumulator.getByteBuffers().get(0); ByteBuffer bytes = accumulator.getByteBuffers().get(0);
@ -160,7 +160,7 @@ public class SettingsGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateSettings(accumulator, settings1, true); generator.generateSettings(accumulator, settings1, true);
frames.clear(); frames.clear();
@ -205,7 +205,7 @@ public class SettingsGenerateParseTest
settings.put(i + 10, i); settings.put(i + 10, i);
} }
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateSettings(accumulator, settings, false); generator.generateSettings(accumulator, settings, false);
for (ByteBuffer buffer : accumulator.getByteBuffers()) for (ByteBuffer buffer : accumulator.getByteBuffers())
@ -283,7 +283,7 @@ public class SettingsGenerateParseTest
Map<Integer, Integer> settings = new HashMap<>(); Map<Integer, Integer> settings = new HashMap<>();
settings.put(13, 17); settings.put(13, 17);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
for (int i = 0; i < maxSettingsKeys + 1; ++i) for (int i = 0; i < maxSettingsKeys + 1; ++i)
{ {
generator.generateSettings(accumulator, settings, false); generator.generateSettings(accumulator, settings, false);

View File

@ -22,7 +22,7 @@ import java.util.function.UnaryOperator;
import org.eclipse.jetty.http2.ErrorCode; import org.eclipse.jetty.http2.ErrorCode;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
public class UnknownParseTest public class UnknownParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testParse() public void testParse()

View File

@ -22,14 +22,14 @@ import org.eclipse.jetty.http2.generator.HeaderGenerator;
import org.eclipse.jetty.http2.generator.WindowUpdateGenerator; import org.eclipse.jetty.http2.generator.WindowUpdateGenerator;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
public class WindowUpdateGenerateParseTest public class WindowUpdateGenerateParseTest
{ {
private final RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); private final ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
@Test @Test
public void testGenerateParse() throws Exception public void testGenerateParse() throws Exception
@ -53,7 +53,7 @@ public class WindowUpdateGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateWindowUpdate(accumulator, streamId, windowUpdate); generator.generateWindowUpdate(accumulator, streamId, windowUpdate);
frames.clear(); frames.clear();
@ -94,7 +94,7 @@ public class WindowUpdateGenerateParseTest
// Iterate a few times to be sure generator and parser are properly reset. // Iterate a few times to be sure generator and parser are properly reset.
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.generateWindowUpdate(accumulator, streamId, windowUpdate); generator.generateWindowUpdate(accumulator, streamId, windowUpdate);
frames.clear(); frames.clear();

View File

@ -37,9 +37,9 @@ import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.parser.ServerParser; import org.eclipse.jetty.http2.parser.ServerParser;
import org.eclipse.jetty.http2.server.internal.HTTP2ServerConnection; import org.eclipse.jetty.http2.server.internal.HTTP2ServerConnection;
import org.eclipse.jetty.http2.server.internal.HTTP2ServerSession; import org.eclipse.jetty.http2.server.internal.HTTP2ServerSession;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.AbstractConnectionFactory; import org.eclipse.jetty.server.AbstractConnectionFactory;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConfiguration;
@ -271,7 +271,7 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne
{ {
ServerSessionListener listener = newSessionListener(connector, endPoint); ServerSessionListener listener = newSessionListener(connector, endPoint);
Generator generator = new Generator(connector.getRetainableByteBufferPool(), isUseOutputDirectByteBuffers(), getMaxDynamicTableSize(), getMaxHeaderBlockFragment()); Generator generator = new Generator(connector.getByteBufferPool(), isUseOutputDirectByteBuffers(), getMaxDynamicTableSize(), getMaxHeaderBlockFragment());
FlowControlStrategy flowControl = getFlowControlStrategyFactory().newFlowControlStrategy(); FlowControlStrategy flowControl = getFlowControlStrategyFactory().newFlowControlStrategy();
HTTP2ServerSession session = new HTTP2ServerSession(connector.getScheduler(), endPoint, generator, listener, flowControl); HTTP2ServerSession session = new HTTP2ServerSession(connector.getScheduler(), endPoint, generator, listener, flowControl);
session.setMaxLocalStreams(getMaxConcurrentStreams()); session.setMaxLocalStreams(getMaxConcurrentStreams());
@ -291,9 +291,9 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne
parser.setMaxFrameLength(getMaxFrameLength()); parser.setMaxFrameLength(getMaxFrameLength());
parser.setMaxSettingsKeys(getMaxSettingsKeys()); parser.setMaxSettingsKeys(getMaxSettingsKeys());
RetainableByteBufferPool retainableByteBufferPool = connector.getRetainableByteBufferPool(); ByteBufferPool byteBufferPool = connector.getByteBufferPool();
HTTP2Connection connection = new HTTP2ServerConnection(retainableByteBufferPool, connector, HTTP2Connection connection = new HTTP2ServerConnection(byteBufferPool, connector,
endPoint, httpConfiguration, parser, session, getInputBufferSize(), listener); endPoint, httpConfiguration, parser, session, getInputBufferSize(), listener);
connection.setUseInputDirectByteBuffers(isUseInputDirectByteBuffers()); connection.setUseInputDirectByteBuffers(isUseInputDirectByteBuffers());
connection.setUseOutputDirectByteBuffers(isUseOutputDirectByteBuffers()); connection.setUseOutputDirectByteBuffers(isUseOutputDirectByteBuffers());
@ -305,7 +305,7 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne
private ServerParser newServerParser(Connector connector, ServerParser.Listener listener, RateControl rateControl) private ServerParser newServerParser(Connector connector, ServerParser.Listener listener, RateControl rateControl)
{ {
return new ServerParser(connector.getRetainableByteBufferPool(), listener, getMaxDynamicTableSize(), getHttpConfiguration().getRequestHeaderSize(), rateControl); return new ServerParser(connector.getByteBufferPool(), listener, getMaxDynamicTableSize(), getHttpConfiguration().getRequestHeaderSize(), rateControl);
} }
@ManagedObject("The container of HTTP/2 sessions") @ManagedObject("The container of HTTP/2 sessions")

View File

@ -40,9 +40,9 @@ import org.eclipse.jetty.http2.frames.PrefaceFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame; import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.parser.ServerParser; import org.eclipse.jetty.http2.parser.ServerParser;
import org.eclipse.jetty.http2.parser.SettingsBodyParser; import org.eclipse.jetty.http2.parser.SettingsBodyParser;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.ssl.SslConnection; import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.server.ConnectionMetaData; import org.eclipse.jetty.server.ConnectionMetaData;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
@ -69,9 +69,9 @@ public class HTTP2ServerConnection extends HTTP2Connection implements Connection
private final HttpConfiguration httpConfig; private final HttpConfiguration httpConfig;
private final String id; private final String id;
public HTTP2ServerConnection(RetainableByteBufferPool retainableByteBufferPool, Connector connector, EndPoint endPoint, HttpConfiguration httpConfig, ServerParser parser, HTTP2Session session, int inputBufferSize, ServerSessionListener listener) public HTTP2ServerConnection(ByteBufferPool byteBufferPool, Connector connector, EndPoint endPoint, HttpConfiguration httpConfig, ServerParser parser, HTTP2Session session, int inputBufferSize, ServerSessionListener listener)
{ {
super(retainableByteBufferPool, connector.getExecutor(), endPoint, parser, session, inputBufferSize); super(byteBufferPool, connector.getExecutor(), endPoint, parser, session, inputBufferSize);
this.connector = connector; this.connector = connector;
this.listener = listener; this.listener = listener;
this.httpConfig = httpConfig; this.httpConfig = httpConfig;

View File

@ -30,7 +30,7 @@ import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory; import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory; import org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.server.ConnectionFactory; import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConfiguration;
@ -42,7 +42,7 @@ import org.junit.jupiter.api.AfterEach;
public class AbstractServerTest public class AbstractServerTest
{ {
protected ServerConnector connector; protected ServerConnector connector;
protected RetainableByteBufferPool bufferPool; protected ByteBufferPool bufferPool;
protected Generator generator; protected Generator generator;
protected Server server; protected Server server;
protected String path; protected String path;

View File

@ -31,7 +31,7 @@ import org.eclipse.jetty.http2.frames.PrefaceFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame; import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.generator.Generator; import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory; import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
@ -97,7 +97,7 @@ public class BadURITest
} }
}); });
RetainableByteBufferPool bufferPool = connector.getRetainableByteBufferPool(); ByteBufferPool bufferPool = connector.getByteBufferPool();
Generator generator = new Generator(bufferPool); Generator generator = new Generator(bufferPool);
// Craft a request with a bad URI, it will not hit the Handler. // Craft a request with a bad URI, it will not hit the Handler.
@ -111,7 +111,7 @@ public class BadURITest
HttpFields.EMPTY, HttpFields.EMPTY,
-1 -1
); );
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
generator.control(accumulator, new HeadersFrame(1, metaData1, null, true)); generator.control(accumulator, new HeadersFrame(1, metaData1, null, true));

View File

@ -37,7 +37,7 @@ import org.eclipse.jetty.http2.frames.HeadersFrame;
import org.eclipse.jetty.http2.frames.PrefaceFrame; import org.eclipse.jetty.http2.frames.PrefaceFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame; import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RuntimeIOException; import org.eclipse.jetty.io.RuntimeIOException;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
@ -74,7 +74,7 @@ public class CloseTest extends AbstractServerTest
} }
}); });
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -135,7 +135,7 @@ public class CloseTest extends AbstractServerTest
} }
}); });
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -202,7 +202,7 @@ public class CloseTest extends AbstractServerTest
}); });
connector.setIdleTimeout(idleTimeout); connector.setIdleTimeout(idleTimeout);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);

View File

@ -36,7 +36,7 @@ import org.eclipse.jetty.http2.frames.DataFrame;
import org.eclipse.jetty.http2.frames.HeadersFrame; import org.eclipse.jetty.http2.frames.HeadersFrame;
import org.eclipse.jetty.http2.generator.Generator; import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.FuturePromise; import org.eclipse.jetty.util.FuturePromise;
import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.Promise;
@ -365,9 +365,9 @@ public class DataDemandTest extends AbstractTest
// Generate a lot of small DATA frames and write them in a single // Generate a lot of small DATA frames and write them in a single
// write so that the server will continuously be notified and demand, // write so that the server will continuously be notified and demand,
// which will test that it won't throw StackOverflowError. // which will test that it won't throw StackOverflowError.
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
Generator generator = new Generator(bufferPool); Generator generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
for (int i = 512; i >= 0; --i) for (int i = 512; i >= 0; --i)
generator.data(accumulator, new DataFrame(clientStream.getId(), ByteBuffer.allocate(1), i == 0), 1); generator.data(accumulator, new DataFrame(clientStream.getId(), ByteBuffer.allocate(1), i == 0), 1);

View File

@ -51,7 +51,7 @@ import org.eclipse.jetty.http2.frames.ResetFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame; import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame; import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory; import org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.ServerConnector;
@ -844,7 +844,7 @@ public abstract class FlowControlStrategyTest
// Now the client is supposed to not send more frames. // Now the client is supposed to not send more frames.
// If it does, the connection must be closed. // If it does, the connection must be closed.
HTTP2Session http2Session = (HTTP2Session)session; HTTP2Session http2Session = (HTTP2Session)session;
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
ByteBuffer extraData = ByteBuffer.allocate(1024); ByteBuffer extraData = ByteBuffer.allocate(1024);
http2Session.getGenerator().data(accumulator, new DataFrame(stream.getId(), extraData, true), extraData.remaining()); http2Session.getGenerator().data(accumulator, new DataFrame(stream.getId(), extraData, true), extraData.remaining());
List<ByteBuffer> buffers = accumulator.getByteBuffers(); List<ByteBuffer> buffers = accumulator.getByteBuffers();
@ -949,7 +949,7 @@ public abstract class FlowControlStrategyTest
// Now the client is supposed to not send more frames. // Now the client is supposed to not send more frames.
// If it does, the connection must be closed. // If it does, the connection must be closed.
HTTP2Session http2Session = (HTTP2Session)session; HTTP2Session http2Session = (HTTP2Session)session;
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
ByteBuffer extraData = ByteBuffer.allocate(1024); ByteBuffer extraData = ByteBuffer.allocate(1024);
http2Session.getGenerator().data(accumulator, new DataFrame(stream.getId(), extraData, true), extraData.remaining()); http2Session.getGenerator().data(accumulator, new DataFrame(stream.getId(), extraData, true), extraData.remaining());
List<ByteBuffer> buffers = accumulator.getByteBuffers(); List<ByteBuffer> buffers = accumulator.getByteBuffers();

View File

@ -39,9 +39,9 @@ import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.generator.Generator; import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.ServerConnector;
@ -196,7 +196,7 @@ public class HTTP2CServerTest extends AbstractServerTest
headersRef.set(null); headersRef.set(null);
dataRef.set(null); dataRef.set(null);
latchRef.set(new CountDownLatch(2)); latchRef.set(new CountDownLatch(2));
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:" + connector.getLocalPort()), "/two", HttpVersion.HTTP_2, HttpFields.EMPTY, -1); MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:" + connector.getLocalPort()), "/two", HttpVersion.HTTP_2, HttpFields.EMPTY, -1);
@ -234,7 +234,7 @@ public class HTTP2CServerTest extends AbstractServerTest
bufferPool = new ArrayRetainableByteBufferPool(); bufferPool = new ArrayRetainableByteBufferPool();
generator = new Generator(bufferPool); generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:" + connector.getLocalPort()), "/test", HttpVersion.HTTP_2, HttpFields.EMPTY, -1); MetaData.Request metaData = new MetaData.Request("GET", HttpScheme.HTTP.asString(), new HostPortHttpField("localhost:" + connector.getLocalPort()), "/test", HttpVersion.HTTP_2, HttpFields.EMPTY, -1);
@ -331,7 +331,7 @@ public class HTTP2CServerTest extends AbstractServerTest
bufferPool = new ArrayRetainableByteBufferPool(); bufferPool = new ArrayRetainableByteBufferPool();
generator = new Generator(bufferPool); generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
try (Socket client = new Socket("localhost", connector.getLocalPort())) try (Socket client = new Socket("localhost", connector.getLocalPort()))

View File

@ -47,9 +47,9 @@ import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.internal.Flags; import org.eclipse.jetty.http2.internal.Flags;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory; import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ManagedSelector; import org.eclipse.jetty.io.ManagedSelector;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.SocketChannelEndPoint; import org.eclipse.jetty.io.SocketChannelEndPoint;
import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
@ -85,7 +85,7 @@ public class HTTP2ServerTest extends AbstractServerTest
// No preface bytes. // No preface bytes.
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new HeadersFrame(1, metaData, null, true)); generator.control(accumulator, new HeadersFrame(1, metaData, null, true));
try (Socket client = new Socket("localhost", connector.getLocalPort())) try (Socket client = new Socket("localhost", connector.getLocalPort()))
@ -128,7 +128,7 @@ public class HTTP2ServerTest extends AbstractServerTest
} }
}); });
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -187,7 +187,7 @@ public class HTTP2ServerTest extends AbstractServerTest
} }
}); });
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -255,7 +255,7 @@ public class HTTP2ServerTest extends AbstractServerTest
} }
}); });
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
generator.control(accumulator, new PingFrame(new byte[8], false)); generator.control(accumulator, new PingFrame(new byte[8], false));
@ -301,7 +301,7 @@ public class HTTP2ServerTest extends AbstractServerTest
} }
}); });
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
generator.control(accumulator, new PingFrame(new byte[8], false)); generator.control(accumulator, new PingFrame(new byte[8], false));
@ -374,7 +374,7 @@ public class HTTP2ServerTest extends AbstractServerTest
server.addConnector(connector2); server.addConnector(connector2);
server.start(); server.start();
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -414,7 +414,7 @@ public class HTTP2ServerTest extends AbstractServerTest
} }
}); });
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -443,7 +443,7 @@ public class HTTP2ServerTest extends AbstractServerTest
{ {
testRequestWithContinuationFrames(null, () -> testRequestWithContinuationFrames(null, () ->
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -458,7 +458,7 @@ public class HTTP2ServerTest extends AbstractServerTest
PriorityFrame priority = new PriorityFrame(1, 13, 200, true); PriorityFrame priority = new PriorityFrame(1, 13, 200, true);
testRequestWithContinuationFrames(priority, () -> testRequestWithContinuationFrames(priority, () ->
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -472,7 +472,7 @@ public class HTTP2ServerTest extends AbstractServerTest
{ {
testRequestWithContinuationFrames(null, () -> testRequestWithContinuationFrames(null, () ->
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -494,7 +494,7 @@ public class HTTP2ServerTest extends AbstractServerTest
PriorityFrame priority = new PriorityFrame(1, 13, 200, true); PriorityFrame priority = new PriorityFrame(1, 13, 200, true);
testRequestWithContinuationFrames(null, () -> testRequestWithContinuationFrames(null, () ->
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -515,7 +515,7 @@ public class HTTP2ServerTest extends AbstractServerTest
{ {
testRequestWithContinuationFrames(null, () -> testRequestWithContinuationFrames(null, () ->
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -539,7 +539,7 @@ public class HTTP2ServerTest extends AbstractServerTest
{ {
testRequestWithContinuationFrames(null, () -> testRequestWithContinuationFrames(null, () ->
{ {
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
generator.control(accumulator, new SettingsFrame(new HashMap<>(), false)); generator.control(accumulator, new SettingsFrame(new HashMap<>(), false));
MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY); MetaData.Request metaData = newRequest("GET", HttpFields.EMPTY);
@ -560,7 +560,7 @@ public class HTTP2ServerTest extends AbstractServerTest
}); });
} }
private void testRequestWithContinuationFrames(PriorityFrame priorityFrame, Callable<RetainableByteBufferPool.Accumulator> frames) throws Exception private void testRequestWithContinuationFrames(PriorityFrame priorityFrame, Callable<ByteBufferPool.Accumulator> frames) throws Exception
{ {
CountDownLatch serverLatch = new CountDownLatch(1); CountDownLatch serverLatch = new CountDownLatch(1);
startServer(new ServerSessionListener() startServer(new ServerSessionListener()
@ -588,7 +588,7 @@ public class HTTP2ServerTest extends AbstractServerTest
}); });
generator = new Generator(bufferPool, 4096, 4); generator = new Generator(bufferPool, 4096, 4);
RetainableByteBufferPool.Accumulator accumulator = frames.call(); ByteBufferPool.Accumulator accumulator = frames.call();
try (Socket client = new Socket("localhost", connector.getLocalPort())) try (Socket client = new Socket("localhost", connector.getLocalPort()))
{ {

View File

@ -68,9 +68,9 @@ import org.eclipse.jetty.http2.hpack.HpackException;
import org.eclipse.jetty.http2.parser.ServerParser; import org.eclipse.jetty.http2.parser.ServerParser;
import org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory; import org.eclipse.jetty.http2.server.RawHTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.ClientConnector; import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
@ -111,7 +111,7 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest
assertTrue(http2Client.isStarted()); assertTrue(http2Client.isStarted());
assertSame(httpClient.getExecutor(), http2Client.getExecutor()); assertSame(httpClient.getExecutor(), http2Client.getExecutor());
assertSame(httpClient.getScheduler(), http2Client.getScheduler()); assertSame(httpClient.getScheduler(), http2Client.getScheduler());
assertSame(httpClient.getRetainableByteBufferPool(), http2Client.getRetainableByteBufferPool()); assertSame(httpClient.getByteBufferPool(), http2Client.getByteBufferPool());
assertEquals(httpClient.getConnectTimeout(), http2Client.getConnectTimeout()); assertEquals(httpClient.getConnectTimeout(), http2Client.getConnectTimeout());
assertEquals(httpClient.getIdleTimeout(), http2Client.getIdleTimeout()); assertEquals(httpClient.getIdleTimeout(), http2Client.getIdleTimeout());
assertEquals(httpClient.isUseInputDirectByteBuffers(), http2Client.isUseInputDirectByteBuffers()); assertEquals(httpClient.isUseInputDirectByteBuffers(), http2Client.isUseInputDirectByteBuffers());
@ -541,8 +541,8 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest
resultLatch.countDown(); resultLatch.countDown();
}); });
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
Generator generator = new Generator(bufferPool); Generator generator = new Generator(bufferPool);
try (Socket socket = server.accept()) try (Socket socket = server.accept())

View File

@ -51,8 +51,8 @@ import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.http2.parser.Parser; import org.eclipse.jetty.http2.parser.Parser;
import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory; import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory;
import org.eclipse.jetty.io.ArrayRetainableByteBufferPool; import org.eclipse.jetty.io.ArrayRetainableByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.HttpConnectionFactory;
@ -148,13 +148,13 @@ public class PrefaceTest extends AbstractTest
} }
}); });
RetainableByteBufferPool bufferPool = http2Client.getRetainableByteBufferPool(); ByteBufferPool bufferPool = http2Client.getByteBufferPool();
try (SocketChannel socket = SocketChannel.open()) try (SocketChannel socket = SocketChannel.open())
{ {
socket.connect(new InetSocketAddress("localhost", connector.getLocalPort())); socket.connect(new InetSocketAddress("localhost", connector.getLocalPort()));
Generator generator = new Generator(bufferPool); Generator generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
Map<Integer, Integer> clientSettings = new HashMap<>(); Map<Integer, Integer> clientSettings = new HashMap<>();
clientSettings.put(SettingsFrame.ENABLE_PUSH, 0); clientSettings.put(SettingsFrame.ENABLE_PUSH, 0);
@ -247,7 +247,7 @@ public class PrefaceTest extends AbstractTest
}); });
server.start(); server.start();
RetainableByteBufferPool bufferPool = new ArrayRetainableByteBufferPool(); ByteBufferPool bufferPool = new ArrayRetainableByteBufferPool();
try (SocketChannel socket = SocketChannel.open()) try (SocketChannel socket = SocketChannel.open())
{ {
socket.connect(new InetSocketAddress("localhost", connector.getLocalPort())); socket.connect(new InetSocketAddress("localhost", connector.getLocalPort()));
@ -296,7 +296,7 @@ public class PrefaceTest extends AbstractTest
// After the 101, the client must send the connection preface. // After the 101, the client must send the connection preface.
Generator generator = new Generator(bufferPool); Generator generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
Map<Integer, Integer> clientSettings = new HashMap<>(); Map<Integer, Integer> clientSettings = new HashMap<>();
clientSettings.put(SettingsFrame.ENABLE_PUSH, 1); clientSettings.put(SettingsFrame.ENABLE_PUSH, 1);

View File

@ -33,7 +33,7 @@ import org.eclipse.jetty.http2.frames.HeadersFrame;
import org.eclipse.jetty.http2.frames.ResetFrame; import org.eclipse.jetty.http2.frames.ResetFrame;
import org.eclipse.jetty.http2.frames.SettingsFrame; import org.eclipse.jetty.http2.frames.SettingsFrame;
import org.eclipse.jetty.http2.generator.Generator; import org.eclipse.jetty.http2.generator.Generator;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.FuturePromise; import org.eclipse.jetty.util.FuturePromise;
@ -201,7 +201,7 @@ public class StreamCountTest extends AbstractTest
HeadersFrame frame3 = new HeadersFrame(streamId3, metaData, null, false); HeadersFrame frame3 = new HeadersFrame(streamId3, metaData, null, false);
DataFrame data3 = new DataFrame(streamId3, BufferUtil.EMPTY_BUFFER, true); DataFrame data3 = new DataFrame(streamId3, BufferUtil.EMPTY_BUFFER, true);
Generator generator = ((HTTP2Session)session).getGenerator(); Generator generator = ((HTTP2Session)session).getGenerator();
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, frame3); generator.control(accumulator, frame3);
generator.data(accumulator, data3, data3.remaining()); generator.data(accumulator, data3, data3.remaining());
((HTTP2Session)session).getEndPoint().write(Callback.NOOP, accumulator.getByteBuffers().toArray(ByteBuffer[]::new)); ((HTTP2Session)session).getEndPoint().write(Callback.NOOP, accumulator.getByteBuffers().toArray(ByteBuffer[]::new));

View File

@ -64,8 +64,8 @@ import org.eclipse.jetty.http2.internal.HTTP2Flusher;
import org.eclipse.jetty.http2.server.AbstractHTTP2ServerConnectionFactory; import org.eclipse.jetty.http2.server.AbstractHTTP2ServerConnectionFactory;
import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory; import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory;
import org.eclipse.jetty.io.AbstractEndPoint; import org.eclipse.jetty.io.AbstractEndPoint;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Content; import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.io.WriteFlusher; import org.eclipse.jetty.io.WriteFlusher;
import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
@ -887,7 +887,7 @@ public class StreamResetTest extends AbstractTest
} }
}); });
RetainableByteBufferPool bufferPool = http2Client.getRetainableByteBufferPool(); ByteBufferPool bufferPool = http2Client.getByteBufferPool();
try (SocketChannel socket = SocketChannel.open()) try (SocketChannel socket = SocketChannel.open())
{ {
String host = "localhost"; String host = "localhost";
@ -895,7 +895,7 @@ public class StreamResetTest extends AbstractTest
socket.connect(new InetSocketAddress(host, port)); socket.connect(new InetSocketAddress(host, port));
Generator generator = new Generator(bufferPool); Generator generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
Map<Integer, Integer> clientSettings = new HashMap<>(); Map<Integer, Integer> clientSettings = new HashMap<>();
// Max stream HTTP/2 flow control window. // Max stream HTTP/2 flow control window.
@ -978,7 +978,7 @@ public class StreamResetTest extends AbstractTest
} }
}); });
RetainableByteBufferPool bufferPool = http2Client.getRetainableByteBufferPool(); ByteBufferPool bufferPool = http2Client.getByteBufferPool();
try (SocketChannel socket = SocketChannel.open()) try (SocketChannel socket = SocketChannel.open())
{ {
String host = "localhost"; String host = "localhost";
@ -986,7 +986,7 @@ public class StreamResetTest extends AbstractTest
socket.connect(new InetSocketAddress(host, port)); socket.connect(new InetSocketAddress(host, port));
Generator generator = new Generator(bufferPool); Generator generator = new Generator(bufferPool);
RetainableByteBufferPool.Accumulator accumulator = new RetainableByteBufferPool.Accumulator(); ByteBufferPool.Accumulator accumulator = new ByteBufferPool.Accumulator();
generator.control(accumulator, new PrefaceFrame()); generator.control(accumulator, new PrefaceFrame());
Map<Integer, Integer> clientSettings = new HashMap<>(); Map<Integer, Integer> clientSettings = new HashMap<>();
// Max stream HTTP/2 flow control window. // Max stream HTTP/2 flow control window.

View File

@ -69,7 +69,7 @@ public class HttpClientTransportOverHTTP3 extends AbstractHttpClientTransport im
ClientConnector clientConnector = this.client.getClientConnector(); ClientConnector clientConnector = this.client.getClientConnector();
clientConnector.setExecutor(httpClient.getExecutor()); clientConnector.setExecutor(httpClient.getExecutor());
clientConnector.setScheduler(httpClient.getScheduler()); clientConnector.setScheduler(httpClient.getScheduler());
clientConnector.setRetainableByteBufferPool(httpClient.getRetainableByteBufferPool()); clientConnector.setByteBufferPool(httpClient.getByteBufferPool());
clientConnector.setConnectTimeout(Duration.ofMillis(httpClient.getConnectTimeout())); clientConnector.setConnectTimeout(Duration.ofMillis(httpClient.getConnectTimeout()));
clientConnector.setConnectBlocking(httpClient.isConnectBlocking()); clientConnector.setConnectBlocking(httpClient.isConnectBlocking());
clientConnector.setBindAddress(httpClient.getBindAddress()); clientConnector.setBindAddress(httpClient.getBindAddress());

View File

@ -30,7 +30,7 @@ import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.http3.frames.SettingsFrame; import org.eclipse.jetty.http3.frames.SettingsFrame;
import org.eclipse.jetty.http3.qpack.QpackDecoder; import org.eclipse.jetty.http3.qpack.QpackDecoder;
import org.eclipse.jetty.http3.qpack.QpackEncoder; import org.eclipse.jetty.http3.qpack.QpackEncoder;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.quic.client.ClientProtocolSession; import org.eclipse.jetty.quic.client.ClientProtocolSession;
import org.eclipse.jetty.quic.client.ClientQuicSession; import org.eclipse.jetty.quic.client.ClientQuicSession;
import org.eclipse.jetty.quic.common.QuicStreamEndPoint; import org.eclipse.jetty.quic.common.QuicStreamEndPoint;
@ -64,7 +64,7 @@ public class ClientHTTP3Session extends ClientProtocolSession
long encoderStreamId = getQuicSession().newStreamId(StreamType.CLIENT_UNIDIRECTIONAL); long encoderStreamId = getQuicSession().newStreamId(StreamType.CLIENT_UNIDIRECTIONAL);
QuicStreamEndPoint encoderEndPoint = openInstructionEndPoint(encoderStreamId); QuicStreamEndPoint encoderEndPoint = openInstructionEndPoint(encoderStreamId);
InstructionFlusher encoderInstructionFlusher = new InstructionFlusher(quicSession, encoderEndPoint, EncoderStreamConnection.STREAM_TYPE); InstructionFlusher encoderInstructionFlusher = new InstructionFlusher(quicSession, encoderEndPoint, EncoderStreamConnection.STREAM_TYPE);
RetainableByteBufferPool bufferPool = quicSession.getRetainableByteBufferPool(); ByteBufferPool bufferPool = quicSession.getByteBufferPool();
this.encoder = new QpackEncoder(bufferPool, new InstructionHandler(encoderInstructionFlusher), configuration.getMaxBlockedStreams()); this.encoder = new QpackEncoder(bufferPool, new InstructionHandler(encoderInstructionFlusher), configuration.getMaxBlockedStreams());
addBean(encoder); addBean(encoder);
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
@ -85,7 +85,7 @@ public class ClientHTTP3Session extends ClientProtocolSession
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("created control stream #{} on {}", controlStreamId, controlEndPoint); LOG.debug("created control stream #{} on {}", controlStreamId, controlEndPoint);
this.messageFlusher = new MessageFlusher(quicSession.getRetainableByteBufferPool(), encoder, configuration.getMaxRequestHeadersSize(), configuration.isUseOutputDirectByteBuffers()); this.messageFlusher = new MessageFlusher(quicSession.getByteBufferPool(), encoder, configuration.getMaxRequestHeadersSize(), configuration.isUseOutputDirectByteBuffers());
addBean(messageFlusher); addBean(messageFlusher);
} }
@ -199,7 +199,7 @@ public class ClientHTTP3Session extends ClientProtocolSession
private void openUnidirectionalStreamEndPoint(QuicStreamEndPoint endPoint) private void openUnidirectionalStreamEndPoint(QuicStreamEndPoint endPoint)
{ {
UnidirectionalStreamConnection connection = new UnidirectionalStreamConnection(endPoint, getQuicSession().getExecutor(), getQuicSession().getRetainableByteBufferPool(), encoder, decoder, session); UnidirectionalStreamConnection connection = new UnidirectionalStreamConnection(endPoint, getQuicSession().getExecutor(), getQuicSession().getByteBufferPool(), encoder, decoder, session);
endPoint.setConnection(connection); endPoint.setConnection(connection);
endPoint.opened(); endPoint.opened();
} }

View File

@ -22,6 +22,6 @@ public class ClientHTTP3StreamConnection extends HTTP3StreamConnection
{ {
public ClientHTTP3StreamConnection(QuicStreamEndPoint endPoint, ClientHTTP3Session session, MessageParser parser) public ClientHTTP3StreamConnection(QuicStreamEndPoint endPoint, ClientHTTP3Session session, MessageParser parser)
{ {
super(endPoint, session.getQuicSession().getExecutor(), session.getQuicSession().getRetainableByteBufferPool(), parser); super(endPoint, session.getQuicSession().getExecutor(), session.getQuicSession().getByteBufferPool(), parser);
} }
} }

View File

@ -23,8 +23,8 @@ import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.http3.generator.ControlGenerator; import org.eclipse.jetty.http3.generator.ControlGenerator;
import org.eclipse.jetty.http3.internal.ControlStreamConnection; import org.eclipse.jetty.http3.internal.ControlStreamConnection;
import org.eclipse.jetty.http3.internal.VarLenInt; import org.eclipse.jetty.http3.internal.VarLenInt;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.quic.common.QuicSession; import org.eclipse.jetty.quic.common.QuicSession;
import org.eclipse.jetty.quic.common.QuicStreamEndPoint; import org.eclipse.jetty.quic.common.QuicStreamEndPoint;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
@ -42,7 +42,7 @@ public class ControlFlusher extends IteratingCallback
private final Queue<Entry> queue = new ArrayDeque<>(); private final Queue<Entry> queue = new ArrayDeque<>();
private final QuicStreamEndPoint endPoint; private final QuicStreamEndPoint endPoint;
private final ControlGenerator generator; private final ControlGenerator generator;
private final RetainableByteBufferPool.Accumulator accumulator; private final ByteBufferPool.Accumulator accumulator;
private boolean initialized; private boolean initialized;
private Throwable terminated; private Throwable terminated;
private List<Entry> entries; private List<Entry> entries;
@ -51,9 +51,9 @@ public class ControlFlusher extends IteratingCallback
public ControlFlusher(QuicSession session, QuicStreamEndPoint endPoint, boolean useDirectByteBuffers) public ControlFlusher(QuicSession session, QuicStreamEndPoint endPoint, boolean useDirectByteBuffers)
{ {
this.endPoint = endPoint; this.endPoint = endPoint;
RetainableByteBufferPool bufferPool = session.getRetainableByteBufferPool(); ByteBufferPool bufferPool = session.getByteBufferPool();
this.generator = new ControlGenerator(bufferPool, useDirectByteBuffers); this.generator = new ControlGenerator(bufferPool, useDirectByteBuffers);
this.accumulator = new RetainableByteBufferPool.Accumulator(); this.accumulator = new ByteBufferPool.Accumulator();
} }
public boolean offer(Frame frame, Callback callback) public boolean offer(Frame frame, Callback callback)

View File

@ -18,8 +18,8 @@ import java.util.concurrent.Executor;
import org.eclipse.jetty.http3.qpack.QpackEncoder; import org.eclipse.jetty.http3.qpack.QpackEncoder;
import org.eclipse.jetty.http3.qpack.QpackException; import org.eclipse.jetty.http3.qpack.QpackException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
public class DecoderStreamConnection extends InstructionStreamConnection public class DecoderStreamConnection extends InstructionStreamConnection
{ {
@ -28,7 +28,7 @@ public class DecoderStreamConnection extends InstructionStreamConnection
private final QpackEncoder encoder; private final QpackEncoder encoder;
public DecoderStreamConnection(EndPoint endPoint, Executor executor, RetainableByteBufferPool bufferPool, QpackEncoder encoder) public DecoderStreamConnection(EndPoint endPoint, Executor executor, ByteBufferPool bufferPool, QpackEncoder encoder)
{ {
super(endPoint, executor, bufferPool); super(endPoint, executor, bufferPool);
this.encoder = encoder; this.encoder = encoder;

View File

@ -18,8 +18,8 @@ import java.util.concurrent.Executor;
import org.eclipse.jetty.http3.qpack.QpackDecoder; import org.eclipse.jetty.http3.qpack.QpackDecoder;
import org.eclipse.jetty.http3.qpack.QpackException; import org.eclipse.jetty.http3.qpack.QpackException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBufferPool;
public class EncoderStreamConnection extends InstructionStreamConnection public class EncoderStreamConnection extends InstructionStreamConnection
{ {
@ -28,7 +28,7 @@ public class EncoderStreamConnection extends InstructionStreamConnection
private final QpackDecoder decoder; private final QpackDecoder decoder;
public EncoderStreamConnection(EndPoint endPoint, Executor executor, RetainableByteBufferPool bufferPool, QpackDecoder decoder) public EncoderStreamConnection(EndPoint endPoint, Executor executor, ByteBufferPool bufferPool, QpackDecoder decoder)
{ {
super(endPoint, executor, bufferPool); super(endPoint, executor, bufferPool);
this.decoder = decoder; this.decoder = decoder;

View File

@ -27,8 +27,8 @@ import org.eclipse.jetty.http3.frames.HeadersFrame;
import org.eclipse.jetty.http3.parser.MessageParser; import org.eclipse.jetty.http3.parser.MessageParser;
import org.eclipse.jetty.http3.parser.ParserListener; import org.eclipse.jetty.http3.parser.ParserListener;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.quic.common.QuicStreamEndPoint; import org.eclipse.jetty.quic.common.QuicStreamEndPoint;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -40,7 +40,7 @@ public abstract class HTTP3StreamConnection extends AbstractConnection
private static final ByteBuffer EMPTY_DATA_FRAME = ByteBuffer.allocate(2); private static final ByteBuffer EMPTY_DATA_FRAME = ByteBuffer.allocate(2);
private final AtomicReference<Runnable> action = new AtomicReference<>(); private final AtomicReference<Runnable> action = new AtomicReference<>();
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private final MessageParser parser; private final MessageParser parser;
private boolean useInputDirectByteBuffers = true; private boolean useInputDirectByteBuffers = true;
private HTTP3Stream stream; private HTTP3Stream stream;
@ -48,7 +48,7 @@ public abstract class HTTP3StreamConnection extends AbstractConnection
private boolean applicationMode; private boolean applicationMode;
private boolean remotelyClosed; private boolean remotelyClosed;
public HTTP3StreamConnection(QuicStreamEndPoint endPoint, Executor executor, RetainableByteBufferPool bufferPool, MessageParser parser) public HTTP3StreamConnection(QuicStreamEndPoint endPoint, Executor executor, ByteBufferPool bufferPool, MessageParser parser)
{ {
super(endPoint, executor); super(endPoint, executor);
this.bufferPool = bufferPool; this.bufferPool = bufferPool;

View File

@ -21,8 +21,8 @@ import java.util.Queue;
import org.eclipse.jetty.http3.internal.VarLenInt; import org.eclipse.jetty.http3.internal.VarLenInt;
import org.eclipse.jetty.http3.qpack.Instruction; import org.eclipse.jetty.http3.qpack.Instruction;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.quic.common.QuicSession; import org.eclipse.jetty.quic.common.QuicSession;
import org.eclipse.jetty.quic.common.QuicStreamEndPoint; import org.eclipse.jetty.quic.common.QuicStreamEndPoint;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
@ -41,8 +41,8 @@ public class InstructionFlusher extends IteratingCallback
private final AutoLock lock = new AutoLock(); private final AutoLock lock = new AutoLock();
private final Queue<Instruction> queue = new ArrayDeque<>(); private final Queue<Instruction> queue = new ArrayDeque<>();
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private final RetainableByteBufferPool.Accumulator accumulator; private final ByteBufferPool.Accumulator accumulator;
private final QuicStreamEndPoint endPoint; private final QuicStreamEndPoint endPoint;
private final long streamType; private final long streamType;
private boolean initialized; private boolean initialized;
@ -50,8 +50,8 @@ public class InstructionFlusher extends IteratingCallback
public InstructionFlusher(QuicSession session, QuicStreamEndPoint endPoint, long streamType) public InstructionFlusher(QuicSession session, QuicStreamEndPoint endPoint, long streamType)
{ {
this.bufferPool = session.getRetainableByteBufferPool(); this.bufferPool = session.getByteBufferPool();
this.accumulator = new RetainableByteBufferPool.Accumulator(); this.accumulator = new ByteBufferPool.Accumulator();
this.endPoint = endPoint; this.endPoint = endPoint;
this.streamType = streamType; this.streamType = streamType;
} }

View File

@ -18,10 +18,10 @@ import java.util.concurrent.Executor;
import org.eclipse.jetty.http3.qpack.QpackException; import org.eclipse.jetty.http3.qpack.QpackException;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -29,11 +29,11 @@ import org.slf4j.LoggerFactory;
public abstract class InstructionStreamConnection extends AbstractConnection implements Connection.UpgradeTo public abstract class InstructionStreamConnection extends AbstractConnection implements Connection.UpgradeTo
{ {
private static final Logger LOG = LoggerFactory.getLogger(InstructionStreamConnection.class); private static final Logger LOG = LoggerFactory.getLogger(InstructionStreamConnection.class);
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private boolean useInputDirectByteBuffers = true; private boolean useInputDirectByteBuffers = true;
private RetainableByteBuffer buffer; private RetainableByteBuffer buffer;
public InstructionStreamConnection(EndPoint endPoint, Executor executor, RetainableByteBufferPool bufferPool) public InstructionStreamConnection(EndPoint endPoint, Executor executor, ByteBufferPool bufferPool)
{ {
super(endPoint, executor); super(endPoint, executor);
this.bufferPool = bufferPool; this.bufferPool = bufferPool;

View File

@ -21,7 +21,7 @@ import java.util.Queue;
import org.eclipse.jetty.http3.frames.Frame; import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.http3.generator.MessageGenerator; import org.eclipse.jetty.http3.generator.MessageGenerator;
import org.eclipse.jetty.http3.qpack.QpackEncoder; import org.eclipse.jetty.http3.qpack.QpackEncoder;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.quic.common.QuicStreamEndPoint; import org.eclipse.jetty.quic.common.QuicStreamEndPoint;
import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.IteratingCallback; import org.eclipse.jetty.util.IteratingCallback;
@ -35,13 +35,13 @@ public class MessageFlusher extends IteratingCallback
private final AutoLock lock = new AutoLock(); private final AutoLock lock = new AutoLock();
private final Queue<Entry> entries = new ArrayDeque<>(); private final Queue<Entry> entries = new ArrayDeque<>();
private final RetainableByteBufferPool.Accumulator accumulator; private final ByteBufferPool.Accumulator accumulator;
private final MessageGenerator generator; private final MessageGenerator generator;
private Entry entry; private Entry entry;
public MessageFlusher(RetainableByteBufferPool bufferPool, QpackEncoder encoder, int maxHeadersLength, boolean useDirectByteBuffers) public MessageFlusher(ByteBufferPool bufferPool, QpackEncoder encoder, int maxHeadersLength, boolean useDirectByteBuffers)
{ {
this.accumulator = new RetainableByteBufferPool.Accumulator(); this.accumulator = new ByteBufferPool.Accumulator();
this.generator = new MessageGenerator(bufferPool, encoder, maxHeadersLength, useDirectByteBuffers); this.generator = new MessageGenerator(bufferPool, encoder, maxHeadersLength, useDirectByteBuffers);
} }

View File

@ -23,9 +23,9 @@ import org.eclipse.jetty.http3.parser.ParserListener;
import org.eclipse.jetty.http3.qpack.QpackDecoder; import org.eclipse.jetty.http3.qpack.QpackDecoder;
import org.eclipse.jetty.http3.qpack.QpackEncoder; import org.eclipse.jetty.http3.qpack.QpackEncoder;
import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.quic.common.QuicStreamEndPoint; import org.eclipse.jetty.quic.common.QuicStreamEndPoint;
import org.eclipse.jetty.quic.common.StreamType; import org.eclipse.jetty.quic.common.StreamType;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -35,7 +35,7 @@ public class UnidirectionalStreamConnection extends AbstractConnection implement
{ {
private static final Logger LOG = LoggerFactory.getLogger(UnidirectionalStreamConnection.class); private static final Logger LOG = LoggerFactory.getLogger(UnidirectionalStreamConnection.class);
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
private final QpackEncoder encoder; private final QpackEncoder encoder;
private final QpackDecoder decoder; private final QpackDecoder decoder;
private final ParserListener listener; private final ParserListener listener;
@ -43,7 +43,7 @@ public class UnidirectionalStreamConnection extends AbstractConnection implement
private boolean useInputDirectByteBuffers = true; private boolean useInputDirectByteBuffers = true;
private RetainableByteBuffer buffer; private RetainableByteBuffer buffer;
public UnidirectionalStreamConnection(QuicStreamEndPoint endPoint, Executor executor, RetainableByteBufferPool bufferPool, QpackEncoder encoder, QpackDecoder decoder, ParserListener listener) public UnidirectionalStreamConnection(QuicStreamEndPoint endPoint, Executor executor, ByteBufferPool bufferPool, QpackEncoder encoder, QpackDecoder decoder, ParserListener listener)
{ {
super(endPoint, executor); super(endPoint, executor);
this.bufferPool = bufferPool; this.bufferPool = bufferPool;

View File

@ -16,17 +16,17 @@ package org.eclipse.jetty.http3.generator;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.eclipse.jetty.http3.frames.Frame; import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
public class CancelPushGenerator extends FrameGenerator public class CancelPushGenerator extends FrameGenerator
{ {
public CancelPushGenerator(RetainableByteBufferPool bufferPool) public CancelPushGenerator(ByteBufferPool bufferPool)
{ {
super(bufferPool); super(bufferPool);
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail) public int generate(ByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail)
{ {
return 0; return 0;
} }

View File

@ -17,13 +17,13 @@ import java.util.function.Consumer;
import org.eclipse.jetty.http3.frames.Frame; import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.http3.frames.FrameType; import org.eclipse.jetty.http3.frames.FrameType;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
public class ControlGenerator public class ControlGenerator
{ {
private final FrameGenerator[] generators = new FrameGenerator[FrameType.maxType() + 1]; private final FrameGenerator[] generators = new FrameGenerator[FrameType.maxType() + 1];
public ControlGenerator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers) public ControlGenerator(ByteBufferPool bufferPool, boolean useDirectByteBuffers)
{ {
generators[FrameType.CANCEL_PUSH.type()] = new CancelPushGenerator(bufferPool); generators[FrameType.CANCEL_PUSH.type()] = new CancelPushGenerator(bufferPool);
generators[FrameType.SETTINGS.type()] = new SettingsGenerator(bufferPool, useDirectByteBuffers); generators[FrameType.SETTINGS.type()] = new SettingsGenerator(bufferPool, useDirectByteBuffers);
@ -31,7 +31,7 @@ public class ControlGenerator
generators[FrameType.MAX_PUSH_ID.type()] = new MaxPushIdGenerator(bufferPool); generators[FrameType.MAX_PUSH_ID.type()] = new MaxPushIdGenerator(bufferPool);
} }
public int generate(RetainableByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail) public int generate(ByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail)
{ {
return generators[frame.getFrameType().type()].generate(accumulator, streamId, frame, fail); return generators[frame.getFrameType().type()].generate(accumulator, streamId, frame, fail);
} }

View File

@ -20,33 +20,33 @@ import org.eclipse.jetty.http3.frames.DataFrame;
import org.eclipse.jetty.http3.frames.Frame; import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.http3.frames.FrameType; import org.eclipse.jetty.http3.frames.FrameType;
import org.eclipse.jetty.http3.internal.VarLenInt; import org.eclipse.jetty.http3.internal.VarLenInt;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class DataGenerator extends FrameGenerator public class DataGenerator extends FrameGenerator
{ {
private final boolean useDirectByteBuffers; private final boolean useDirectByteBuffers;
public DataGenerator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers) public DataGenerator(ByteBufferPool bufferPool, boolean useDirectByteBuffers)
{ {
super(bufferPool); super(bufferPool);
this.useDirectByteBuffers = useDirectByteBuffers; this.useDirectByteBuffers = useDirectByteBuffers;
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail) public int generate(ByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail)
{ {
DataFrame dataFrame = (DataFrame)frame; DataFrame dataFrame = (DataFrame)frame;
return generateDataFrame(accumulator, dataFrame); return generateDataFrame(accumulator, dataFrame);
} }
private int generateDataFrame(RetainableByteBufferPool.Accumulator accumulator, DataFrame frame) private int generateDataFrame(ByteBufferPool.Accumulator accumulator, DataFrame frame)
{ {
ByteBuffer data = frame.getByteBuffer(); ByteBuffer data = frame.getByteBuffer();
int dataLength = data.remaining(); int dataLength = data.remaining();
int headerLength = VarLenInt.length(FrameType.DATA.type()) + VarLenInt.length(dataLength); int headerLength = VarLenInt.length(FrameType.DATA.type()) + VarLenInt.length(dataLength);
RetainableByteBuffer header = getRetainableByteBufferPool().acquire(headerLength, useDirectByteBuffers); RetainableByteBuffer header = getByteBufferPool().acquire(headerLength, useDirectByteBuffers);
ByteBuffer byteBuffer = header.getByteBuffer(); ByteBuffer byteBuffer = header.getByteBuffer();
BufferUtil.clearToFill(byteBuffer); BufferUtil.clearToFill(byteBuffer);
VarLenInt.encode(byteBuffer, FrameType.DATA.type()); VarLenInt.encode(byteBuffer, FrameType.DATA.type());

View File

@ -16,21 +16,21 @@ package org.eclipse.jetty.http3.generator;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.eclipse.jetty.http3.frames.Frame; import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
public abstract class FrameGenerator public abstract class FrameGenerator
{ {
private final RetainableByteBufferPool bufferPool; private final ByteBufferPool bufferPool;
public FrameGenerator(RetainableByteBufferPool bufferPool) public FrameGenerator(ByteBufferPool bufferPool)
{ {
this.bufferPool = bufferPool; this.bufferPool = bufferPool;
} }
public RetainableByteBufferPool getRetainableByteBufferPool() public ByteBufferPool getByteBufferPool()
{ {
return bufferPool; return bufferPool;
} }
public abstract int generate(RetainableByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail); public abstract int generate(ByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail);
} }

View File

@ -20,33 +20,33 @@ import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.http3.frames.FrameType; import org.eclipse.jetty.http3.frames.FrameType;
import org.eclipse.jetty.http3.frames.GoAwayFrame; import org.eclipse.jetty.http3.frames.GoAwayFrame;
import org.eclipse.jetty.http3.internal.VarLenInt; import org.eclipse.jetty.http3.internal.VarLenInt;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class GoAwayGenerator extends FrameGenerator public class GoAwayGenerator extends FrameGenerator
{ {
private final boolean useDirectByteBuffers; private final boolean useDirectByteBuffers;
public GoAwayGenerator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers) public GoAwayGenerator(ByteBufferPool bufferPool, boolean useDirectByteBuffers)
{ {
super(bufferPool); super(bufferPool);
this.useDirectByteBuffers = useDirectByteBuffers; this.useDirectByteBuffers = useDirectByteBuffers;
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail) public int generate(ByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail)
{ {
GoAwayFrame goAwayFrame = (GoAwayFrame)frame; GoAwayFrame goAwayFrame = (GoAwayFrame)frame;
return generateGoAwayFrame(accumulator, goAwayFrame); return generateGoAwayFrame(accumulator, goAwayFrame);
} }
private int generateGoAwayFrame(RetainableByteBufferPool.Accumulator accumulator, GoAwayFrame frame) private int generateGoAwayFrame(ByteBufferPool.Accumulator accumulator, GoAwayFrame frame)
{ {
long lastId = frame.getLastId(); long lastId = frame.getLastId();
int lastIdLength = VarLenInt.length(lastId); int lastIdLength = VarLenInt.length(lastId);
int length = VarLenInt.length(FrameType.GOAWAY.type()) + VarLenInt.length(lastIdLength) + lastIdLength; int length = VarLenInt.length(FrameType.GOAWAY.type()) + VarLenInt.length(lastIdLength) + lastIdLength;
RetainableByteBuffer buffer = getRetainableByteBufferPool().acquire(length, useDirectByteBuffers); RetainableByteBuffer buffer = getByteBufferPool().acquire(length, useDirectByteBuffers);
ByteBuffer byteBuffer = buffer.getByteBuffer(); ByteBuffer byteBuffer = buffer.getByteBuffer();
BufferUtil.clearToFill(byteBuffer); BufferUtil.clearToFill(byteBuffer);
VarLenInt.encode(byteBuffer, FrameType.GOAWAY.type()); VarLenInt.encode(byteBuffer, FrameType.GOAWAY.type());

View File

@ -22,8 +22,8 @@ import org.eclipse.jetty.http3.frames.HeadersFrame;
import org.eclipse.jetty.http3.internal.VarLenInt; import org.eclipse.jetty.http3.internal.VarLenInt;
import org.eclipse.jetty.http3.qpack.QpackEncoder; import org.eclipse.jetty.http3.qpack.QpackEncoder;
import org.eclipse.jetty.http3.qpack.QpackException; import org.eclipse.jetty.http3.qpack.QpackException;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class HeadersGenerator extends FrameGenerator public class HeadersGenerator extends FrameGenerator
@ -32,7 +32,7 @@ public class HeadersGenerator extends FrameGenerator
private final int maxLength; private final int maxLength;
private final boolean useDirectByteBuffers; private final boolean useDirectByteBuffers;
public HeadersGenerator(RetainableByteBufferPool bufferPool, QpackEncoder encoder, int maxLength, boolean useDirectByteBuffers) public HeadersGenerator(ByteBufferPool bufferPool, QpackEncoder encoder, int maxLength, boolean useDirectByteBuffers)
{ {
super(bufferPool); super(bufferPool);
this.encoder = encoder; this.encoder = encoder;
@ -41,13 +41,13 @@ public class HeadersGenerator extends FrameGenerator
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail) public int generate(ByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail)
{ {
HeadersFrame headersFrame = (HeadersFrame)frame; HeadersFrame headersFrame = (HeadersFrame)frame;
return generateHeadersFrame(accumulator, streamId, headersFrame, fail); return generateHeadersFrame(accumulator, streamId, headersFrame, fail);
} }
private int generateHeadersFrame(RetainableByteBufferPool.Accumulator accumulator, long streamId, HeadersFrame frame, Consumer<Throwable> fail) private int generateHeadersFrame(ByteBufferPool.Accumulator accumulator, long streamId, HeadersFrame frame, Consumer<Throwable> fail)
{ {
try try
{ {
@ -55,7 +55,7 @@ public class HeadersGenerator extends FrameGenerator
int frameTypeLength = VarLenInt.length(FrameType.HEADERS.type()); int frameTypeLength = VarLenInt.length(FrameType.HEADERS.type());
int maxHeaderLength = frameTypeLength + VarLenInt.MAX_LENGTH; int maxHeaderLength = frameTypeLength + VarLenInt.MAX_LENGTH;
// The capacity of the buffer is larger than maxLength, but we need to enforce at most maxLength. // The capacity of the buffer is larger than maxLength, but we need to enforce at most maxLength.
RetainableByteBuffer buffer = getRetainableByteBufferPool().acquire(maxHeaderLength + maxLength, useDirectByteBuffers); RetainableByteBuffer buffer = getByteBufferPool().acquire(maxHeaderLength + maxLength, useDirectByteBuffers);
ByteBuffer byteBuffer = buffer.getByteBuffer(); ByteBuffer byteBuffer = buffer.getByteBuffer();
BufferUtil.clearToFill(byteBuffer); BufferUtil.clearToFill(byteBuffer);
byteBuffer.position(maxHeaderLength); byteBuffer.position(maxHeaderLength);

View File

@ -16,17 +16,17 @@ package org.eclipse.jetty.http3.generator;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.eclipse.jetty.http3.frames.Frame; import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
public class MaxPushIdGenerator extends FrameGenerator public class MaxPushIdGenerator extends FrameGenerator
{ {
public MaxPushIdGenerator(RetainableByteBufferPool bufferPool) public MaxPushIdGenerator(ByteBufferPool bufferPool)
{ {
super(bufferPool); super(bufferPool);
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail) public int generate(ByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail)
{ {
return 0; return 0;
} }

View File

@ -18,20 +18,20 @@ import java.util.function.Consumer;
import org.eclipse.jetty.http3.frames.Frame; import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.http3.frames.FrameType; import org.eclipse.jetty.http3.frames.FrameType;
import org.eclipse.jetty.http3.qpack.QpackEncoder; import org.eclipse.jetty.http3.qpack.QpackEncoder;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
public class MessageGenerator public class MessageGenerator
{ {
private final FrameGenerator[] generators = new FrameGenerator[FrameType.maxType() + 1]; private final FrameGenerator[] generators = new FrameGenerator[FrameType.maxType() + 1];
public MessageGenerator(RetainableByteBufferPool bufferPool, QpackEncoder encoder, int maxHeadersLength, boolean useDirectByteBuffers) public MessageGenerator(ByteBufferPool bufferPool, QpackEncoder encoder, int maxHeadersLength, boolean useDirectByteBuffers)
{ {
generators[FrameType.DATA.type()] = new DataGenerator(bufferPool, useDirectByteBuffers); generators[FrameType.DATA.type()] = new DataGenerator(bufferPool, useDirectByteBuffers);
generators[FrameType.HEADERS.type()] = new HeadersGenerator(bufferPool, encoder, maxHeadersLength, useDirectByteBuffers); generators[FrameType.HEADERS.type()] = new HeadersGenerator(bufferPool, encoder, maxHeadersLength, useDirectByteBuffers);
generators[FrameType.PUSH_PROMISE.type()] = new PushPromiseGenerator(bufferPool); generators[FrameType.PUSH_PROMISE.type()] = new PushPromiseGenerator(bufferPool);
} }
public int generate(RetainableByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail) public int generate(ByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail)
{ {
return generators[frame.getFrameType().type()].generate(accumulator, streamId, frame, fail); return generators[frame.getFrameType().type()].generate(accumulator, streamId, frame, fail);
} }

View File

@ -16,17 +16,17 @@ package org.eclipse.jetty.http3.generator;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.eclipse.jetty.http3.frames.Frame; import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.io.RetainableByteBufferPool; import org.eclipse.jetty.io.ByteBufferPool;
public class PushPromiseGenerator extends FrameGenerator public class PushPromiseGenerator extends FrameGenerator
{ {
public PushPromiseGenerator(RetainableByteBufferPool bufferPool) public PushPromiseGenerator(ByteBufferPool bufferPool)
{ {
super(bufferPool); super(bufferPool);
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail) public int generate(ByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail)
{ {
return 0; return 0;
} }

View File

@ -20,28 +20,28 @@ import java.util.function.Consumer;
import org.eclipse.jetty.http3.frames.Frame; import org.eclipse.jetty.http3.frames.Frame;
import org.eclipse.jetty.http3.frames.SettingsFrame; import org.eclipse.jetty.http3.frames.SettingsFrame;
import org.eclipse.jetty.http3.internal.VarLenInt; import org.eclipse.jetty.http3.internal.VarLenInt;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.RetainableByteBuffer; import org.eclipse.jetty.io.RetainableByteBuffer;
import org.eclipse.jetty.io.RetainableByteBufferPool;
import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.BufferUtil;
public class SettingsGenerator extends FrameGenerator public class SettingsGenerator extends FrameGenerator
{ {
private final boolean useDirectByteBuffers; private final boolean useDirectByteBuffers;
public SettingsGenerator(RetainableByteBufferPool bufferPool, boolean useDirectByteBuffers) public SettingsGenerator(ByteBufferPool bufferPool, boolean useDirectByteBuffers)
{ {
super(bufferPool); super(bufferPool);
this.useDirectByteBuffers = useDirectByteBuffers; this.useDirectByteBuffers = useDirectByteBuffers;
} }
@Override @Override
public int generate(RetainableByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail) public int generate(ByteBufferPool.Accumulator accumulator, long streamId, Frame frame, Consumer<Throwable> fail)
{ {
SettingsFrame settingsFrame = (SettingsFrame)frame; SettingsFrame settingsFrame = (SettingsFrame)frame;
return generateSettings(accumulator, settingsFrame); return generateSettings(accumulator, settingsFrame);
} }
private int generateSettings(RetainableByteBufferPool.Accumulator accumulator, SettingsFrame frame) private int generateSettings(ByteBufferPool.Accumulator accumulator, SettingsFrame frame)
{ {
int length = 0; int length = 0;
Map<Long, Long> settings = frame.getSettings(); Map<Long, Long> settings = frame.getSettings();
@ -50,7 +50,7 @@ public class SettingsGenerator extends FrameGenerator
length += VarLenInt.length(e.getKey()) + VarLenInt.length(e.getValue()); length += VarLenInt.length(e.getKey()) + VarLenInt.length(e.getValue());
} }
int capacity = VarLenInt.length(frame.getFrameType().type()) + VarLenInt.length(length) + length; int capacity = VarLenInt.length(frame.getFrameType().type()) + VarLenInt.length(length) + length;
RetainableByteBuffer buffer = getRetainableByteBufferPool().acquire(capacity, useDirectByteBuffers); RetainableByteBuffer buffer = getByteBufferPool().acquire(capacity, useDirectByteBuffers);
ByteBuffer byteBuffer = buffer.getByteBuffer(); ByteBuffer byteBuffer = buffer.getByteBuffer();
BufferUtil.clearToFill(byteBuffer); BufferUtil.clearToFill(byteBuffer);
VarLenInt.encode(byteBuffer, frame.getFrameType().type()); VarLenInt.encode(byteBuffer, frame.getFrameType().type());

Some files were not shown because too many files have changed in this diff Show More