rename connectors

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2021-03-23 14:51:47 +01:00 committed by Simone Bordet
parent 0ab056238b
commit 44606d94be
7 changed files with 23 additions and 24 deletions

View File

@ -52,7 +52,7 @@ public class ClientQuicConnection extends QuicConnection
try try
{ {
InetSocketAddress remoteAddress = (InetSocketAddress)context.get(ClientDatagramConnector.REMOTE_SOCKET_ADDRESS_CONTEXT_KEY); InetSocketAddress remoteAddress = (InetSocketAddress)context.get(ClientQuicConnector.REMOTE_SOCKET_ADDRESS_CONTEXT_KEY);
QuicheConnection quicheConnection = QuicheConnection.connect(getQuicheConfig(), remoteAddress); QuicheConnection quicheConnection = QuicheConnection.connect(getQuicheConfig(), remoteAddress);
QuicSession session = new ClientQuicSession(getExecutor(), getScheduler(), getByteBufferPool(), quicheConnection, this, remoteAddress, context); QuicSession session = new ClientQuicSession(getExecutor(), getScheduler(), getByteBufferPool(), quicheConnection, this, remoteAddress, context);
pendingSessions.put(remoteAddress, session); pendingSessions.put(remoteAddress, session);

View File

@ -50,7 +50,7 @@ import org.eclipse.jetty.util.thread.Scheduler;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ClientDatagramConnector extends ContainerLifeCycle implements IClientConnector public class ClientQuicConnector extends ContainerLifeCycle implements IClientConnector
{ {
public static final String CLIENT_CONNECTOR_CONTEXT_KEY = "org.eclipse.jetty.client.connector"; public static final String CLIENT_CONNECTOR_CONTEXT_KEY = "org.eclipse.jetty.client.connector";
public static final String REMOTE_SOCKET_ADDRESS_CONTEXT_KEY = CLIENT_CONNECTOR_CONTEXT_KEY + ".remoteSocketAddress"; public static final String REMOTE_SOCKET_ADDRESS_CONTEXT_KEY = CLIENT_CONNECTOR_CONTEXT_KEY + ".remoteSocketAddress";
@ -69,7 +69,7 @@ public class ClientDatagramConnector extends ContainerLifeCycle implements IClie
private SocketAddress bindAddress; private SocketAddress bindAddress;
private boolean reuseAddress = true; private boolean reuseAddress = true;
public ClientDatagramConnector(Origin.Protocol... protocols) public ClientQuicConnector(Origin.Protocol... protocols)
{ {
String[] applicationProtos = Arrays.stream(protocols) String[] applicationProtos = Arrays.stream(protocols)
.flatMap(protocol -> protocol.getProtocols().stream()) .flatMap(protocol -> protocol.getProtocols().stream())
@ -331,7 +331,7 @@ public class ClientDatagramConnector extends ContainerLifeCycle implements IClie
@Override @Override
protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey selectionKey) protected EndPoint newEndPoint(SelectableChannel channel, ManagedSelector selector, SelectionKey selectionKey)
{ {
EndPoint endPoint = ClientDatagramConnector.this.newEndPoint((DatagramChannel)channel, selector, selectionKey); EndPoint endPoint = ClientQuicConnector.this.newEndPoint((DatagramChannel)channel, selector, selectionKey);
endPoint.setIdleTimeout(getIdleTimeout().toMillis()); endPoint.setIdleTimeout(getIdleTimeout().toMillis());
return endPoint; return endPoint;
} }

View File

@ -22,7 +22,6 @@ import org.eclipse.jetty.http3.common.QuicConnection;
import org.eclipse.jetty.http3.common.QuicSession; import org.eclipse.jetty.http3.common.QuicSession;
import org.eclipse.jetty.http3.common.QuicStreamEndPoint; import org.eclipse.jetty.http3.common.QuicStreamEndPoint;
import org.eclipse.jetty.http3.quiche.QuicheConnection; import org.eclipse.jetty.http3.quiche.QuicheConnection;
import org.eclipse.jetty.http3.quiche.QuicheConnectionId;
import org.eclipse.jetty.io.ByteBufferPool; 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;
@ -42,7 +41,7 @@ public class ClientQuicSession extends QuicSession
@Override @Override
protected QuicStreamEndPoint createQuicStreamEndPoint(long streamId) protected QuicStreamEndPoint createQuicStreamEndPoint(long streamId)
{ {
ClientConnectionFactory connectionFactory = (ClientConnectionFactory)context.get(ClientDatagramConnector.CLIENT_CONNECTION_FACTORY_CONTEXT_KEY); ClientConnectionFactory connectionFactory = (ClientConnectionFactory)context.get(ClientQuicConnector.CLIENT_CONNECTION_FACTORY_CONTEXT_KEY);
QuicStreamEndPoint endPoint = new QuicStreamEndPoint(getScheduler(), this, streamId); QuicStreamEndPoint endPoint = new QuicStreamEndPoint(getScheduler(), this, streamId);
Connection connection; Connection connection;
try try

View File

@ -36,14 +36,14 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
public class HttpClientTransportOverQuic extends AbstractHttpClientTransport public class HttpClientTransportOverQuic extends AbstractHttpClientTransport
{ {
private final ClientConnectionFactory connectionFactory = new HttpClientConnectionFactory(); private final ClientConnectionFactory connectionFactory = new HttpClientConnectionFactory();
private final ClientDatagramConnector connector; private final ClientQuicConnector connector;
private final Origin.Protocol protocol; private final Origin.Protocol protocol;
public HttpClientTransportOverQuic() public HttpClientTransportOverQuic()
{ {
//TODO the ClientConnectionFactory should be built according to the Protocol instance. See HttpClientTransportDynamic //TODO the ClientConnectionFactory should be built according to the Protocol instance. See HttpClientTransportDynamic
protocol = new Origin.Protocol(HttpClientConnectionFactory.HTTP11.getProtocols(true), false); protocol = new Origin.Protocol(HttpClientConnectionFactory.HTTP11.getProtocols(true), false);
connector = new ClientDatagramConnector(protocol); connector = new ClientQuicConnector(protocol);
addBean(connector); addBean(connector);
setConnectionPoolFactory(destination -> setConnectionPoolFactory(destination ->
{ {

View File

@ -22,7 +22,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpCompliance; import org.eclipse.jetty.http.HttpCompliance;
import org.eclipse.jetty.http3.server.ServerDatagramConnector; import org.eclipse.jetty.http3.server.ServerQuicConnector;
import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
@ -48,9 +48,9 @@ public class End2EndClientTest
config.setHttpCompliance(HttpCompliance.LEGACY); // enable HTTP/0.9 config.setHttpCompliance(HttpCompliance.LEGACY); // enable HTTP/0.9
HttpConnectionFactory connectionFactory = new HttpConnectionFactory(config); HttpConnectionFactory connectionFactory = new HttpConnectionFactory(config);
ServerDatagramConnector serverDatagramConnector = new ServerDatagramConnector(server, connectionFactory); ServerQuicConnector connector = new ServerQuicConnector(server, connectionFactory);
serverDatagramConnector.setPort(8443); connector.setPort(8443);
server.addConnector(serverDatagramConnector); server.addConnector(connector);
server.setHandler(new AbstractHandler() server.setHandler(new AbstractHandler()
{ {

View File

@ -40,14 +40,14 @@ import org.eclipse.jetty.util.IO;
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;
public class ServerDatagramConnector extends AbstractNetworkConnector public class ServerQuicConnector extends AbstractNetworkConnector
{ {
private final ServerDatagramSelectorManager _manager; private final ServerDatagramSelectorManager _manager;
private final QuicheConfig _quicheConfig; private final QuicheConfig _quicheConfig;
private volatile DatagramChannel _datagramChannel; private volatile DatagramChannel _datagramChannel;
private volatile int _localPort = -1; private volatile int _localPort = -1;
public ServerDatagramConnector( public ServerQuicConnector(
@Name("server") Server server, @Name("server") Server server,
@Name("executor") Executor executor, @Name("executor") Executor executor,
@Name("scheduler") Scheduler scheduler, @Name("scheduler") Scheduler scheduler,
@ -89,7 +89,7 @@ public class ServerDatagramConnector extends AbstractNetworkConnector
_quicheConfig.setApplicationProtos(protocols.toArray(new String[0])); _quicheConfig.setApplicationProtos(protocols.toArray(new String[0]));
} }
public ServerDatagramConnector( public ServerQuicConnector(
@Name("server") Server server, @Name("server") Server server,
@Name("factories") ConnectionFactory... factories) @Name("factories") ConnectionFactory... factories)
{ {
@ -211,13 +211,13 @@ public class ServerDatagramConnector extends AbstractNetworkConnector
@Override @Override
public Connection newConnection(SelectableChannel channel, EndPoint endpoint, Object attachment) throws IOException public Connection newConnection(SelectableChannel channel, EndPoint endpoint, Object attachment) throws IOException
{ {
return new ServerQuicConnection(getExecutor(), getScheduler(), getByteBufferPool(), endpoint, _quicheConfig, ServerDatagramConnector.this); return new ServerQuicConnection(getExecutor(), getScheduler(), getByteBufferPool(), endpoint, _quicheConfig, ServerQuicConnector.this);
} }
@Override @Override
public String toString() public String toString()
{ {
return String.format("DatagramSelectorManager@%s", ServerDatagramConnector.this); return String.format("DatagramSelectorManager@%s", ServerQuicConnector.this);
} }
class Accept implements ManagedSelector.SelectorUpdate, ManagedSelector.Selectable, Runnable, Closeable class Accept implements ManagedSelector.SelectorUpdate, ManagedSelector.Selectable, Runnable, Closeable

View File

@ -30,7 +30,7 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.handler.AbstractHandler;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class ServerDatagramConnectorTest public class ServerQuicConnectorTest
{ {
@Test @Test
public void testSmall() throws Exception public void testSmall() throws Exception
@ -41,9 +41,9 @@ public class ServerDatagramConnectorTest
config.setHttpCompliance(HttpCompliance.LEGACY); // enable HTTP/0.9 config.setHttpCompliance(HttpCompliance.LEGACY); // enable HTTP/0.9
HttpConnectionFactory connectionFactory = new HttpConnectionFactory(config); HttpConnectionFactory connectionFactory = new HttpConnectionFactory(config);
ServerDatagramConnector serverDatagramConnector = new ServerDatagramConnector(server, connectionFactory); ServerQuicConnector connector = new ServerQuicConnector(server, connectionFactory);
serverDatagramConnector.setPort(8443); connector.setPort(8443);
server.addConnector(serverDatagramConnector); server.addConnector(connector);
server.setHandler(new AbstractHandler() server.setHandler(new AbstractHandler()
{ {
@ -77,9 +77,9 @@ public class ServerDatagramConnectorTest
config.setHttpCompliance(HttpCompliance.LEGACY); // enable HTTP/0.9 config.setHttpCompliance(HttpCompliance.LEGACY); // enable HTTP/0.9
HttpConnectionFactory connectionFactory = new HttpConnectionFactory(config); HttpConnectionFactory connectionFactory = new HttpConnectionFactory(config);
ServerDatagramConnector serverDatagramConnector = new ServerDatagramConnector(server, connectionFactory); ServerQuicConnector connector = new ServerQuicConnector(server, connectionFactory);
serverDatagramConnector.setPort(8443); connector.setPort(8443);
server.addConnector(serverDatagramConnector); server.addConnector(connector);
server.setHandler(new AbstractHandler() server.setHandler(new AbstractHandler()
{ {