Search in sources :

Example 1 with RoutingTableSpec

use of com.yahoo.messagebus.routing.RoutingTableSpec 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 2 with RoutingTableSpec

use of com.yahoo.messagebus.routing.RoutingTableSpec 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 3 with RoutingTableSpec

use of com.yahoo.messagebus.routing.RoutingTableSpec in project vespa by vespa-engine.

the class ConfigAgent method configure.

@Override
public void configure(MessagebusConfig config) {
    RoutingSpec routing = new RoutingSpec();
    for (int table = 0; table < config.routingtable().size(); table++) {
        MessagebusConfig.Routingtable tableConfig = config.routingtable(table);
        RoutingTableSpec tableSpec = new RoutingTableSpec(tableConfig.protocol());
        for (int hop = 0; hop < tableConfig.hop().size(); hop++) {
            MessagebusConfig.Routingtable.Hop hopConfig = tableConfig.hop(hop);
            HopSpec hopSpec = new HopSpec(hopConfig.name(), hopConfig.selector());
            for (int recipient = 0; recipient < hopConfig.recipient().size(); recipient++) {
                hopSpec.addRecipient(hopConfig.recipient(recipient));
            }
            hopSpec.setIgnoreResult(hopConfig.ignoreresult());
            tableSpec.addHop(hopSpec);
        }
        for (int route = 0; route < tableConfig.route().size(); route++) {
            MessagebusConfig.Routingtable.Route routeConfig = tableConfig.route(route);
            RouteSpec routeSpec = new RouteSpec(routeConfig.name());
            for (int hop = 0; hop < routeConfig.hop().size(); hop++) {
                routeSpec.addHop(routeConfig.hop(hop));
            }
            tableSpec.addRoute(routeSpec);
        }
        routing.addTable(tableSpec);
    }
    handler.setupRouting(routing);
}
Also used : RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) MessagebusConfig(com.yahoo.messagebus.MessagebusConfig) HopSpec(com.yahoo.messagebus.routing.HopSpec) RouteSpec(com.yahoo.messagebus.routing.RouteSpec) RoutingSpec(com.yahoo.messagebus.routing.RoutingSpec)

Example 4 with RoutingTableSpec

use of com.yahoo.messagebus.routing.RoutingTableSpec in project vespa by vespa-engine.

the class TraceTripTestCase method setUp.

public void setUp() throws ListenFailedException, UnknownHostException {
    RoutingTableSpec table = new RoutingTableSpec(SimpleProtocol.NAME).addHop("pxy", "test/pxy/session", Arrays.asList("test/pxy/session")).addHop("dst", "test/dst/session", Arrays.asList("test/dst/session")).addRoute("test", Arrays.asList("pxy", "dst"));
    slobrok = new Slobrok();
    src = new TestServer("test/src", table, slobrok, null);
    pxy = new TestServer("test/pxy", table, slobrok, null);
    dst = new TestServer("test/dst", table, slobrok, null);
}
Also used : RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Example 5 with RoutingTableSpec

use of com.yahoo.messagebus.routing.RoutingTableSpec in project vespa by vespa-engine.

the class ThrottlerTestCase method setUp.

public void setUp() throws ListenFailedException, UnknownHostException {
    RoutingTableSpec table = new RoutingTableSpec(SimpleProtocol.NAME);
    table.addHop("dst", "test/dst/session", Arrays.asList("test/dst/session"));
    table.addRoute("test", Arrays.asList("dst"));
    slobrok = new Slobrok();
    src = new TestServer("test/src", table, slobrok, null);
    dst = new TestServer("test/dst", table, slobrok, null);
}
Also used : RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Aggregations

RoutingTableSpec (com.yahoo.messagebus.routing.RoutingTableSpec)11 RouteSpec (com.yahoo.messagebus.routing.RouteSpec)6 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)4 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)4 Test (org.junit.Test)4 RoutingTable (com.yahoo.messagebus.routing.RoutingTable)3 Route (com.yahoo.messagebus.routing.Route)2 VespaModel (com.yahoo.vespa.model.VespaModel)2 DocumentProtocol (com.yahoo.vespa.model.routing.DocumentProtocol)2 Routing (com.yahoo.vespa.model.routing.Routing)2 DocumentrouteselectorpolicyConfig (com.yahoo.documentapi.messagebus.protocol.DocumentrouteselectorpolicyConfig)1 MessagebusConfig (com.yahoo.messagebus.MessagebusConfig)1 HopSpec (com.yahoo.messagebus.routing.HopSpec)1 RoutingSpec (com.yahoo.messagebus.routing.RoutingSpec)1 Receptor (com.yahoo.messagebus.test.Receptor)1 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)1 HostResource (com.yahoo.vespa.model.HostResource)1 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)1 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)1