use of com.yahoo.messagebus.Reply 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.Reply in project vespa by vespa-engine.
the class BasicTests method testVerifyBucketOneNodePreferenceInTenNodeDefaultCluster.
/**
* To be independent of changes in distribution algorithm, we programmatically calculate preferred order of
* bucket 1, which we will be using in the tests. To avoid doing this ahead of every test, we still hardcode the
* values, though only one place, and have this test to verify they are correct, and make it easy to update the values.
*/
public void testVerifyBucketOneNodePreferenceInTenNodeDefaultCluster() {
int[] result = new int[10];
setClusterNodes(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
String clusterState = " bits:16 storage:10 distributor:10";
for (int i = 0; i < 10; ++i) {
// Update cached cluster state, to reflect which node we want to find
RoutingNode target = select();
target.handleReply(new WrongDistributionReply("version:" + (i + 1) + clusterState));
Reply reply = frame.getReceptor().getReply(60);
assertNotNull(reply);
assertFalse(reply.hasErrors());
// Find correct target
target = select();
Pair<String, Integer> address = getAddress(target);
result[i] = address.getSecond();
removeNode(address.getSecond());
clusterState += " ." + result[i] + ".s:d";
}
assertEquals(Arrays.toString(bucketOneNodePreference), Arrays.toString(result));
}
use of com.yahoo.messagebus.Reply 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);
}
use of com.yahoo.messagebus.Reply in project vespa by vespa-engine.
the class RoundRobinPolicy method select.
// Inherit doc from RoutingPolicy.
public void select(RoutingContext ctx) {
Hop hop = getRecipient(ctx);
if (hop != null) {
Route route = new Route(ctx.getRoute());
route.setHop(0, hop);
ctx.addChild(route);
} else {
Reply reply = new EmptyReply();
reply.addError(new Error(ErrorCode.NO_ADDRESS_FOR_SERVICE, "None of the configured recipients are currently available."));
ctx.setReply(reply);
}
}
Aggregations