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