412840 remove Future in SPDYClient.connect() and return Session instead in blocking version
This commit is contained in:
parent
2e1ad360ae
commit
a1789c8f7c
|
@ -27,8 +27,8 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Future;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
|
@ -112,13 +112,13 @@ public class SPDYClient
|
|||
*
|
||||
* @param address the address to connect to
|
||||
* @param listener the session listener that will be notified of session events
|
||||
* @return a {@link Future} that provides a {@link Session} when connected
|
||||
* @return a {@link Session} when connected
|
||||
*/
|
||||
public Future<Session> connect(SocketAddress address, SessionFrameListener listener)
|
||||
public Session connect(SocketAddress address, SessionFrameListener listener) throws ExecutionException, InterruptedException
|
||||
{
|
||||
FuturePromise<Session> promise = new FuturePromise<>();
|
||||
connect(address, listener, promise);
|
||||
return promise;
|
||||
return promise.get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -178,7 +178,7 @@ public class SPDYProxyEngine extends ProxyEngine implements StreamFrameListener
|
|||
if (session == null)
|
||||
{
|
||||
SPDYClient client = factory.newSPDYClient(version);
|
||||
session = client.connect(address, sessionListener).get(getConnectTimeout(), TimeUnit.MILLISECONDS);
|
||||
session = client.connect(address, sessionListener);
|
||||
LOG.debug("Proxy session connected to {}", address);
|
||||
Session existing = serverSessions.putIfAbsent(host, session);
|
||||
if (existing != null)
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.net.InetSocketAddress;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
|
@ -122,7 +121,7 @@ public abstract class AbstractHTTPSPDYTest
|
|||
clientFactory = newSPDYClientFactory(threadPool);
|
||||
clientFactory.start();
|
||||
}
|
||||
return clientFactory.newSPDYClient(version).connect(socketAddress, listener).get(5, TimeUnit.SECONDS);
|
||||
return clientFactory.newSPDYClient(version).connect(socketAddress, listener);
|
||||
}
|
||||
|
||||
protected SPDYClient.Factory newSPDYClientFactory(Executor threadPool)
|
||||
|
|
|
@ -231,7 +231,7 @@ public class ProxySPDYToHTTPLoadTest
|
|||
{
|
||||
try
|
||||
{
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(15, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
for (int i = 0; i < requestsPerClient; i++)
|
||||
{
|
||||
sendSingleClientRequest(proxyAddress, client, serverIdentificationString, serverHost);
|
||||
|
|
|
@ -169,7 +169,7 @@ public class ProxySPDYToHTTPTest
|
|||
|
||||
InetSocketAddress proxyAddress = startProxy(startServer(new TestServerHandler(header, null)), 30000, 30000);
|
||||
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
|
||||
|
@ -202,7 +202,7 @@ public class ProxySPDYToHTTPTest
|
|||
|
||||
InetSocketAddress proxyAddress = startProxy(startServer(new TestServerHandler(header, data)), 30000, 30000);
|
||||
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
final CountDownLatch dataLatch = new CountDownLatch(1);
|
||||
|
@ -275,7 +275,7 @@ public class ProxySPDYToHTTPTest
|
|||
{
|
||||
resetLatch.countDown();
|
||||
}
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
});
|
||||
|
||||
Fields headers = SPDYTestUtils.createHeaders("localhost", proxyAddress.getPort(), version, "GET", "/");
|
||||
headers.put("connection", "close");
|
||||
|
@ -309,7 +309,7 @@ public class ProxySPDYToHTTPTest
|
|||
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
Fields headers = SPDYTestUtils.createHeaders("localhost", proxyAddress.getPort(), version, "GET", "/");
|
||||
|
||||
client.syn(new SynInfo(headers, true), new StreamFrameListener.Adapter()
|
||||
|
@ -335,7 +335,7 @@ public class ProxySPDYToHTTPTest
|
|||
|
||||
InetSocketAddress proxyAddress = startProxy(startServer(new TestServerHandler(header, null)), 30000, 30000);
|
||||
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
final CountDownLatch dataLatch = new CountDownLatch(1);
|
||||
|
@ -383,7 +383,7 @@ public class ProxySPDYToHTTPTest
|
|||
|
||||
InetSocketAddress proxyAddress = startProxy(startServer(new TestServerHandler(header, null)), 30000, 30000);
|
||||
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
final CountDownLatch dataLatch = new CountDownLatch(1);
|
||||
|
@ -439,7 +439,7 @@ public class ProxySPDYToHTTPTest
|
|||
{
|
||||
goAwayLatch.countDown();
|
||||
}
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
});
|
||||
|
||||
Fields headers = SPDYTestUtils.createHeaders("localhost", proxyAddress.getPort(), version, "POST", "/");
|
||||
((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(true);
|
||||
|
@ -470,7 +470,7 @@ public class ProxySPDYToHTTPTest
|
|||
}
|
||||
}), 30000, timeout);
|
||||
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
|
||||
|
@ -510,7 +510,7 @@ public class ProxySPDYToHTTPTest
|
|||
{
|
||||
pingLatch.countDown();
|
||||
}
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
});
|
||||
|
||||
client.ping(new PingInfo(5, TimeUnit.SECONDS));
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ public class ProxySPDYToSPDYLoadTest
|
|||
{
|
||||
try
|
||||
{
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
for (int i = 0; i < requestsPerClient; i++)
|
||||
{
|
||||
sendSingleClientRequest(proxyAddress, client, serverIdentificationString, serverHost);
|
||||
|
|
|
@ -169,7 +169,7 @@ public class ProxySPDYToSPDYTest
|
|||
}));
|
||||
proxyConnector.addConnectionFactory(proxyConnector.getConnectionFactory("spdy/" + version));
|
||||
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
Fields headers = SPDYTestUtils.createHeaders("localhost", proxyAddress.getPort(), version, "GET", "/");
|
||||
|
@ -215,7 +215,7 @@ public class ProxySPDYToSPDYTest
|
|||
{
|
||||
resetLatch.countDown();
|
||||
}
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
});
|
||||
|
||||
Fields headers = SPDYTestUtils.createHeaders("localhost", proxyAddress.getPort(), version, "GET", "/");
|
||||
headers.put(header, "bar");
|
||||
|
@ -247,7 +247,7 @@ public class ProxySPDYToSPDYTest
|
|||
}));
|
||||
proxyConnector.addConnectionFactory(proxyConnector.getConnectionFactory("spdy/" + version));
|
||||
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
final CountDownLatch dataLatch = new CountDownLatch(1);
|
||||
|
@ -318,7 +318,7 @@ public class ProxySPDYToSPDYTest
|
|||
|
||||
final CountDownLatch pushSynLatch = new CountDownLatch(1);
|
||||
final CountDownLatch pushDataLatch = new CountDownLatch(1);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
|
||||
Fields headers = new Fields();
|
||||
headers.put(HTTPSPDYHeader.HOST.name(version), "localhost:" + proxyAddress.getPort());
|
||||
|
@ -417,7 +417,7 @@ public class ProxySPDYToSPDYTest
|
|||
|
||||
final CountDownLatch pushSynLatch = new CountDownLatch(3);
|
||||
final CountDownLatch pushDataLatch = new CountDownLatch(3);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null).get(5, TimeUnit.SECONDS);
|
||||
Session client = factory.newSPDYClient(version).connect(proxyAddress, null);
|
||||
|
||||
Fields headers = new Fields();
|
||||
headers.put(HTTPSPDYHeader.HOST.name(version), "localhost:" + proxyAddress.getPort());
|
||||
|
@ -516,7 +516,7 @@ public class ProxySPDYToSPDYTest
|
|||
{
|
||||
pingLatch.countDown();
|
||||
}
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
});
|
||||
|
||||
client.ping(new PingInfo(5, TimeUnit.SECONDS));
|
||||
|
||||
|
@ -552,7 +552,7 @@ public class ProxySPDYToSPDYTest
|
|||
{
|
||||
resetLatch.countDown();
|
||||
}
|
||||
}).get(5, TimeUnit.SECONDS);
|
||||
});
|
||||
|
||||
Fields headers = new Fields();
|
||||
headers.put(HTTPSPDYHeader.HOST.name(version), "localhost:" + proxyAddress.getPort());
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.spdy.server;
|
|||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.server.ConnectionFactory;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -114,7 +113,7 @@ public abstract class AbstractTest
|
|||
clientFactory.start();
|
||||
}
|
||||
|
||||
return clientFactory.newSPDYClient(version).connect(socketAddress, listener).get(5, TimeUnit.SECONDS);
|
||||
return clientFactory.newSPDYClient(version).connect(socketAddress, listener);
|
||||
}
|
||||
|
||||
protected SPDYClient.Factory newSPDYClientFactory(Executor threadPool)
|
||||
|
|
|
@ -173,7 +173,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
clientFactory.start();
|
||||
SPDYClient client = clientFactory.newSPDYClient(SPDY.V2);
|
||||
client.setIdleTimeout(idleTimeout);
|
||||
Session session = client.connect(address, null).get(5, TimeUnit.SECONDS);
|
||||
Session session = client.connect(address, null);
|
||||
|
||||
session.syn(new SynInfo(new Fields(), true), null);
|
||||
|
||||
|
@ -199,7 +199,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
clientFactory.start();
|
||||
SPDYClient client = clientFactory.newSPDYClient(SPDY.V2);
|
||||
client.setIdleTimeout(idleTimeout);
|
||||
Session session = client.connect(address, null).get(5, TimeUnit.SECONDS);
|
||||
Session session = client.connect(address, null);
|
||||
|
||||
session.syn(new SynInfo(new Fields(), true), null);
|
||||
|
||||
|
@ -232,7 +232,7 @@ public class IdleTimeoutTest extends AbstractTest
|
|||
clientFactory.start();
|
||||
SPDYClient client = clientFactory.newSPDYClient(SPDY.V2);
|
||||
client.setIdleTimeout(idleTimeout);
|
||||
Session session = client.connect(address, null).get(5, TimeUnit.SECONDS);
|
||||
Session session = client.connect(address, null);
|
||||
|
||||
final CountDownLatch replyLatch = new CountDownLatch(1);
|
||||
session.syn(new SynInfo(new Fields(), true), new StreamFrameListener.Adapter()
|
||||
|
|
|
@ -159,7 +159,7 @@ public class SettingsTest extends AbstractTest
|
|||
Session sessionV2 = startClient(address, null);
|
||||
sessionV2.settings(settingsInfo);
|
||||
|
||||
Session sessionV3 = clientFactory.newSPDYClient(SPDY.V3).connect(address, null).get(5, TimeUnit.SECONDS);
|
||||
Session sessionV3 = clientFactory.newSPDYClient(SPDY.V3).connect(address, null);
|
||||
sessionV3.settings(settingsInfo);
|
||||
|
||||
Assert.assertTrue(settingsLatch.await(5, TimeUnit.SECONDS));
|
||||
|
|
Loading…
Reference in New Issue