Search in sources :

Example 1 with Routing

use of com.yahoo.vespa.model.routing.Routing in project vespa by vespa-engine.

the class IndexingAndDocprocRoutingTest method assertFeedingRouteIndexed.

private void assertFeedingRouteIndexed(VespaModel model, String searchClusterName, String indexingHopName) {
    Routing routing = model.getRouting();
    List<Protocol> protocols = routing.getProtocols();
    DocumentProtocol documentProtocol = null;
    for (Protocol protocol : protocols) {
        if (protocol instanceof DocumentProtocol) {
            documentProtocol = (DocumentProtocol) protocol;
        }
    }
    assertNotNull(documentProtocol);
    RoutingTable table = new RoutingTable(documentProtocol.getRoutingTableSpec());
    Route indexingRoute = table.getRoute("searchcluster-index");
    assertThat(indexingRoute.getNumHops(), is(2));
    assertThat(indexingRoute.getHop(0).toString(), is(indexingHopName));
    assertThat(indexingRoute.getHop(1).toString(), is("[Content:cluster=" + searchClusterName + "]"));
}
Also used : Routing(com.yahoo.vespa.model.routing.Routing) DocumentProtocol(com.yahoo.vespa.model.routing.DocumentProtocol) Protocol(com.yahoo.vespa.model.routing.Protocol) DocumentProtocol(com.yahoo.vespa.model.routing.DocumentProtocol)

Example 2 with Routing

use of com.yahoo.vespa.model.routing.Routing in project vespa by vespa-engine.

the class StorageContentTest method doTestRouting.

public void doTestRouting(String cluster1docs, String cluster2docs, String expectedRoutes) throws Exception {
    VespaModel model = getStorageVespaModel(cluster1docs, cluster2docs);
    if (expectedRoutes == null) {
        return;
    }
    Routing routing = model.getRouting();
    assertNotNull(routing);
    assertEquals(0, routing.getErrors().size());
    assertEquals(1, routing.getProtocols().size());
    DocumentProtocol protocol = (DocumentProtocol) routing.getProtocols().get(0);
    RoutingTableSpec spec = protocol.getRoutingTableSpec();
    assertEquals(1, spec.getNumHops());
    assertEquals("indexing", spec.getHop(0).getName());
    assertEquals("[DocumentRouteSelector]", spec.getHop(0).getSelector());
    Map<String, RouteSpec> routes = new TreeMap<>();
    for (int i = 0; i < spec.getNumRoutes(); ++i) {
        RouteSpec r = spec.getRoute(i);
        routes.put(r.getName(), r);
    }
    {
        RouteSpec r = routes.get("default");
        assertEquals(1, r.getNumHops());
        assertEquals("indexing", r.getHop(0));
    }
    Set<String> configuredRoutes = new TreeSet<>();
    DocumentrouteselectorpolicyConfig.Builder builder = new DocumentrouteselectorpolicyConfig.Builder();
    protocol.getConfig(builder);
    DocumentrouteselectorpolicyConfig config = new DocumentrouteselectorpolicyConfig(builder);
    for (DocumentrouteselectorpolicyConfig.Route r : config.route()) {
        configuredRoutes.add(r.name() + " : " + r.selector());
    }
    StringBuilder routeStr = new StringBuilder();
    for (String r : configuredRoutes) {
        routeStr.append(r).append('\n');
    }
    assertEquals(expectedRoutes, routeStr.toString());
}
Also used : Routing(com.yahoo.vespa.model.routing.Routing) RouteSpec(com.yahoo.messagebus.routing.RouteSpec) DocumentProtocol(com.yahoo.vespa.model.routing.DocumentProtocol) DocumentrouteselectorpolicyConfig(com.yahoo.documentapi.messagebus.protocol.DocumentrouteselectorpolicyConfig) RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) VespaModel(com.yahoo.vespa.model.VespaModel)

Example 3 with Routing

use of com.yahoo.vespa.model.routing.Routing in project vespa by vespa-engine.

the class IndexedTest method requireIndexedOnlyServices.

@Test
public void requireIndexedOnlyServices() {
    VespaModel model = getIndexedVespaModel();
    HostResource h = model.getHostSystem().getHosts().get(0);
    String[] expectedServices = { "logserver", "configserver", "adminserver", "slobrok", "logd", "configproxy", "config-sentinel", "qrserver", "fleetcontroller", "topleveldispatch", "docprocservice", "storagenode", "searchnode", "distributor", "transactionlogserver" };
    // TODO DomContentBuilderTest.assertServices(h, expectedServices);
    Routing routing = model.getRouting();
    assertNotNull(routing);
    assertEquals("[]", routing.getErrors().toString());
    assertEquals(1, routing.getProtocols().size());
    DocumentProtocol protocol = (DocumentProtocol) routing.getProtocols().get(0);
    RoutingTableSpec spec = protocol.getRoutingTableSpec();
    assertEquals(2, spec.getNumHops());
    assertEquals("docproc/cluster.test.indexing/chain.indexing", spec.getHop(0).getName());
    assertEquals("indexing", spec.getHop(1).getName());
    RouteSpec r;
    r = spec.getRoute(0);
    assertEquals("default", r.getName());
    assertEquals(1, r.getNumHops());
    assertEquals("indexing", r.getHop(0));
    r = spec.getRoute(1);
    assertEquals("storage/cluster.test", r.getName());
    assertEquals(1, r.getNumHops());
    assertEquals("route:test", r.getHop(0));
    r = spec.getRoute(2);
    assertEquals("test", r.getName());
    assertEquals(1, r.getNumHops());
    assertEquals("[MessageType:test]", r.getHop(0));
    r = spec.getRoute(3);
    assertEquals("test-direct", r.getName());
    assertEquals(1, r.getNumHops());
    assertEquals("[Content:cluster=test]", r.getHop(0));
    r = spec.getRoute(4);
    assertEquals("test-index", r.getName());
    assertEquals(2, r.getNumHops());
    assertEquals("docproc/cluster.test.indexing/chain.indexing", r.getHop(0));
    assertEquals("[Content:cluster=test]", r.getHop(1));
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) VespaModel(com.yahoo.vespa.model.VespaModel) Routing(com.yahoo.vespa.model.routing.Routing) RouteSpec(com.yahoo.messagebus.routing.RouteSpec) DocumentProtocol(com.yahoo.vespa.model.routing.DocumentProtocol) Test(org.junit.Test)

Example 4 with Routing

use of com.yahoo.vespa.model.routing.Routing in project vespa by vespa-engine.

the class IndexingAndDocprocRoutingTest method assertFeedingRoute.

private void assertFeedingRoute(VespaModel model, String searchClusterName, String indexingHopName) {
    Routing routing = model.getRouting();
    List<Protocol> protocols = routing.getProtocols();
    DocumentProtocol documentProtocol = null;
    for (Protocol protocol : protocols) {
        if (protocol instanceof DocumentProtocol) {
            documentProtocol = (DocumentProtocol) protocol;
        }
    }
    assertNotNull(documentProtocol);
    RoutingTable table = new RoutingTable(documentProtocol.getRoutingTableSpec());
    HopBlueprint indexingHop = table.getHop("indexing");
    assertThat(indexingHop, not(nullValue()));
    assertThat(indexingHop.getNumDirectives(), is(1));
    assertThat(indexingHop.getDirective(0), instanceOf(PolicyDirective.class));
    assertThat(indexingHop.getDirective(0).toString(), is("[DocumentRouteSelector]"));
    // assertThat(indexingHop.getNumRecipients(), is(1));
    // assertThat(indexingHop.getRecipient(0).getServiceName(), is(searchClusterName));
    Route route = table.getRoute(searchClusterName);
    assertNotNull(route);
    assertThat(route.getNumHops(), is(1));
    Hop messageTypeHop = route.getHop(0);
    assertThat(messageTypeHop.getNumDirectives(), is(1));
    assertThat(messageTypeHop.getDirective(0), instanceOf(PolicyDirective.class));
    assertThat(messageTypeHop.getDirective(0).toString(), is("[MessageType:" + searchClusterName + "]"));
    PolicyDirective messageTypeDirective = (PolicyDirective) messageTypeHop.getDirective(0);
    assertThat(messageTypeDirective.getName(), is("MessageType"));
    assertThat(messageTypeDirective.getParam(), is(searchClusterName));
    String indexingRouteName = DocumentProtocol.getIndexedRouteName(model.getContentClusters().get(searchClusterName).getConfigId());
    Route indexingRoute = table.getRoute(indexingRouteName);
    assertThat(indexingRoute.getNumHops(), is(2));
    assertThat(indexingRoute.getHop(0).getServiceName(), is(indexingHopName));
    assertThat(indexingRoute.getHop(1), not(nullValue()));
}
Also used : Routing(com.yahoo.vespa.model.routing.Routing) DocumentProtocol(com.yahoo.vespa.model.routing.DocumentProtocol) Protocol(com.yahoo.vespa.model.routing.Protocol) DocumentProtocol(com.yahoo.vespa.model.routing.DocumentProtocol)

Example 5 with Routing

use of com.yahoo.vespa.model.routing.Routing in project vespa by vespa-engine.

the class ApplicationConfigProducerRoot method setupRouting.

// TODO: Do this as another config model depending on the other models
public void setupRouting(ConfigModelRepo configModels) {
    if (admin != null) {
        Routing routing = configModels.getRouting();
        if (routing == null) {
            routing = new Routing(ConfigModelContext.create(configModels, this, "routing"));
            configModels.add(routing);
        }
        this.routing = routing;
    }
}
Also used : Routing(com.yahoo.vespa.model.routing.Routing)

Aggregations

Routing (com.yahoo.vespa.model.routing.Routing)5 DocumentProtocol (com.yahoo.vespa.model.routing.DocumentProtocol)4 RouteSpec (com.yahoo.messagebus.routing.RouteSpec)2 RoutingTableSpec (com.yahoo.messagebus.routing.RoutingTableSpec)2 VespaModel (com.yahoo.vespa.model.VespaModel)2 Protocol (com.yahoo.vespa.model.routing.Protocol)2 DocumentrouteselectorpolicyConfig (com.yahoo.documentapi.messagebus.protocol.DocumentrouteselectorpolicyConfig)1 HostResource (com.yahoo.vespa.model.HostResource)1 Test (org.junit.Test)1