use of com.yahoo.messagebus.routing.RouteSpec in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testRoutingTableHasNoStorageClusters.
@Test
public void testRoutingTableHasNoStorageClusters() {
VisitorParameters visitorParameters = createVisitorParameters("");
visitorParameters.setRoute(new Route());
RoutingTableSpec spec = new RoutingTableSpec(DocumentProtocol.NAME);
spec.addRoute(new RouteSpec("storage/lobster.foo"));
RoutingTable table = new RoutingTable(spec);
try {
createDefaultMock(visitorParameters, table);
fail("No exception thrown on zero storage clusters");
} catch (IllegalArgumentException e) {
assertEquals("No storage cluster found in your application.", e.getMessage());
}
}
use of com.yahoo.messagebus.routing.RouteSpec in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method createDummyRoutingTable.
RoutingTable createDummyRoutingTable() {
RoutingTableSpec spec = new RoutingTableSpec(DocumentProtocol.NAME);
spec.addRoute(new RouteSpec("storage/badger.bar"));
RouteSpec storageCluster = new RouteSpec("storage/cluster.foo");
storageCluster.addHop("bunnies");
spec.addRoute(storageCluster);
spec.addRoute(new RouteSpec("storage/otters.baz"));
return new RoutingTable(spec);
}
use of com.yahoo.messagebus.routing.RouteSpec in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testRoutingTableHasMultipleStorageClusters.
@Test
public void testRoutingTableHasMultipleStorageClusters() {
VisitorParameters visitorParameters = createVisitorParameters("");
visitorParameters.setRoute(new Route());
RoutingTableSpec spec = new RoutingTableSpec(DocumentProtocol.NAME);
spec.addRoute(new RouteSpec("storage/cluster.foo"));
spec.addRoute(new RouteSpec("storage/cluster.bar"));
RoutingTable table = new RoutingTable(spec);
try {
createDefaultMock(visitorParameters, table);
fail("No exception thrown on multiple storage clusters");
} catch (IllegalArgumentException e) {
assertEquals("There are multiple storage clusters in your application, " + "please specify which one to visit.", e.getMessage());
}
}
use of com.yahoo.messagebus.routing.RouteSpec in project vespa by vespa-engine.
the class DocumentProtocol method addDefaultRoute.
/**
* Create the "default" route for the Document protocol. This route will be either a route to storage or a route to
* search. Since we will be supporting recovery from storage, storage takes precedence over search when deciding on
* the final target of the default route. If there is an unambigous docproc cluster in the application, the default
* route will pass through this.
*
* @param content The content model from {@link com.yahoo.vespa.model.VespaModel}.
* @param containerClusters a collection of {@link com.yahoo.vespa.model.container.ContainerCluster}s
* @param table The routing table to add to.
*/
private static void addDefaultRoute(List<ContentCluster> content, Collection<ContainerCluster> containerClusters, RoutingTableSpec table) {
List<String> hops = new ArrayList<>();
if (!content.isEmpty()) {
boolean found = false;
for (int i = 0, len = table.getNumHops(); i < len; ++i) {
if (table.getHop(i).getName().equals("indexing")) {
found = true;
break;
}
}
if (found) {
hops.add("indexing");
}
}
if (!hops.isEmpty()) {
RouteSpec route = new RouteSpec("default");
String hop = getContainerClustersDocprocHop(containerClusters);
if (hop != null) {
route.addHop(hop);
}
int numHops = hops.size();
if (numHops == 1) {
route.addHop(hops.get(0));
} else {
StringBuilder str = new StringBuilder();
for (int i = 0; i < numHops; ++i) {
str.append(hops.get(i)).append(i < numHops - 1 ? " " : "");
}
route.addHop("[AND:" + str.toString() + "]");
}
table.addRoute(route);
}
}
Aggregations