Search in sources :

Example 26 with TwoPools

use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.

the class TestSplitHeaders method setup.

@Before
public void setup() {
    HpackConfig config = new HpackConfig("myhpack");
    config.setLocalMaxFrameSize(50);
    config.setRemoteMaxFrameSize(50);
    parser = HpackParserFactory.createStatefulParser(new TwoPools("pl", new SimpleMeterRegistry()), config);
}
Also used : HpackConfig(com.webpieces.hpack.api.HpackConfig) TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Before(org.junit.Before)

Example 27 with TwoPools

use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.

the class TestStreamingRaw method setUp.

@Before
public void setUp() throws InterruptedException, ExecutionException, TimeoutException {
    Context.clear();
    VirtualFileClasspath metaFile = new VirtualFileClasspath("jsonMeta.txt", PrivateWebserverForTest.class.getClassLoader());
    PrivateWebserverForTest webserver = new PrivateWebserverForTest(getOverrides(new SimpleMeterRegistry()), new TestOverrides(), true, metaFile);
    webserver.start();
    parser = HttpParserFactory.createStatefulParser("testParser", new SimpleMeterRegistry(), new TwoPools(new SimpleMeterRegistry()));
}
Also used : PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) VirtualFileClasspath(org.webpieces.util.file.VirtualFileClasspath) Before(org.junit.Before)

Example 28 with TwoPools

use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.

the class TestBeansAndSplit method testIncomingDataAndDataSeperate.

@Test
public void testIncomingDataAndDataSeperate() {
    HttpFullRequest req = Requests.createPostRequest("/postArray2", "user.accounts[1].name", "Account2Name", "user.accounts[1].color", "green", "user.accounts[2].addresses[0].number", "56", "user.firstName", "D&D", "user.lastName", "Hiller", "user.fullName", "Dean Hiller");
    DataWrapperGenerator dataGen = DataWrapperGeneratorFactory.createDataWrapperGenerator();
    HttpParser parser = HttpParserFactory.createParser("a", new SimpleMeterRegistry(), new TwoPools("pl", new SimpleMeterRegistry()));
    MarshalState state = parser.prepareToMarshal();
    ByteBuffer buffer = parser.marshalToByteBuffer(state, req.getRequest());
    DataWrapper d1 = dataGen.wrapByteBuffer(buffer);
    DataWrapper data = dataGen.chainDataWrappers(d1, req.getData());
    // Split the body in half
    List<? extends DataWrapper> split = dataGen.split(data, data.getReadableSize() - 20);
    ByteBuffer buffer1 = ByteBuffer.wrap(split.get(0).createByteArray());
    ByteBuffer buffer2 = ByteBuffer.wrap(split.get(1).createByteArray());
    dataListener.incomingData(channel, buffer1);
    dataListener.incomingData(channel, buffer2);
    ResponseWrapper response = create();
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    UserDto user = mockSomeLib.getUser();
    Assert.assertEquals("D&D", user.getFirstName());
    Assert.assertEquals(3, user.getAccounts().size());
    Assert.assertEquals("Account2Name", user.getAccounts().get(1).getName());
    Assert.assertEquals(56, user.getAccounts().get(2).getAddresses().get(0).getNumber());
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) DataWrapperGenerator(org.webpieces.data.api.DataWrapperGenerator) MarshalState(org.webpieces.httpparser.api.MarshalState) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) UserDto(org.webpieces.webserver.basic.app.biz.UserDto) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) HttpParser(org.webpieces.httpparser.api.HttpParser) ByteBuffer(java.nio.ByteBuffer) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test)

Example 29 with TwoPools

use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.

the class Http11Clients method createClient.

@Override
public Http2Client createClient() {
    if (config.getClientThreadCount() != null)
        return Http2to11ClientFactory.createHttpClient("onlyClient", config.getClientThreadCount(), config.getBackpressureConfig(), metrics);
    // single threaded version...
    TwoPools pool = new TwoPools("pl", new SimpleMeterRegistry());
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(metrics);
    ChannelManager chanMgr = factory.createSingleThreadedChanMgr("clientCmLoop", pool, config.getBackpressureConfig());
    Http2Client client = Http2to11ClientFactory.createHttpClient("onlyClient", chanMgr, new SimpleMeterRegistry(), pool);
    return client;
}
Also used : ChannelManager(org.webpieces.nio.api.ChannelManager) TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Http2Client(org.webpieces.http2client.api.Http2Client) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Example 30 with TwoPools

use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.

the class Http2Clients method createClient.

@Override
public Http2Client createClient() {
    if (config.getClientThreadCount() != null)
        return createMultiThreadedClient();
    // single threaded version...
    TwoPools pool = new TwoPools("pl", new SimpleMeterRegistry());
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory(metrics);
    ChannelManager chanMgr = factory.createSingleThreadedChanMgr("clientCmLoop", pool, config.getBackpressureConfig());
    return Http2ClientFactory.createHttpClient(http2Config, chanMgr, pool);
}
Also used : ChannelManager(org.webpieces.nio.api.ChannelManager) TwoPools(org.webpieces.data.api.TwoPools) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Aggregations

TwoPools (org.webpieces.data.api.TwoPools)43 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)39 Before (org.junit.Before)15 BufferPool (org.webpieces.data.api.BufferPool)15 ChannelManager (org.webpieces.nio.api.ChannelManager)12 InetSocketAddress (java.net.InetSocketAddress)11 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)11 NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)10 Executor (java.util.concurrent.Executor)8 SSLEngine (javax.net.ssl.SSLEngine)8 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)8 DirectExecutor (org.webpieces.util.threading.DirectExecutor)8 ByteBuffer (java.nio.ByteBuffer)7 AsyncConfig (org.webpieces.asyncserver.api.AsyncConfig)7 BackpressureConfig (org.webpieces.nio.api.BackpressureConfig)7 AsyncServer (org.webpieces.asyncserver.api.AsyncServer)6 HttpParser (org.webpieces.httpparser.api.HttpParser)6 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)5 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)5 ArrayList (java.util.ArrayList)4