Skip to content

Commit

Permalink
Merge pull request #3313 from eclipse/jetty-10.0.x-1350-dynamic_clien…
Browse files Browse the repository at this point in the history
…t_transport

Issue #1350 - Dynamic selection of the transport to use based on ALPN on the client side.
  • Loading branch information
sbordet authored Mar 19, 2019
2 parents f037258 + c661788 commit ec8a1bd
Show file tree
Hide file tree
Showing 60 changed files with 1,826 additions and 952 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public void selected(String protocol)
if (protocol == null || !protocols.contains(protocol))
close();
else
completed();
completed(protocol);
}
}
Original file line number Diff line number Diff line change
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.

Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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;
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
{
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);
}
}
Loading

0 comments on commit ec8a1bd

Please sign in to comment.