Search in sources :

Example 41 with RequestHandler

use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.

the class BindingSetTestCase method requireThatTreeSplitCanBeBoundForHosts.

@Test
public void requireThatTreeSplitCanBeBoundForHosts() {
    Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
    RequestHandler foo = new NonWorkingRequestHandler();
    RequestHandler foobar = new NonWorkingRequestHandler();
    RequestHandler fooqux = new NonWorkingRequestHandler();
    handlers.put(new UriPattern("http://hostabc/foo"), foobar);
    handlers.put(new UriPattern("http://hostpqr/foo"), fooqux);
    handlers.put(new UriPattern("http://host/foo"), foo);
    BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
    assertNotNull(bindings);
}
Also used : RequestHandler(com.yahoo.jdisc.handler.RequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 42 with RequestHandler

use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.

the class BindingSetTestCase method requireThatPathOverPortWorks.

@Test
public void requireThatPathOverPortWorks() {
    Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
    RequestHandler applicationStatus = new NonWorkingRequestHandler();
    RequestHandler search = new NonWorkingRequestHandler();
    RequestHandler legacy = new NonWorkingRequestHandler();
    handlers.put(new UriPattern("http://*/processing/*"), new NonWorkingRequestHandler());
    handlers.put(new UriPattern("http://*/statistics/*"), new NonWorkingRequestHandler());
    handlers.put(new UriPattern("http://*/state/v1/*"), new NonWorkingRequestHandler());
    handlers.put(new UriPattern("http://*/search/*"), search);
    handlers.put(new UriPattern("http://*/status.html"), new NonWorkingRequestHandler());
    handlers.put(new UriPattern("http://*/ApplicationStatus"), applicationStatus);
    handlers.put(new UriPattern("http://*:" + getDefaults().vespaWebServicePort() + "/*"), legacy);
    BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
    assertNotNull(bindings);
    assertSame(applicationStatus, bindings.resolve(URI.create("http://abcxyz.yahoo.com:" + getDefaults().vespaWebServicePort() + "/ApplicationStatus")));
    assertSame(search, bindings.resolve(URI.create("http://abcxyz.yahoo.com:" + getDefaults().vespaWebServicePort() + "/search/?query=sddocname:music")));
    assertSame(legacy, bindings.resolve(URI.create("http://abcxyz.yahoo.com:" + getDefaults().vespaWebServicePort() + "/stats/?query=stat:query")));
}
Also used : RequestHandler(com.yahoo.jdisc.handler.RequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 43 with RequestHandler

use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.

the class ThroughputTestCase method runUnthreadedMeasurementsWithWorkload.

@Test
public void runUnthreadedMeasurementsWithWorkload() throws Exception {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    // warmup
    runMeasurements(driver, new UnthreadedHandler(MAX_LOOPS));
    StringBuilder out = new StringBuilder();
    out.append("\n");
    out.append("      | ");
    for (int i = MIN_THREADS; i <= MAX_THREADS; i *= 2) {
        out.append(String.format("%10d", i));
    }
    out.append("\n");
    out.append("------+-");
    for (int i = MIN_THREADS; i <= MAX_THREADS; i *= 2) {
        out.append("----------");
    }
    out.append("\n");
    for (int i = MIN_LOOPS; i <= MAX_LOOPS; i = Math.max(1, i * 2)) {
        out.append(String.format("%5d | ", i));
        RequestHandler handler = new UnthreadedHandler(i);
        for (Long val : runMeasurements(driver, handler)) {
            out.append(String.format("%10d", val));
        }
        out.append("\n");
    }
    System.err.println(out);
    System.err.println(preventOptimization);
    assertTrue(driver.close());
}
Also used : RequestHandler(com.yahoo.jdisc.handler.RequestHandler) AbstractRequestHandler(com.yahoo.jdisc.handler.AbstractRequestHandler) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Aggregations

RequestHandler (com.yahoo.jdisc.handler.RequestHandler)43 Test (org.junit.Test)33 NonWorkingRequestHandler (com.yahoo.jdisc.test.NonWorkingRequestHandler)23 LinkedHashMap (java.util.LinkedHashMap)19 TestDriver (com.yahoo.jdisc.test.TestDriver)6 Map (java.util.Map)6 AbstractRequestHandler (com.yahoo.jdisc.handler.AbstractRequestHandler)5 ComponentId (com.yahoo.component.ComponentId)4 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)4 BindingSet (com.yahoo.jdisc.application.BindingSet)3 ContentChannel (com.yahoo.jdisc.handler.ContentChannel)3 Container (com.yahoo.container.Container)2 RequestHandlerTestDriver (com.yahoo.container.jdisc.RequestHandlerTestDriver)2 ThreadedHttpRequestHandler (com.yahoo.container.jdisc.ThreadedHttpRequestHandler)2 DocumentProcessingHandler (com.yahoo.docproc.jdisc.DocumentProcessingHandler)2 Request (com.yahoo.jdisc.Request)2 UriPattern (com.yahoo.jdisc.application.UriPattern)2 BindingNotFoundException (com.yahoo.jdisc.handler.BindingNotFoundException)2 RequestDeniedException (com.yahoo.jdisc.handler.RequestDeniedException)2 JSONArray (org.json.JSONArray)2