String getRandomTargetSpec(RoutingContext context) {
            Targets targets = validTargets.get();
            // Try to use list of random targets, if at least X % of the nodes are up
            while (100 * targets.size() >= requiredUpPercentageToSendToKnownGoodNodes * targets.total)
            {
                Integer distributor = targets.get(randomizer);
                String targetSpec = getTargetSpec(distributor, context);
                if (targetSpec != null) {
                    context.trace(3, "Sending to random node seen up in cluster state");
                    return targetSpec;
                }
                targets.remove(distributor);
            }
            context.trace(3, "Too few nodes seen up in state. Sending totally random.");
            return getTargetSpec(null, context);
        }
Helper class to match a host pattern with node to use.
documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java