Search in sources :

Example 1 with RateRecorder

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();
        }
    }
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) HttpResponse(org.webpieces.httpparser.api.dto.HttpResponse) Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg) DataWrapper(org.webpieces.data.api.DataWrapper) RateRecorder(org.webpieces.util.time.RateRecorder) HttpPayload(org.webpieces.httpparser.api.dto.HttpPayload) Socket(java.net.Socket)

Example 2 with RateRecorder

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();
        }
    }
}
Also used : Http2Response(com.webpieces.http2.api.dto.highlevel.Http2Response) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg) DataWrapper(org.webpieces.data.api.DataWrapper) RateRecorder(org.webpieces.util.time.RateRecorder) UnmarshalState(com.webpieces.hpack.api.UnmarshalState) Socket(java.net.Socket)

Aggregations

Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 Socket (java.net.Socket)2 DataWrapper (org.webpieces.data.api.DataWrapper)2 RateRecorder (org.webpieces.util.time.RateRecorder)2 UnmarshalState (com.webpieces.hpack.api.UnmarshalState)1 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)1 HttpPayload (org.webpieces.httpparser.api.dto.HttpPayload)1 HttpResponse (org.webpieces.httpparser.api.dto.HttpResponse)1