Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1350 - Dynamic selection of the transport to use based on ALPN on the client side. #3313

Merged
merged 3 commits into from Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -48,6 +48,6 @@ public void selected(String protocol)
if (protocol == null || !protocols.contains(protocol))
close();
else
completed();
completed(protocol);
}
}
Expand Up @@ -111,4 +111,12 @@ public Connection newConnection(EndPoint endPoint, Map<String, Object> context)
}
throw new IllegalStateException("No ALPNProcessor for " + engine);
}

public static class ALPN extends Info
{
public ALPN(Executor executor, ClientConnectionFactory factory, List<String> protocols)
{
super(List.of("alpn"), new ALPNClientConnectionFactory(executor, factory, protocols));
}
}
}

This file was deleted.

Expand Up @@ -78,7 +78,6 @@ private SslContextFactory newSslContextFactory()
sslContextFactory.setKeyStorePath("src/test/resources/keystore.jks");
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
sslContextFactory.setIncludeProtocols("TLSv1.2");
// The mandatory HTTP/2 cipher.
sslContextFactory.setIncludeCipherSuites("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256");
return sslContextFactory;
Expand Down
6 changes: 6 additions & 0 deletions jetty-client/pom.xml
Expand Up @@ -112,6 +112,12 @@
<artifactId>jetty-io</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-alpn-client</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions jetty-client/src/main/java/module-info.java
Expand Up @@ -20,8 +20,10 @@
{
exports org.eclipse.jetty.client;
exports org.eclipse.jetty.client.api;
exports org.eclipse.jetty.client.dynamic;
exports org.eclipse.jetty.client.http;
exports org.eclipse.jetty.client.jmx to org.eclipse.jetty.jmx;
exports org.eclipse.jetty.client.proxy;
exports org.eclipse.jetty.client.util;

requires org.eclipse.jetty.http;
Expand All @@ -30,6 +32,8 @@

// Only required if using SPNEGO.
requires static java.security.jgss;
// Only required if using the dynamic transport.
requires static org.eclipse.jetty.alpn.client;
// Only required if using JMX.
requires static org.eclipse.jetty.jmx;
}
Expand Up @@ -119,14 +119,14 @@ protected void tryCreate(int maxPending)
if (LOG.isDebugEnabled())
LOG.debug("newConnection {}/{} connections {}/{} pending", total+1, maxConnections, pending+1, maxPending);

destination.newConnection(new Promise<Connection>()
destination.newConnection(new Promise<>()
{
@Override
public void succeeded(Connection connection)
{
if (LOG.isDebugEnabled())
LOG.debug("Connection {}/{} creation succeeded {}", total+1, maxConnections, connection);
connections.add(-1,0);
LOG.debug("Connection {}/{} creation succeeded {}", total + 1, maxConnections, connection);
connections.add(-1, 0);
onCreated(connection);
proceed();
}
Expand All @@ -135,8 +135,8 @@ public void succeeded(Connection connection)
public void failed(Throwable x)
{
if (LOG.isDebugEnabled())
LOG.debug("Connection " + (total+1) + "/" + maxConnections + " creation failed", x);
connections.add(-1,-1);
LOG.debug("Connection " + (total + 1) + "/" + maxConnections + " creation failed", x);
connections.add(-1, -1);
requester.failed(x);
}
});
Expand Down
Expand Up @@ -16,25 +16,22 @@
// ========================================================================
//

package org.eclipse.jetty.client.http;
package org.eclipse.jetty.client;

import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpExchange;
import org.eclipse.jetty.client.Origin;
import org.eclipse.jetty.client.PoolingHttpDestination;
import org.eclipse.jetty.client.SendFailure;
import org.eclipse.jetty.client.api.Connection;

public class HttpDestinationOverHTTP extends PoolingHttpDestination
/**
* <p>A destination for those network transports that are duplex (e.g. HTTP/1.1 and FastCGI).</p>
*
* @see MultiplexHttpDestination
*/
public class DuplexHttpDestination extends HttpDestination
gregw marked this conversation as resolved.
Show resolved Hide resolved
{
public HttpDestinationOverHTTP(HttpClient client, Origin origin)
public DuplexHttpDestination(HttpClient client, Origin origin)
{
super(client, origin);
this(client, new Key(origin, null));
}

@Override
protected SendFailure send(Connection connection, HttpExchange exchange)
public DuplexHttpDestination(HttpClient client, Key key)
{
return ((HttpConnectionOverHTTP)connection).send(exchange);
super(client, key);
}
}