Search in sources :

Example 1 with HopSpec

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

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

the class StoragePolicyTestEnvironment method setUp.

@Override
public void setUp() throws Exception {
    DocumentTypeManager manager = new DocumentTypeManager();
    DocumentTypeManagerConfigurer.configure(manager, "file:./test/cfg/testdoc.cfg");
    frame = new PolicyTestFrame(manager);
    nodes = new TreeSet<>();
    DocumentProtocol protocol = (DocumentProtocol) frame.getMessageBus().getProtocol((Utf8Array) DocumentProtocol.NAME);
    policyFactory = new StoragePolicyTestFactory(nodes);
    protocol.putRoutingPolicyFactory("storage", policyFactory);
    frame.setMessage(createMessage("userdoc:ns:1:foo"));
    frame.setHop(new HopSpec("test", "[storage:cluster=foo]"));
}
Also used : DocumentTypeManager(com.yahoo.document.DocumentTypeManager) HopSpec(com.yahoo.messagebus.routing.HopSpec) PolicyTestFrame(com.yahoo.documentapi.messagebus.protocol.test.PolicyTestFrame) Utf8Array(com.yahoo.text.Utf8Array)

Example 3 with HopSpec

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

the class DocumentProtocol method addChainHop.

private static void addChainHop(RoutingTableSpec table, String configId, String policy, DocprocChain chain) {
    final String selector;
    if (policy != null) {
        selector = configId + "/" + policy + "/" + chain.getSessionName();
    } else {
        selector = "[LoadBalancer:cluster=" + configId + ";session=" + chain.getSessionName() + "]";
    }
    table.addHop(new HopSpec(chain.getServiceName(), selector));
}
Also used : HopSpec(com.yahoo.messagebus.routing.HopSpec)

Aggregations

HopSpec (com.yahoo.messagebus.routing.HopSpec)3 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)1 PolicyTestFrame (com.yahoo.documentapi.messagebus.protocol.test.PolicyTestFrame)1 MessagebusConfig (com.yahoo.messagebus.MessagebusConfig)1 RouteSpec (com.yahoo.messagebus.routing.RouteSpec)1 RoutingSpec (com.yahoo.messagebus.routing.RoutingSpec)1 RoutingTableSpec (com.yahoo.messagebus.routing.RoutingTableSpec)1 Utf8Array (com.yahoo.text.Utf8Array)1