use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestHttp1Backpressure method create4BuffersWith3Messags.
private List<ByteBuffer> create4BuffersWith3Messags(Http2Response response1, HttpChunk response2, HttpLastChunk lastChunk) {
HttpStatefulParser parser = HttpParserFactory.createStatefulParser("a", new SimpleMeterRegistry(), new TwoPools("pl", new SimpleMeterRegistry()));
HttpResponse resp1 = Http2ToHttp11.translateResponse(response1);
ByteBuffer buf1 = parser.marshalToByteBuffer(resp1);
ByteBuffer buf2 = parser.marshalToByteBuffer(response2);
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;
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestConnecting method setup.
@Before
public void setup() {
BufferPool pool = new TwoPools("pl", new SimpleMeterRegistry());
httpClient = Http2to11ClientFactory.createHttpClient("myClient2", mockChannelMgr, new SimpleMeterRegistry(), pool);
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestWriteReads method setup.
@Before
public void setup() throws InterruptedException, ExecutionException, TimeoutException {
BufferPool pool = new TwoPools("pl", new SimpleMeterRegistry());
httpClient = Http2to11ClientFactory.createHttpClient("myClient4", mockChannelMgr, new SimpleMeterRegistry(), pool);
mockChannelMgr.addTCPChannelToReturn(mockChannel);
socket = httpClient.createHttpSocket(new Http2CloseListener());
mockChannel.setConnectFuture(XFuture.completedFuture(null));
XFuture<Void> future = socket.connect(new InetSocketAddress(8080));
future.get(2, TimeUnit.SECONDS);
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class TestSslBasicSvr method setup.
@Before
public void setup() throws GeneralSecurityException, IOException, InterruptedException, ExecutionException, TimeoutException {
System.setProperty("jdk.tls.server.protocols", "TLSv1.2");
System.setProperty("jdk.tls.client.protocols", "TLSv1.2");
SSLEngineFactoryForTestOld sslFactory = new SSLEngineFactoryForTestOld();
MeterRegistry meters = Metrics.globalRegistry;
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(mockJdk, meters);
ChannelManager mgr = factory.createMultiThreadedChanMgr("test'n", new TwoPools("pl", new SimpleMeterRegistry()), new BackpressureConfig(), new DirectExecutor());
AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(mgr, meters);
server = svrMgr.createTcpServer(new AsyncConfig(), listener, sslFactory);
XFuture<Void> future = server.start(new InetSocketAddress(8443));
Assert.assertFalse(future.isDone());
mockJdk.setThread(Thread.currentThread());
mockJdk.fireSelector();
future.get(2, TimeUnit.SECONDS);
BufferPool pool = new TwoPools("p1", new SimpleMeterRegistry());
SSLEngine clientSsl = sslFactory.createEngineForSocket();
SSLMetrics sslMetrics = new SSLMetrics("", meters);
clientSslParser = AsyncSSLFactory.create("svr", clientSsl, pool, sslMetrics);
SslAction result = clientSslParser.beginHandshake();
// simulate the jdk firing the selector with a new channel...
mockSvrChannel.addNewChannel(mockChannel);
mockJdk.setThread(Thread.currentThread());
mockJdk.fireSelector();
// assert connectionOpened was called with value of isReadyForWrites=false
// (This feature is specifically so clients can start a time and timeout the connection if they do not
// receive a valid payload in a certain amount of time).
ConnectionOpen connectionOpenedInfo = listener.getConnectionOpenedInfo();
channel = connectionOpenedInfo.channel;
Assert.assertEquals(false, connectionOpenedInfo.isReadyForWrites);
mockChannel.setNumBytesToConsume(100000);
mockChannel.forceDataRead(mockJdk, result.getEncryptedData());
}
use of org.webpieces.data.api.TwoPools in project webpieces by deanhiller.
the class IntegTestClientNotRead method testSoTimeoutOnSocket.
public void testSoTimeoutOnSocket() throws InterruptedException {
TwoPools pool = new TwoPools("pl", new SimpleMeterRegistry());
AsyncServerManager serverMgr = AsyncServerMgrFactory.createAsyncServer("server", pool, new BackpressureConfig(), Metrics.globalRegistry);
AsyncServer server = serverMgr.createTcpServer(new AsyncConfig("tcpServer"), new IntegTestClientNotReadListener());
server.start(new InetSocketAddress(8080));
TwoPools pool2 = new TwoPools("pl", new SimpleMeterRegistry());
ChannelManagerFactory factory = ChannelManagerFactory.createFactory(Metrics.globalRegistry);
ChannelManager mgr = factory.createSingleThreadedChanMgr("client", pool2, new BackpressureConfig());
TCPChannel channel = mgr.createTCPChannel("clientChan");
log.info("client");
timer.schedule(new TimerTask() {
@Override
public void run() {
logBytesTxfrd();
}
}, 1000, 5000);
XFuture<Void> connect = channel.connect(new InetSocketAddress(8080), new ClientDataListener());
connect.thenAccept(p -> runWriting(channel));
Thread.sleep(1000000000);
}
Aggregations