Search in sources :

Example 6 with Http2Config

use of com.webpieces.http2engine.api.client.Http2Config in project webpieces by deanhiller.

the class Http2ClientFactory method createHttpClient.

public static Http2Client createHttpClient(int numThreads) {
    Http2Config config = new Http2Config();
    Executor executor = Executors.newFixedThreadPool(numThreads, new NamedThreadFactory("httpclient"));
    BufferCreationPool pool = new BufferCreationPool();
    HpackParser hpackParser = HpackParserFactory.createParser(pool, false);
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager mgr = factory.createMultiThreadedChanMgr("httpClientChanMgr", pool, executor);
    InjectionConfig injConfig = new InjectionConfig(hpackParser, new TimeImpl(), config);
    return createHttpClient(mgr, injConfig);
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) Http2Config(com.webpieces.http2engine.api.client.Http2Config) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) TimeImpl(com.webpieces.util.time.TimeImpl)

Example 7 with Http2Config

use of com.webpieces.http2engine.api.client.Http2Config in project webpieces by deanhiller.

the class AbstractHttp1Test method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
    MockTcpServerChannel svrChannel = new MockTcpServerChannel();
    mockChanMgr.addTCPSvrChannelToReturn(svrChannel);
    mockChannel.setIncomingFrameDefaultReturnValue(XFuture.completedFuture(null));
    mockListener.setDefaultRetVal(mockStreamWriter);
    mockStreamWriter.setDefaultRetValToThis();
    Http2Config config = new Http2Config();
    config.setLocalSettings(localSettings);
    SimpleMeterRegistry metrics = new SimpleMeterRegistry();
    InjectionConfig injConfig = new InjectionConfig(mockTime, config, metrics);
    HttpSvrConfig frontendConfig = new HttpSvrConfig("http", new InetSocketAddress("me", 8080));
    HttpFrontendManager manager = HttpFrontendFactory.createFrontEnd(mockChanMgr, mockTimer, injConfig, Metrics.globalRegistry);
    HttpServer httpServer = manager.createHttpServer(frontendConfig, mockListener);
    httpServer.start();
    simulateClientConnecting();
}
Also used : HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpServer(org.webpieces.frontend2.api.HttpServer) HttpSvrConfig(org.webpieces.frontend2.api.HttpSvrConfig) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) MockTcpServerChannel(org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel) Before(org.junit.Before)

Example 8 with Http2Config

use of com.webpieces.http2engine.api.client.Http2Config in project webpieces by deanhiller.

the class TestS3InitialHttpConnections method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
    MockTcpServerChannel svrChannel = new MockTcpServerChannel();
    mockChanMgr.addTCPSvrChannelToReturn(svrChannel);
    mockTcpChannel.setIncomingFrameDefaultReturnValue(XFuture.completedFuture(null));
    mockListener.setDefaultRetVal(mockStreamWriter);
    mockStreamWriter.setDefaultRetValToThis();
    Http2Config config = new Http2Config();
    config.setLocalSettings(localSettings);
    SimpleMeterRegistry metrics = new SimpleMeterRegistry();
    InjectionConfig injConfig = new InjectionConfig(mockTime, config, metrics);
    HttpSvrConfig frontendConfig = new HttpSvrConfig("http", new InetSocketAddress("me", 8080));
    HttpFrontendManager manager = HttpFrontendFactory.createFrontEnd(mockChanMgr, mockTimer, injConfig, Metrics.globalRegistry);
    HttpServer httpServer = manager.createHttpServer(frontendConfig, mockListener);
    httpServer.start();
    ConnectionListener listener = mockChanMgr.getSingleConnectionListener();
    XFuture<DataListener> futureList = listener.connected(mockTcpChannel, true);
    DataListener dataListener = futureList.get(3, TimeUnit.SECONDS);
    mockChannel.setDataListener(dataListener);
}
Also used : HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) HttpServer(org.webpieces.frontend2.api.HttpServer) HttpSvrConfig(org.webpieces.frontend2.api.HttpSvrConfig) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) DataListener(org.webpieces.nio.api.handlers.DataListener) ConnectionListener(org.webpieces.nio.api.handlers.ConnectionListener) MockTcpServerChannel(org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel) Before(org.junit.Before)

Example 9 with Http2Config

use of com.webpieces.http2engine.api.client.Http2Config in project webpieces by deanhiller.

the class TestC6x5SettingsFrameErrors method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
    mockChannel.setIncomingFrameDefaultReturnValue(XFuture.completedFuture(null));
    Http2Config config = new Http2Config();
    // start with 1 max concurrent
    config.setInitialRemoteMaxConcurrent(1);
    config.setLocalSettings(localSettings);
    SimpleMeterRegistry metrics = new SimpleMeterRegistry();
    InjectionConfig injConfig = new InjectionConfig(mockTime, config, metrics);
    Http2Client client = Http2ClientFactory.createHttpClient("test2Client", mockChanMgr, injConfig);
    mockChanMgr.addTCPChannelToReturn(mockChannel);
    socket = client.createHttpSocket(new SocketListener());
    XFuture<Void> connect = socket.connect(new InetSocketAddress(555));
    connect.get(2, TimeUnit.SECONDS);
    // clear preface and settings frame from client
    mockChannel.getFramesAndClear();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) Http2Client(org.webpieces.http2client.api.Http2Client) Before(org.junit.Before)

Example 10 with Http2Config

use of com.webpieces.http2engine.api.client.Http2Config in project webpieces by deanhiller.

the class AbstractTest method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
    mockChannel.setIncomingFrameDefaultReturnValue(XFuture.completedFuture(null));
    Http2Config config = new Http2Config();
    // start with 1 max concurrent
    config.setInitialRemoteMaxConcurrent(1);
    localSettings.setInitialWindowSize(localSettings.getMaxFrameSize() * 4);
    config.setLocalSettings(localSettings);
    SimpleMeterRegistry metrics = new SimpleMeterRegistry();
    InjectionConfig injConfig = new InjectionConfig(mockTime, config, metrics);
    Http2Client client = Http2ClientFactory.createHttpClient("test2Client", mockChanMgr, injConfig);
    mockChanMgr.addTCPChannelToReturn(mockChannel);
    httpSocket = client.createHttpSocket(new SocketListener());
    XFuture<Void> connect = httpSocket.connect(new InetSocketAddress(555));
    connect.get(2, TimeUnit.SECONDS);
    // clear preface and settings frame from client
    mockChannel.getFramesAndClear();
    // server's settings frame is finally coming in as well with maxConcurrent=1
    sendAndAckSettingsFrame(1);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Http2Config(com.webpieces.http2engine.api.client.Http2Config) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) Http2Client(org.webpieces.http2client.api.Http2Client) Before(org.junit.Before)

Aggregations

Http2Config (com.webpieces.http2engine.api.client.Http2Config)11 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)11 InetSocketAddress (java.net.InetSocketAddress)9 Before (org.junit.Before)9 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)7 Http2Client (org.webpieces.http2client.api.Http2Client)5 HttpFrontendManager (org.webpieces.frontend2.api.HttpFrontendManager)4 HttpServer (org.webpieces.frontend2.api.HttpServer)4 MockTcpServerChannel (org.webpieces.httpfrontend2.api.mock2.MockTcpServerChannel)4 HttpSvrConfig (org.webpieces.frontend2.api.HttpSvrConfig)3 HpackParser (com.webpieces.hpack.api.HpackParser)2 TimeImpl (com.webpieces.util.time.TimeImpl)2 Executor (java.util.concurrent.Executor)2 ChannelManager (org.webpieces.nio.api.ChannelManager)2 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)2 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)2 Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)1 Http2ServerEngineFactory (com.webpieces.http2engine.api.server.Http2ServerEngineFactory)1 SSLEngine (javax.net.ssl.SSLEngine)1 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)1