use of com.yahoo.messagebus.routing.RoutingNodeIterator in project vespa by vespa-engine.
the class DocumentProtocol method merge.
/**
* This method implements the common way to merge document replies for whatever routing policy. In case of an error
* in any of the replies, it will prepare an EmptyReply() and add all errors to it. If there are no errors, this
* method will use the first reply in the list and transfer whatever feed answers might exist in the replies to it.
*
* @param ctx The context whose children to merge.
* @param mask The indexes of the children to skip.
*/
public static void merge(RoutingContext ctx, Set<Integer> mask) {
List<Reply> replies = new LinkedList<>();
for (RoutingNodeIterator it = ctx.getChildIterator(); it.isValid(); it.next()) {
Reply ref = it.getReplyRef();
replies.add(ref);
}
Tuple2<Integer, Reply> tuple = merge(replies, mask);
if (tuple.first != null) {
ctx.getChildIterator().skip(tuple.first).removeReply();
}
ctx.setReply(tuple.second);
}
use of com.yahoo.messagebus.routing.RoutingNodeIterator in project vespa by vespa-engine.
the class CustomPolicy method merge.
public void merge(RoutingContext context) {
List<String> lst = new ArrayList<String>();
Reply ret = new EmptyReply();
for (RoutingNodeIterator it = context.getChildIterator(); it.isValid(); it.next()) {
lst.add(it.getRoute().toString());
Reply reply = it.getReplyRef();
for (int i = 0; i < reply.getNumErrors(); ++i) {
ret.addError(reply.getError(i));
}
}
context.setReply(ret);
context.trace(1, "Merged " + lst + ".");
}
use of com.yahoo.messagebus.routing.RoutingNodeIterator in project vespa by vespa-engine.
the class LoadBalancerPolicy method merge.
public void merge(RoutingContext context) {
RoutingNodeIterator it = context.getChildIterator();
Reply reply = it.removeReply();
LoadBalancer.Node target = (LoadBalancer.Node) context.getContext();
boolean busy = false;
for (int i = 0; i < reply.getNumErrors(); i++) {
if (reply.getError(i).getCode() == ErrorCode.SESSION_BUSY) {
busy = true;
}
}
loadBalancer.received(target, busy);
context.setReply(reply);
}
Aggregations