Search in sources :

Example 1 with RoutingTable

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

the class MessageBusVisitorSession method createForMessageBus.

public static MessageBusVisitorSession createForMessageBus(final MessageBus mbus, final ScheduledExecutorService scheduledExecutorService, final VisitorParameters params) throws ParseException {
    final AsyncTaskExecutor executor = new ThreadAsyncTaskExecutor(scheduledExecutorService);
    final MessageBusSenderFactory senderFactory = new MessageBusSenderFactory(mbus);
    final MessageBusReceiverFactory receiverFactory = new MessageBusReceiverFactory(mbus);
    final RoutingTable table = mbus.getRoutingTable(DocumentProtocol.NAME);
    return new MessageBusVisitorSession(params, executor, senderFactory, receiverFactory, table);
}
Also used : RoutingTable(com.yahoo.messagebus.routing.RoutingTable)

Example 2 with RoutingTable

use of com.yahoo.messagebus.routing.RoutingTable 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());
    }
}
Also used : RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) RoutingTable(com.yahoo.messagebus.routing.RoutingTable) RouteSpec(com.yahoo.messagebus.routing.RouteSpec) Route(com.yahoo.messagebus.routing.Route) Test(org.junit.Test)

Example 3 with RoutingTable

use of com.yahoo.messagebus.routing.RoutingTable 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);
}
Also used : RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) RoutingTable(com.yahoo.messagebus.routing.RoutingTable) RouteSpec(com.yahoo.messagebus.routing.RouteSpec)

Example 4 with RoutingTable

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

the class MessageBusVisitorSessionTestCase method testDefaultClusterRouteResolutionNoHops.

/**
 * Test that we try to get a route to the storage cluster automatically if
 * the provided route has no hops.
 */
@Test
public void testDefaultClusterRouteResolutionNoHops() {
    VisitorParameters visitorParameters = createVisitorParameters("");
    visitorParameters.setRoute(new Route());
    RoutingTable table = createDummyRoutingTable();
    createDefaultMock(visitorParameters, table);
    assertEquals("storage/cluster.foo", visitorParameters.getRoute().toString());
}
Also used : RoutingTable(com.yahoo.messagebus.routing.RoutingTable) Route(com.yahoo.messagebus.routing.Route) Test(org.junit.Test)

Example 5 with RoutingTable

use of com.yahoo.messagebus.routing.RoutingTable 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());
    }
}
Also used : RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) RoutingTable(com.yahoo.messagebus.routing.RoutingTable) RouteSpec(com.yahoo.messagebus.routing.RouteSpec) Route(com.yahoo.messagebus.routing.Route) Test(org.junit.Test)

Aggregations

RoutingTable (com.yahoo.messagebus.routing.RoutingTable)8 Test (org.junit.Test)5 Route (com.yahoo.messagebus.routing.Route)4 RouteSpec (com.yahoo.messagebus.routing.RouteSpec)3 RoutingTableSpec (com.yahoo.messagebus.routing.RoutingTableSpec)3