Search in sources :

Example 1 with ContentChannelOutputStream

use of com.yahoo.container.jdisc.ContentChannelOutputStream in project vespa by vespa-engine.

the class AsynchronousSectionedRendererTest method render.

@SuppressWarnings("unchecked")
public String render(Renderer renderer, DataList data) throws InterruptedException, IOException {
    TestContentChannel contentChannel = new TestContentChannel();
    Execution execution = Execution.createRoot(new NoopProcessor(), 0, null);
    final ContentChannelOutputStream stream = new ContentChannelOutputStream(contentChannel);
    ListenableFuture result = renderer.render(stream, new Response(data), execution, null);
    int waitCounter = 1000;
    while (!result.isDone()) {
        Thread.sleep(60);
        --waitCounter;
        if (waitCounter < 0) {
            throw new IllegalStateException();
        }
    }
    stream.close();
    contentChannel.close(null);
    String str = "";
    for (ByteBuffer buf : contentChannel.getBuffers()) {
        str += Utf8.toString(buf);
    }
    return str;
}
Also used : Response(com.yahoo.processing.Response) Execution(com.yahoo.processing.execution.Execution) ContentChannelOutputStream(com.yahoo.container.jdisc.ContentChannelOutputStream) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ContentChannelOutputStream (com.yahoo.container.jdisc.ContentChannelOutputStream)1 Response (com.yahoo.processing.Response)1 Execution (com.yahoo.processing.execution.Execution)1 ByteBuffer (java.nio.ByteBuffer)1