use of test.r2.perf.PerfStreamWriter in project rest.li by linkedin.
the class AbstractPerfServerFactory method createPureStreamServer.
public Server createPureStreamServer(int port, URI echoUri, final int msg_size, int numHeaders, int headerSize) {
String headerContent = new StringGenerator(headerSize).nextMessage();
StreamRequestHandler handler = new StreamRequestHandler() {
@Override
public void handleRequest(StreamRequest request, RequestContext requestContext, final Callback<StreamResponse> callback) {
request.getEntityStream().setReader(new PerfStreamReader<>(new Callback<None>() {
@Override
public void onError(Throwable e) {
callback.onError(e);
}
@Override
public void onSuccess(None result) {
StreamResponseBuilder builder = new StreamResponseBuilder();
for (int i = 0; i < numHeaders; i++) {
builder.setHeader(STATIC_HEADER_PREFIX + i, headerContent);
}
callback.onSuccess(builder.build(EntityStreams.newEntityStream(new PerfStreamWriter(msg_size))));
}
}, None.none()));
}
};
final TransportDispatcher dispatcher = new TransportDispatcherBuilder().addStreamHandler(echoUri, handler).build();
return createServer(port, dispatcher, true);
}
use of test.r2.perf.PerfStreamWriter in project rest.li by linkedin.
the class StreamRequestGenerator method nextMessage.
@Override
public StreamRequest nextMessage() {
if (_msgCounter.getAndDecrement() > 0) {
StreamRequestBuilder builder = new StreamRequestBuilder(_uri);
builder.setMethod(HTTP_POST_METHOD);
for (int i = 0; i < _numHeaders; i++) {
builder.setHeader(STATIC_HEADER_PREFIX + i, _headerContent);
}
return builder.build(EntityStreams.newEntityStream(new PerfStreamWriter(_msgSize)));
} else {
return null;
}
}
Aggregations