use of com.yahoo.jdisc.Request in project vespa by vespa-engine.
the class CurrentContainerTestCase method requireThatNewRequestsCreateSnapshot.
@Test
public void requireThatNewRequestsCreateSnapshot() throws Exception {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
driver.activateContainer(driver.newContainerBuilder());
Request request = new Request(driver, URI.create("http://host/path"));
assertNotNull(request.container());
request.release();
driver.close();
}
use of com.yahoo.jdisc.Request in project vespa by vespa-engine.
the class ServerProviderConformanceTest method testRequestExceptionAfterResponseWriteWithAsyncHandleResponse.
private <T extends ServerProvider, U, V> void testRequestExceptionAfterResponseWriteWithAsyncHandleResponse(final Adapter<T, U, V> adapter, final Module... config) throws Throwable {
runTest(adapter, Modules.combine(config), RequestType.WITHOUT_CONTENT, new TestRequestHandler() {
@Override
public ContentChannel handle(final Request request, final ResponseHandler handler) {
callInOtherThread(new Callable<Void>() {
@Override
public Void call() throws Exception {
final ContentChannel out = handler.handleResponse(new Response(Response.Status.OK));
writeResponse(out);
closeResponse(out);
return null;
}
});
responseWritten.await();
throw new ConformanceException();
}
});
}
use of com.yahoo.jdisc.Request in project vespa by vespa-engine.
the class LatencyTestCase method measureLatency.
private static TimeFrame measureLatency(CurrentContainer container, MyRequestHandler requestHandler) {
TimeFrame frame = new TimeFrame();
Request request = null;
ContentChannel requestContent = null;
MyResponseHandler responseHandler = new MyResponseHandler();
try {
URI uri = URI.create(requestHandler.uri);
request = new Request(container, uri);
frame.handleRequestBegin = System.nanoTime();
requestContent = request.connect(responseHandler);
frame.handleRequestEnd = requestHandler.handleTime;
} finally {
if (request != null) {
request.release();
}
}
ByteBuffer buf = ByteBuffer.allocate(69);
MyCompletion requestWrite = new MyCompletion();
frame.requestWriteBegin = System.nanoTime();
requestContent.write(buf, requestWrite);
frame.requestWriteEnd = requestHandler.requestContent.writeTime;
frame.requestWriteCompletionBegin = System.nanoTime();
requestHandler.requestContent.writeCompletion.completed();
frame.requestWriteCompletionEnd = requestWrite.completedTime;
MyCompletion requestClose = new MyCompletion();
frame.requestCloseBegin = System.nanoTime();
requestContent.close(requestClose);
frame.requestCloseEnd = requestHandler.requestContent.closeTime;
frame.requestCloseCompletionBegin = System.nanoTime();
requestHandler.requestContent.closeCompletion.completed();
frame.requestCloseCompletionEnd = requestClose.completedTime;
Response response = new Response(Response.Status.OK);
frame.handleResponseBegin = System.nanoTime();
ContentChannel responseContent = requestHandler.responseHandler.handleResponse(response);
frame.handleResponseEnd = responseHandler.handleTime;
MyCompletion responseWrite = new MyCompletion();
frame.responseWriteBegin = System.nanoTime();
responseContent.write(buf, responseWrite);
frame.responseWriteEnd = responseHandler.responseContent.writeTime;
frame.responseWriteCompletionBegin = System.nanoTime();
responseHandler.responseContent.writeCompletion.completed();
frame.responseWriteCompletionEnd = responseWrite.completedTime;
MyCompletion responseClose = new MyCompletion();
frame.responseCloseBegin = System.nanoTime();
responseContent.close(responseClose);
frame.responseCloseEnd = responseHandler.responseContent.closeTime;
frame.responseCloseCompletionBegin = System.nanoTime();
responseHandler.responseContent.closeCompletion.completed();
frame.responseCloseCompletionEnd = responseClose.completedTime;
return frame;
}
use of com.yahoo.jdisc.Request in project vespa by vespa-engine.
the class ApplicationRestartTestCase method assertGracefulStop.
private static void assertGracefulStop(ApplicationLoader loader) throws Exception {
MyRequestHandler requestHandler = new MyRequestHandler();
ContainerBuilder builder = loader.newContainerBuilder();
builder.serverBindings().bind("http://host/path", requestHandler);
loader.activateContainer(builder);
MyResponseHandler responseHandler = new MyResponseHandler();
Request request = new Request(loader, URI.create("http://host/path"));
request.connect(responseHandler).close(null);
request.release();
StopTask task = new StopTask(loader);
task.start();
assertFalse(task.latch.await(100, TimeUnit.MILLISECONDS));
requestHandler.responseHandler.handleResponse(new Response(Response.Status.OK)).close(null);
assertTrue(task.latch.await(600, TimeUnit.SECONDS));
}
use of com.yahoo.jdisc.Request in project vespa by vespa-engine.
the class ContainerSnapshotTestCase method requireThatServerHandlerCanBeResolved.
@Test
public void requireThatServerHandlerCanBeResolved() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://foo/*", MyRequestHandler.newInstance());
driver.activateContainer(builder);
Request request = new Request(driver, URI.create("http://foo/"));
assertNotNull(request.container().resolveHandler(request));
assertNotNull(request.getBindingMatch());
request.release();
request = new Request(driver, URI.create("http://foo/"));
request.setServerRequest(false);
assertNull(request.container().resolveHandler(request));
assertNull(request.getBindingMatch());
request.release();
request = new Request(driver, URI.create("http://bar/"));
assertNull(request.container().resolveHandler(request));
assertNull(request.getBindingMatch());
request.release();
request = new Request(driver, URI.create("http://bar/"));
request.setServerRequest(false);
assertNull(request.container().resolveHandler(request));
assertNull(request.getBindingMatch());
request.release();
assertTrue(driver.close());
}
Aggregations