public DocumentProtocolRoutingPolicy createPolicy(String param) { return new LoadBalancerPolicy(param); }
public LoadBalancerPolicy(String param) { this(param, parse(param)); }
/** Finds the TCP address of the target. @return Returns a hop representing the TCP address of the target, or null if none could be found. */ LoadBalancer.Node getRecipient(RoutingContext context) { Mirror.Entry [] lastLookup = lookup(context, pattern); return loadBalancer.getRecipient(lastLookup); }
@Override public void doSelect(RoutingContext context) { LoadBalancer.Node node = getRecipient(context); if (node != null) { context.setContext(node); Route route = new Route(context.getRoute()); route.setHop(0, Hop.parse(node.entry.getSpec() + "/" + session)); context.addChild(route); } else { context.setError(ErrorCode.NO_ADDRESS_FOR_SERVICE, "Could not resolve any nodes to send to in pattern " + pattern); } }