use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestConnecting method setup.
@Before
public void setup() {
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, Metrics.globalRegistry);
DirectExecutor exec = new DirectExecutor();
mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), exec);
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestSslCloseClient method createClientChannel.
public static TCPChannel createClientChannel(String name, MockJdk mockJdk) throws GeneralSecurityException, IOException {
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, Metrics.globalRegistry);
BufferPool pool = new TwoPools("pClient", new SimpleMeterRegistry());
ChannelManager chanMgr = factory.createMultiThreadedChanMgr(name + "Mgr", pool, new BackpressureConfig(), new DirectExecutor());
MockSSLEngineFactory sslFactory = new MockSSLEngineFactory();
SSLEngine clientSsl = sslFactory.createEngineForSocket();
TCPChannel channel1 = chanMgr.createTCPChannel("client", clientSsl);
return channel1;
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class Http2ClientFactory method createHttpClient.
public static Http2Client createHttpClient(Http2ClientConfig config, MeterRegistry metrics) {
Executor executor = Executors.newFixedThreadPool(config.getNumThreads(), new NamedThreadFactory("httpclient"));
MetricsCreator.monitor(metrics, executor, config.getId());
TwoPools pool = new TwoPools(config.getId() + ".bufferpool", metrics);
HpackParser hpackParser = HpackParserFactory.createParser(pool, false);
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(metrics);
ChannelManager mgr = factory.createMultiThreadedChanMgr("httpClientChanMgr", pool, config.getBackpressureConfig(), executor);
InjectionConfig injConfig = new InjectionConfig(hpackParser, new TimeImpl(), config.getHttp2Config());
return createHttpClient(config.getHttp2Config().getId(), mgr, injConfig);
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class ServerFactory method createTestServer.
static int createTestServer(boolean alwaysHttp2, Long maxConcurrentStreams) {
TwoPools pool = new TwoPools("pl", new SimpleMeterRegistry());
ScheduledExecutorService timer = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("webpieces-timer"));
FrontendMgrConfig config = new FrontendMgrConfig();
HttpFrontendManager frontEndMgr = HttpFrontendFactory.createFrontEnd("frontEnd", timer, pool, config, Metrics.globalRegistry);
HttpSvrConfig svrConfig = new HttpSvrConfig("id2");
HttpServer server = frontEndMgr.createHttpServer(svrConfig, new OurListener());
XFuture<Void> fut = server.start();
try {
fut.get(2, TimeUnit.SECONDS);
} catch (ExecutionException | InterruptedException | TimeoutException e) {
throw SneakyThrow.sneak(e);
}
return server.getUnderlyingChannel().getLocalAddress().getPort();
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestHttp11Backpressure method create4SplitPayloads.
private List<ByteBuffer> create4SplitPayloads() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/xxxx");
req.addHeader(new Header(KnownHeaderName.TRANSFER_ENCODING, "chunked"));
HttpChunk chunk = new HttpChunk();
String bodyStr = "hi here and there";
DataWrapper data = DATA_GEN.wrapByteArray(bodyStr.getBytes(StandardCharsets.UTF_8));
chunk.setBody(data);
HttpLastChunk lastChunk = new HttpLastChunk();
HttpStatefulParser parser = HttpParserFactory.createStatefulParser("a", new SimpleMeterRegistry(), new TwoPools("pl", new SimpleMeterRegistry()));
ByteBuffer buf1 = parser.marshalToByteBuffer(req);
ByteBuffer buf2 = parser.marshalToByteBuffer(chunk);
ByteBuffer buf3 = parser.marshalToByteBuffer(lastChunk);
byte[] part1 = new byte[10];
byte[] part2 = new byte[buf1.remaining()];
buf1.get(part1);
int toWrite = buf1.remaining();
buf1.get(part2, 0, toWrite);
buf2.get(part2, toWrite, part2.length - toWrite);
byte[] part3 = new byte[buf2.remaining() + 2];
int toWrite2 = buf2.remaining();
buf2.get(part3, 0, toWrite2);
buf3.get(part3, toWrite2, 2);
byte[] part4 = new byte[buf3.remaining()];
buf3.get(part4);
List<ByteBuffer> buffers = new ArrayList<>();
buffers.add(ByteBuffer.wrap(part1));
buffers.add(ByteBuffer.wrap(part2));
buffers.add(ByteBuffer.wrap(part3));
buffers.add(ByteBuffer.wrap(part4));
return buffers;
}
Aggregations