use of org.webpieces.util.time.RateRecorder in project webpieces by deanhiller.
the class Http11SynchronousClient method startImpl.
public void startImpl(InetSocketAddress svrAddress) throws UnknownHostException, IOException {
@SuppressWarnings("resource") Socket socket = new Socket(svrAddress.getHostName(), svrAddress.getPort());
OutputStream output = socket.getOutputStream();
Runnable client = new ClientWriter(parser, output);
Thread t1 = new Thread(client);
t1.setName("clientWriter");
t1.start();
InputStream input = socket.getInputStream();
RateRecorder recorder = new RateRecorder(10);
while (true) {
byte[] bytes = new byte[1024];
int read = input.read(bytes);
if (read < 0)
break;
DataWrapper dataWrapper = dataGen.wrapByteArray(bytes, 0, read);
List<HttpPayload> messages = parser.parse(dataWrapper);
// simulate going all the way to http2 like the other test does as well
for (HttpPayload p : messages) {
HttpResponse resp = (HttpResponse) p;
Http2Msg translate = Http11ToHttp2.responseToHeaders(resp);
translate.getMessageType();
recorder.increment();
}
}
}
use of org.webpieces.util.time.RateRecorder in project webpieces by deanhiller.
the class Http2SynchronousClient method startImpl.
public void startImpl(InetSocketAddress svrAddress) throws UnknownHostException, IOException {
@SuppressWarnings("resource") Socket socket = new Socket(svrAddress.getHostName(), svrAddress.getPort());
OutputStream output = socket.getOutputStream();
Runnable client = new ClientWriter(parser, output);
Thread t1 = new Thread(client);
t1.setName("clientWriter");
t1.start();
InputStream input = socket.getInputStream();
RateRecorder recorder = new RateRecorder(10);
while (true) {
byte[] bytes = new byte[1024];
int read = input.read(bytes);
if (read < 0)
break;
DataWrapper dataWrapper = dataGen.wrapByteArray(bytes, 0, read);
UnmarshalState state = parser.unmarshal(dataWrapper);
List<Http2Msg> messages = state.getParsedFrames();
// simulate going all the way to http2 like the other test does as well
for (Http2Msg p : messages) {
Http2Response resp = (Http2Response) p;
resp.getStreamId();
recorder.increment();
}
}
}
Aggregations