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());
}
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));
}
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);
}
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);
}
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);
}
Aggregations